检测本体是否启动

This commit is contained in:
BTMuli
2026-02-22 18:03:49 +08:00
parent eb4061748e
commit 6e40784682
4 changed files with 59 additions and 11 deletions

View File

@@ -23,8 +23,6 @@
<script lang="ts" setup>
import VpReplyDebug from "@comp/viewPost/vp-reply-debug.vue";
import { invoke } from "@tauri-apps/api/core";
import { appConfigDir, resourceDir } from "@tauri-apps/api/path";
import { copyFile, exists } from "@tauri-apps/plugin-fs";
import { ref } from "vue";
const showReply = ref<boolean>(false);
@@ -34,13 +32,8 @@ function testReply(): void {
}
async function test() {
await invoke("is_msix");
const filePath = `${await resourceDir()}\\resources\\YaeAchievementLib.dll`;
console.log(filePath);
const check = await exists(filePath);
const check = await invoke("is_process_running", { processName: "Yuanshen.exe" });
console.log(check);
const targetPath = `${await appConfigDir()}\\YaeAchievementLib.dll`;
await copyFile(filePath, targetPath);
}
</script>
<style lang="css" scoped>

View File

@@ -1,6 +1,6 @@
/**
* 游戏文件相关功能
* @since Beta v0.9.4
* @since Beta v0.9.6
*/
import showDialog from "@comp/func/dialog.js";
@@ -83,7 +83,7 @@ export async function tryCopyYae(): Promise<boolean> {
/**
* 尝试调用Yae
* @since Beta v0.9.2
* @since Beta v0.9.6
* @param gameDir - 游戏目录
* @param uid - 启动UID
* @returns void
@@ -102,6 +102,11 @@ export async function tryCallYae(gameDir: string, uid?: string): Promise<void> {
showSnackbar.warn("未检测到游戏本体");
return;
}
const isRun = await invoke<boolean>("is_process_running", { processName: "Yuanshen.exe" });
if (isRun) {
showSnackbar.warn("检测到已启动的原神进程请关闭进程Yuanshen.exe后重试");
return;
}
const gameVer = await tryReadGameVer(gameDir);
if (gameVer !== YAE_GAME_VER) {
const check = await showDialog.check(