File tree Expand file tree Collapse file tree 3 files changed +45
-6
lines changed
Expand file tree Collapse file tree 3 files changed +45
-6
lines changed Original file line number Diff line number Diff line change 1111 {
1212 "identifier" : " opener:allow-open-path" ,
1313 "allow" : [
14+ {
15+ "path" : " $HOME/.codeforge/**"
16+ },
17+ {
18+ "path" : " $APPDATA/**"
19+ },
20+ {
21+ "path" : " $LOCALAPPDATA/**"
22+ },
1423 {
1524 "path" : " **"
1625 }
2029 " shell:allow-open" ,
2130 " dialog:default" ,
2231 " fs:allow-read-text-file" ,
32+ " fs:allow-read-dir" ,
33+ " fs:allow-read-file" ,
34+ " fs:allow-write-file" ,
35+ " fs:allow-write-text-file" ,
36+ " fs:allow-remove" ,
37+ " fs:allow-mkdir" ,
38+ " fs:allow-exists" ,
2339 {
2440 "identifier" : " fs:scope" ,
2541 "allow" : [
42+ {
43+ "path" : " $HOME/.codeforge/**"
44+ },
2645 {
2746 "path" : " /var/folders/**"
2847 },
3251 {
3352 "path" : " /private/var/folders/**"
3453 },
54+ {
55+ "path" : " $APPDATA/**"
56+ },
57+ {
58+ "path" : " $LOCALAPPDATA/**"
59+ },
3560 {
3661 "path" : " **"
3762 }
Original file line number Diff line number Diff line change @@ -107,11 +107,24 @@ fn get_effective_log_directory(app: &AppHandle) -> PathBuf {
107107}
108108
109109// 获取默认日志目录
110- fn get_default_log_directory ( app : & AppHandle ) -> PathBuf {
111- app. path ( )
112- . app_data_dir ( )
113- . expect ( "Failed to get app data dir" )
114- . join ( "logs" )
110+ fn get_default_log_directory ( _app : & AppHandle ) -> PathBuf {
111+ let home_dir = dirs:: home_dir ( ) . expect ( "Failed to get home directory" ) ;
112+ let log_dir = home_dir. join ( ".codeforge" ) . join ( "logs" ) ;
113+
114+ // 确保目录存在
115+ if !log_dir. exists ( ) {
116+ if let Err ( e) = fs:: create_dir_all ( & log_dir) {
117+ eprintln ! ( "Failed to create log directory: {}" , e) ;
118+ // 如果创建失败,回退到应用数据目录
119+ return _app
120+ . path ( )
121+ . app_data_dir ( )
122+ . expect ( "Failed to get app data dir" )
123+ . join ( "logs" ) ;
124+ }
125+ }
126+
127+ log_dir
115128}
116129
117130// 公共函数,供其他模块调用
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import { ref } from 'vue'
22import { invoke } from '@tauri-apps/api/core'
33import { open as openDialog } from '@tauri-apps/plugin-dialog'
44import { openPath } from '@tauri-apps/plugin-opener'
5+ import { join } from '@tauri-apps/api/path'
56import { useToast } from '../plugins/toast'
67
78export function useLogDirectory ( emit : any )
@@ -97,7 +98,7 @@ export function useLogDirectory(emit: any)
9798
9899 const openLogFile = async ( filename : string ) => {
99100 try {
100- const logPath = ` ${ currentLogDir . value } / ${ filename } `
101+ const logPath = await join ( currentLogDir . value , filename )
101102 await openPath ( logPath )
102103 }
103104 catch ( error ) {
You can’t perform that action at this time.
0 commit comments