mirror of
https://gitcode.com/JianFeeeee/HomeAgent.git
synced 2026-09-23 18:38:11 +00:00
chore(version): 客户端版本与内核对齐(唯一事实源 internal/meta.Version)
此前三份版本号互不相干:内核 1.4.0、GUI 1.0.0、鸿蒙 1.1.1。手工各改各的 必然漂移,所以把「对齐」做成机械动作而不是约定: - deploy/scripts/sync-client-versions.sh:从 internal/meta.Version 读版本, 同步 cmd/gui/package.json 与鸿蒙 AppScope/app.json5(versionName + versionCode=X*1e6+Y*1e3+Z);--check 给 CI/Makefile 做漂移门禁。 - Makefile 新增 sync-client-versions / check-client-versions;build-cli 也注入 LDFLAGS,waiter 与 homed 同版本。 - 鸿蒙:新增 common/AppVersion.ets,从 bundleManager 读安装包 versionName, BridgeProtocol/BridgeCaps 里两处硬编码 '1.1.1' 改为读它——版本只剩 app.json5 一份,杜绝第二真相。 - waiter:`-version` 打印版本,启动横幅与设备桥 hello 的 version 字段 直接引用 internal/meta,与内核天然同源。 对齐后:GUI 1.4.0 / 鸿蒙 1.4.0(1004000) / waiter 1.4.0 / 内核 1.4.0。
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "homeagent-gui",
|
||||
"version": "1.0.0",
|
||||
"version": "1.4.0",
|
||||
"author": "JianFeeeee <jianfeeeee@homeagent.local>",
|
||||
"homepage": "https://gitcode.com/JianFeeeee/HomeAgent",
|
||||
"description": "HomeAgent Desktop GUI - Multi-connection management dashboard",
|
||||
|
||||
@ -2,8 +2,8 @@
|
||||
"app": {
|
||||
"bundleName": "com.example.homeagent",
|
||||
"vendor": "HomeAgent",
|
||||
"versionCode": 1001001,
|
||||
"versionName": "1.1.1",
|
||||
"versionCode": 1004000,
|
||||
"versionName": "1.4.0",
|
||||
// 分层图标:前景是字形,背景(沉淀色)在 base/ 与 dark/ 各一份,随系统主题切换。
|
||||
// 直接指向位图会把浅色底烧进图标,深色模式下桌面和启动页都会跳脱。
|
||||
"icon": "$media:layered_image",
|
||||
|
||||
19
cmd/ohos/HomeAgent/entry/src/main/ets/common/AppVersion.ets
Normal file
19
cmd/ohos/HomeAgent/entry/src/main/ets/common/AppVersion.ets
Normal file
@ -0,0 +1,19 @@
|
||||
import { bundleManager } from '@kit.AbilityKit';
|
||||
|
||||
/**
|
||||
* 应用版本号:从 bundle 元数据读取,而不是在 .ets 里再抄一份。
|
||||
*
|
||||
* AppScope/app.json5 是版本的唯一来源(由 deploy/scripts/sync-client-versions.sh
|
||||
* 与内核 internal/meta.Version 对齐)。在代码里再写一个字面量就是第二份真相,
|
||||
* 实测已经漂过:app.json5 写 1.1.1、设备桥上又是一份 1.1.1,而内核早已 1.4.0。
|
||||
* 设备桥上报 / deviceinfo 回显的真实安装包版本,应当来自同一个来源。
|
||||
*/
|
||||
export function appVersion(): string {
|
||||
try {
|
||||
const info: bundleManager.BundleInfo =
|
||||
bundleManager.getBundleInfoForSelfSync(bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT);
|
||||
return info.versionName;
|
||||
} catch (e) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
@ -5,6 +5,7 @@ import { deviceInfo } from '@kit.BasicServicesKit';
|
||||
import { textToSpeech } from '@kit.CoreSpeechKit';
|
||||
import { componentSnapshot } from '@kit.ArkUI';
|
||||
import { abilityAccessCtrl, common, PermissionRequestResult, Permissions } from '@kit.AbilityKit';
|
||||
import { appVersion } from './AppVersion';
|
||||
|
||||
// ===== 能力结果 =====
|
||||
|
||||
@ -249,7 +250,7 @@ export function capDeviceInfo(deviceId: string, deviceName: string): CapResult {
|
||||
platform: 'OpenHarmony',
|
||||
arch: deviceInfo.abiList,
|
||||
os_release: deviceInfo.osFullName,
|
||||
version: '1.1.1',
|
||||
version: appVersion(),
|
||||
cpus: 0,
|
||||
brand: deviceInfo.brand,
|
||||
manufacturer: deviceInfo.manufacture,
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
*/
|
||||
|
||||
import { CapResult } from './BridgeCaps';
|
||||
import { appVersion } from './AppVersion';
|
||||
|
||||
// ===== 协议消息(与 remotedevice 插件对齐)=====
|
||||
|
||||
@ -83,7 +84,7 @@ export function bridgeHelloFrame(deviceId: string, name: string, kind: string,
|
||||
platform: 'OpenHarmony',
|
||||
arch: '',
|
||||
os_release: '',
|
||||
version: '1.1.1',
|
||||
version: appVersion(),
|
||||
cpus: 0,
|
||||
};
|
||||
const device: HelloDevice = {
|
||||
|
||||
@ -15,6 +15,7 @@ import (
|
||||
"time"
|
||||
|
||||
"gitcode.com/JianFeeeee/HomeAgent/internal/devicebridge/client"
|
||||
"gitcode.com/JianFeeeee/HomeAgent/internal/meta"
|
||||
)
|
||||
|
||||
// ===== 设备桥管理 =====
|
||||
@ -46,6 +47,9 @@ func startDeviceBridge(addr, token string) error {
|
||||
"platform": runtime.GOOS,
|
||||
"arch": runtime.GOARCH,
|
||||
"cpus": runtime.NumCPU(),
|
||||
// 客户端版本与内核同源(internal/meta),deviceinfo 回显的软件版本
|
||||
// 因此与 homed 一致,不再是一个空缺字段。
|
||||
"version": meta.Version,
|
||||
}
|
||||
|
||||
// 确保 gateway URL 格式正确
|
||||
|
||||
@ -11,6 +11,8 @@ import (
|
||||
"sync"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"gitcode.com/JianFeeeee/HomeAgent/internal/meta"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -129,8 +131,15 @@ func main() {
|
||||
daemonMode := flag.Bool("daemon", false, "后台驻留模式:维持 homed 连接 + 设备桥,等待 TUI 实例接入")
|
||||
testCap := flag.String("test-cap", "", "测试本地能力(screensue/speakeruse/screensee/clipboardsee/clipboardsue/computeruse/camerasue),如 --test-cap screensue")
|
||||
testCapArgs := flag.String("test-cap-args", "", "测试能力的参数")
|
||||
showVersion := flag.Bool("version", false, "打印版本并退出")
|
||||
flag.Parse()
|
||||
|
||||
// 版本号直接来自 internal/meta(与 homed 同一事实源,不可能各写一个)。
|
||||
if *showVersion {
|
||||
fmt.Printf("waiter %s (commit %s, built %s)\n", meta.Version, meta.Commit, meta.BuildTime)
|
||||
return
|
||||
}
|
||||
|
||||
// 本地能力测试模式(无需连接服务器)
|
||||
if *testCap != "" {
|
||||
runCapTest(*testCap, *testCapArgs)
|
||||
@ -270,9 +279,9 @@ func runLineMode(state *State, cfg *Config, history *History) {
|
||||
addrLabel = cfg.Remote
|
||||
}
|
||||
if colors {
|
||||
fmt.Printf("%sHomeAgent CLI%s %s(%s://%s)%s\n", colorBold, colorReset, colorDim, modeLabel, addrLabel, colorReset)
|
||||
fmt.Printf("%sHomeAgent CLI%s %s%s (%s://%s)%s\n", colorBold, colorReset, colorDim, "v"+meta.Version, modeLabel, addrLabel, colorReset)
|
||||
} else {
|
||||
fmt.Printf("HomeAgent CLI (%s://%s)\n", modeLabel, addrLabel)
|
||||
fmt.Printf("HomeAgent CLI v%s (%s://%s)\n", meta.Version, modeLabel, addrLabel)
|
||||
}
|
||||
fmt.Println("Type /help for commands.")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user