版本号

This commit is contained in:
dzc committed 2026-09-23 18:45:57 +08:00
1 parent 6a9dbf9080
commit 7897e77c52
7 files changed
+95 -4

No files matched your search

+3 -1
View File
@@ -4,6 +4,7 @@ import 'print/backend.dart';
import 'print/mock_backend.dart';
import 'server/http_server.dart';
import 'server/print_queue.dart';
import 'build_info.g.dart';
import 'utils/file_log.dart';
/// 启动参数:--mock 模拟打印;--port=NNN / --port NNN 指定监听端口(默认 38200-38202 顺延)。
@@ -73,10 +74,11 @@ class Agent {
backend: backend,
mock: options.mock,
manifestBackendName: backendName,
appVersion: kBuildVersion,
);
final ports = options.port == null ? const [38200, 38201, 38202] : <int>[options.port!];
port = await server.start(candidatePorts: ports);
log.write('资安信插件助手已启动 http://127.0.0.1:$port'
log.write('资安信插件助手 v$kBuildVersion 已启动 http://127.0.0.1:$port'
'(后端=$backendName,mock=${options.mock},agent=desktop-plugin)');
return port!;
}
+3
View File
@@ -0,0 +1,3 @@
// 由打包脚本自动生成(tool/package_windows.ps1 / tool/package_macos.sh),勿手改。
// 手动 flutter build 未跑脚本时保持上次打包的值;脚本打包会写入"版本+git提交+时间"。
const String kBuildVersion = 'dev';
+5
View File
@@ -16,6 +16,7 @@ class AgentHttpServer {
required this.backend,
required this.mock,
required this.manifestBackendName,
this.appVersion = '',
this.agentName = 'desktop-plugin',
});
@@ -27,6 +28,9 @@ class AgentHttpServer {
/// manifest 里的 backend 字段按操作系统报(pavo/cups),与是否 mock 无关(对齐 C# 版)
final String manifestBackendName;
/// 构建版本(打包脚本注入),随 manifest 暴露给前端核对
final String appVersion;
final String agentName;
HttpServer? _server;
@@ -65,6 +69,7 @@ class AgentHttpServer {
..get('/manifest', (Request r) => _ok({
'plugins': [ManifestPlugin().toJson()],
'agent': agentName,
'version': appVersion,
'backend': manifestBackendName,
'mock': mock,
}))
+10
View File
@@ -3,6 +3,8 @@ import 'dart:io';
import 'package:flutter/material.dart';
import '../build_info.g.dart';
import '../agent.dart';
import '../server/protocol.dart';
import '../utils/file_log.dart';
@@ -121,6 +123,14 @@ class _CardPrinterPageState extends State<CardPrinterPage> {
.bodyMedium
?.copyWith(color: scheme.onSurfaceVariant),
),
const SizedBox(height: 2),
Text(
'版本 $kBuildVersion',
style: Theme.of(context)
.textTheme
.labelSmall
?.copyWith(color: scheme.onSurfaceVariant.withValues(alpha: 0.7)),
),
],
),
),