v1.3.13: 模块化注册架构 + PDS流程设计套件更名 + 依赖/圆周交互修复
- 模块化:EdcModule 契约 + registry + 模块独立目录;发布包增加 modules/registry.json - 更名:PDS流程设计套件 / ProcessDesignSuite;同步构建、发布脚本与文档 - 时序图:依赖偏移以时间显示/编辑;紧贴依赖隐藏箭头并在接缝显示标签;动作条磁吸 - 圆周:依赖标签沿圆弧方向、环间空隙;动作旋转磁吸增强;短弧标签优先动作名 - 清理:release 移至源码同级(本地不入库);tool 合并到 tools;发布说明迁移 docs/release-notes
This commit is contained in:
@@ -16,18 +16,18 @@ import 'dart:typed_data';
|
||||
|
||||
import 'package:flutter/material.dart' hide Action;
|
||||
|
||||
import '../arch/arch_models.dart';
|
||||
import '../arch/arch_samples.dart';
|
||||
import '../persistence/android_docs.dart';
|
||||
import '../sketch/sketch_models.dart';
|
||||
import '../sketch/sketch_solver.dart';
|
||||
import '../version.dart';
|
||||
import '../layout/dep_routes.dart';
|
||||
import '../layout/layout.dart';
|
||||
import '../layout/flow_layout.dart';
|
||||
import '../model/models.dart';
|
||||
import '../model/units.dart';
|
||||
import '../persistence/storage.dart';
|
||||
import 'package:sequence_diagram/modules/architecture/domain/arch_models.dart';
|
||||
import 'package:sequence_diagram/modules/architecture/domain/arch_samples.dart';
|
||||
import 'package:sequence_diagram/persistence/android_docs.dart';
|
||||
import 'package:sequence_diagram/modules/architecture/sketch/sketch_models.dart';
|
||||
import 'package:sequence_diagram/modules/architecture/sketch/sketch_solver.dart';
|
||||
import 'package:sequence_diagram/version.dart';
|
||||
import 'package:sequence_diagram/modules/sequence/layout/dep_routes.dart';
|
||||
import 'package:sequence_diagram/modules/sequence/layout/layout.dart';
|
||||
import 'package:sequence_diagram/modules/sequence/layout/flow_layout.dart';
|
||||
import 'package:sequence_diagram/model/models.dart';
|
||||
import 'package:sequence_diagram/model/units.dart';
|
||||
import 'package:sequence_diagram/persistence/storage.dart';
|
||||
|
||||
/// 全局应用控制器(继承 [ChangeNotifier])。
|
||||
class AppController extends ChangeNotifier {
|
||||
@@ -45,8 +45,9 @@ class AppController extends ChangeNotifier {
|
||||
/// 当前主题亮度(默认浅色 / 白底)。
|
||||
Brightness _brightness = Brightness.light;
|
||||
|
||||
/// 当前顶层设计模块(时序图 / 架构图);仅运行时状态,不随文件保存。
|
||||
AppMode _appMode = AppMode.sequence;
|
||||
/// 当前顶层设计模块 id;null = 首页。模块由 `lib/modules/registry.dart`
|
||||
/// 注册,控制器不依赖具体模块枚举,新增模块无需修改此处。
|
||||
String? _activeModuleId = 'sequence';
|
||||
|
||||
/// 架构图当前工具。
|
||||
ArchTool _archTool = ArchTool.select;
|
||||
@@ -124,7 +125,7 @@ class AppController extends ChangeNotifier {
|
||||
|
||||
/// 当前模块对应的文件路径(标题 / 状态显示用)。
|
||||
String? get currentFilePath =>
|
||||
_appMode == AppMode.architecture ? _archFilePath : _filePath;
|
||||
_activeModuleId == 'architecture' ? _archFilePath : _filePath;
|
||||
|
||||
/// 架构图文档文件路径。
|
||||
String? get archFilePath => _archFilePath;
|
||||
@@ -254,7 +255,7 @@ class AppController extends ChangeNotifier {
|
||||
/// 安卓写入公共 Documents,桌面写文件并同步 `.bak` 备份。
|
||||
Future<void> _autoSaveDocument() async {
|
||||
final String? path =
|
||||
_appMode == AppMode.architecture ? _archFilePath : _filePath;
|
||||
_activeModuleId == 'architecture' ? _archFilePath : _filePath;
|
||||
if (!_project.autoSaveEnabled || !_dirty || path == null) return;
|
||||
final DateTime now = DateTime.now();
|
||||
// 从未保存过时间戳(如刚打开文件):以“现在”为基准,等满一个间隔再自动保存。
|
||||
@@ -267,7 +268,7 @@ class AppController extends ChangeNotifier {
|
||||
if (now.difference(_lastSavedAt!).inSeconds < minutes * 60) return;
|
||||
_lastSavedAt = now;
|
||||
try {
|
||||
if (_appMode == AppMode.architecture) {
|
||||
if (_activeModuleId == 'architecture') {
|
||||
final String json = _project.arch.encode();
|
||||
if (AndroidDocs.isAvailable) {
|
||||
await AndroidDocs.saveFile(
|
||||
@@ -391,18 +392,19 @@ class AppController extends ChangeNotifier {
|
||||
|
||||
// ============ 设计合集(模块切换)与架构图 ============
|
||||
|
||||
/// 当前顶层设计模块(时序图 / 架构图)。
|
||||
AppMode get appMode => _appMode;
|
||||
/// 当前顶层设计模块 id;null = 首页。
|
||||
String? get activeModuleId => _activeModuleId;
|
||||
|
||||
/// 是否处于首页。
|
||||
bool get isHome => _activeModuleId == null;
|
||||
|
||||
/// 切换顶层设计模块并刷新界面(品牌菜单 / 首页调用)。
|
||||
void setAppMode(AppMode m) {
|
||||
if (_appMode == m) return;
|
||||
_appMode = m;
|
||||
_status = switch (m) {
|
||||
AppMode.home => '首页',
|
||||
AppMode.sequence => '时序图设计',
|
||||
AppMode.architecture => '架构图设计 · 手绘识别',
|
||||
};
|
||||
///
|
||||
/// [status] 由模块提供进入提示;不传时使用通用文案。
|
||||
void setModuleId(String? id, {String? status}) {
|
||||
if (_activeModuleId == id) return;
|
||||
_activeModuleId = id;
|
||||
_status = status ?? (id == null ? '首页' : '已进入模块 $id');
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
@@ -412,11 +414,11 @@ class AppController extends ChangeNotifier {
|
||||
/// (当前文档数据在进入新模块时会由新建文档替换)。
|
||||
/// 外壳在离开「有未保存修改的文档」前负责弹窗确认。
|
||||
void goHome() {
|
||||
final bool changed = _appMode != AppMode.home ||
|
||||
final bool changed = _activeModuleId != null ||
|
||||
_dirty ||
|
||||
_filePath != null ||
|
||||
_archFilePath != null;
|
||||
_appMode = AppMode.home;
|
||||
_activeModuleId = null;
|
||||
_dirty = false;
|
||||
_filePath = null;
|
||||
_archFilePath = null;
|
||||
@@ -1954,19 +1956,29 @@ class AppController extends ChangeNotifier {
|
||||
///
|
||||
/// 参数 [keepAngle]:为 true 时保持各动作角度不变;为 false 时按
|
||||
/// `旧时长 / 新时长` 缩放所有动作的起始角与持续角,从而保持其时间不变。
|
||||
/// 依赖偏移始终按时间不变换算(界面以时间为主,角度仅内部存储)。
|
||||
/// 副作用:通过 [_mutate] 记录历史并重算关键路径。
|
||||
void setCycleDuration(double ms, {bool keepAngle = true}) {
|
||||
// 计算角度缩放比例:keepAngle 时保持 1;否则按旧/新时长比例缩放。
|
||||
// 动作角度按策略缩放;依赖偏移始终按“时间不变”换算(界面以时间为主)。
|
||||
final double oldMs = _project.cycle.durationMs;
|
||||
double angleScale = 1;
|
||||
if (!keepAngle && _project.cycle.durationMs > 0) {
|
||||
angleScale = _project.cycle.durationMs / ms;
|
||||
if (!keepAngle && oldMs > 0) {
|
||||
angleScale = oldMs / ms;
|
||||
}
|
||||
final double depScale = oldMs > 0 && ms > 0 ? oldMs / ms : 1;
|
||||
List<Action> actions = _project.actions;
|
||||
if (angleScale != 1) {
|
||||
if (angleScale != 1 || depScale != 1) {
|
||||
actions = actions
|
||||
.map((Action a) => a.copyWith(
|
||||
startAngle: a.startAngle * angleScale,
|
||||
durationAngle: a.durationAngle * angleScale,
|
||||
startAngle: angleScale == 1 ? a.startAngle : a.startAngle * angleScale,
|
||||
durationAngle:
|
||||
angleScale == 1 ? a.durationAngle : a.durationAngle * angleScale,
|
||||
deps: depScale == 1
|
||||
? a.deps
|
||||
: a.deps
|
||||
.map((Dependency d) =>
|
||||
d.copyWith(offsetAngle: d.offsetAngle * depScale))
|
||||
.toList(),
|
||||
))
|
||||
.toList();
|
||||
}
|
||||
@@ -2262,6 +2274,45 @@ class AppController extends ChangeNotifier {
|
||||
);
|
||||
}
|
||||
|
||||
/// 修改一条已有依赖(保留手动拖拽的走线偏移)。
|
||||
///
|
||||
/// [oldFromId] 为原前置动作;[fromId] 为修改后的前置动作(可保持不变);
|
||||
/// [type] / [offset] 为新的依赖类型与偏移角。若目标动作已存在来自
|
||||
/// [fromId] 的另一条依赖,则合并为本条,避免重复。
|
||||
void updateDependency(
|
||||
String oldFromId,
|
||||
String toId, {
|
||||
required String fromId,
|
||||
required DepType type,
|
||||
required double offset,
|
||||
}) {
|
||||
if (fromId == toId) return;
|
||||
if (_project.actionById(fromId) == null) return;
|
||||
final Action? to = _project.actionById(toId);
|
||||
if (to == null) return;
|
||||
final int index = to.deps.indexWhere((Dependency d) => d.fromId == oldFromId);
|
||||
if (index < 0) return;
|
||||
final Dependency old = to.deps[index];
|
||||
final List<Dependency> deps = <Dependency>[
|
||||
for (int i = 0; i < to.deps.length; i++)
|
||||
if (i != index && to.deps[i].fromId != fromId) to.deps[i],
|
||||
];
|
||||
deps.insert(
|
||||
index > deps.length ? deps.length : index,
|
||||
old.copyWith(
|
||||
fromId: fromId,
|
||||
toId: toId,
|
||||
type: type,
|
||||
offsetAngle: offset,
|
||||
),
|
||||
);
|
||||
updateAction(
|
||||
toId,
|
||||
(Action x) => x.copyWith(deps: deps),
|
||||
status: '已修改依赖 $fromId→$toId',
|
||||
);
|
||||
}
|
||||
|
||||
/// 移除 [toId] 上来自 [fromId] 的依赖。
|
||||
void removeDependency(String fromId, String toId) {
|
||||
updateAction(
|
||||
|
||||
Reference in New Issue
Block a user