mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2026-05-07 00:15:48 +08:00
♻️ 获取游戏版本,完善检测
This commit is contained in:
@@ -93,13 +93,11 @@ import TSUserAchi from "@Sqlm/userAchi.js";
|
||||
import useAppStore from "@store/app.js";
|
||||
import useUserStore from "@store/user.js";
|
||||
import { path } from "@tauri-apps/api";
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import { listen, type UnlistenFn } from "@tauri-apps/api/event";
|
||||
import { open, save } from "@tauri-apps/plugin-dialog";
|
||||
import { exists, writeTextFile } from "@tauri-apps/plugin-fs";
|
||||
import { platform } from "@tauri-apps/plugin-os";
|
||||
import { writeTextFile } from "@tauri-apps/plugin-fs";
|
||||
import { tryCallYae } from "@utils/TGGame.js";
|
||||
import TGLogger from "@utils/TGLogger.js";
|
||||
import { isRunInAdmin } from "@utils/toolFunc.js";
|
||||
import {
|
||||
getUiafHeader,
|
||||
readUiafData,
|
||||
@@ -315,50 +313,7 @@ async function deleteUid(): Promise<void> {
|
||||
}
|
||||
|
||||
async function toYae(): Promise<void> {
|
||||
if (platform() !== "windows") {
|
||||
showSnackbar.warn("该功能仅支持Windows系统");
|
||||
return;
|
||||
}
|
||||
if (gameDir.value === "未设置") {
|
||||
showSnackbar.warn("请前往设置页面设置游戏安装目录");
|
||||
return;
|
||||
}
|
||||
const gamePath = `${gameDir.value}${path.sep()}YuanShen.exe`;
|
||||
if (!(await exists(gamePath))) {
|
||||
showSnackbar.warn("未检测到原神本体应用!");
|
||||
return;
|
||||
}
|
||||
const isInAdmin = await isRunInAdmin();
|
||||
if (!isInAdmin) {
|
||||
const check = await showDialog.check("是否以管理员模式重启?", "该功能需要管理员权限才能使用");
|
||||
if (!check) {
|
||||
showSnackbar.cancel("已取消以管理员模式重启");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await invoke("run_with_admin");
|
||||
} catch (err) {
|
||||
showSnackbar.error(`以管理员模式重启失败:${err}`);
|
||||
await TGLogger.Error(`[pageAchi][toYae]以管理员模式启动失败 - ${err}`);
|
||||
return;
|
||||
}
|
||||
}
|
||||
const input = await showDialog.input("请输入存档UID", "UID:", uidCur.value.toString());
|
||||
if (!input) {
|
||||
showSnackbar.cancel("已取消存档导入");
|
||||
return;
|
||||
}
|
||||
if (input === "" || isNaN(Number(input))) {
|
||||
showSnackbar.warn("请输入合法数字");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await invoke("call_yae_dll", { gamePath: gamePath, uid: input });
|
||||
} catch (err) {
|
||||
showSnackbar.error(`调用Yae DLL失败: ${err}`);
|
||||
await TGLogger.Error(`[pageAchi][toYae]调用Yae DLL失败: ${err}`);
|
||||
return;
|
||||
}
|
||||
await tryCallYae(gameDir.value, uidCur.value.toString());
|
||||
}
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
class="pbm-ne-btn"
|
||||
prepend-icon="mdi-import"
|
||||
variant="elevated"
|
||||
@click="tryCallYae()"
|
||||
@click="tryImportMaterial()"
|
||||
>
|
||||
导入
|
||||
</v-btn>
|
||||
@@ -121,12 +121,7 @@ import PboMaterial from "@comp/pageBag/pbo-material.vue";
|
||||
import TSUserBagMaterial, { BAG_TYPE_LIST } from "@Sqlm/userBagMaterial.js";
|
||||
import useAppStore from "@store/app.js";
|
||||
import useUserStore from "@store/user.js";
|
||||
import { path } from "@tauri-apps/api";
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import { exists } from "@tauri-apps/plugin-fs";
|
||||
import { platform } from "@tauri-apps/plugin-os";
|
||||
import TGLogger from "@utils/TGLogger.js";
|
||||
import { isRunInAdmin } from "@utils/toolFunc.js";
|
||||
import { tryCallYae } from "@utils/TGGame.js";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { nextTick, onMounted, ref, shallowRef, triggerRef, watch } from "vue";
|
||||
|
||||
@@ -342,54 +337,8 @@ function handleUpdate(info: MaterialInfo): void {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 尝试导入材料(通过Yae)
|
||||
*/
|
||||
async function tryCallYae(): Promise<void> {
|
||||
if (platform() !== "windows") {
|
||||
showSnackbar.warn("该功能仅支持Windows系统");
|
||||
return;
|
||||
}
|
||||
if (gameDir.value === "未设置") {
|
||||
showSnackbar.warn("请前往设置页面设置游戏安装目录");
|
||||
return;
|
||||
}
|
||||
const gamePath = `${gameDir.value}${path.sep()}YuanShen.exe`;
|
||||
if (!(await exists(gamePath))) {
|
||||
showSnackbar.warn("未检测到原神本体应用!");
|
||||
return;
|
||||
}
|
||||
const isInAdmin = await isRunInAdmin();
|
||||
if (!isInAdmin) {
|
||||
const check = await showDialog.check("是否以管理员模式重启?", "该功能需要管理员权限才能使用");
|
||||
if (!check) {
|
||||
showSnackbar.cancel("已取消以管理员模式重启");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await invoke("run_with_admin");
|
||||
} catch (err) {
|
||||
showSnackbar.error(`以管理员模式重启失败:${err}`);
|
||||
await TGLogger.Error(`[pageAchi][toYae]以管理员模式启动失败 - ${err}`);
|
||||
return;
|
||||
}
|
||||
}
|
||||
const input = await showDialog.input("请输入存档UID", "UID:", curUid.value?.toString());
|
||||
if (!input) {
|
||||
showSnackbar.cancel("已取消存档导入");
|
||||
return;
|
||||
}
|
||||
if (input === "" || isNaN(Number(input))) {
|
||||
showSnackbar.warn("请输入合法数字");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await invoke("call_yae_dll", { gamePath: gamePath, uid: input.toString() });
|
||||
} catch (err) {
|
||||
showSnackbar.error(`调用Yae DLL失败: ${err}`);
|
||||
await TGLogger.Error(`[pageAchi][toYae]调用Yae DLL失败: ${err}`);
|
||||
return;
|
||||
}
|
||||
async function tryImportMaterial(): Promise<void> {
|
||||
await tryCallYae(gameDir.value, curUid.value.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,17 +16,17 @@
|
||||
<div class="btn-list">
|
||||
<v-btn class="test-btn" @click="test()">测试</v-btn>
|
||||
</div>
|
||||
<TcoHutaoVerify v-model="show" />
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import TcoHutaoVerify from "@comp/pageConfig/tco-hutaoVerify.vue";
|
||||
import { ref } from "vue";
|
||||
import useAppStore from "@store/app.js";
|
||||
import { tryReadGameVer } from "@utils/TGGame.js";
|
||||
import { storeToRefs } from "pinia";
|
||||
|
||||
const show = ref<boolean>(false);
|
||||
const { gameDir } = storeToRefs(useAppStore());
|
||||
|
||||
async function test() {
|
||||
show.value = true;
|
||||
await tryReadGameVer(gameDir.value);
|
||||
}
|
||||
</script>
|
||||
<style lang="css" scoped>
|
||||
|
||||
Reference in New Issue
Block a user