mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-13 09:28:14 +08:00
⚡️ 微调
This commit is contained in:
@@ -198,7 +198,7 @@
|
|||||||
class="side-item-menu"
|
class="side-item-menu"
|
||||||
title="登录"
|
title="登录"
|
||||||
@click="login"
|
@click="login"
|
||||||
v-show="userStore.cookie.value?.game_token === ''"
|
v-show="userStore.cookie.value?.stoken === ''"
|
||||||
>
|
>
|
||||||
<template #prepend>
|
<template #prepend>
|
||||||
<img src="/source/UI/lumine.webp" class="side-icon-menu" alt="login" />
|
<img src="/source/UI/lumine.webp" class="side-icon-menu" alt="login" />
|
||||||
@@ -227,8 +227,9 @@
|
|||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { event, window as TauriWindow } from "@tauri-apps/api";
|
import { event, window as TauriWindow } from "@tauri-apps/api";
|
||||||
|
import { UnlistenFn } from "@tauri-apps/api/helpers/event";
|
||||||
import { storeToRefs } from "pinia";
|
import { storeToRefs } from "pinia";
|
||||||
import { computed, onMounted, ref, watch } from "vue";
|
import { computed, onMounted, onUnmounted, ref, watch } from "vue";
|
||||||
|
|
||||||
import { useAppStore } from "../../store/modules/app";
|
import { useAppStore } from "../../store/modules/app";
|
||||||
import { useUserStore } from "../../store/modules/user";
|
import { useUserStore } from "../../store/modules/user";
|
||||||
@@ -273,20 +274,18 @@ function collapse(): void {
|
|||||||
appStore.sidebar.collapse = rail.value;
|
appStore.sidebar.collapse = rail.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let themeListener: UnlistenFn;
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await listenOnTheme();
|
themeListener = await event.listen("readTheme", (e) => {
|
||||||
|
const theme = <string>e.payload;
|
||||||
|
themeGet.value = theme === "default" ? "default" : "dark";
|
||||||
|
});
|
||||||
if (TauriWindow.getCurrent().label === "TeyvatGuide") {
|
if (TauriWindow.getCurrent().label === "TeyvatGuide") {
|
||||||
await mhyClient.run();
|
await mhyClient.run();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
async function listenOnTheme(): Promise<void> {
|
|
||||||
await event.listen("readTheme", (e) => {
|
|
||||||
const theme = <string>e.payload;
|
|
||||||
themeGet.value = theme === "default" ? "default" : "dark";
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async function switchTheme(): Promise<void> {
|
async function switchTheme(): Promise<void> {
|
||||||
await event.emit("readTheme", themeGet.value === "default" ? "dark" : "default");
|
await event.emit("readTheme", themeGet.value === "default" ? "dark" : "default");
|
||||||
}
|
}
|
||||||
@@ -304,6 +303,14 @@ function login(): void {
|
|||||||
text: "请前往设置页面扫码登录",
|
text: "请前往设置页面扫码登录",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function codeScan(detectedCodes): Promise<void> {
|
||||||
|
console.log("codeScan", detectedCodes);
|
||||||
|
}
|
||||||
|
|
||||||
|
onUnmounted(() => {
|
||||||
|
themeListener();
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="css" scoped>
|
<style lang="css" scoped>
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
import { event, invoke } from "@tauri-apps/api";
|
import { event, invoke } from "@tauri-apps/api";
|
||||||
import type { Event } from "@tauri-apps/api/event";
|
import type { Event } from "@tauri-apps/api/event";
|
||||||
|
import type { UnlistenFn } from "@tauri-apps/api/helpers/event";
|
||||||
import { appWindow, WebviewWindow } from "@tauri-apps/api/window";
|
import { appWindow, WebviewWindow } from "@tauri-apps/api/window";
|
||||||
|
|
||||||
import { parseLink } from "./linkParser";
|
import { parseLink } from "./linkParser";
|
||||||
@@ -38,7 +39,7 @@ class TGClient {
|
|||||||
* @type {EventEmitter}
|
* @type {EventEmitter}
|
||||||
* @memberof TGClient
|
* @memberof TGClient
|
||||||
*/
|
*/
|
||||||
private listener: any;
|
private listener: UnlistenFn | undefined;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private 窗口实例
|
* @private 窗口实例
|
||||||
@@ -83,6 +84,8 @@ class TGClient {
|
|||||||
this.listener = await event.listen("post_mhy_client", async (arg: Event<string>) => {
|
this.listener = await event.listen("post_mhy_client", async (arg: Event<string>) => {
|
||||||
await this.handleCallback(arg);
|
await this.handleCallback(arg);
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
console.warn("[TGClient][run] 监听器已存在");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user