新增一个 devEnv 用于判断生产环境|开发环境

fix #26
This commit is contained in:
BTMuli
2023-05-24 15:45:03 +08:00
parent d1e39ed8cd
commit f55a688aae
4 changed files with 23 additions and 12 deletions

View File

@@ -40,12 +40,12 @@
</template> </template>
</v-list-item> </v-list-item>
<v-divider /> <v-divider />
<v-list-item title="测试" value="test" link href="/user/test"> <v-list-item v-show="appStore.devEnv" title="测试" value="test" link href="/user/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-divider v-show="appStore.devEnv" />
<v-list-group value="wiki" fluid> <v-list-group value="wiki" fluid>
<template #activator="{ props }"> <template #activator="{ props }">
<v-list-item title="图鉴" v-bind="props"> <v-list-item title="图鉴" v-bind="props">

View File

@@ -119,7 +119,7 @@
调试 调试
</v-list-subheader> </v-list-subheader>
<v-divider inset class="border-opacity-75" /> <v-divider inset class="border-opacity-75" />
<v-list-item title="开发者模式" subtitle="开启后将显示调试信息"> <v-list-item v-if="appStore.devEnv" title="调试模式" subtitle="开启后将显示调试信息">
<template #prepend> <template #prepend>
<v-icon>mdi-bug</v-icon> <v-icon>mdi-bug</v-icon>
</template> </template>
@@ -138,12 +138,9 @@
<span style="cursor: pointer" @click="tryConfirm('inputCookie')">手动输入 Cookie</span> <span style="cursor: pointer" @click="tryConfirm('inputCookie')">手动输入 Cookie</span>
</template> </template>
<template #append> <template #append>
<div style="cursor: pointer" @click="toOuter('https://github.com/BTMuli/Tauri.Genshin/issues/18')"> <v-icon style="cursor: pointer" @click="toOuter('https://github.com/BTMuli/Tauri.Genshin/issues/18')">
<span>如何获取 Cookie</span> mdi-help-circle-outline
<v-icon @click=""> </v-icon>
mdi-help-circle-outline
</v-icon>
</div>
</template> </template>
</v-list-item> </v-list-item>
<v-list-item title="删除 IndexedDB" prepend-icon="mdi-delete" @click="tryConfirm('delDB')" /> <v-list-item title="删除 IndexedDB" prepend-icon="mdi-delete" @click="tryConfirm('delDB')" />
@@ -178,7 +175,6 @@
<script lang="ts" setup> <script lang="ts" setup>
// vue // vue
import { computed, onMounted, ref } from "vue"; import { computed, onMounted, ref } from "vue";
import { getBuildTime } from "../utils/TGBuild";
import TLoading from "../components/t-loading.vue"; import TLoading from "../components/t-loading.vue";
import TConfirm from "../components/t-confirm.vue"; import TConfirm from "../components/t-confirm.vue";
// tauri // tauri
@@ -204,7 +200,7 @@ const achievementsStore = useAchievementsStore();
// About App // About App
const versionApp = ref("" as string); const versionApp = ref("" as string);
const versionTauri = ref("" as string); const versionTauri = ref("" as string);
const buildTime = ref(getBuildTime()); const buildTime = computed(() => appStore.buildTime);
// About OS // About OS
const osPlatform = ref("" as string); const osPlatform = ref("" as string);

View File

@@ -12,8 +12,12 @@ import TPosition from "../components/t-position.vue";
import TCalendar from "../components/t-calendar.vue"; import TCalendar from "../components/t-calendar.vue";
// store // store
import { useHomeStore } from "../store/modules/home"; import { useHomeStore } from "../store/modules/home";
import { useAppStore } from "../store/modules/app";
// utils
import { getBuildTime } from "../utils/TGBuild";
// store // store
const appStore = useAppStore();
const homeStore = useHomeStore(); const homeStore = useHomeStore();
// loading // loading
@@ -57,6 +61,13 @@ onMounted(async () => {
}), }),
); );
timer.value = setInterval(readLoading, 100); timer.value = setInterval(readLoading, 100);
// 获取当前环境
const timeGet = getBuildTime();
appStore.devEnv = timeGet.startsWith("dev");
if (!appStore.devEnv && appStore.devMode) {
appStore.devMode = false;
}
appStore.buildTime = getBuildTime();
}); });
function setItemRef (item: any) { function setItemRef (item: any) {

View File

@@ -38,6 +38,8 @@ export const useAppStore = defineStore(
}); });
// 开发者模式 // 开发者模式
const devMode = ref(false); const devMode = ref(false);
// 环境检测
const devEnv = ref(false);
// 应用主题 // 应用主题
const theme = ref("default"); const theme = ref("default");
// 是否登录 // 是否登录
@@ -57,6 +59,7 @@ 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,
}; };
@@ -81,6 +84,7 @@ export const useAppStore = defineStore(
buildTime, buildTime,
sidebar, sidebar,
devMode, devMode,
devEnv,
dataPath, dataPath,
userPath, userPath,
init, init,
@@ -98,7 +102,7 @@ export const useAppStore = defineStore(
{ {
key: "app", key: "app",
storage: window.localStorage, storage: window.localStorage,
paths: ["devMode", "loading", "buildTime", "isLogin"], paths: ["devMode", "loading", "buildTime", "isLogin", "devEnv"],
}, },
{ {
key: "sidebar", key: "sidebar",