feat(V1.1.1): 软件授权(license)——MAC 绑定 .lic 校验,未授权禁用导出
- 新增 lib/license/license_service.dart:读取 exe 同级 license/*.lic,按算法由本机 MAC 计算期望授权串比对 - 算法:MAC 去分隔符 → A=01..Z=26(数字 00..09)→ 末尾加 26 → 整串倒序 - 未授权时「导出 SVG / PNG」置灰,并在导出入口二次拦截 - 关于页:显示授权状态、本机 MAC、授权申请邮箱 liuyu65@126.com,并可「提交授权申请」(唤起邮件客户端发送 MAC+发件人信息) - 新增 license/ 目录(含说明);构建脚本把 license/ 复制到 dist/ - 新增 tools/keygen(Win32 图形界面 keygen.exe + 构建脚本)用于生成 .lic - 版本 1.1.1+3;新增授权算法单元测试;重新构建 dist
This commit is contained in:
+19
-9
@@ -150,6 +150,10 @@ class _AppShellState extends State<AppShell> {
|
||||
|
||||
/// 导出 SVG:将当前视图交给 [SvgWriter] 生成矢量内容并写入文件。
|
||||
Future<void> _exportSvg() async {
|
||||
if (!c.licensed) {
|
||||
if (mounted) await showMessage(context, '未授权', '未检测到有效授权(license/*.lic),无法导出 SVG。');
|
||||
return;
|
||||
}
|
||||
final String? path = await pickFile(context, save: true, initialPath: c.filePath);
|
||||
if (path == null) return;
|
||||
final String svgPath = path.replaceAll(RegExp(r'\.json$'), '.svg');
|
||||
@@ -169,6 +173,10 @@ class _AppShellState extends State<AppShell> {
|
||||
/// 导出 PNG:把画布舞台的 [RenderRepaintBoundary] 以 2 倍像素比
|
||||
/// 渲染为位图并写入文件。
|
||||
Future<void> _exportPng() async {
|
||||
if (!c.licensed) {
|
||||
if (mounted) await showMessage(context, '未授权', '未检测到有效授权(license/*.lic),无法导出 PNG。');
|
||||
return;
|
||||
}
|
||||
final String? path = await pickFile(context, save: true, initialPath: c.filePath);
|
||||
if (path == null) return;
|
||||
final String pngPath = path.replaceAll(RegExp(r'\.(json|svg)$'), '.png');
|
||||
@@ -347,9 +355,10 @@ class _AppShellState extends State<AppShell> {
|
||||
_segmented(t),
|
||||
];
|
||||
right = <Widget>[
|
||||
_primaryBtn(t, '导出 SVG', _exportSvg),
|
||||
// 未授权时导出按钮置灰(授权有效才允许导出)。
|
||||
_primaryBtn(t, '导出 SVG', c.licensed ? _exportSvg : null),
|
||||
const SizedBox(width: 6),
|
||||
_ghost(t, '导出 PNG', _exportPng),
|
||||
_ghost(t, '导出 PNG', c.licensed ? _exportPng : null),
|
||||
const SizedBox(width: 6),
|
||||
_zoomBox(t),
|
||||
const SizedBox(width: 6),
|
||||
@@ -384,10 +393,10 @@ class _AppShellState extends State<AppShell> {
|
||||
_segmented(t, compact: true),
|
||||
];
|
||||
right = <Widget>[
|
||||
// 导出保持两个独立按钮(不用合并菜单,便于一眼识别)。
|
||||
_ghost(t, '导出 SVG', _exportSvg),
|
||||
// 导出保持两个独立按钮;未授权时置灰。
|
||||
_ghost(t, '导出 SVG', c.licensed ? _exportSvg : null),
|
||||
const SizedBox(width: 4),
|
||||
_ghost(t, '导出 PNG', _exportPng),
|
||||
_ghost(t, '导出 PNG', c.licensed ? _exportPng : null),
|
||||
const SizedBox(width: 4),
|
||||
_zoomBox(t),
|
||||
_iconBtn(t, Icons.crop_free, c.fitView, tooltip: '适应视图'),
|
||||
@@ -586,13 +595,14 @@ class _AppShellState extends State<AppShell> {
|
||||
);
|
||||
}
|
||||
|
||||
/// 主色填充按钮(用于导出等主要动作)。
|
||||
Widget _primaryBtn(Tokens t, String label, VoidCallback onTap) {
|
||||
/// 主色填充按钮(用于导出等主要动作);[onTap] 为 null 时禁用(置灰)。
|
||||
Widget _primaryBtn(Tokens t, String label, VoidCallback? onTap) {
|
||||
final bool enabled = onTap != null;
|
||||
return FilledButton(
|
||||
onPressed: onTap,
|
||||
style: FilledButton.styleFrom(
|
||||
backgroundColor: t.accent2,
|
||||
foregroundColor: Colors.white,
|
||||
backgroundColor: enabled ? t.accent2 : t.panel2,
|
||||
foregroundColor: enabled ? Colors.white : t.dim,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(9)),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10),
|
||||
minimumSize: const Size(0, 34),
|
||||
|
||||
Reference in New Issue
Block a user