🐛 修复一堆bug

This commit is contained in:
目棃
2024-09-06 11:23:19 +08:00
parent 8e995283ea
commit 599f9273e2
23 changed files with 102 additions and 492 deletions

View File

@@ -23,10 +23,10 @@ const themeGet = computed({
appStore.theme = value;
},
});
let themeListener: UnlistenFn;
let themeListener: UnlistenFn | null = null;
onMounted(() => {
themeListener = listenOnTheme();
onMounted(async () => {
themeListener = await listenOnTheme();
});
async function switchTheme(): Promise<void> {
@@ -34,14 +34,19 @@ async function switchTheme(): Promise<void> {
await event.emit("readTheme", themeGet.value);
}
function listenOnTheme(): UnlistenFn {
return event.listen("readTheme", (e: Event<string>) => {
async function listenOnTheme(): Promise<UnlistenFn> {
return await event.listen("readTheme", (e: Event<string>) => {
const theme = e.payload;
themeGet.value = theme === "default" ? "default" : "dark";
});
}
onUnmounted(() => themeListener());
onUnmounted(() => {
if (themeListener !== null) {
themeListener();
themeListener = null;
}
});
</script>
<style lang="css" scoped>
.switch-box {