-
-
Notifications
You must be signed in to change notification settings - Fork 24
Open
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers
Description
问题
目前 THUAI7 的配置文件是 %USERPROFILE%\Documents\THUAI7.json:
THUAI7/installer/Data/ConfigFileData.cs
Lines 205 to 207 in b728f8c
| path = string.IsNullOrEmpty(p) ? Path.Combine( | |
| Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), | |
| "THUAI7.json") : p; |
THUAI7/installer/Data/ConfigFileData.cs
Line 214 in b728f8c
| watcher = new FileSystemWatcher(Directory.GetParent(path)?.FullName ?? Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)); |
实际上这个文件夹主要目的是用于存放用户的一些文档,而非应用配置数据。原则上讲,存放配置数据应该是:
%LOCALAPPDATA%:对应于%USERPROFILE%\AppData\Local,用于存放本用户在本地计算机上的配置数据或应用程序%APPDATA%:对应于%USERPROFILE%\AppData\Roaming,用于存放本用户的漫游配置数据%ALLUSERSPROFILE%:对应于%HOMEDRIVE%\ProgramData,用于存放所有用户的公共配置数据(一般由 Administrator 用户管理)
综上,咱们的 THUAI7 更适合存放在 %LOCALAPPDATA% 中。
修改建议
具体的规范是,在改文件夹下,再创建一个属于自己应用的文件夹,然后在该文件夹下存放配置数据。对于 THUAI7,一个可能的配置文件路径是:%LOCALAPPDATA%\THUAI7\config.json,例如上段代码改成如下的:
var dataDir = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "THUAI7");
if (!System.IO.Directory.Exists(dataDir))
{
System.IO.Directory.CreateDirectory(dataDir);
}
var configPath = System.IO.Path.Combine(dataDir, "config.json");然后将数据放在该 config.json 里(卸载时直接删除该 THUAI7 文件夹即可)。
其他
同时,默认的安装位置:
THUAI7/installer/Data/ConfigFileData.cs
Lines 43 to 46 in b728f8c
| public string InstallPath { get; set; } = Path.Combine( | |
| Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), | |
| "THUAI7" | |
| ); |
Local_Data:THUAI7/installer/Model/Local_Data.cs
Lines 42 to 46 in b728f8c
| if (!Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments))) | |
| Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)); | |
| ConfigPath = Path.Combine( | |
| Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), | |
| "THUAI7.json"); |
也应当放在这个文件夹内。
此外存放配置信息的命名似乎使用 config.json 比 THUAI7.json 要更好一些。
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers
Type
Projects
Status
No status