@@ -267,7 +267,7 @@ def open_access_token_window():
267267 reg_pos = "HKEY_CURRENT_USER\\ Software\\ tchMaterial-parser\\ AccessToken"
268268 messagebox .showinfo ("提示" , f"Access Token 已保存!\n 已写入注册表:{ reg_pos } " )
269269 elif os_name == "Linux" :
270- file_path = "~/.tchMaterial-parser/data.json"
270+ file_path = "~/.config/ tchMaterial-parser/data.json"
271271 messagebox .showinfo ("提示" , f"Access Token 已保存!\n 已写入文件:{ file_path } " )
272272 else :
273273 messagebox .showinfo ("提示" , "Access Token 已保存!" )
@@ -446,21 +446,24 @@ def load_access_token_from_registry():
446446 except :
447447 pass # 读取失败则不做处理
448448
449- # 尝试从Linux系统的 ~/.tchMaterial-parser/data.json 文件加载 access_token
449+ # 尝试从Linux系统的 ~/.config/ tchMaterial-parser/data.json 文件加载 access_token
450450def load_access_token_on_linux ():
451451 global access_token
452452 try :
453453 # 构建文件路径
454- target_file = os .path .join (os .path .expanduser ("~" ),
455- ".tchMaterial-parser" ,
456- "data.json" )
454+ target_file = os .path .join (
455+ os .path .expanduser ("~" ),
456+ ".config" ,
457+ "tchMaterial-parser" ,
458+ "data.json"
459+ )
457460 # 检查文件是否存在
458461 if not os .path .exists (target_file ):
459462 return # 文件不存在不做处理
460463 # 读取JSON文件
461464 with open (target_file , 'r' ) as f :
462465 data = json .load (f )
463- # 提取access_token字段
466+ # 提取 access_token 字段
464467 access_token = data ["access_token" ]
465468 except :
466469 pass
@@ -474,13 +477,17 @@ def save_access_token_to_registry(token: str):
474477 except :
475478 pass
476479
477- # 将access_token保存到 Linux 系统的 ~/.tchMaterial-parser/data.json 文件中
480+ # 将access_token保存到 Linux 系统的 ~/.config/ tchMaterial-parser/data.json 文件中
478481def save_access_token_on_linux (token : str ):
479482 try :
480483 # 获取用户主目录路径
481484 home_dir = os .path .expanduser ("~" )
482485 # 构建目标目录和文件路径
483- target_dir = os .path .join (home_dir , ".tchMaterial-parser" )
486+ target_dir = os .path .join (
487+ home_dir ,
488+ ".config" , # 新增的目录层级
489+ "tchMaterial-parser"
490+ )
484491 target_file = os .path .join (target_dir , "data.json" )
485492 # 创建目录(如果不存在)
486493 os .makedirs (target_dir , exist_ok = True )
0 commit comments