feat: 原创「环序」标志;双视图与侧栏优化;工位管理;帮助完善

- 原创应用标志「环序/Cycle-Step」:tools/gen-icon.py 重写 + 工具栏 Logo 同源,小尺寸简化版

- 条形时序视图:标题/副标题精简、双刻度值置于分区与刻度线之间、时间默认内嵌、依赖线箭头收窄、同泳道箭头接色块外侧、图注自动避让

- 圆周时序视图:去掉色块描边、环宽与间隙优化、度数外侧标时间、方向箭头外移;固定顺时针(移除逆时针)

- 左侧栏:编辑工位/编辑相位分区入口;双击画布色块或动作行进入编辑;至少保留一个动作/泳道

- 右侧栏:移除重复的编辑操作、导出与单位卡片;文件浏览器新增「桌面」快捷入口

- AI 对话框:字号优化并新增「编辑示例」;节拍统计移除无依据的预估产能

- 文档:README 与 docs/HELP.md 全面更新;dist 同步重建
This commit is contained in:
admin
2026-09-18 23:32:36 +08:00
parent 71e84e05aa
commit 43c99fc4b6
18 changed files with 1079 additions and 779 deletions
+335 -17
View File
@@ -127,6 +127,26 @@ class _FileBrowserDialogState extends State<FileBrowserDialog> {
setState(() {});
}
/// 解析桌面目录:优先 OneDrive 桌面,其次 `%USERPROFILE%\Desktop`。
///
/// 返回存在的目录;都不存在时返回 null(按钮不产生跳转)。
Directory? _desktop() {
final String? home = Platform.environment['USERPROFILE'];
final String? oneDrive = Platform.environment['OneDrive'];
final String sep = Platform.pathSeparator;
final List<String> candidates = <String>[
if (oneDrive != null && oneDrive.isNotEmpty) '$oneDrive${sep}Desktop',
if (home != null && home.isNotEmpty) '$home${sep}Desktop',
if (home != null && home.isNotEmpty) '$home${sep}OneDrive${sep}Desktop',
];
for (final String p in candidates) {
try {
if (Directory(p).existsSync()) return Directory(p);
} catch (_) {}
}
return null;
}
/// 枚举 Windows 盘符(A–Z)中当前存在的根目录。
List<String> _drives() {
final List<String> out = <String>[];
@@ -189,18 +209,35 @@ class _FileBrowserDialogState extends State<FileBrowserDialog> {
SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Row(
children: drives.map((String d) {
return Padding(
children: <Widget>[
// 桌面快捷入口:导出 / 打开 / 保存时一键跳到桌面。
Padding(
padding: const EdgeInsets.only(right: 6),
child: ActionChip(
label: Text(d),
avatar: Icon(Icons.desktop_windows_outlined, size: 15, color: t.accent),
label: const Text('桌面'),
onPressed: () {
_dir = Directory(d);
_refresh();
final Directory? d = _desktop();
if (d != null) {
_dir = d;
_refresh();
}
},
),
);
}).toList(),
),
...drives.map((String d) {
return Padding(
padding: const EdgeInsets.only(right: 6),
child: ActionChip(
label: Text(d),
onPressed: () {
_dir = Directory(d);
_refresh();
},
),
);
}),
],
),
),
const Divider(),
@@ -778,7 +815,7 @@ class _SettingsDialogState extends State<SettingsDialog> {
],
),
const SizedBox(height: 18),
// 循环与相位:循环时长可编辑,起点与方向为固定展示。
// 循环与相位:循环时长可编辑,起点与方向为固定展示(顺时针)。
Text('循环与相位', style: TextStyle(color: t.sub, fontSize: 11)),
const SizedBox(height: 8),
Row(
@@ -807,6 +844,7 @@ class _SettingsDialogState extends State<SettingsDialog> {
),
),
const SizedBox(width: 10),
// 旋转方向:固定为顺时针(圆周视图约定)。
Expanded(
child: TextField(
controller: TextEditingController(text: '顺时针 CW'),
@@ -1233,6 +1271,281 @@ class _ZoneRowState extends State<_ZoneRow> {
}
}
// ===================== 工位管理对话框 =====================
/// 工位管理对话框:增删工位、改名称与颜色、调整顺序。
///
/// 一个流程可能包含多个工位;删除工位后,其原动作会自动改挂到第一个工位。
class StationDialog extends StatefulWidget {
const StationDialog({super.key, required this.controller});
/// 全局应用控制器。
final AppController controller;
@override
State<StationDialog> createState() => _StationDialogState();
}
class _StationDialogState extends State<StationDialog> {
late List<Station> _stations;
@override
void initState() {
super.initState();
_stations = List<Station>.of(widget.controller.project.stations);
}
/// 生成不冲突的新工位 id(ST{n})。
String _nextId() {
final Set<String> used = _stations.map((Station s) => s.id).toSet();
int n = _stations.length + 1;
while (used.contains('ST$n')) {
n++;
}
return 'ST$n';
}
void _add() {
setState(() {
_stations.add(Station(
id: _nextId(),
name: '工位 ${_stations.length + 1}',
order: _stations.length,
color: kActionPalette[_stations.length % kActionPalette.length],
));
});
}
void _remove(int i) {
if (_stations.length <= 1) return;
setState(() => _stations.removeAt(i));
}
void _move(int i, int delta) {
final int j = i + delta;
if (j < 0 || j >= _stations.length) return;
setState(() {
final Station s = _stations.removeAt(i);
_stations.insert(j, s);
});
}
void _save() {
// 归一化 order 为列表顺序,保证条形视图按此排序。
final List<Station> out = <Station>[
for (int i = 0; i < _stations.length; i++) _stations[i].copyWith(order: i),
];
widget.controller.setStations(out, status: '工位已更新(${out.length} 个)');
Navigator.pop(context);
}
@override
Widget build(BuildContext context) {
final Tokens t = context.tok;
return Dialog(
backgroundColor: t.dialog,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(14)),
child: scaledDialogBox(
context,
640,
560,
Padding(
padding: const EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(
children: <Widget>[
Icon(Icons.precision_manufacturing_outlined, size: 18, color: t.accent),
const SizedBox(width: 8),
Text('工位管理', style: TextStyle(fontSize: 15, fontWeight: FontWeight.w700, color: t.text)),
const SizedBox(width: 10),
Expanded(
child: Text('可增删工位、改名称与颜色、调整顺序;删除工位后其动作自动改挂到第一个工位',
style: TextStyle(fontSize: 10, color: t.dim)),
),
],
),
const Divider(height: 20),
Expanded(
child: ListView.builder(
itemCount: _stations.length,
itemBuilder: (BuildContext ctx, int i) {
return _StationRow(
key: ValueKey<String>(_stations[i].id),
t: t,
station: _stations[i],
first: i == 0,
last: i == _stations.length - 1,
canDelete: _stations.length > 1,
onChanged: (Station s) => setState(() => _stations[i] = s),
onMoveUp: () => _move(i, -1),
onMoveDown: () => _move(i, 1),
onDelete: () => _remove(i),
);
},
),
),
const Divider(height: 20),
Row(
children: <Widget>[
OutlinedButton.icon(
onPressed: _add,
icon: const Icon(Icons.add, size: 16),
label: const Text('添加工位'),
),
const SizedBox(width: 10),
Text('共 ${_stations.length} 个工位', style: TextStyle(color: t.dim, fontSize: 11)),
const Spacer(),
TextButton(onPressed: () => Navigator.pop(context), child: const Text('取消')),
const SizedBox(width: 8),
FilledButton(onPressed: _save, child: const Text('确定')),
],
),
],
),
),
),
);
}
}
/// 工位管理中的单行:颜色、id、名称、排序与删除。
class _StationRow extends StatefulWidget {
const _StationRow({
super.key,
required this.t,
required this.station,
required this.first,
required this.last,
required this.canDelete,
required this.onChanged,
required this.onMoveUp,
required this.onMoveDown,
required this.onDelete,
});
final Tokens t;
final Station station;
final bool first;
final bool last;
final bool canDelete;
final ValueChanged<Station> onChanged;
final VoidCallback onMoveUp;
final VoidCallback onMoveDown;
final VoidCallback onDelete;
@override
State<_StationRow> createState() => _StationRowState();
}
class _StationRowState extends State<_StationRow> {
late final TextEditingController _name;
@override
void initState() {
super.initState();
_name = TextEditingController(text: widget.station.name);
}
@override
void dispose() {
_name.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
final Tokens t = widget.t;
return Padding(
padding: const EdgeInsets.only(bottom: 8),
child: Row(
children: <Widget>[
// 颜色:点击弹出调色板。
PopupMenuButton<int>(
tooltip: '选择颜色',
onSelected: (int c) => widget.onChanged(widget.station.copyWith(color: c)),
itemBuilder: (BuildContext ctx) => kActionPalette
.map((int c) => PopupMenuItem<int>(
value: c,
height: 36,
child: Row(
children: <Widget>[
Container(
width: 18,
height: 18,
decoration: BoxDecoration(color: Color(c), borderRadius: BorderRadius.circular(5)),
),
const SizedBox(width: 8),
Text('#${c.toRadixString(16).padLeft(8, '0').substring(2).toUpperCase()}',
style: TextStyle(color: t.text, fontSize: 11)),
],
),
))
.toList(),
child: Container(
width: 30,
height: 30,
decoration: BoxDecoration(
color: Color(widget.station.color),
borderRadius: BorderRadius.circular(8),
border: Border.all(color: t.line2),
),
),
),
const SizedBox(width: 8),
Container(
width: 44,
height: 30,
alignment: Alignment.center,
decoration: BoxDecoration(
color: t.panel2,
borderRadius: BorderRadius.circular(8),
border: Border.all(color: t.line),
),
child: Text(widget.station.id, style: TextStyle(color: t.sub, fontSize: 11, fontWeight: FontWeight.w600)),
),
const SizedBox(width: 8),
Expanded(
child: TextField(
controller: _name,
onChanged: (String v) => widget.onChanged(
widget.station.copyWith(name: v.trim().isEmpty ? widget.station.name : v.trim())),
style: TextStyle(color: t.text, fontSize: 11.5),
decoration: InputDecoration(
isDense: true,
hintText: '工位名称',
hintStyle: TextStyle(color: t.dim, fontSize: 11),
filled: true,
fillColor: t.panel2,
border: OutlineInputBorder(borderRadius: BorderRadius.circular(8)),
),
),
),
IconButton(
onPressed: widget.first ? null : widget.onMoveUp,
icon: const Icon(Icons.keyboard_arrow_up, size: 18),
splashRadius: 15,
tooltip: '上移',
),
IconButton(
onPressed: widget.last ? null : widget.onMoveDown,
icon: const Icon(Icons.keyboard_arrow_down, size: 18),
splashRadius: 15,
tooltip: '下移',
),
IconButton(
onPressed: widget.canDelete ? widget.onDelete : null,
icon: Icon(Icons.delete_outline, size: 17, color: widget.canDelete ? t.danger : t.dim),
splashRadius: 16,
tooltip: widget.canDelete ? '删除工位' : '至少保留一个工位',
),
],
),
);
}
}
// ===================== 帮助中心对话框 =====================
/// 帮助中心对话框:以四个标签页展示快速开始、快捷键、
@@ -1288,15 +1601,16 @@ class HelpDialog extends StatelessWidget {
<String>['我要新建方案', '顶部「新建」创建空白节拍;「打开」载入 .seq.json。'],
<String>['我要先看看示例', '首次启动载入 2 个动作的示例节拍,可直接修改。'],
<String>['我要新增动作', '双击画布空白处在点击相位新增;或左侧「新建」在 0° 新增(默认最外层)。'],
<String>['我要删除动作', '选中后:左侧「删除」/ 行内删除图标 / 右侧删除 / Delete 键 / 右键菜单。'],
<String>['我要改动作属性', '选中动作 → 右侧「编辑」,可改名称、工位、驱动与颜色。'],
<String>['我要复制 / 对齐', '右侧「编辑操作」→「复制」/「对齐相位」;圆周视图还可改层。'],
<String>['我要删除动作', '选中后:左侧「删除」/ 行内删除图标 / Delete 键 / 右键菜单;至少保留一个动作 / 泳道。'],
<String>['我要改动作属性', '双击画布色块(条形块 / 圆弧)或左侧动作行 → 打开动作编辑对话框;也可选中后点左侧行内编辑图标。'],
<String>['我要复制 / 对齐', '画布左下角「编辑工具」→「复制」/「对齐」;圆周视图右侧浮动工具条同款。'],
<String>['我要编辑工位', '左侧「动作和执行编辑」→「编辑工位」:可增删工位、改名称与颜色、上下调整顺序;删除工位后其动作自动改挂到第一个工位。'],
<String>['一条泳道放多个动作', '泳道/轨道=一个执行器:上下拖拽(条形)或 Shift+径向拖拽(圆周)换道;不重叠即可共存,标题合并显示(/ 分隔,≤2 行)。'],
]),
// 目标:调整时间轴与动作间的先后 / 并行关系。
_section(t, <List<String>>[
<String>['我要改时间轴长度', '点左侧项目卡的「循环 …」,或按 F2 →「循环与相位」→ 循环时长 → 应用。'],
<String>['我要调相位 / 时长', '拖动动作块平移相位;拖条形右端改持续角;右侧滑杆可精调。'],
<String>['我要改时间轴长度', '左侧「时序创建和编辑」→「编辑时序与节拍参数」,或按 F2 →「循环与相位」→ 循环时长 → 应用。'],
<String>['我要调相位 / 时长', '拖动动作块平移相位;拖条形右端改持续角;圆周视图拖弧两端改起止角;右侧滑杆可精调。'],
<String>['我要让动作跨循环', '使「起始角 + 持续角 > 360°」,会自动拆分并以半透明虚线渲染尾段。'],
<String>['我要加前置依赖(输入)', '右侧「前置依赖 · 输入」→「添加前置依赖」;或右键动作 →「添加依赖」。'],
<String>['一个动作多输入', '可重复添加多条前置依赖,逐条列出、逐条可删。'],
@@ -1306,9 +1620,10 @@ class HelpDialog extends StatelessWidget {
// 目标:编辑相位分区并控制画布显示。
_section(t, <List<String>>[
<String>['相位分区是什么', '把一个循环按角度分成的命名工艺阶段(默认上料/夹紧/加工/检测/下料),条形图顶部标注带即它。'],
<String>['我要编辑相位分区', 'F2 →「相位分区」→「编辑…」:增删分区、改名称与起止角;可重叠、可留空、>360° 表示跨圈。'],
<String>['我要编辑相位分区', '左侧「动作和执行编辑」→「编辑相位分区」;或 F2 →「相位分区」→「编辑…」。增删分区、改名称与起止角;可重叠、可留空、>360° 表示跨圈。'],
<String>['我要隐藏相位分区', '左侧「显示选项」取消勾选「相位分区标注」。'],
<String>['我要切换视图', '顶部「条形节拍 / 圆周节拍」分段开关,两种视图共享同一份数据。'],
<String>['刻度怎么读', '条形视图:分区带与刻度线之间上排为相位、下排为等价时间;圆周视图:每 30° 的度数外侧标注等价时间。'],
<String>['我要切换视图', '顶部「条形节拍 / 圆周节拍」分段开关,两种视图共享同一份数据;标题分别为「条形时序视图」「圆周时序视图」。'],
<String>['我要缩放 / 平移', 'Ctrl+滚轮 以光标为锚点缩放;普通滚轮或拖拽空白平移。'],
<String>['我要完整显示', '顶部「适应视图」:自动按内容(含刻度、箭头、跨圈标注)计算缩放与居中,编辑后也不会被裁切。'],
<String>['我要开关标注', '左侧「显示选项」逐项开关双刻度、依赖箭头、圆环背景、层标注、跨循环高亮等。'],
@@ -1317,7 +1632,7 @@ class HelpDialog extends StatelessWidget {
_section(t, <List<String>>[
<String>['我要 AI 生成', '顶部「AI 生成」→ 填 DeepSeek API Key → 选模型(Flash / Pro)→ 选强度(高 / 最高)→ 用自然语言描述 → 生成。'],
<String>['生成效果不好', '描述里写清:循环时长、工位数、各动作时长、哪些顺序(完成后启动)、哪些并行。'],
<String>['我要看节拍统计', '画布左下角「节拍统计」按钮 → 弹窗查看关键路径、并行度、瓶颈工位、产能等。'],
<String>['我要看节拍统计', '画布左下角「节拍统计」按钮 → 弹窗查看循环周期、动作数、关键路径、最大并行度、相位覆盖率与瓶颈工位(仅展示可从项目数据推导的指标)。'],
<String>['我要导出 SVG', '顶部「导出 SVG」:矢量、分层、带语义 id 与 data-*,可直接进工艺卡 / MES。'],
<String>['我要导出 PNG', '顶部「导出 PNG」:按 2 倍像素比导出当前画布为位图。'],
<String>['我要保存 / 恢复', '「保存」写入 .seq.json 并生成 .bak;每 5 秒自动快照,异常退出后启动可恢复。'],
@@ -1328,9 +1643,12 @@ class HelpDialog extends StatelessWidget {
<String>['我要钉住侧栏', '侧栏标题右侧图钉:钉住=固定占位;取消钉住=悬浮,鼠标移开自动收起。'],
<String>['边缘把手', '侧栏收起后画布边缘有细把手:悬停临时展开,点击固定显示。'],
<String>['拖拽 / 缩放', '左键拖拽平移相位;拖端点改时长;Shift+拖拽改层;Ctrl+滚轮缩放。'],
<String>['双击编辑', '双击画布色块(条形块 / 圆弧)或左侧动作行 → 打开动作编辑对话框。'],
<String>['右键动作', '菜单:添加依赖 / 改层 / 复制 / 删除。'],
<String>['撤销 / 保存', 'Ctrl+Z / Ctrl+Y 撤销重做;Ctrl+S 保存;Ctrl+O / Ctrl+N 打开 / 新建。'],
<String>['其它', 'F1 帮助;F2 工艺参数(含相位分区);F3 切换深/浅主题;Delete 删除选中动作。'],
<String>['帮助入口', '顶部工具栏右侧「?」或 F1 打开帮助中心;画布编辑工具条不重复放置帮助按钮。'],
<String>['导出入口', '导出 SVG / PNG 统一放在顶部工具栏右侧,避免多处重复。'],
<String>['其它', 'F2 编辑时序与节拍参数(含单位与相位分区);F3 切换深/浅主题;Delete 删除选中动作。'],
]),
// 关于:设计人、版本与版权声明。
_section(t, <List<String>>[