rvis-aiui-kit 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -19,4 +19,4 @@ import glass3 from 'rvis-aiui-kit';
19
19
  }
20
20
  ```
21
21
 
22
- Available component exports: `rvis-aiui-kit/image`, `rvis-aiui-kit/list`, `rvis-aiui-kit/markdown`, `rvis-aiui-kit/model-list`, `rvis-aiui-kit/paragraph`, `rvis-aiui-kit/table`.
22
+ Available component exports: `rvis-aiui-kit/image`, `rvis-aiui-kit/list`, `rvis-aiui-kit/markdown`, `rvis-aiui-kit/model-list`, `rvis-aiui-kit/paragraph`, `rvis-aiui-kit/status-bar`, `rvis-aiui-kit/table`.
@@ -13,11 +13,11 @@ export default {
13
13
  },
14
14
  width: {
15
15
  type: String,
16
- value: '66px'
16
+ value: '168px'
17
17
  },
18
18
  height: {
19
19
  type: String,
20
- value: '66px'
20
+ value: '104px'
21
21
  },
22
22
  objectFit: {
23
23
  type: String,
@@ -38,7 +38,7 @@ export default {
38
38
 
39
39
  <style>
40
40
  .image-content {
41
- border-radius: 4px;
41
+ border-radius: 2px;
42
42
  overflow: hidden;
43
43
  }
44
44
  </style>
@@ -0,0 +1,35 @@
1
+ # Image 图片组件
2
+
3
+ 注册路径:`rvis-aiui-kit/image`。
4
+
5
+ Image 用于在 AIUI 页面中显示应用图片,并与 Glass3 默认相机预览区域保持一致的尺寸和圆角。
6
+
7
+ | 属性 | 类型 | 默认值 | 说明 |
8
+ | --- | --- | --- | --- |
9
+ | `src` | String | `''` | 图片地址,支持运行时可读取的网络地址、本地路径或 Base64 Data URL。 |
10
+ | `width` | String | `'168px'` | 图片宽度。 |
11
+ | `height` | String | `'104px'` | 图片高度。 |
12
+ | `objectFit` | String | `'fill'` | 缩放方式:`contain`、`cover` 或 `fill`。 |
13
+
14
+ 组件使用固定 `2px` 圆角。默认 `168px × 104px` 几何与 `glass3.camera.startPreview()` 的默认预览尺寸一致,适合在预览停止后用拍照结果替换同一媒体区域。
15
+
16
+ ```json
17
+ {
18
+ "usingComponents": {
19
+ "rvis-image": "rvis-aiui-kit/image"
20
+ }
21
+ }
22
+ ```
23
+
24
+ ```xml
25
+ <rvis-image
26
+ src="{{ imageSrc }}"
27
+ objectFit="cover"
28
+ ></rvis-image>
29
+ ```
30
+
31
+ 拍照结果使用 Base64 时,将 `photoMime` 和 `photoBase64` 组成 Data URL 后传给 `src`:
32
+
33
+ ```js
34
+ const imageSrc = `data:${photo.photoMime || 'image/jpeg'};base64,${photo.photoBase64}`;
35
+ ```
@@ -0,0 +1,139 @@
1
+ <script def>
2
+ {
3
+ "component": true
4
+ }
5
+ </script>
6
+
7
+ <script setup>
8
+ import glass3 from 'rvis-aiui-kit';
9
+
10
+ function logError(error) {
11
+ if (error && error.code === 'CALL_DISPOSED') return;
12
+ console.error('[Status Bar]', error);
13
+ }
14
+
15
+ export default {
16
+ properties: {
17
+ title: {
18
+ type: String,
19
+ value: ''
20
+ }
21
+ },
22
+
23
+ data: {
24
+ dateText: '',
25
+ timeText: '',
26
+ batteryText: '--%',
27
+ active: false,
28
+ clockTimer: null,
29
+ powerObserveRequestId: ''
30
+ },
31
+
32
+ methods: {
33
+ updateTime() {
34
+ const now = new Date();
35
+ const hours = now.getHours();
36
+ const minutes = now.getMinutes();
37
+ this.setData({
38
+ dateText: `${now.getMonth() + 1}/${now.getDate()}`,
39
+ timeText: `${hours < 10 ? '0' : ''}${hours}:${minutes < 10 ? '0' : ''}${minutes}`
40
+ });
41
+ },
42
+
43
+ updateBattery(event) {
44
+ if (!this.data.active) return;
45
+ if (event.eventType === 'invalidated') {
46
+ this.data.powerObserveRequestId = '';
47
+ this.setData({ batteryText: '--%' });
48
+ return;
49
+ }
50
+
51
+ const power = event.eventType === 'snapshot'
52
+ ? event.snapshot && event.snapshot.power
53
+ : event.patch && event.patch.power;
54
+ if (!power) return;
55
+
56
+ this.setData({
57
+ batteryText: power.levelPercent === undefined
58
+ ? '--%'
59
+ : `${power.levelPercent}%`
60
+ });
61
+ },
62
+
63
+ observePower() {
64
+ glass3.deviceContext.observe(
65
+ { domains: ['power'] },
66
+ { onEvent: event => this.updateBattery(event) }
67
+ ).then(result => {
68
+ if (this.data.active) {
69
+ this.data.powerObserveRequestId = result.requestId;
70
+ return;
71
+ }
72
+
73
+ glass3.deviceContext.stopObserve({
74
+ requestId: result.requestId
75
+ }).catch(logError);
76
+ }).catch(logError);
77
+ }
78
+ },
79
+
80
+ lifetimes: {
81
+ attached() {
82
+ this.data.active = true;
83
+ this.updateTime();
84
+ this.data.clockTimer = setInterval(() => this.updateTime(), 1000);
85
+ this.observePower();
86
+ },
87
+
88
+ detached() {
89
+ this.data.active = false;
90
+
91
+ if (this.data.clockTimer !== null) {
92
+ clearInterval(this.data.clockTimer);
93
+ this.data.clockTimer = null;
94
+ }
95
+ if (this.data.powerObserveRequestId) {
96
+ glass3.deviceContext.stopObserve({
97
+ requestId: this.data.powerObserveRequestId
98
+ }).catch(logError);
99
+ this.data.powerObserveRequestId = '';
100
+ }
101
+ }
102
+ }
103
+ };
104
+ </script>
105
+
106
+ <page>
107
+ <view class="status-bar">
108
+ <text class="status-text">{{ title }}</text>
109
+ <view class="status-right">
110
+ <text class="status-text">{{ dateText }}</text>
111
+ <text class="status-text">{{ timeText }}</text>
112
+ <text class="status-text">{{ batteryText }}</text>
113
+ </view>
114
+ </view>
115
+ </page>
116
+
117
+ <style>
118
+ .status-bar {
119
+ display: flex;
120
+ flex-direction: row;
121
+ align-items: center;
122
+ justify-content: space-between;
123
+ width: 480px;
124
+ height: 20px;
125
+ }
126
+
127
+ .status-right {
128
+ display: flex;
129
+ flex-direction: row;
130
+ align-items: center;
131
+ gap: 10px;
132
+ }
133
+
134
+ .status-text {
135
+ color: #40ff5e;
136
+ font-size: 14px;
137
+ line-height: 20px;
138
+ }
139
+ </style>
@@ -0,0 +1,45 @@
1
+ # Status Bar 组件
2
+
3
+ 标准 Glass3 HUD 状态栏,左侧显示应用标题,右侧显示本地月/日、时间和实时电量。
4
+
5
+ 组件会在 `attached` 时启动时钟和 `power` 订阅,在 `detached` 时清理计时器并停止订阅。
6
+
7
+ ## 注册与使用
8
+
9
+ ```json
10
+ {
11
+ "usingComponents": {
12
+ "rvis-status-bar": "rvis-aiui-kit/status-bar"
13
+ }
14
+ }
15
+ ```
16
+
17
+ ```html
18
+ <rvis-status-bar title="应用名称"></rvis-status-bar>
19
+ ```
20
+
21
+ 属性:
22
+
23
+ - `title: String`,默认 `''`,显示在状态栏左侧。
24
+
25
+ 组件固定为 `480px × 20px`,使用 `14px / 20px` 的绿色文本;页面负责将它放在全屏绘制区域的 `(0, 0)`。
26
+
27
+ ## Host 消息转发
28
+
29
+ Ink 当前只把 Host 消息交给 Page,不会直接调用自定义组件的 `onMessage`。使用该组件的页面必须把消息转发到与组件共享的 `glass3` 单例:
30
+
31
+ ```js
32
+ import glass3 from 'rvis-aiui-kit';
33
+
34
+ export default {
35
+ onMessage(messageEvent) {
36
+ glass3.handleMessage(messageEvent);
37
+ },
38
+
39
+ onUnload() {
40
+ glass3.dispose();
41
+ }
42
+ };
43
+ ```
44
+
45
+ 除这条 Page 级消息入口外,时间刷新、电量显示、订阅和清理逻辑均由组件管理。电量不可读时显示 `--%`。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rvis-aiui-kit",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "RVIS AIUI components and Glass3 extension SDK.",
5
5
  "type": "module",
6
6
  "main": "./sdk/index.js",
@@ -18,6 +18,7 @@
18
18
  "./markdown": "./components/markdown/index",
19
19
  "./model-list": "./components/model-list/index",
20
20
  "./paragraph": "./components/paragraph/index",
21
+ "./status-bar": "./components/status-bar/index",
21
22
  "./table": "./components/table/index"
22
23
  }
23
24
  },
package/sdk/README.md CHANGED
@@ -589,7 +589,7 @@ const preview = await glass3.camera.startPreview();
589
589
  left: 0,
590
590
  top: 40,
591
591
  width: 168,
592
- height: 103,
592
+ height: 104,
593
593
  cornerRadius: 2,
594
594
  outline: true
595
595
  }
@@ -611,7 +611,7 @@ const preview = await glass3.camera.startPreview({
611
611
  | 字段 | 类型 | 约束 |
612
612
  | --- | --- | --- |
613
613
  | `left` | `number` | 有限、非负。 |
614
- | `top` | `number` | 有限、非负。自定义普通预览建议 `top >= 150`。 |
614
+ | `top` | `number` | 有限、非负。标准 HUD 布局使用默认值 `40`。 |
615
615
  | `width` | `number` | 有限且大于 0。 |
616
616
  | `height` | `number` | 有限且大于 0。 |
617
617
  | `cornerRadius` | `number` | 有限、非负。 |
@@ -19,7 +19,7 @@ const DEFAULT_PREVIEW_ARGS = {
19
19
  left: 0,
20
20
  top: 40,
21
21
  width: 168,
22
- height: 103,
22
+ height: 104,
23
23
  cornerRadius: 2,
24
24
  outline: true
25
25
  };
@@ -33,7 +33,7 @@ const preview = await glass3.camera.startPreview();
33
33
  left: 0,
34
34
  top: 40,
35
35
  width: 168,
36
- height: 103,
36
+ height: 104,
37
37
  cornerRadius: 2,
38
38
  outline: true
39
39
  }