chore(env): add VITE_DEFAULT_DATA_TO_ENCODE variable to .env.example, README, docker-compose.yml, and env.d.ts files to provide a default data value for encoding in the app (#170)

fix(QRCodeCreate.vue): update data initialization to use VITE_DEFAULT_DATA_TO_ENCODE value from environment variables if available, ensuring a default data value for encoding in the QR code creation component
This commit is contained in:
Estee Tey 2025-06-08 12:00:39 +08:00 committed by GitHub
parent c5a9bf91c8
commit d2d59059b4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 15 additions and 11 deletions

View File

@ -10,6 +10,7 @@ BASE_PATH=/
VITE_HIDE_CREDITS=false
VITE_DEFAULT_PRESET=plain
VITE_DEFAULT_DATA_TO_ENCODE=
VITE_QR_CODE_PRESETS=
VITE_FRAME_PRESET=
VITE_FRAME_PRESETS=

View File

@ -141,10 +141,11 @@ docker run -d -p 8081:8080 mini-qr
#### Environment Variables
| Variable | Description | Default |
| ---------------------------- | ---------------------------------------------------------------------------------- | --------- |
| ----------------------------- | ---------------------------------------------------------------------------------- | --------- |
| `BASE_PATH` | Base path for deployment | `/` |
| `VITE_HIDE_CREDITS` | Set to `"true"` to hide credits in the footer | `"false"` |
| `VITE_DEFAULT_PRESET` | Name of the default QR code preset to load (e.g., `"lyqht"`) | `""` |
| `VITE_DEFAULT_DATA_TO_ENCODE` | Default data to encode when the app first loads | `""` |
| `VITE_QR_CODE_PRESETS` | JSON string defining custom QR code presets. E.g., `'[{"name":"c1","data":"hi"}]'` | `"[]"` |
| `VITE_FRAME_PRESET` | Name of the default frame preset to load (e.g., `"default"`) | `""` |
| `VITE_FRAME_PRESETS` | JSON string defining custom frame presets. E.g., `'[{"name":"fA","text":"QR"}]'` | `"[]"` |

View File

@ -8,6 +8,7 @@ services:
- VITE_HIDE_CREDITS=${HIDE_CREDITS:-false}
- BASE_PATH=${BASE_PATH:-/}
- VITE_DEFAULT_PRESET=${DEFAULT_PRESET:-}
- VITE_DEFAULT_DATA_TO_ENCODE=${DEFAULT_DATA:-}
- VITE_QR_CODE_PRESETS=${PRESETS:-}
- VITE_FRAME_PRESET=${FRAME_PRESET:-}
- VITE_FRAME_PRESETS=${FRAME_PRESETS:-}

1
env.d.ts vendored
View File

@ -4,6 +4,7 @@ interface ImportMetaEnv {
readonly BASE_PATH?: string
readonly VITE_HIDE_CREDITS?: string
readonly VITE_DEFAULT_PRESET?: string
readonly VITE_DEFAULT_DATA_TO_ENCODE?: string
readonly VITE_QR_CODE_PRESETS?: string
readonly VITE_FRAME_PRESET?: string
readonly VITE_FRAME_PRESETS?: string

View File

@ -65,7 +65,7 @@ const { t } = useI18n()
//#endregion
//#region /* QR code style settings */
const data = ref(props.initialData || '')
const data = ref(props.initialData || import.meta.env.VITE_DEFAULT_DATA_TO_ENCODE || '')
const debouncedData = ref(data.value)
let dataDebounceTimer: ReturnType<typeof setTimeout>