mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2026-03-25 05:29:45 +08:00
♻️ use opener instead of window.open/shell
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { app } from "@tauri-apps/api";
|
||||
import { openUrl } from "@tauri-apps/plugin-opener";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { onMounted, ref } from "vue";
|
||||
|
||||
@@ -33,24 +34,24 @@ const versionApp = ref<string>();
|
||||
|
||||
onMounted(async () => (versionApp.value = await app.getVersion()));
|
||||
|
||||
function toRelease(): void {
|
||||
window.open("https://github.com/BTMuli/TeyvatGuide/releases/latest");
|
||||
async function toRelease(): Promise<void> {
|
||||
await openUrl("https://github.com/BTMuli/TeyvatGuide/releases/latest");
|
||||
}
|
||||
|
||||
function toGroup(): void {
|
||||
window.open("https://h5.qun.qq.com/s/3cgX0hJ4GA");
|
||||
async function toGroup(): Promise<void> {
|
||||
await openUrl("https://h5.qun.qq.com/s/3cgX0hJ4GA");
|
||||
}
|
||||
|
||||
function toGithub(): void {
|
||||
window.open("https://github.com/BTMuli/TeyvatGuide");
|
||||
async function toGithub(): Promise<void> {
|
||||
await openUrl("https://github.com/BTMuli/TeyvatGuide");
|
||||
}
|
||||
|
||||
function toStore(): void {
|
||||
window.open("https://www.microsoft.com/store/productId/9NLBNNNBNSJN");
|
||||
async function toStore(): Promise<void> {
|
||||
await openUrl("https://www.microsoft.com/store/productId/9NLBNNNBNSJN");
|
||||
}
|
||||
|
||||
function toSite(): void {
|
||||
window.open("https://app.btmuli.ink/docs/TeyvatGuide/changelogs.html");
|
||||
async function toSite(): Promise<void> {
|
||||
await openUrl("https://app.btmuli.ink/docs/TeyvatGuide/changelogs.html");
|
||||
}
|
||||
</script>
|
||||
<style lang="css" scoped>
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<template #append>
|
||||
<div class="config-opers">
|
||||
<v-icon @click="confirmCUD()" title="修改用户数据目录"> mdi-pencil</v-icon>
|
||||
<v-icon @click="openPath('user')" title="打开用户数据目录"> mdi-folder-open</v-icon>
|
||||
<v-icon @click="openDataPath('user')" title="打开用户数据目录"> mdi-folder-open</v-icon>
|
||||
<v-icon @click="copyPath('user')" title="复制用户数据目录路径"> mdi-content-copy</v-icon>
|
||||
</div>
|
||||
</template>
|
||||
@@ -24,7 +24,7 @@
|
||||
</template>
|
||||
<template #append>
|
||||
<div class="config-opers">
|
||||
<v-icon @click="openPath('db')" title="打开数据库目录"> mdi-folder-open</v-icon>
|
||||
<v-icon @click="openDataPath('db')" title="打开数据库目录"> mdi-folder-open</v-icon>
|
||||
<v-icon @click="copyPath('db')" title="复制数据库目录路径"> mdi-content-copy</v-icon>
|
||||
</div>
|
||||
</template>
|
||||
@@ -38,7 +38,7 @@
|
||||
<template #append>
|
||||
<div class="config-opers">
|
||||
<v-icon @click="confirmCGD()" title="修改游戏安装目录"> mdi-pencil</v-icon>
|
||||
<v-icon @click="openPath('game')" title="打开游戏安装目录"> mdi-folder-open</v-icon>
|
||||
<v-icon @click="openDataPath('game')" title="打开游戏安装目录"> mdi-folder-open</v-icon>
|
||||
<v-icon @click="copyPath('game')" title="复制游戏安装目录"> mdi-content-copy</v-icon>
|
||||
</div>
|
||||
</template>
|
||||
@@ -52,7 +52,7 @@
|
||||
<template #append>
|
||||
<div class="config-opers">
|
||||
<v-icon @click="confirmCLD()" title="清理日志文件"> mdi-delete</v-icon>
|
||||
<v-icon @click="openPath('log')" title="打开日志目录"> mdi-folder-open</v-icon>
|
||||
<v-icon @click="openDataPath('log')" title="打开日志目录"> mdi-folder-open</v-icon>
|
||||
<v-icon @click="copyPath('log')" title="复制日志目录路径"> mdi-content-copy</v-icon>
|
||||
</div>
|
||||
</template>
|
||||
@@ -68,13 +68,13 @@ import { path } from "@tauri-apps/api";
|
||||
import { sep } from "@tauri-apps/api/path";
|
||||
import { open } from "@tauri-apps/plugin-dialog";
|
||||
import { exists, readDir, remove } from "@tauri-apps/plugin-fs";
|
||||
import { openPath } from "@tauri-apps/plugin-opener";
|
||||
import { platform } from "@tauri-apps/plugin-os";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { onMounted } from "vue";
|
||||
|
||||
import { useAppStore } from "@/store/modules/app.js";
|
||||
import { backUpUserData } from "@/utils/dataBS.js";
|
||||
import TGShell from "@/utils/TGShell.js";
|
||||
|
||||
const { dbPath, logDir, userDir, gameDir } = storeToRefs(useAppStore());
|
||||
|
||||
@@ -225,7 +225,7 @@ function copyPath(type: "db" | "user" | "log" | "game"): void {
|
||||
showSnackbar.success(`${targetName}路径已复制!`);
|
||||
}
|
||||
|
||||
async function openPath(type: "db" | "user" | "log" | "game"): Promise<void> {
|
||||
async function openDataPath(type: "db" | "user" | "log" | "game"): Promise<void> {
|
||||
let targetPath: string;
|
||||
switch (type) {
|
||||
case "db":
|
||||
@@ -245,7 +245,7 @@ async function openPath(type: "db" | "user" | "log" | "game"): Promise<void> {
|
||||
targetPath = gameDir.value;
|
||||
break;
|
||||
}
|
||||
await TGShell.openPath(targetPath);
|
||||
await openPath(targetPath);
|
||||
}
|
||||
</script>
|
||||
<style lang="css" scoped>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<v-list class="config-list">
|
||||
<v-list-subheader :inset="true" class="config-header" title="相关信息" />
|
||||
<v-divider :inset="true" class="border-opacity-75" />
|
||||
<v-list-item title="Tauri 版本" @click="toOuter('https://v2.tauri.app/')">
|
||||
<v-list-item title="Tauri 版本" @click="openUrl('https://v2.tauri.app/')">
|
||||
<template #prepend>
|
||||
<v-img class="config-icon" src="/platforms/tauri.webp" alt="Tauri" />
|
||||
</template>
|
||||
@@ -77,6 +77,7 @@ import showSnackbar from "@comp/func/snackbar.js";
|
||||
import TGSqlite from "@Sqlite/index.js";
|
||||
import TSUserAchi from "@Sqlite/modules/userAchi.js";
|
||||
import { app } from "@tauri-apps/api";
|
||||
import { openUrl } from "@tauri-apps/plugin-opener";
|
||||
import { platform, version } from "@tauri-apps/plugin-os";
|
||||
import { onMounted, ref, shallowRef } from "vue";
|
||||
|
||||
@@ -123,10 +124,6 @@ onMounted(async () => {
|
||||
await TGLogger.Error(`加载数据库错误: ${e}`);
|
||||
}
|
||||
});
|
||||
|
||||
function toOuter(url: string): void {
|
||||
window.open(url);
|
||||
}
|
||||
</script>
|
||||
<style lang="css" scoped>
|
||||
.config-header {
|
||||
|
||||
Reference in New Issue
Block a user