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