🚸 处理大小写

close #219
This commit is contained in:
BTMuli
2026-02-26 17:07:10 +08:00
parent 8b60a7f8dd
commit b965cccbf1
4 changed files with 33 additions and 13 deletions

View File

@@ -330,7 +330,7 @@ import useUserStore from "@store/user.js";
import { event, path, webviewWindow } from "@tauri-apps/api";
import { invoke } from "@tauri-apps/api/core";
import type { Event, UnlistenFn } from "@tauri-apps/api/event";
import { exists } from "@tauri-apps/plugin-fs";
import { readDir } from "@tauri-apps/plugin-fs";
import mhyClient from "@utils/TGClient.js";
import { isRunInAdmin, tryCopyYae, tryReadGameVer, YAE_GAME_VER } from "@utils/TGGame.js";
import TGLogger from "@utils/TGLogger.js";
@@ -729,11 +729,17 @@ async function tryLaunchGame(): Promise<void> {
showSnackbar.warn("请先登录");
return;
}
const gamePath = `${gameDir.value}${path.sep()}YuanShen.exe`;
if (!(await exists(gamePath))) {
if (gameDir.value === "未设置") {
showSnackbar.warn("请前往设置页面设置游戏安装目录");
return;
}
const dirRead = await readDir(gameDir.value);
const find = dirRead.find((i) => i.isFile && i.name.toLowerCase() === "yuanshen.exe");
if (!find) {
showSnackbar.warn("未检测到原神本体应用");
return;
}
const gamePath = `${gameDir.value}${path.sep()}${find.name}`;
const resp = await passportReq.authTicket(account.value, cookie.value);
if (typeof resp !== "string") {
showSnackbar.error(`[${resp.retcode}] ${resp.message}`);

View File

@@ -145,7 +145,7 @@ async function confirmCGD(): Promise<void> {
const oriEmpty = gameDir.value === "未设置";
const editCheck = await showDialog.check(
oriEmpty ? "确认设置游戏目录?" : "确认修改游戏目录?",
oriEmpty ? "请选择 Yuanshen.exe 所在目录" : `当前:${gameDir.value}`,
oriEmpty ? "请选择 YuanShen.exe 所在目录" : `当前:${gameDir.value}`,
);
if (!editCheck) {
showSnackbar.cancel(oriEmpty ? "已取消设置" : "已取消修改");
@@ -159,11 +159,14 @@ async function confirmCGD(): Promise<void> {
showSnackbar.warn("路径不能为空!");
return;
}
if (!file.endsWith("YuanShen.exe")) {
if (!file.toLowerCase().endsWith("yuanshen.exe")) {
showSnackbar.warn("请选中游戏本体(YuanShen.exe)");
return;
}
if (!oriEmpty && `${gameDir.value}${path.sep()}YuanShen.exe` === file) {
if (
!oriEmpty &&
`${gameDir.value}${path.sep()}YuanShen.exe`.toLowerCase() === file.toLowerCase()
) {
showSnackbar.warn("路径未修改!");
return;
}

View File

@@ -2,7 +2,7 @@
<div class="tgb-box">
<div class="tgb-top">
<div class="tgb-title">原神启动</div>
<v-btn size="small" icon="mdi-rocket" variant="outlined" @click="tryPlayGame()" />
<v-btn icon="mdi-rocket" size="small" variant="outlined" @click="tryPlayGame()" />
</div>
<v-list-item v-if="account.uid">
<v-list-item-title class="tgb-name">
@@ -22,7 +22,7 @@ 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 { readDir } from "@tauri-apps/plugin-fs";
import TGLogger from "@utils/TGLogger.js";
import { storeToRefs } from "pinia";
@@ -42,11 +42,13 @@ async function tryPlayGame(): Promise<void> {
showSnackbar.warn("未设置游戏安装目录!");
return;
}
const gamePath = `${gameDir.value}${path.sep()}YuanShen.exe`;
if (!(await exists(gamePath))) {
const dirRead = await readDir(gameDir.value);
const find = dirRead.find((i) => i.isFile && i.name.toLowerCase() === "yuanshen.exe");
if (!find) {
showSnackbar.warn("未检测到原神本体应用!");
return;
}
const gamePath = `${gameDir.value}${path.sep()}${find.name}`;
const resp = await passportReq.authTicket(account.value, cookie.value);
if (typeof resp !== "string") {
showSnackbar.error(`[${resp.retcode}] ${resp.message}`);

View File

@@ -7,7 +7,14 @@ import showDialog from "@comp/func/dialog.js";
import showSnackbar from "@comp/func/snackbar.js";
import { invoke } from "@tauri-apps/api/core";
import { documentDir, resourceDir, sep } from "@tauri-apps/api/path";
import { copyFile, exists, mkdir, readTextFile, readTextFileLines } from "@tauri-apps/plugin-fs";
import {
copyFile,
exists,
mkdir,
readDir,
readTextFile,
readTextFileLines,
} from "@tauri-apps/plugin-fs";
import { platform } from "@tauri-apps/plugin-os";
import TGLogger from "@utils/TGLogger.js";
@@ -97,11 +104,13 @@ export async function tryCallYae(gameDir: string, uid?: string): Promise<void> {
showSnackbar.warn("请前往设置页面设置游戏安装目录");
return;
}
const gamePath = `${gameDir}${sep()}YuanShen.exe`;
if (!(await exists(gamePath))) {
const dirRead = await readDir(gameDir);
const find = dirRead.find((i) => i.isFile && i.name.toLowerCase() === "yuanshen.exe");
if (!find) {
showSnackbar.warn("未检测到游戏本体");
return;
}
const gamePath = `${gameDir}${sep()}${find.name}`;
const isRun = await invoke<boolean>("is_process_running", { processName: "Yuanshen.exe" });
if (isRun) {
showSnackbar.warn("检测到已启动的原神进程请关闭进程Yuanshen.exe后重试");