mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-12 09:18:14 +08:00
♻️ 通过 import.meta 获取当前环境
This commit is contained in:
@@ -96,7 +96,7 @@ async function createDataDir(): Promise<void> {
|
|||||||
|
|
||||||
// 初始化数据库
|
// 初始化数据库
|
||||||
async function initData(): Promise<void> {
|
async function initData(): Promise<void> {
|
||||||
if (appStore.devEnv) {
|
if (!import.meta?.env?.PROD) {
|
||||||
console.info("开发环境,跳过数据库初始化!");
|
console.info("开发环境,跳过数据库初始化!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,12 +57,12 @@
|
|||||||
</template>
|
</template>
|
||||||
</v-list-item>
|
</v-list-item>
|
||||||
<v-divider />
|
<v-divider />
|
||||||
<v-list-item v-show="appStore.devEnv" title="测试" value="test" :link="true" href="/test">
|
<v-list-item v-show="isDevEnv" title="测试" value="test" :link="true" href="/test">
|
||||||
<template #prepend>
|
<template #prepend>
|
||||||
<v-icon>mdi-test-tube</v-icon>
|
<v-icon>mdi-test-tube</v-icon>
|
||||||
</template>
|
</template>
|
||||||
</v-list-item>
|
</v-list-item>
|
||||||
<v-divider v-show="appStore.devEnv" />
|
<v-divider v-show="isDevEnv" />
|
||||||
<v-list-group value="wiki" :fluid="true">
|
<v-list-group value="wiki" :fluid="true">
|
||||||
<template #activator="{ props }">
|
<template #activator="{ props }">
|
||||||
<v-list-item title="图鉴" v-bind="props">
|
<v-list-item title="图鉴" v-bind="props">
|
||||||
@@ -132,6 +132,8 @@ 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 userInfo = computed(() => {
|
const userInfo = computed(() => {
|
||||||
const info = userStore.getBriefInfo();
|
const info = userStore.getBriefInfo();
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -107,7 +107,7 @@
|
|||||||
<v-list-subheader :inset="true" class="config-header" title="调试" />
|
<v-list-subheader :inset="true" class="config-header" title="调试" />
|
||||||
<v-divider :inset="true" class="border-opacity-75" />
|
<v-divider :inset="true" class="border-opacity-75" />
|
||||||
<v-list-item
|
<v-list-item
|
||||||
v-if="appStore.devEnv"
|
v-if="isDevEnv"
|
||||||
title="调试模式"
|
title="调试模式"
|
||||||
subtitle="开启后将显示调试信息"
|
subtitle="开启后将显示调试信息"
|
||||||
prepend-icon="mdi-bug-play"
|
prepend-icon="mdi-bug-play"
|
||||||
@@ -176,6 +176,8 @@ const userStore = useUserStore();
|
|||||||
const homeStore = useHomeStore();
|
const homeStore = useHomeStore();
|
||||||
const achievementsStore = useAchievementsStore();
|
const achievementsStore = useAchievementsStore();
|
||||||
|
|
||||||
|
const isDevEnv = ref<boolean>(!import.meta?.env?.PROD);
|
||||||
|
|
||||||
// About App
|
// About App
|
||||||
const versionApp = ref<string>("");
|
const versionApp = ref<string>("");
|
||||||
const versionTauri = ref<string>("");
|
const versionTauri = ref<string>("");
|
||||||
|
|||||||
@@ -49,10 +49,9 @@ function readLoading(): void {
|
|||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
loadingTitle.value = "正在加载首页";
|
loadingTitle.value = "正在加载首页";
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
|
const isProdEnv = import.meta?.env?.PROD;
|
||||||
// 获取当前环境
|
// 获取当前环境
|
||||||
const timeGet = getBuildTime();
|
if (isProdEnv && appStore.devMode) {
|
||||||
appStore.devEnv = timeGet.startsWith("dev");
|
|
||||||
if (!appStore.devEnv && appStore.devMode) {
|
|
||||||
appStore.devMode = false;
|
appStore.devMode = false;
|
||||||
}
|
}
|
||||||
const showItems = homeStore.getShowValue();
|
const showItems = homeStore.getShowValue();
|
||||||
@@ -71,7 +70,7 @@ onMounted(async () => {
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
timer.value = setInterval(readLoading, 100);
|
timer.value = setInterval(readLoading, 100);
|
||||||
if (appStore.buildTime !== getBuildTime() && !appStore.devEnv) {
|
if (appStore.buildTime !== getBuildTime() && isProdEnv) {
|
||||||
const confirm = await showConfirm({
|
const confirm = await showConfirm({
|
||||||
title: "检测到版本更新",
|
title: "检测到版本更新",
|
||||||
text: "请到设置页手动更新版本,即将弹出更新说明子页面",
|
text: "请到设置页手动更新版本,即将弹出更新说明子页面",
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
* @file store modules app.ts
|
* @file store modules app.ts
|
||||||
* @description App store module
|
* @description App store module
|
||||||
* @author BTMuli <bt-muli@outlook.com>
|
* @author BTMuli <bt-muli@outlook.com>
|
||||||
* @since Beta v0.3.1
|
* @since Beta v0.3.3
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// vue
|
// vue
|
||||||
@@ -36,8 +36,6 @@ export const useAppStore = defineStore(
|
|||||||
});
|
});
|
||||||
// 开发者模式
|
// 开发者模式
|
||||||
const devMode = ref(false);
|
const devMode = ref(false);
|
||||||
// 环境检测
|
|
||||||
const devEnv = ref(false);
|
|
||||||
// 应用主题
|
// 应用主题
|
||||||
const theme = ref("default");
|
const theme = ref("default");
|
||||||
|
|
||||||
@@ -54,7 +52,6 @@ export const useAppStore = defineStore(
|
|||||||
function init(): void {
|
function init(): void {
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
devMode.value = false;
|
devMode.value = false;
|
||||||
devEnv.value = false;
|
|
||||||
sidebar.submenu = {
|
sidebar.submenu = {
|
||||||
wiki: false,
|
wiki: false,
|
||||||
};
|
};
|
||||||
@@ -78,7 +75,6 @@ export const useAppStore = defineStore(
|
|||||||
buildTime,
|
buildTime,
|
||||||
sidebar,
|
sidebar,
|
||||||
devMode,
|
devMode,
|
||||||
devEnv,
|
|
||||||
dataPath,
|
dataPath,
|
||||||
userPath,
|
userPath,
|
||||||
init,
|
init,
|
||||||
@@ -96,7 +92,7 @@ export const useAppStore = defineStore(
|
|||||||
{
|
{
|
||||||
key: "app",
|
key: "app",
|
||||||
storage: window.localStorage,
|
storage: window.localStorage,
|
||||||
paths: ["devMode", "loading", "buildTime", "devEnv"],
|
paths: ["devMode", "loading", "buildTime"],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: "sidebar",
|
key: "sidebar",
|
||||||
|
|||||||
Reference in New Issue
Block a user