mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2026-03-15 03:53:16 +08:00
♻️ 移除isInAdmin的store
This commit is contained in:
@@ -31,13 +31,12 @@ import { openUrl } from "@tauri-apps/plugin-opener";
|
||||
import { getBuildTime } from "@utils/TGBuild.js";
|
||||
import TGLogger from "@utils/TGLogger.js";
|
||||
import { getWindowSize, resizeWindow } from "@utils/TGWindow.js";
|
||||
import { isRunInAdmin } from "@utils/toolFunc.js";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { computed, nextTick, onMounted, onUnmounted, ref } from "vue";
|
||||
import { useRouter } from "vue-router";
|
||||
|
||||
const router = useRouter();
|
||||
const { theme, needResize, deviceInfo, isLogin, userDir, buildTime, closeToTray, isInAdmin } =
|
||||
const { theme, needResize, deviceInfo, isLogin, userDir, buildTime, closeToTray } =
|
||||
storeToRefs(useAppStore());
|
||||
const { uid, briefInfo, account, cookie } = storeToRefs(useUserStore());
|
||||
|
||||
@@ -63,7 +62,6 @@ onMounted(async () => {
|
||||
yaeListener = await event.listen<TGApp.Plugins.Yae.RsEvent>("yae_read", handleYaeListen);
|
||||
closeListener = await event.listen("main-window-close-requested", handleWindowClose);
|
||||
await nextTick();
|
||||
if (isInAdmin.value) await win.setTitle(`${title} - AdminMode`);
|
||||
}
|
||||
if (needResize.value !== "false") await resizeWindow();
|
||||
document.documentElement.className = theme.value;
|
||||
@@ -228,7 +226,6 @@ async function handleResizeListen(event: Event<string>): Promise<void> {
|
||||
async function listenOnInit(): Promise<void> {
|
||||
console.info("[App][listenOnInit] 监听初始化事件!");
|
||||
await event.listen<void>("initApp", async () => {
|
||||
await checkIsAdmin();
|
||||
await checkAppLoad();
|
||||
await checkDeviceFp();
|
||||
try {
|
||||
@@ -242,10 +239,6 @@ async function listenOnInit(): Promise<void> {
|
||||
});
|
||||
}
|
||||
|
||||
async function checkIsAdmin(): Promise<void> {
|
||||
isInAdmin.value = await isRunInAdmin();
|
||||
}
|
||||
|
||||
async function checkAppLoad(): Promise<void> {
|
||||
let checkDB = false;
|
||||
try {
|
||||
|
||||
@@ -317,11 +317,12 @@ import { exists } from "@tauri-apps/plugin-fs";
|
||||
import { Command } from "@tauri-apps/plugin-shell";
|
||||
import mhyClient from "@utils/TGClient.js";
|
||||
import TGLogger from "@utils/TGLogger.js";
|
||||
import { isRunInAdmin } from "@utils/toolFunc.js";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { computed, onMounted, onUnmounted, ref, shallowRef } from "vue";
|
||||
|
||||
const userStore = useUserStore();
|
||||
const { sidebar, theme, isLogin, recentNewsType, gameDir, isInAdmin } = storeToRefs(useAppStore());
|
||||
const { sidebar, theme, isLogin, recentNewsType, gameDir } = storeToRefs(useAppStore());
|
||||
const { uid, briefInfo, cookie, account } = storeToRefs(userStore);
|
||||
let themeListener: UnlistenFn | null = null;
|
||||
// @ts-expect-error The import.meta meta-property is not allowed in files which will build into CommonJS output.
|
||||
@@ -720,7 +721,8 @@ async function tryLaunchGame(): Promise<void> {
|
||||
await TGLogger.Error(`[sidebar][tryLaunchGame] resp: ${JSON.stringify(resp)}`);
|
||||
return;
|
||||
}
|
||||
if (!isInAdmin.value) {
|
||||
const isInAdmin = await isRunInAdmin();
|
||||
if (!isInAdmin) {
|
||||
showSnackbar.success(`成功获取ticket:${resp},正在启动应用...`);
|
||||
const cmd = Command.create("exec-sh", [`&"${gamePath}" login_auth_ticket=${resp}`], {
|
||||
cwd: gameDir.value,
|
||||
|
||||
@@ -99,6 +99,7 @@ import { open, save } from "@tauri-apps/plugin-dialog";
|
||||
import { exists, writeTextFile } from "@tauri-apps/plugin-fs";
|
||||
import { platform } from "@tauri-apps/plugin-os";
|
||||
import TGLogger from "@utils/TGLogger.js";
|
||||
import { isRunInAdmin } from "@utils/toolFunc.js";
|
||||
import {
|
||||
getUiafHeader,
|
||||
readUiafData,
|
||||
@@ -115,7 +116,7 @@ const seriesList = AppAchievementSeriesData.sort((a, b) => a.order - b.order).ma
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const { gameDir, isInAdmin, isLogin } = storeToRefs(useAppStore());
|
||||
const { gameDir, isLogin } = storeToRefs(useAppStore());
|
||||
const { account } = storeToRefs(useUserStore());
|
||||
|
||||
let achiListener: UnlistenFn | null = null;
|
||||
@@ -327,7 +328,8 @@ async function toYae(): Promise<void> {
|
||||
showSnackbar.warn("未检测到原神本体应用!");
|
||||
return;
|
||||
}
|
||||
if (!isInAdmin.value) {
|
||||
const isInAdmin = await isRunInAdmin();
|
||||
if (!isInAdmin) {
|
||||
const check = await showDialog.check("是否以管理员模式重启?", "该功能需要管理员权限才能使用");
|
||||
if (!check) {
|
||||
showSnackbar.cancel("已取消以管理员模式重启");
|
||||
|
||||
@@ -126,6 +126,7 @@ import { invoke } from "@tauri-apps/api/core";
|
||||
import { exists } from "@tauri-apps/plugin-fs";
|
||||
import { platform } from "@tauri-apps/plugin-os";
|
||||
import TGLogger from "@utils/TGLogger.js";
|
||||
import { isRunInAdmin } from "@utils/toolFunc.js";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { nextTick, onMounted, ref, shallowRef, triggerRef, watch } from "vue";
|
||||
|
||||
@@ -165,7 +166,7 @@ export type MaterialInfo = {
|
||||
info: TGApp.App.Material.WikiItem;
|
||||
};
|
||||
|
||||
const { gameDir, isInAdmin, isLogin } = storeToRefs(useAppStore());
|
||||
const { gameDir, isLogin } = storeToRefs(useAppStore());
|
||||
const { account } = storeToRefs(useUserStore());
|
||||
|
||||
const sortList: Array<MaterialSort> = [
|
||||
@@ -347,7 +348,8 @@ async function tryCallYae(): Promise<void> {
|
||||
showSnackbar.warn("未检测到原神本体应用!");
|
||||
return;
|
||||
}
|
||||
if (!isInAdmin.value) {
|
||||
const isInAdmin = await isRunInAdmin();
|
||||
if (!isInAdmin) {
|
||||
const check = await showDialog.check("是否以管理员模式重启?", "该功能需要管理员权限才能使用");
|
||||
if (!check) {
|
||||
showSnackbar.cancel("已取消以管理员模式重启");
|
||||
|
||||
@@ -65,8 +65,6 @@ const useAppStore = defineStore(
|
||||
const cancelLike = ref<boolean>(true);
|
||||
/** 关闭窗口时最小化到托盘 */
|
||||
const closeToTray = ref<boolean>(false);
|
||||
/** 是否是管理员模式 */
|
||||
const isInAdmin = ref<boolean>(false);
|
||||
|
||||
/**
|
||||
* 初始化应用状态
|
||||
@@ -150,7 +148,6 @@ const useAppStore = defineStore(
|
||||
init,
|
||||
changeTheme,
|
||||
getImageUrl,
|
||||
isInAdmin,
|
||||
};
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user