Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于下载器存放位置的问题 #169

Open
Timothy-Liuxf opened this issue Apr 1, 2024 · 3 comments
Open

关于下载器存放位置的问题 #169

Timothy-Liuxf opened this issue Apr 1, 2024 · 3 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@Timothy-Liuxf
Copy link
Member

问题

目前 THUAI7 的配置文件是 %USERPROFILE%\Documents\THUAI7.json

path = string.IsNullOrEmpty(p) ? Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
"THUAI7.json") : p;

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 文件夹即可)。

其他

同时,默认的安装位置:

public string InstallPath { get; set; } = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
"THUAI7"
);

Local_Data
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.jsonTHUAI7.json 要更好一些。

@Timothy-Liuxf
Copy link
Member Author

THUAI6 中的原 issue 位于 eesast/THUAI6#566

@FranGuam
Copy link

FranGuam commented Apr 1, 2024

我超,这就是一个好的issue的模样吗?大开眼界(

@Timothy-Liuxf
Copy link
Member Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Development

No branches or pull requests

5 participants