hookehuyr

新增环境变量类型定义,智能提示

1 +interface ImportMetaEnv extends Readonly<Record<string, string>> {
2 + readonly VITE_OPENID: string
3 + readonly VITE_ID: string
4 + readonly VITE_PIN: string
5 +}
6 +
7 +interface ImportMeta {
8 + readonly env: ImportMetaEnv
9 +}
...@@ -11,8 +11,7 @@ const $route = useRoute(); ...@@ -11,8 +11,7 @@ const $route = useRoute();
11 onMounted(() => { 11 onMounted(() => {
12 // php需要先跳转链接获取openid 12 // php需要先跳转链接获取openid
13 let url = encodeURIComponent(location.origin + location.pathname + $route.query.href); // 未授权的地址 13 let url = encodeURIComponent(location.origin + location.pathname + $route.query.href); // 未授权的地址
14 - if (process.env.NODE_ENV === 'development') { 14 + if (import.meta.env.DEV) { // TAG: 开发环境测试数据
15 - // TAG: 开发环境测试数据
16 location.href = `/srv/?f=voice&a=openid_${$route.query.userType}&res=${url}&input_openid=${import.meta.env.VITE_OPENID}` 15 location.href = `/srv/?f=voice&a=openid_${$route.query.userType}&res=${url}&input_openid=${import.meta.env.VITE_OPENID}`
17 } else { 16 } else {
18 location.href = `/srv/?f=voice&a=openid_${$route.query.userType}&res=${url}`; 17 location.href = `/srv/?f=voice&a=openid_${$route.query.userType}&res=${url}`;
......
...@@ -73,7 +73,7 @@ const validator = (val) => { ...@@ -73,7 +73,7 @@ const validator = (val) => {
73 const phone = ref(''); 73 const phone = ref('');
74 const code = ref(''); 74 const code = ref('');
75 // TAG: 开发环境测试数据 75 // TAG: 开发环境测试数据
76 -if (process.env.NODE_ENV === 'development') { 76 +if (import.meta.env.DEV) {
77 phone.value = import.meta.env.VITE_ID 77 phone.value = import.meta.env.VITE_ID
78 code.value = import.meta.env.VITE_PIN 78 code.value = import.meta.env.VITE_PIN
79 } 79 }
......