Skip to content

Commit 1e21f8c

Browse files
update(other): 🧩 update
update logic generate env variable in client-side
1 parent c2a67d9 commit 1e21f8c

File tree

4 files changed

+30
-16
lines changed

4 files changed

+30
-16
lines changed

config/.eslintrc-auto-import.json

+16-15
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,24 @@
77
"ExtractDefaultPropTypes": true,
88
"ExtractPropTypes": true,
99
"ExtractPublicPropTypes": true,
10+
"GENERAL_GREETING": true,
1011
"InjectionKey": true,
1112
"PropType": true,
13+
"ROUTER_BASE_PATH": true,
14+
"ROUTER_COMMENT_NAME": true,
15+
"ROUTER_COMMENT_PATH": true,
16+
"ROUTER_CONTENT_COMMENT_NAME": true,
17+
"ROUTER_CONTENT_COMMENT_PATH": true,
18+
"ROUTER_CONTENT_NAME": true,
19+
"ROUTER_CONTENT_PATH": true,
20+
"ROUTER_HOME_NAME": true,
21+
"ROUTER_HOME_PATH": true,
22+
"ROUTER_LOGIN_NAME": true,
23+
"ROUTER_LOGIN_PATH": true,
24+
"ROUTER_NOT_FOUND_NAME": true,
25+
"ROUTER_NOT_FOUND_PATH": true,
1226
"Ref": true,
27+
"STORE_KEY_USER": true,
1328
"VNode": true,
1429
"WritableComputedRef": true,
1530
"computed": true,
@@ -83,20 +98,6 @@
8398
"watch": true,
8499
"watchEffect": true,
85100
"watchPostEffect": true,
86-
"watchSyncEffect": true,
87-
"ROUTER_BASE_PATH": true,
88-
"ROUTER_COMMENT_NAME": true,
89-
"ROUTER_COMMENT_PATH": true,
90-
"ROUTER_CONTENT_COMMENT_NAME": true,
91-
"ROUTER_CONTENT_COMMENT_PATH": true,
92-
"ROUTER_CONTENT_NAME": true,
93-
"ROUTER_CONTENT_PATH": true,
94-
"ROUTER_HOME_NAME": true,
95-
"ROUTER_HOME_PATH": true,
96-
"ROUTER_LOGIN_NAME": true,
97-
"ROUTER_LOGIN_PATH": true,
98-
"ROUTER_NOT_FOUND_NAME": true,
99-
"ROUTER_NOT_FOUND_PATH": true,
100-
"STORE_KEY_USER": true
101+
"watchSyncEffect": true
101102
}
102103
}

config/auto-imports.d.ts

+7
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
export {}
77
declare global {
88
const EffectScope: typeof import('vue')['EffectScope']
9+
const GENERAL_GREETING: typeof import('@/config/env/ENV_AUTO_IMPORT.mjs')['GENERAL_GREETING']
910
const ROUTER_BASE_PATH: typeof import('@/config/env/ENV_AUTO_IMPORT.mjs')['ROUTER_BASE_PATH']
1011
const ROUTER_COMMENT_NAME: typeof import('@/config/env/ENV_AUTO_IMPORT.mjs')['ROUTER_COMMENT_NAME']
1112
const ROUTER_COMMENT_PATH: typeof import('@/config/env/ENV_AUTO_IMPORT.mjs')['ROUTER_COMMENT_PATH']
@@ -116,6 +117,9 @@ import { UnwrapRef } from 'vue'
116117
declare module 'vue' {
117118
interface ComponentCustomProperties {
118119
readonly EffectScope: UnwrapRef<typeof import('vue')['EffectScope']>
120+
readonly GENERAL_GREETING: UnwrapRef<
121+
typeof import('@/config/env/ENV_AUTO_IMPORT.mjs')['GENERAL_GREETING']
122+
>
119123
readonly ROUTER_BASE_PATH: UnwrapRef<
120124
typeof import('@/config/env/ENV_AUTO_IMPORT.mjs')['ROUTER_BASE_PATH']
121125
>
@@ -279,6 +283,9 @@ declare module 'vue' {
279283
declare module '@vue/runtime-core' {
280284
interface ComponentCustomProperties {
281285
readonly EffectScope: UnwrapRef<typeof import('vue')['EffectScope']>
286+
readonly GENERAL_GREETING: UnwrapRef<
287+
typeof import('@/config/env/ENV_AUTO_IMPORT.mjs')['GENERAL_GREETING']
288+
>
282289
readonly ROUTER_BASE_PATH: UnwrapRef<
283290
typeof import('@/config/env/ENV_AUTO_IMPORT.mjs')['ROUTER_BASE_PATH']
284291
>

config/env/ENV_AUTO_IMPORT.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export const ROUTER_BASE_PATH="/";export const ROUTER_HOME_NAME="HomePage";export const ROUTER_HOME_PATH="/";export const ROUTER_CONTENT_NAME="ContentPage";export const ROUTER_CONTENT_PATH="/:title?-:id(\\d+)?";export const ROUTER_CONTENT_COMMENT_NAME="ContentComment";export const ROUTER_CONTENT_COMMENT_PATH="comment";export const ROUTER_COMMENT_NAME="CommentPage";export const ROUTER_COMMENT_PATH="comment/detail";export const ROUTER_LOGIN_NAME="LoginPage";export const ROUTER_LOGIN_PATH="/login";export const ROUTER_NOT_FOUND_NAME="NotFoundPage";export const ROUTER_NOT_FOUND_PATH="/:pathMatch(.*)*";export const STORE_KEY_USER="user";export const ENV_VARIABLE_EXPORTER_FOR_AUTO_IMPORT={"@/config/env/ENV_AUTO_IMPORT.mjs":["ROUTER_BASE_PATH","ROUTER_HOME_NAME","ROUTER_HOME_PATH","ROUTER_CONTENT_NAME","ROUTER_CONTENT_PATH","ROUTER_CONTENT_COMMENT_NAME","ROUTER_CONTENT_COMMENT_PATH","ROUTER_COMMENT_NAME","ROUTER_COMMENT_PATH","ROUTER_LOGIN_NAME","ROUTER_LOGIN_PATH","ROUTER_NOT_FOUND_NAME","ROUTER_NOT_FOUND_PATH","STORE_KEY_USER"]}
1+
export const ROUTER_BASE_PATH="/";export const ROUTER_HOME_NAME="HomePage";export const ROUTER_HOME_PATH="/";export const ROUTER_CONTENT_NAME="ContentPage";export const ROUTER_CONTENT_PATH="/:title?-:id(\\d+)?";export const ROUTER_CONTENT_COMMENT_NAME="ContentComment";export const ROUTER_CONTENT_COMMENT_PATH="comment";export const ROUTER_COMMENT_NAME="CommentPage";export const ROUTER_COMMENT_PATH="comment/detail";export const ROUTER_LOGIN_NAME="LoginPage";export const ROUTER_LOGIN_PATH="/login";export const ROUTER_NOT_FOUND_NAME="NotFoundPage";export const ROUTER_NOT_FOUND_PATH="/:pathMatch(.*)*";export const GENERAL_GREETING="Vue 3.x";export const STORE_KEY_USER="user";export const ENV_VARIABLE_EXPORTER_FOR_AUTO_IMPORT={"@/config/env/ENV_AUTO_IMPORT.mjs":["ROUTER_BASE_PATH","ROUTER_HOME_NAME","ROUTER_HOME_PATH","ROUTER_CONTENT_NAME","ROUTER_CONTENT_PATH","ROUTER_CONTENT_COMMENT_NAME","ROUTER_CONTENT_COMMENT_PATH","ROUTER_COMMENT_NAME","ROUTER_COMMENT_PATH","ROUTER_LOGIN_NAME","ROUTER_LOGIN_PATH","ROUTER_NOT_FOUND_NAME","ROUTER_NOT_FOUND_PATH","GENERAL_GREETING","STORE_KEY_USER"]}

config/env/env.mjs

+6
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ const generateObjectFormatted = (obj, prefix) => {
5454

5555
delete obj[key]
5656
} else {
57+
ENV_VARIABLE_EXPORTER += `export const ${tmpKey}=${JSON.stringify(
58+
obj[key]
59+
)};`
60+
ENV_VARIABLE_EXPORTER_FOR_AUTO_IMPORT[
61+
'@/config/env/ENV_AUTO_IMPORT.mjs'
62+
].push(tmpKey)
5763
setValueForObject(ENV_OBJECT_DEFAULT, tmpKey, obj[key])
5864
setValueForObject(
5965
ENV_OBJ_WITH_JSON_STRINGIFY_VALUE,

0 commit comments

Comments
 (0)