1.3.5:更名 EDC|易得设计,空白启动首页 + 可扩展图元库识别,架构图大版本
- 品牌:更名 EDC|易得设计(exe/安卓/仓库 EasyDesignCollection;旧地址 301 兼容老客户端更新) - 首页:空白启动 + 六模块「新建文档」选择 + 最近打开;品牌菜单重做 - 架构图:手绘识别统一图形;Visio 式可扩展图元库(导入 / 存为图元 / 分类折叠 / 手绘匹配 / 多笔回溯组合);识别后图形尺寸编辑(宽高长径 + 画布标注 + 双击改值); IT 系统图元;mm 标尺(右轴数值 / 实线游标 / A0 默认画布);图层、F8 正交 / F10 极轴、 对齐均布;连线端点换绑重吸附;DXF / SVG / PNG 导出;缩小时画布溢出到侧栏的裁剪修复 - 时序图:分文件保存(*.seq.json / *.arch.json;旧 .edc.json 兼容) - 路径:运行时目录迁移 %APPDATA%/EDC;素材库 library/;安卓 Documents/EDC - 清理:参数化草图入口冻结;Windows Ink 原生桥移除;dist/ 退役 - 构建:exe + APK 双端同步(1.3.5+26);发布脚本切换 release/ 新目录结构
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
/// 持久化层:负责项目文件的读写、自动保存与崩溃恢复。
|
||||
///
|
||||
/// 存储布局(位于用户 AppData/LocalAppData 下的 `SequenceDiagramStudio`):
|
||||
/// 存储布局(位于用户 AppData/LocalAppData 下的 `EDC`;旧目录
|
||||
/// `SequenceDiagramStudio` 首次启动时自动复制迁移,不改写旧目录):
|
||||
/// - `autosave/current.seq.json`:最近一次项目快照;
|
||||
/// - `autosave/session.json`:会话元数据(来源路径、是否干净、更新时间);
|
||||
/// - `recent.json`:最近打开列表(见 `recent_store.dart`);
|
||||
/// - `library/`:用户素材库(符号 / 图片 / 模板,见 `app_paths.dart`);
|
||||
/// - `<项目路径>.bak`:保存前自动生成的备份。
|
||||
///
|
||||
/// 与上层关系:AppController 通过单例 [Storage.instance] 调用自动保存与保存;
|
||||
@@ -73,13 +76,29 @@ class Storage {
|
||||
/// 目录优先级:`APPDATA` > `LOCALAPPDATA` > 系统临时目录;随后创建
|
||||
/// `autosave` 子目录。副作用:设置 [appDir]/[autosaveDir]/[currentFile]/
|
||||
/// [sessionFile] 并置 [_inited]。
|
||||
///
|
||||
/// 迁移:品牌更名(EDC)后首次启动,若旧目录 `SequenceDiagramStudio`
|
||||
/// 存在且新目录尚无自动快照,则**复制**旧内容(不改写旧目录)。
|
||||
Future<void> init() async {
|
||||
if (_inited) return;
|
||||
final String base = Platform.environment['APPDATA'] ??
|
||||
Platform.environment['LOCALAPPDATA'] ??
|
||||
Directory.systemTemp.path;
|
||||
appDir = Directory('$base${Platform.pathSeparator}SequenceDiagramStudio');
|
||||
final Directory legacy =
|
||||
Directory('$base${Platform.pathSeparator}SequenceDiagramStudio');
|
||||
appDir = Directory('$base${Platform.pathSeparator}EDC');
|
||||
autosaveDir = Directory('${appDir.path}${Platform.pathSeparator}autosave');
|
||||
// 一次性迁移(失败不阻塞启动)。
|
||||
try {
|
||||
final Directory newAuto = autosaveDir;
|
||||
final Directory oldAuto =
|
||||
Directory('${legacy.path}${Platform.pathSeparator}autosave');
|
||||
if (await legacy.exists() &&
|
||||
!await newAuto.exists() &&
|
||||
await oldAuto.exists()) {
|
||||
await _copyDir(oldAuto, newAuto);
|
||||
}
|
||||
} catch (_) {}
|
||||
currentFile = File('${autosaveDir.path}${Platform.pathSeparator}current.seq.json');
|
||||
sessionFile = File('${autosaveDir.path}${Platform.pathSeparator}session.json');
|
||||
if (!await autosaveDir.exists()) {
|
||||
@@ -88,6 +107,23 @@ class Storage {
|
||||
_inited = true;
|
||||
}
|
||||
|
||||
/// 递归复制目录(迁移用;已存在的目标文件会被覆盖)。
|
||||
static Future<void> _copyDir(Directory from, Directory to) async {
|
||||
await to.create(recursive: true);
|
||||
await for (final FileSystemEntity e
|
||||
in from.list(recursive: true, followLinks: false)) {
|
||||
final String rel = e.path.substring(from.path.length);
|
||||
final String dest = '${to.path}$rel';
|
||||
if (e is File) {
|
||||
final File f = File(dest);
|
||||
await f.parent.create(recursive: true);
|
||||
await e.copy(dest);
|
||||
} else if (e is Directory) {
|
||||
await Directory(dest).create(recursive: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// 写入自动保存快照与会话元数据。
|
||||
///
|
||||
/// 参数 [project]:项目;[projectPath]:来源文件路径;[clean]:是否已正常
|
||||
@@ -208,9 +244,13 @@ class Storage {
|
||||
|
||||
/// 将项目保存到 [path]。
|
||||
///
|
||||
/// [includeArch] 为 false 时写出**不含架构图部分**的时序图文档
|
||||
/// (`*.seq.json`);架构图单独保存为 `*.arch.json`。
|
||||
///
|
||||
/// 流程:初始化 -> 备份已有文件 -> 确保父目录存在 -> 写入项目 JSON ->
|
||||
/// 同步写自动保存(标记为干净)。返回保存路径。
|
||||
Future<String> saveProject(String path, Project project) async {
|
||||
Future<String> saveProject(String path, Project project,
|
||||
{bool includeArch = false}) async {
|
||||
await init();
|
||||
// 1) 覆盖前先备份,防止写坏原文件。
|
||||
await backupExisting(path);
|
||||
@@ -221,7 +261,7 @@ class Storage {
|
||||
await parent.create(recursive: true);
|
||||
}
|
||||
// 3) 写入项目并 flush;随后把自动保存标记为干净。
|
||||
await target.writeAsString(project.encode(), flush: true);
|
||||
await target.writeAsString(project.encode(includeArch: includeArch), flush: true);
|
||||
await writeAutosave(project, projectPath: path, clean: true);
|
||||
return path;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user