mirror of
https://github.com/waynebian01/Shigure.git
synced 2026-09-03 07:15:24 +08:00
模块存储位置从 exe 旁 baseDirectory/module 迁移到 {UserProfile}/.config/{AppName}/module
(AppName 动态取程序集名,Windows 下为 C:\Users\<用户名>\.config\Shigure\module)。
- ModuleStore.ResolveModuleDirectory 改为无参静态方法,删除 Shigure.csproj 检测死代码
- AppInfo 新增 AppName(程序集名单一来源,与 Version 惯例一致)
- Program.cs 新增启动迁移提示:旧目录有内容且新目录无模块文件时弹纯文案提示
- StatusForm 关于页在路径位于 exe 目录外时显示完整路径;编辑器打开文件夹跟随新路径
- csproj 删除 module 复制项;仓库根 module/ 示例目录保留
- 文档同步更新(README/CLAUDE/打包说明/Obsidian 01/11/00/10)
- 旧模块不自动迁移,由提示引导用户手动移动
71 lines
2.6 KiB
C#
71 lines
2.6 KiB
C#
namespace Shigure;
|
|
|
|
internal static class Program
|
|
{
|
|
[STAThread]
|
|
private static void Main(string[] args)
|
|
{
|
|
if (!OperatingSystem.IsWindows())
|
|
{
|
|
MessageBox.Show(
|
|
"Shigure 需要在 Windows 上运行。",
|
|
"Shigure",
|
|
MessageBoxButtons.OK,
|
|
MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
|
|
ApplicationConfiguration.Initialize();
|
|
|
|
var options = AppOptions.FromArgs(args);
|
|
var baseDirectory = AppPaths.BaseDirectory;
|
|
var moduleStore = new ModuleStore(ModuleStore.ResolveModuleDirectory());
|
|
ShowModuleMigrationHint(baseDirectory, moduleStore);
|
|
var triggerKeyState = new WindowsTriggerKeyState();
|
|
var processLocator = new WowProcessLocator(baseDirectory);
|
|
var runtimeFactory = new ShigureRuntimeFactory(baseDirectory, moduleStore, triggerKeyState, processLocator);
|
|
var runtimeSession = new RuntimeSessionCoordinator(runtimeFactory);
|
|
|
|
Application.Run(new MainForm(
|
|
options,
|
|
baseDirectory,
|
|
moduleStore,
|
|
triggerKeyState,
|
|
processLocator,
|
|
runtimeSession));
|
|
}
|
|
|
|
// 模块目录迁移提示:旧目录(baseDirectory/module)存在且有内容、且新目录(用户配置目录)尚无模块文件时,
|
|
// 弹一次纯文案提示,引导用户手动移动模块;条件不满足或检测异常时静默,不影响启动。
|
|
private static void ShowModuleMigrationHint(string baseDirectory, ModuleStore moduleStore)
|
|
{
|
|
try
|
|
{
|
|
var oldDirectory = Path.Combine(baseDirectory, "module");
|
|
if (!Directory.Exists(oldDirectory)
|
|
|| !Directory.EnumerateFileSystemEntries(oldDirectory).Any())
|
|
{
|
|
return;
|
|
}
|
|
|
|
// 新目录以是否存在模块文件(.json)判空,避免保存崩溃残留的 .tmp 原子写文件阻断提示。
|
|
if (Directory.EnumerateFiles(moduleStore.ModuleDirectory, "*.json", SearchOption.AllDirectories).Any())
|
|
{
|
|
return;
|
|
}
|
|
|
|
MessageBox.Show(
|
|
$"模块目录已迁移到用户配置目录。\n\n" +
|
|
$"新的模块目录:\n{moduleStore.ModuleDirectory}\n\n" +
|
|
$"请将旧目录 {oldDirectory} 中的模块文件手动移动到新目录。",
|
|
"Shigure",
|
|
MessageBoxButtons.OK,
|
|
MessageBoxIcon.Information);
|
|
}
|
|
catch
|
|
{
|
|
// 检测或提示异常时静默跳过,避免影响启动。
|
|
}
|
|
}
|
|
}
|