Skip to content

Commit 12f464b

Browse files
authored
fix: frontend environment variable type error (#164)
* fix: frontend environment variable type error * fix: lowcode designer enable type * refactor: remove unused import
1 parent 182fce2 commit 12f464b

2 files changed

Lines changed: 20 additions & 14 deletions

File tree

template/tinyvue/config/vite.config.dev.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ const proxyConfig = {
1616
[loadEnv('', process.cwd()).VITE_MOCK_SERVER_HOST]: {
1717
target: loadEnv('', process.cwd()).VITE_SERVER_HOST,
1818
changeOrigin: true,
19-
rewrite: (path: string) => path.replace(/^\/mock/, '/mock'),
19+
rewrite: (path: string) => {
20+
21+
return path.replace(new RegExp(`${loadEnv('', process.cwd()).VITE_MOCK_SERVER_HOST}`), '/mock')
22+
},
2023
},
2124
};
2225
export default mergeConfig(

template/tinyvue/src/env.d.ts

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,22 @@ declare module '*.vue' {
99
export default component;
1010
}
1111

12-
interface ImportMetaEnv {
13-
readonly VITE_API_BASE_URL: string;
12+
declare global {
13+
interface ImportMetaEnv {
14+
readonly VITE_API_BASE_URL: string;
15+
readonly VITE_MOCK_SERVER_HOST: string;
16+
readonly VITE_LOWCODE_DESIGNER_ENABLED: string;
17+
readonly VITE_CONTEXT: string;
18+
readonly VITE_BASE_API: string;
19+
readonly VITE_SERVER_HOST: string;
20+
readonly VITE_MOCK_HOST: string;
21+
readonly VITE_USE_MOCK: string;
22+
readonly VITE_MOCK_IGNORE: string;
23+
}
24+
declare const BUILD_TOOLS: string;
25+
declare interface NodeRequire {
26+
context: any;
27+
}
1428
}
1529

1630
declare module '@opentiny/vue-locale';
@@ -19,14 +33,3 @@ declare module '@opentiny/vue-icon';
1933
declare module '@opentiny/vue-theme/theme-tool.js';
2034
declare module '@opentiny/vue-theme/theme';
2135
declare module 'query-string';
22-
declare const BUILD_TOOLS: string;
23-
declare interface NodeRequire {
24-
context: any;
25-
}
26-
27-
declare module '@vue/runtime-core' {
28-
interface ComponentCustomProperties {
29-
$t: (key: string) => string;
30-
$tm: (key: string) => [] | { [p: string]: any };
31-
}
32-
}

0 commit comments

Comments
 (0)