diff --git a/.env.example b/.env.example index a9211ce..a838db3 100644 --- a/.env.example +++ b/.env.example @@ -10,7 +10,8 @@ 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= -VITE_DISABLE_LOCAL_STORAGE=false \ No newline at end of file +VITE_DISABLE_LOCAL_STORAGE=false diff --git a/README.md b/README.md index b290d55..e96490d 100644 --- a/README.md +++ b/README.md @@ -140,15 +140,16 @@ 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_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"}]'` | `"[]"` | -| `VITE_DISABLE_LOCAL_STORAGE` | Set to `"true"` to disable loading saved settings from local storage on startup | `"false"` | +| 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"}]'` | `"[]"` | +| `VITE_DISABLE_LOCAL_STORAGE` | Set to `"true"` to disable loading saved settings from local storage on startup | `"false"` | ### Docker configuration diff --git a/docker-compose.yml b/docker-compose.yml index 968dec0..0510253 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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:-} diff --git a/env.d.ts b/env.d.ts index 45e8422..c30781d 100644 --- a/env.d.ts +++ b/env.d.ts @@ -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 diff --git a/src/components/QRCodeCreate.vue b/src/components/QRCodeCreate.vue index 34db448..8bd7190 100644 --- a/src/components/QRCodeCreate.vue +++ b/src/components/QRCodeCreate.vue @@ -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