File tree Expand file tree Collapse file tree
src-tauri/src/database/repository
components/PathSettingsModal Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -64,7 +64,7 @@ impl GamesRepository {
6464 savepath : NotSet ,
6565 autosave : NotSet ,
6666 maxbackups : NotSet ,
67- clear : NotSet ,
67+ clear : Set ( Some ( 1 ) ) , // 数据库迁移默认值麻烦,临时设定默认值为 1
6868 le_launch : NotSet ,
6969 magpie : NotSet ,
7070 vndb_data : Set ( game. vndb_data ) ,
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ import { isTauri } from "@tauri-apps/api/core";
3535import { useEffect , useState } from "react" ;
3636import { useTranslation } from "react-i18next" ;
3737import { settingsService } from "@/services" ;
38- import { handleGetFolder , moveBackupFolder } from "@/utils" ;
38+ import { getAppDataDirPath , handleGetFolder , moveBackupFolder } from "@/utils" ;
3939
4040/**
4141 * 路径设置弹窗组件属性
@@ -160,16 +160,17 @@ export const PathSettingsModal: React.FC<PathSettingsModalProps> = ({
160160 * 保存游戏存档备份路径
161161 */
162162 const handleSaveSavePath = async ( ) => {
163- if ( ! savePath . trim ( ) ) return ;
164-
165163 try {
166164 setSavePathLoading ( true ) ;
167165 await settingsService . setSaveRootPath ( savePath ) ;
168166
169167 // 如果路径发生了变化,需要移动备份文件夹
170168 if ( savePathOriginal !== savePath || savePathOriginal !== "" ) {
171169 try {
172- const moveResult = await moveBackupFolder ( savePathOriginal , savePath ) ;
170+ const moveResult = await moveBackupFolder (
171+ savePathOriginal ,
172+ savePath === "" ? getAppDataDirPath ( ) : savePath ,
173+ ) ;
173174 if ( moveResult ) {
174175 setSavePathOriginal ( savePath ) ;
175176 }
Original file line number Diff line number Diff line change @@ -20,32 +20,10 @@ export class BaseService {
2020 args ?: Record < string , unknown > ,
2121 ) : Promise < T > {
2222 try {
23- const result = await invoke < T > ( command , args ) ;
24- return result ;
23+ return await invoke < T > ( command , args ) ;
2524 } catch ( error ) {
2625 console . error ( `[Service Error] ${ command } :` , error ) ;
2726 throw error ;
2827 }
2928 }
30-
31- /**
32- * 带错误处理的调用
33- * @param command 命令名称
34- * @param args 参数
35- * @param errorMessage 自定义错误消息
36- * @returns Promise 结果
37- */
38- protected async invokeWithErrorHandling < T > (
39- command : string ,
40- args ?: Record < string , unknown > ,
41- errorMessage ?: string ,
42- ) : Promise < T > {
43- try {
44- return await this . invoke < T > ( command , args ) ;
45- } catch ( error ) {
46- const message = errorMessage || `调用 ${ command } 失败` ;
47- console . error ( message , error ) ;
48- throw new Error ( `${ message } : ${ error } ` ) ;
49- }
50- }
5129}
You can’t perform that action at this time.
0 commit comments