mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2026-05-30 06:55:45 +08:00
🚸 添加游戏目录存在性检查,优化用户提示信息
This commit is contained in:
@@ -330,7 +330,7 @@ import useUserStore from "@store/user.js";
|
|||||||
import { event, path, webviewWindow } from "@tauri-apps/api";
|
import { event, path, webviewWindow } from "@tauri-apps/api";
|
||||||
import { invoke } from "@tauri-apps/api/core";
|
import { invoke } from "@tauri-apps/api/core";
|
||||||
import type { Event, UnlistenFn } from "@tauri-apps/api/event";
|
import type { Event, UnlistenFn } from "@tauri-apps/api/event";
|
||||||
import { readDir } from "@tauri-apps/plugin-fs";
|
import { exists, readDir } from "@tauri-apps/plugin-fs";
|
||||||
import mhyClient from "@utils/TGClient.js";
|
import mhyClient from "@utils/TGClient.js";
|
||||||
import TGHttps from "@utils/TGHttps.js";
|
import TGHttps from "@utils/TGHttps.js";
|
||||||
import TGLogger from "@utils/TGLogger.js";
|
import TGLogger from "@utils/TGLogger.js";
|
||||||
@@ -849,6 +849,11 @@ async function tryLaunchGame(): Promise<void> {
|
|||||||
showSnackbar.warn("请前往设置页面设置游戏安装目录");
|
showSnackbar.warn("请前往设置页面设置游戏安装目录");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!(await exists(gameDir.value))) {
|
||||||
|
showSnackbar.warn("游戏目录不存在,请检查设置");
|
||||||
|
await TGLogger.Warn(`[sidebar][tryLaunchGame] 游戏目录不存在: ${gameDir.value}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
const dirRead = await readDir(gameDir.value);
|
const dirRead = await readDir(gameDir.value);
|
||||||
const find = dirRead.find((i) => i.isFile && i.name.toLowerCase() === "yuanshen.exe");
|
const find = dirRead.find((i) => i.isFile && i.name.toLowerCase() === "yuanshen.exe");
|
||||||
if (!find) {
|
if (!find) {
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import useAppStore from "@store/app.js";
|
|||||||
import useUserStore from "@store/user.js";
|
import useUserStore from "@store/user.js";
|
||||||
import { path } from "@tauri-apps/api";
|
import { path } from "@tauri-apps/api";
|
||||||
import { invoke } from "@tauri-apps/api/core";
|
import { invoke } from "@tauri-apps/api/core";
|
||||||
import { readDir } from "@tauri-apps/plugin-fs";
|
import { exists, readDir } from "@tauri-apps/plugin-fs";
|
||||||
import TGHttps from "@utils/TGHttps.js";
|
import TGHttps from "@utils/TGHttps.js";
|
||||||
import TGLogger from "@utils/TGLogger.js";
|
import TGLogger from "@utils/TGLogger.js";
|
||||||
import { storeToRefs } from "pinia";
|
import { storeToRefs } from "pinia";
|
||||||
@@ -43,6 +43,11 @@ async function tryPlayGame(): Promise<void> {
|
|||||||
showSnackbar.warn("未设置游戏安装目录!");
|
showSnackbar.warn("未设置游戏安装目录!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!(await exists(gameDir.value))) {
|
||||||
|
showSnackbar.warn("游戏目录不存在,请检查设置");
|
||||||
|
await TGLogger.Warn(`[config][gameBadge] 游戏目录不存在: ${gameDir.value}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
const dirRead = await readDir(gameDir.value);
|
const dirRead = await readDir(gameDir.value);
|
||||||
const find = dirRead.find((i) => i.isFile && i.name.toLowerCase() === "yuanshen.exe");
|
const find = dirRead.find((i) => i.isFile && i.name.toLowerCase() === "yuanshen.exe");
|
||||||
if (!find) {
|
if (!find) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* 游戏文件相关功能
|
* 游戏文件相关功能
|
||||||
* @since Beta v0.9.9
|
* @since Beta v0.10.2
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import showDialog from "@comp/func/dialog.js";
|
import showDialog from "@comp/func/dialog.js";
|
||||||
@@ -32,7 +32,7 @@ function verifyConfigIni(data: object): data is TGApp.Game.Config.GameConf {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 尝试获取游戏版本
|
* 尝试获取游戏版本
|
||||||
* @since Beta v0.9.9
|
* @since Beta v0.10.2
|
||||||
* @remarks
|
* @remarks
|
||||||
* 1. 读取 config.ini 下的 game_version
|
* 1. 读取 config.ini 下的 game_version
|
||||||
* 2. 没有 config.ini ,读取 YuanShen_Data\\Persistent\\ScriptVersion
|
* 2. 没有 config.ini ,读取 YuanShen_Data\\Persistent\\ScriptVersion
|
||||||
@@ -44,6 +44,10 @@ export async function tryReadGameVer(gameDir: string): Promise<false | string> {
|
|||||||
showSnackbar.warn("该功能仅支持Windows系统");
|
showSnackbar.warn("该功能仅支持Windows系统");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (!(await exists(gameDir))) {
|
||||||
|
await TGLogger.Warn(`[TGGame][tryReadGameVer] 游戏目录不存在: ${gameDir}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
const iniPath = `${gameDir}${sep()}config.ini`;
|
const iniPath = `${gameDir}${sep()}config.ini`;
|
||||||
if (await exists(iniPath)) {
|
if (await exists(iniPath)) {
|
||||||
const iniRead = await readTextFile(iniPath);
|
const iniRead = await readTextFile(iniPath);
|
||||||
@@ -113,6 +117,11 @@ export async function tryCallYae(gameDir: string, uid?: string): Promise<void> {
|
|||||||
showSnackbar.warn("请前往设置页面设置游戏安装目录");
|
showSnackbar.warn("请前往设置页面设置游戏安装目录");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!(await exists(gameDir))) {
|
||||||
|
showSnackbar.warn("游戏目录不存在,请检查设置");
|
||||||
|
await TGLogger.Warn(`[TGGame][tryCallYae] 游戏目录不存在: ${gameDir}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
const dirRead = await readDir(gameDir);
|
const dirRead = await readDir(gameDir);
|
||||||
const find = dirRead.find((i) => i.isFile && i.name.toLowerCase() === "yuanshen.exe");
|
const find = dirRead.find((i) => i.isFile && i.name.toLowerCase() === "yuanshen.exe");
|
||||||
if (!find) {
|
if (!find) {
|
||||||
|
|||||||
Reference in New Issue
Block a user