fix(title): window.appWindow.setTitle

This commit is contained in:
BTMuli
2023-04-03 08:21:47 +08:00
parent f4bac5622a
commit 2a56d7ee8c
2 changed files with 8 additions and 1 deletions

View File

@@ -30,7 +30,7 @@ import { onMounted, ref } from "vue";
import TSidebar from "./components/t-sidebar.vue";
import TBackTop from "./components/t-backTop.vue";
// tauri
import { fs, window } from "@tauri-apps/api";
import { fs, window, app } from "@tauri-apps/api";
// store
import useAppStore from "./store/modules/app";
// utils
@@ -46,6 +46,8 @@ onMounted(async () => {
const win = await window.getCurrent();
isMain.value = win.label === "tauri-genshin";
if (isMain.value) {
const title = "Tauri.Genshin v" + (await app.getVersion()) + " Alpha";
await win.setTitle(title);
await checkLoad();
}
});

View File

@@ -9,6 +9,8 @@
import { ref, onMounted } from "vue";
import { useRoute } from "vue-router";
import TLoading from "../components/t-loading.vue";
// tauri
import { appWindow } from "@tauri-apps/api/window";
// plugins
import MysOper from "../plugins/Mys";
@@ -26,6 +28,7 @@ onMounted(async () => {
if (!post_id) {
loadingEmpty.value = true;
loadingTitle.value = "未找到数据";
await appWindow.setTitle("未找到数据");
return;
}
// 获取数据
@@ -34,9 +37,11 @@ onMounted(async () => {
const postData = await MysOper.Post.get(post_id);
loadingTitle.value = "正在渲染数据...";
postHtml.value = MysOper.Post.parser(postData);
await appWindow.setTitle(postData.post.subject);
} catch (error) {
loadingEmpty.value = true;
loadingTitle.value = "帖子不存在或解析失败";
await appWindow.setTitle("帖子不存在或解析失败");
return;
}
setInterval(() => {