mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-14 09:38:13 +08:00
✏️ 修复 import.meta.env 引用
This commit is contained in:
@@ -133,7 +133,7 @@ async function createDataDir(): Promise<void> {
|
|||||||
|
|
||||||
// 初始化数据库
|
// 初始化数据库
|
||||||
async function initData(): Promise<void> {
|
async function initData(): Promise<void> {
|
||||||
if (!import.meta?.env?.PROD) {
|
if (import.meta.env.MODE === "development") {
|
||||||
console.info("开发环境,跳过数据库初始化!");
|
console.info("开发环境,跳过数据库初始化!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ import { useUserStore } from "../../store/modules/user";
|
|||||||
const appStore = useAppStore();
|
const appStore = useAppStore();
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
|
|
||||||
const isDevEnv = ref<boolean>(!import.meta?.env?.PROD);
|
const isDevEnv = ref<boolean>(import.meta.env.MODE === "development");
|
||||||
|
|
||||||
const userInfo = computed(() => {
|
const userInfo = computed(() => {
|
||||||
const info = userStore.getBriefInfo();
|
const info = userStore.getBriefInfo();
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import "./assets/index.css";
|
|||||||
// gt.js
|
// gt.js
|
||||||
import "https://static.geetest.com/static/js/gt.0.4.9.js";
|
import "https://static.geetest.com/static/js/gt.0.4.9.js";
|
||||||
|
|
||||||
if (import.meta?.env?.MODE === "development") {
|
if (import.meta.env.MODE === "development") {
|
||||||
await import("@vue/devtools").then((i) => {
|
await import("@vue/devtools").then((i) => {
|
||||||
i.default.connect(/* host, port */);
|
i.default.connect(/* host, port */);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -176,7 +176,7 @@ const userStore = useUserStore();
|
|||||||
const homeStore = useHomeStore();
|
const homeStore = useHomeStore();
|
||||||
const achievementsStore = useAchievementsStore();
|
const achievementsStore = useAchievementsStore();
|
||||||
|
|
||||||
const isDevEnv = ref<boolean>(!import.meta?.env?.PROD);
|
const isDevEnv = ref<boolean>(import.meta.env.MODE === "development");
|
||||||
|
|
||||||
// About App
|
// About App
|
||||||
const versionApp = ref<string>("");
|
const versionApp = ref<string>("");
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ function readLoading(): void {
|
|||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
loadingTitle.value = "正在加载首页";
|
loadingTitle.value = "正在加载首页";
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
const isProdEnv = import.meta?.env?.PROD;
|
const isProdEnv = import.meta.env.MODE === "production";
|
||||||
// 获取当前环境
|
// 获取当前环境
|
||||||
if (isProdEnv && appStore.devMode) {
|
if (isProdEnv && appStore.devMode) {
|
||||||
appStore.devMode = false;
|
appStore.devMode = false;
|
||||||
|
|||||||
26
src/vite-env.d.ts
vendored
26
src/vite-env.d.ts
vendored
@@ -2,7 +2,7 @@
|
|||||||
* @file vite-env.d.ts
|
* @file vite-env.d.ts
|
||||||
* @description vite-env.d.ts
|
* @description vite-env.d.ts
|
||||||
* @author BTMuli<bt-muli@outlook.com>
|
* @author BTMuli<bt-muli@outlook.com>
|
||||||
* @since Alpha v0.1.3
|
* @since Beta v0.3.3
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare module "*.vue" {
|
declare module "*.vue" {
|
||||||
@@ -26,3 +26,27 @@ declare module "vue-json-viewer" {
|
|||||||
}>;
|
}>;
|
||||||
export default component;
|
export default component;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description import.meta.env
|
||||||
|
* @package vite
|
||||||
|
* @description 只写了用到的属性
|
||||||
|
*/
|
||||||
|
interface ImportMetaEnv {
|
||||||
|
TAURI_ARCH: string;
|
||||||
|
TAURI_DEBUG: boolean;
|
||||||
|
TAURI_FAMILY: string;
|
||||||
|
TAURI_KEY_PASSWORD: string;
|
||||||
|
TAURI_PLATFORM: string;
|
||||||
|
TAURI_PLATFORM_TYPE: string;
|
||||||
|
BASE_URL: string;
|
||||||
|
MODE: string;
|
||||||
|
DEV: boolean;
|
||||||
|
PROD: boolean;
|
||||||
|
SSR: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare interface ImportMeta {
|
||||||
|
readonly env: ImportMetaEnv;
|
||||||
|
readonly glob: (path: string) => Record<string, () => Promise<any>>;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user