@harmonyos-arkts/d2h 0.1.34 → 0.1.35
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/.claude-plugin/plugin.json +1 -1
- package/agents/android-to-hmos-00-orchestrator.md +1 -1
- package/agents/d2h.md +5 -4
- package/package.json +1 -1
- package/schemas/code-stats.schema.json +2 -2
- package/skills/d2h-code-audit/SKILL.md +17 -6
- package/skills/d2h-code-audit/references/code-stats-schema.md +64 -2
- package/skills/d2h-code-audit/scripts/code_stats.py +1 -1
- package/skills/d2h-code-audit/scripts/increment_delta.py +299 -0
- package/skills/d2h-dashboard/app/assets/{Analysis-Dj-4QEJi.js → Analysis-S3iFh2nP.js} +1 -1
- package/skills/d2h-dashboard/app/assets/CodeAudit-BI5iNy2f.css +1 -0
- package/skills/d2h-dashboard/app/assets/CodeAudit-BeZMoO_s.js +1 -0
- package/skills/d2h-dashboard/app/assets/{FeaturesList-C5yGUbRo.js → FeaturesList-CdKAoNw5.js} +1 -1
- package/skills/d2h-dashboard/app/assets/{Overview-CNkA3J9F.js → Overview-C43KVHdP.js} +1 -1
- package/skills/d2h-dashboard/app/assets/Overview-CzysQJHh.css +1 -0
- package/skills/d2h-dashboard/app/assets/{Project-BC9Tz1WY.js → Project-D5loWYjZ.js} +1 -1
- package/skills/d2h-dashboard/app/assets/{SpecDetail-DguVmqAE.js → SpecDetail-XCDyawZ3.js} +1 -1
- package/skills/d2h-dashboard/app/assets/{SpecItemDetail-7s7SaF3O.js → SpecItemDetail-BDl_Qqfx.js} +2 -2
- package/skills/d2h-dashboard/app/assets/datetime-DBOJn2GA.js +1 -0
- package/skills/d2h-dashboard/app/assets/{index-B3nfIPBm.js → index-C1bO3C02.js} +2 -2
- package/skills/d2h-dashboard/app/assets/{navigation-d1Uf6TR4.js → navigation-BGPexEv8.js} +1 -1
- package/skills/d2h-dashboard/app/index.html +1 -1
- package/skills/d2h-spec-generate/SKILL.md +17 -11
- package/skills/language/h5/d2h-h5-analyse/SKILL.md +34 -0
- package/skills/language/h5/d2h-h5-analyse/references/scenarios.md +36 -0
- package/skills/language/h5/d2h-h5-coding/SKILL.md +33 -0
- package/skills/language/h5/d2h-h5-coding/references/bridge-contracts.md +44 -0
- package/skills/language/h5/d2h-h5-coding/references/examples.md +28 -0
- package/skills/language/h5/d2h-h5-coding/references/scenarios.md +40 -0
- package/skills/language/h5/d2h-h5-coding/references/webview-implementation.md +144 -0
- package/skills/preparing-migration-workspace/SKILL.md +0 -1
- package/skills/d2h-dashboard/app/assets/CodeAudit-Ctt3XEec.css +0 -1
- package/skills/d2h-dashboard/app/assets/CodeAudit-TcIcLwQL.js +0 -1
- package/skills/d2h-dashboard/app/assets/Overview-Cmz8yjX-.css +0 -1
- package/skills/d2h-dashboard/app/assets/datetime-CHrzCsjX.js +0 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: d2h-spec-generate
|
|
3
|
-
description: Generate page-scoped Android-to-HarmonyOS spec.md files
|
|
3
|
+
description: Generate page-scoped Android-to-HarmonyOS spec.md files using inventory.json, migration Facts, `.migration/utg/page.json`, source code, and existing HarmonyOS implementation. Use when pages, dialogs, sheets, or page modes need evidence-backed development specifications without copied UI artifacts. Milestones and waves are planned after generation.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Page Spec generation
|
|
7
7
|
|
|
8
|
-
Generate one implementation-ready `spec.md` for every Android page, dialog, sheet, and behaviorally distinct page mode. The AI determines page boundaries, evidence mapping, dependencies and initial order from page.json, Facts and source.
|
|
8
|
+
Generate one implementation-ready `spec.md` for every Android page, dialog, sheet, and behaviorally distinct page mode needed by features with `should_develop: true` in `.migration/feature-analysis/inventory.json`. If inventory.json is missing, generate all source-proven features; if a feature's should_develop field is missing, treat it as true. These default-included features follow all true-feature rules below. Features with `should_develop: false` are outside generation scope. The AI determines page boundaries, evidence mapping, dependencies and initial order from the selected inventory features, page.json, Facts and source. Milestones, waves and further development selection within that scope are handled after generation.
|
|
9
9
|
|
|
10
10
|
Do not invoke task-planning, graph-generation, migration, or page-validation scripts. Do not modify Android source, HarmonyOS source, `.migration/spec/`, `.migration/utg/`, `.migration/tasks/`, or the migration report.
|
|
11
11
|
|
|
@@ -14,12 +14,13 @@ Do not invoke task-planning, graph-generation, migration, or page-validation scr
|
|
|
14
14
|
Resolve these paths before writing:
|
|
15
15
|
|
|
16
16
|
- `migration_root`: workspace containing `.migration/`.
|
|
17
|
+
- `feature_inventory`: optional `<migration_root>/.migration/feature-analysis/inventory.json`.
|
|
17
18
|
- `spec_root`: `<migration_root>/.migration/spec`; require `index.json` and `facts/`.
|
|
18
19
|
- `page_plan`: require `<migration_root>/.migration/utg/page.json`; this is the source-derived page and navigation plan produced by the UTG stage.
|
|
19
20
|
- `android_root`: `.migration/config.json.androidProject`, unless explicitly supplied.
|
|
20
21
|
- `harmony_root`: `.migration/config.json.harmonyProject`, resolved relative to `migration_root` when not absolute, unless explicitly supplied.
|
|
21
|
-
- `legacy_tasks_root`: optional `<migration_root>/.migration/tasks`; use existing briefs, core facts, source context, and acceptance files only as read-only evidence from an older flow.
|
|
22
22
|
- `output_root`: default `<migration_root>/.migration/page-specs`.
|
|
23
|
+
|
|
23
24
|
Facts are the deterministic structured evidence baseline extracted from Android source. They support scope discovery, entity and interaction linkage, report initialization, and omission checks, but unresolved items and extraction gaps mean they are not substitutes for reading Android source and, where necessary, observing runtime behavior. Legacy Task artifacts are read-only indexes from the older flow. Existing HarmonyOS files and tests are implementation evidence, not proof that a behavior is complete.
|
|
24
25
|
|
|
25
26
|
## Output contract
|
|
@@ -44,21 +45,23 @@ Preserve existing page identities and package directories when evidence is uncha
|
|
|
44
45
|
### 1. Read the complete evidence index
|
|
45
46
|
|
|
46
47
|
1. Read `.migration/spec/index.json`, `facts/app.json`, all `facts/pages/*.json`, `facts/interactions.json`, and `facts/unresolved.json`.
|
|
47
|
-
2.
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
2. If `feature_inventory` exists, read it and map features marked `should_develop: true` or missing that field to their pages, behaviors and source evidence using stable IDs and source mappings.
|
|
49
|
+
Read false entries only as needed to identify scope boundaries; do not expand their behavior, implementation or acceptance requirements. An unreadable or malformed inventory, non-boolean flag, or ambiguous mapping is unresolved, not permission to broaden scope. If every feature is excluded, return an empty-scope result before writing any artifacts.
|
|
50
|
+
3. Read `.migration/utg/page.json` completely. Use `pages[]` as the page/navigation index and consume each node's `node_id`, `kind`, `label`, `declared_at`, `required_state`, `expected`, `reachable`, `depth`, `ui_sequence`, `path_text`, `steps`, and `skip_reason` when present.
|
|
51
|
+
4. Treat `page.json.source.utg` and `page.json.source.click_paths` as provenance links. Read those referenced UTG artifacts only when page boundaries, transitions, guards, or selectors need clarification.
|
|
50
52
|
5. Read the current migration report to understand existing mappings and unresolved items, without treating report status as proof of implementation.
|
|
51
53
|
6. Inspect HarmonyOS route registration, `.ets`/`.ts` components, shared state, resources, and tests to distinguish existing implementation from planned work.
|
|
52
54
|
|
|
53
55
|
### 2. Determine page units with AI reasoning
|
|
54
56
|
|
|
55
57
|
1. Start from `page.json.pages[]`, then join each page node to Facts surfaces, entries, controls, and interactions by stable ref, declared source, transition, and source behavior.
|
|
56
|
-
2.
|
|
58
|
+
2. Within the selected feature scope, treat independently reachable pages, dialogs, sheets, and distinct add/edit or selection modes as separate units when they have their own lifecycle or acceptance flow.
|
|
57
59
|
3. Prefer exact ref or normalized identity matches between `page.json.pages[].node_id` and Facts surfaces. Then use labels, `declared_at`, parent relations, navigation steps, source symbols, controls, and Android source behavior.
|
|
58
60
|
4. Never assign behavior from name similarity alone. Record ambiguous mappings in the owning Spec under “未决项与平台差异”.
|
|
59
|
-
5. `capture=false`, an empty `expected`, or a `skip_reason` does not remove a source-proven page. Use those fields as evidence limitations and verify the page through Facts and Android source.
|
|
61
|
+
5. `capture=false`, an empty `expected`, or a `skip_reason` does not remove a source-proven page within the selected feature scope. Use those fields as evidence limitations and verify the page through Facts and Android source.
|
|
60
62
|
6. Do not create a fake page for background-only capabilities. Assign startup, notification, widget, receiver, persistence, or other shared responsibilities to the earliest real page that needs them and list downstream consumers.
|
|
61
63
|
7. Split aggregate packages by actual page lifecycle and behavior ownership, keeping one complete Spec per page unit.
|
|
64
|
+
8. For pages shared by true and false features, generate only the true features and the minimum shared entry/state needed by them. Pages belonging only to false features produce no Spec or new ledger task. If a true feature depends on an explicitly excluded feature, return the dependency conflict for clarification rather than enabling the excluded feature.
|
|
62
65
|
|
|
63
66
|
### 3. Determine initial page order
|
|
64
67
|
|
|
@@ -77,7 +80,7 @@ Before writing Specs, create pages.json with `schema_version: d2h-page-plan/v1`.
|
|
|
77
80
|
|
|
78
81
|
### 5. Write only `spec.md`
|
|
79
82
|
|
|
80
|
-
Use these headings in every page Spec, preserving complete behavior, exception paths and acceptance assertions. F-xxx labels identify page-local behaviors:
|
|
83
|
+
Use these headings in every page Spec, preserving complete behavior, exception paths and acceptance assertions for the selected features. When inventory exists, cite its feature IDs or JSON Pointers in scope and evidence; excluded features have no F-xxx behavior or acceptance requirements. F-xxx labels identify page-local behaviors:
|
|
81
84
|
|
|
82
85
|
```markdown
|
|
83
86
|
# <页面名称> 迁移 Spec
|
|
@@ -114,6 +117,7 @@ Use these headings in every page Spec, preserving complete behavior, exception p
|
|
|
114
117
|
|
|
115
118
|
| 证据 | 路径 / Ref | 支持的结论 |
|
|
116
119
|
|---|---|---|
|
|
120
|
+
| 功能清单 | `.migration/feature-analysis/inventory.json` 中的 <feature_id 或 JSON Pointer>,`should_develop: true` 或字段缺失默认纳入 | <本 Spec 纳入的功能范围> |
|
|
117
121
|
| Facts | <surface/entry/control/interaction ref> | <范围或行为> |
|
|
118
122
|
| Android 源码 | <android_root 相对路径及符号/行> | <触发、分支和结果> |
|
|
119
123
|
| UTG Page | `.migration/utg/page.json` 中的 <node_id> | <到达路径、深度、前置状态、导航步骤与证据限制> |
|
|
@@ -133,7 +137,7 @@ When a page has no independent interaction, write one display/reachability featu
|
|
|
133
137
|
|
|
134
138
|
### 6. Initialize the execution ledger
|
|
135
139
|
|
|
136
|
-
After all page Specs exist, create the initial batch_report.json with the bundled renderer:
|
|
140
|
+
After all selected page Specs exist, create the initial batch_report.json with the bundled renderer. If no features are selected, return an empty-scope result without creating placeholder Specs, a new page plan, or a ledger:
|
|
137
141
|
|
|
138
142
|
```bash
|
|
139
143
|
python scripts/build_batch_report.py \
|
|
@@ -145,7 +149,8 @@ The renderer requires pages.json v1 and one spec.md per package. Tasks start pen
|
|
|
145
149
|
|
|
146
150
|
## Quality gates
|
|
147
151
|
|
|
148
|
-
- Every source-proven page, dialog, sheet, and behaviorally distinct mode has exactly one `spec.md`, or its ownership is explicitly assigned to another Spec.
|
|
152
|
+
- Every source-proven page, dialog, sheet, and behaviorally distinct mode needed by true features has exactly one `spec.md`, or its ownership is explicitly assigned to another Spec. False features do not create behavior requirements or new tasks; excluded-only nodes have an explicit scope-exclusion reason.
|
|
153
|
+
- Every true feature maps to a Spec or an explicit unresolved item. Flag changes on rerun require scope reconciliation; preserve existing Specs, task identities and execution history instead of deleting them automatically.
|
|
149
154
|
- Every distinct interaction has a unique `F-xxx`, and feature IDs match UI operation/acceptance sections one-to-one.
|
|
150
155
|
- Each feature states a user action and observable result, not an implementation instruction.
|
|
151
156
|
- Navigation, state changes, persistence, destructive confirmation, external intents, cancellation, dismissal, and error behavior remain explicit.
|
|
@@ -164,6 +169,7 @@ Return:
|
|
|
164
169
|
- the ordered page directory list and ordering rationale;
|
|
165
170
|
- the number of generated, updated, and unchanged Specs;
|
|
166
171
|
- the absolute `pages.json` path;
|
|
172
|
+
- the absolute inventory.json path when present, included and excluded feature IDs or JSON Pointers and unresolved scope/dependency mappings; when absent, report that full generation used the default scope without inventing inventory IDs;
|
|
167
173
|
- unreachable pages, capture-disabled nodes, and pages with incomplete arrival rules in `page.json`;
|
|
168
174
|
- ambiguous mappings and unmatched Facts;
|
|
169
175
|
- unresolved selector steps;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: d2h-h5-analyse
|
|
3
|
+
description: 从 Android 工程识别 WebView 容器、H5 内容来源及双向原生桥接,梳理可达功能和调用证据,并按需对照 HarmonyOS 工程。适用于 H5 迁移盘点、桥接契约提取和双端差异定位。
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# 识别 WebView 和 H5 功能
|
|
7
|
+
|
|
8
|
+
以用户入口为单位追踪「原生入口 → 容器 → 内容来源 → 网页动作 → 原生处理 → 结果回流」。容器可复用,入口可能携带不同配置,同名桥在不同容器中也可能暴露不同的方法。按入口和实际载体建立对应关系。
|
|
9
|
+
|
|
10
|
+
## 找到容器和内容
|
|
11
|
+
|
|
12
|
+
1. 从 Android XML 的 WebView 标签、继承 WebView 的组件、代码创建、第三方封装及 `loadUrl`、`loadData`、`loadDataWithBaseURL` 反查。检查 Activity、Fragment、弹窗、列表项和富文本编辑器,顺着路由注册、调用方、布局绑定及服务端菜单配置验证可达性。
|
|
13
|
+
2. 分辨远程 URL、本地 HTML/JS/CSS、动态 HTML 字符串和远程包装页。记录 URL 构造、嵌套 URL 编码、base URL、初始参数来源和重定向;区分普通外链、H5 业务页、富文本展示、本地交互编辑器。搜索 assets、构建复制产物和 `<script src>`;远程或动态下发的页面标明内容是否可得。
|
|
14
|
+
3. 查看 WebViewClient、WebChromeClient、历史栈、加载错误、Cookie/DOM Storage、权限、文件选择和下载。URL 拦截可能是路由桥;网页文件输入走浏览器事件时,即使没有 JS 接口也依赖宿主。
|
|
15
|
+
4. 有鸿蒙工程时,从业务入口反查 `Web`、`WebviewController`、`loadData`、`javaScriptProxy`、`registerJavaScriptProxy` 和 `runJavaScript`。对照同一入口的来源、外壳、桥注册清单及处理器,沿分发追到真正实现,记录差异和空实现。
|
|
16
|
+
|
|
17
|
+
## 还原双向契约
|
|
18
|
+
|
|
19
|
+
- **H5 → 原生**。配对 `addJavascriptInterface` 的对象名和 `@JavascriptInterface` 方法;也查 URL scheme、`postMessage` 及项目自己的分发器。网页侧查 `window` 属性、平台检测、桥包装器、点击事件、回调注册和 `location` 写入。沿桥处理器追到导航、关闭回传、登录、分享、选图、定位、标题栏等实际效果,区分原生事件、系统权限和网页内完成的逻辑。
|
|
20
|
+
- **原生 → H5**。查 `evaluateJavascript`、`loadUrl("javascript:…")`、页面生命周期和异步结果监听。分开记录初始化脚本、原生主动通知与请求响应。核对回调参数是对象、JSON 字符串还是位置参数,核对注册时机、页面就绪信号及取消、错误和多次调用行为。
|
|
21
|
+
- **本地编辑器**。结合 `contenteditable`、DOM 监听、格式化命令、选区和内容变更回传,分别记录网页负责的编辑行为和原生负责的工具栏、草稿或提交。对只渲染的富文本,优先确认空态、图片、超链接、相对资源和内容来源。
|
|
22
|
+
- **远程 H5**。分别标记「网页调用已证实」「仅原生暴露」「待验证」。接口存在只证明容器具备暴露能力。以可访问的前端调用点或已获授权的运行证据确认网页用法;缺失时保留未知参数、触发条件或可达性。
|
|
23
|
+
|
|
24
|
+
## 交付迁移输入
|
|
25
|
+
|
|
26
|
+
每个入口记录容器形态、内容来源、初始化、回退和错误行为。每条桥契约记录方向、触发条件、对象与方法或 scheme、参数类型、同步返回或异步回调、完成/取消/失败、权限依赖、原生效果、双端差异、证据和置信度。引用实际分析任务的文件和行号或运行记录,注明缺失证据。
|
|
27
|
+
|
|
28
|
+
虚构例子:帮助中心的附件按钮使用网页文件输入,宿主通过文件选择回调返回文件,取消时结束该次请求。网页按钮与宿主回调可分别举证。若仓库还暴露了分享接口,但远程页面不可读,则分享记为「仅原生暴露」。迁移优先还原文件选择链路,分享等待调用证据。
|
|
29
|
+
|
|
30
|
+
技能示例统一使用虚构名称与数据,抽象描述实现。项目地址、业务标识、凭据和源码保留在各自授权范围内。
|
|
31
|
+
|
|
32
|
+
完整盘点时使用 [场景盘点清单](references/scenarios.md),按入口形态和能力分别记录覆盖结论。定向排查时只选与故障相关的行。
|
|
33
|
+
|
|
34
|
+
梳理到具体桥方法后,可用 [JSBridge 契约与验收用例](../d2h-h5-coding/references/bridge-contracts.md) 补查常见分支。把实际调用中未知的字段、取消行为和失败表现单独记为待验证。
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# H5 场景盘点清单
|
|
2
|
+
|
|
3
|
+
逐行在目标工程标记「双端已证实 / 仅 Android 已证实 / 仅鸿蒙已证实 / 待验证 / 不适用」,附入口或配置证据。载体和能力分别标记,同一个入口可以命中多行。表中有通用补查项,实际命中以仓库和运行证据为准。
|
|
4
|
+
|
|
5
|
+
## 用户入口与载体
|
|
6
|
+
|
|
7
|
+
| 场景 | 从哪里查起 | 容易漏掉的差异 |
|
|
8
|
+
|---|---|---|
|
|
9
|
+
| 通用全屏页、服务菜单、个人中心活动 | 查页面路由、菜单响应、链接构造器 | 标题、登录门槛、URL 来源和默认参数 |
|
|
10
|
+
| 首页或底部 Tab 内嵌网页 | 查 Tab 切换、缓存、组件显隐和刷新 | 再次进入是否重载、滚动位置与会话是否保留 |
|
|
11
|
+
| 弹窗、底部半屏、透明承载页 | 查 Dialog/Sheet、弹层宿主及关闭监听 | 遮罩、拖动关闭、键盘避让、关闭结果 |
|
|
12
|
+
| 业务工作台和二级 Web 页 | 查子页创建、根页收起、替换与出栈 | 每页独立控制器、谁接收子页结果 |
|
|
13
|
+
| 社区图文、圈子公告、商品或车型介绍 | 查详情字段、包装页参数、原始 HTML 和自适应高度 | 空态、图片预览、内外层滚动、相对资源 |
|
|
14
|
+
| 商城订单、预约订金和支付回跳 | 查业务按钮、原生支付入口、外部回跳与订单刷新 | 原生跳转间接打开网页,回跳后查询真实状态 |
|
|
15
|
+
| 车辆、服务、维保及附近入口 | 查业务模块传入的链接、地图和定位上下文 | 登录或绑定状态、位置缺失、服务端动态入口 |
|
|
16
|
+
| 用户协议、隐私声明、帮助文档 | 查 assets、本地化变体、公共 Web 容器 | 首次启动可读性、离线、版本与语言 |
|
|
17
|
+
| 本地富文本编辑器 | 查 HTML、编辑脚本、WebView 子类和原生工具栏 | 网页格式化、原生保存、草稿与内容变更回传 |
|
|
18
|
+
| 推送、扫码、分享链接和外部 scheme | 查应用启动入口、路由分发、URL 拦截及第三方回调 | 冷启动、登录后继续、参数编码和重复跳转 |
|
|
19
|
+
|
|
20
|
+
## 宿主能力与证据
|
|
21
|
+
|
|
22
|
+
| 能力组 | 搜索线索 | 每条契约补查 |
|
|
23
|
+
|---|---|---|
|
|
24
|
+
| 上下文与登录 | URL 查询参数、Cookie、DOM Storage、平台变量、登录桥 | 注入时机、刷新和退出清理、不同账号隔离 |
|
|
25
|
+
| 页面导航与事件 | URL 拦截、桥路由、带结果跳转、事件总线 | push/replace/close、结果接收方、事件订阅者 |
|
|
26
|
+
| 原生外壳 | 标题和按钮、状态栏、安全区、Toast、返回回调 | 页面提供的参数、恢复默认值时机 |
|
|
27
|
+
| 文件选择与拍摄 | 文件输入、系统选择事件、显式桥、媒体权限 | MIME、选图/拍照、单多选、上传或回传格式、取消 |
|
|
28
|
+
| 图片与文件输出 | 图片预览、保存相册、下载回调或外部打开 | 网络 URL、网页生成数据、权限、进度和失败反馈 |
|
|
29
|
+
| 地图、定位与设备 | 网页地理位置授权、定位桥、地图跳转、Wi-Fi 信息 | 请求来源、系统权限、坐标格式、拒绝与超时 |
|
|
30
|
+
| 分享、拨号与第三方应用 | 分享处理器、链接拦截、系统能力 | 目标应用缺失、取消、前后台回流 |
|
|
31
|
+
| 相机/麦克风与页面保护 | 网页权限事件、应用权限、截屏策略 | 资源类型、受信页面、离开恢复 |
|
|
32
|
+
| 网络和导航 | 主框架错误、HTTP 错误、重定向、iframe、外链、新窗口 | 是否显示全页错误、是否传递身份、是否打开新宿主 |
|
|
33
|
+
| 生命周期与交互 | 进度、标题、前后台、历史栈、键盘和滚动监听 | 重入、重新加载、迟到回调、内部和外部滚动归属 |
|
|
34
|
+
| 网页消息机制 | JS 对象、scheme、postMessage、脚本执行、DOM 事件 | 精确区分同步返回、异步响应、初始化和主动事件 |
|
|
35
|
+
|
|
36
|
+
对资源下载、新窗口、iframe、第三方 SDK 等没有代码证据的通用场景,保留检查结论。对于已确认的能力,分别检查网页调用、代理注册、处理器、原生依赖和结果消费;记录链路停在哪一步。
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: d2h-h5-coding
|
|
3
|
+
description: 将 Android H5 和 WebView 功能迁移到 HarmonyOS ArkWeb,或为现有鸿蒙 H5 容器增量开发。用于远程网页、富文本、本地交互页面、双向桥接、系统能力和端到端验收。
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# 迁移或扩展 H5 容器
|
|
7
|
+
|
|
8
|
+
先核对入口与桥契约。输入不完整时,用 [d2h-h5-analyse](../d2h-h5-analyse/SKILL.md) 的方法补齐当前需求所涉及的调用链。查目标工程的既有实现、SDK 版本和类型定义后选用 API。将远程网页视为独立发布的调用方,确认是否可以同步修改网页。
|
|
9
|
+
|
|
10
|
+
## 选择宿主
|
|
11
|
+
|
|
12
|
+
| 场景 | 实施方式 |
|
|
13
|
+
|---|---|
|
|
14
|
+
| 远程业务页 | 复用现有通用容器,保留页面预期的 URL、会话初始化、标题、桥与回退契约。 |
|
|
15
|
+
| 底部弹层或带子页的工作台 | 复用能力处理器,独立接入弹层关闭、子页出栈和结果回传。按宿主注册所需方法。 |
|
|
16
|
+
| URL、HTML 或富文本展示 | 分流远程 URL、包装页、本地内容与空态。使用项目已有的渲染通道,按来源决定脚本、存储和访问权限。 |
|
|
17
|
+
| 本地交互页面 | 按工程约定放置资源,保持 HTML 与 CSS、脚本、图片的相对关系,迁移脚本调用和原生工具栏交互。 |
|
|
18
|
+
|
|
19
|
+
## 实现步骤
|
|
20
|
+
|
|
21
|
+
1. **接入入口和生命周期**。复用 `Web` 和控制器模式,控制器就绪后执行需要实例的加载操作。区分控制器已附着、文档已加载、网页回调已可用。若页面首屏就读宿主信息,按现有契约在加载前或文档早期提供;页面结束时注入适用于消费更晚的值。新文档重建必要上下文,同一文档避免重复注册。进度仅用于界面反馈,主框架错误与子资源错误分别处理。
|
|
22
|
+
2. **对齐桥契约**。用项目支持的 ArkWeb JS 代理注册方式暴露明确的方法清单。旧网页固定依赖的对象名、大小写、参数顺序、类型、回调格式和同步语义须保留,或由双方发布的兼容层适配。解析输入后调用已有路由、登录、权限或媒体服务。增量能力先确定涉及的宿主,并检查每个宿主的注册、处理和响应三处是否都接通。
|
|
23
|
+
3. **处理返回和异步结果**。按实际产品契约决定标题返回、系统返回、网页返回、关闭和结果回传的优先级。常见默认顺序是网页已注册的返回处理、Web 历史、宿主退出。异步请求完成一次,包含取消和失败;用当前 Web 实例及文档代次关联结果,退出或换页时清理待处理状态。检查切后台、双击和重试时的状态。
|
|
24
|
+
4. **约束网页权限和注入**。按协议、主机及需要的端口/路径校验入口和导航,覆盖重定向与跨来源 iframe。核对目标 API 的代理作用范围;无法可靠限制时,将带敏感能力的可信页面与普通外链隔离。按能力校验业务参数和系统权限,保护登录态。回调采用固定分发函数和序列化参数;兼容旧式回调名时校验允许调用的名称。Cookie、URL、网页存储按原契约评估作用域、时序和清理;日志使用脱敏信息。
|
|
25
|
+
5. **从正常入口验收**。在目标 SDK 构建,并在 Web 容器中验证网页实际收发。覆盖有效入口、初次加载和重载、主页面错误重试、标题与系统返回、外链、每个改动能力的成功/失败/取消。涉及异步时加测请求中离开、重入和回调只完成一次。记录入口、设备和观察结果;缺少远程网页或设备时注明对应的验收缺口。
|
|
26
|
+
|
|
27
|
+
处理旧网页回调、文件选择或富文本时,查看 [迁移示例](references/examples.md)。示例采用虚构契约和伪代码,落地时替换为目标工程的类型与接口。
|
|
28
|
+
|
|
29
|
+
做全量迁移或跨宿主增量时,按 [场景实施与验收](references/scenarios.md) 选择相关分支,并用入口与能力矩阵检查遗漏。
|
|
30
|
+
|
|
31
|
+
开发或修复桥接时,使用 [JSBridge 契约与验收用例](references/bridge-contracts.md) 核对参数、响应格式和终态,并覆盖并发、取消及换页后的回调归属。
|
|
32
|
+
|
|
33
|
+
需要编写或改造 Web 组件时,参考 [ArkWeb 实现用例](references/webview-implementation.md),两个用例均使用 `@ComponentV2`,包含远程只读页的加载、重试和返回,以及本地 HTML 与同步 JSBridge 的完整交互片段。
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# JSBridge 契约与验收用例
|
|
2
|
+
|
|
3
|
+
以下对象名、方法名、错误码、参数和结果均为虚构示例。迁移既有网页时,先按调用点确认实际对象名、参数顺序与默认值、参数编码、同步返回、回调注册时机和错误语义,再实现兼容。新增契约可采用下面的请求号和固定分发入口。
|
|
4
|
+
|
|
5
|
+
## 双端识别与实现
|
|
6
|
+
|
|
7
|
+
Android 侧从 `addJavascriptInterface` 和 `@JavascriptInterface` 配对找到对象与方法。继续查原生处理器、结果监听,以及 `evaluateJavascript` 或 `javascript:` URL 回调;若走 URL scheme、文件选择或权限事件,记录该通道自身的结果机制。HarmonyOS 侧在对应容器通过 ArkWeb 代理注册实际使用的方法,复用路由、会话、媒体等能力服务。用控制器向当前文档回传,Web 自带事件则通过该事件的结果接口完成。
|
|
8
|
+
|
|
9
|
+
| 能力 | Android 识别线索 | HarmonyOS 实现与输入 | 回调、取消与失败 | 验收用例 |
|
|
10
|
+
|---|---|---|---|---|
|
|
11
|
+
| 读取平台与安全区 | 桥同步返回、注入全局变量或执行网页回调 | 读宿主上下文,按契约返回平台、版本或四边距,明确单位和字段类型 | 同步读取沿用同步返回;数据未就绪按契约给默认值或错误;异步读取才关联请求号 | 首屏首次读取、旋转、显示区域变化、旧网页类型检查 |
|
|
12
|
+
| 登录和会话 | 登录桥、账号/会话读取桥、登录结果或页面恢复回调 | 复用登录服务,校验来源,传入请求号及允许的业务上下文 | 成功按契约回传登录结果或刷新;用户退出登录流程为取消;会话过期与服务故障分别反馈 | 登录成功、用户返回、会话过期、退出后重进、外域调用 |
|
|
13
|
+
| 路由与关闭回传 | scheme 分发、带结果跳转、页面 finish | 校验路由与参数,使用宿主导航;关闭结果由原生父页或发起文档按契约接收 | 路由失败返回错误;用户从子页退出时按契约取消;发起页已销毁时丢弃迟到结果 | 正常结果、子页取消、非法路由、发起页重载、弹层关闭 |
|
|
14
|
+
| 标题与返回按钮 | 标题属性桥、按钮监听及网页函数名 | 校验标题、按钮 ID、回调标识;按钮点击发送网页事件,外壳销毁时清理监听 | 设置失败按契约报告;用户点击是独立事件;网页未注册回退处理时走宿主规则 | 标题设置、按钮点击、系统返回、页面切换后不触发旧监听 |
|
|
15
|
+
| 文件选择与拍照 | 文件选择回调或拍照/选图桥,Activity 结果监听 | 传入 MIME、单多选、来源;网页文件输入走 ArkWeb 选择事件,显式桥走业务回调 | 用户关闭选择器为取消;拒权、文件不可读和过大各按约定反馈;成功返回该通道约定的 URI、文件描述或上传结果 | 多选、拒权、取消后重试、超限、网页换页、文件实际提交 |
|
|
16
|
+
| 图片预览与保存 | 预览、相册写入桥和写入结果监听 | 校验图片列表、起始索引或保存来源;复用预览和媒体服务 | 仅打开预览可按旧契约无响应;保存区分成功、取消、拒权、写入失败 | 越界索引、拒权、断网、写入失败、成功后可读取 |
|
|
17
|
+
| 定位与地图 | 网页定位授权回调、定位桥或地图 scheme | 校验来源与权限,明确精度、超时、坐标系和经纬度类型 | 用户主动关闭为取消;拒权、定位服务关闭和超时分别反馈;网页地理位置使用 Web 事件通道 | 成功坐标、超时、拒权、关闭定位、页面退出后收到系统结果 |
|
|
18
|
+
| 分享、拨号与外部应用 | 分享 SDK 完成监听、拨号 Intent、外部 scheme | 传入允许的渠道、内容或号码,复用系统入口 | 平台只确认发起时回传已发起;可观测时才回传完成或取消;目标缺失返回失败 | 成功发起、分享取消、未安装目标、无效号码、回到原页 |
|
|
19
|
+
| 业务支付 | 支付 SDK、外部回跳和订单刷新 | 校验订单标识,复用支付服务并按回跳查询订单 | 用户中止为取消;支付结果未知时进入待确认或重查;已确认失败与成功分别处理 | 取消、重复回跳、查询超时、成功查询、回跳时发起页已离开 |
|
|
20
|
+
| 全局通知与原生主动事件 | 事件总线、前后台监听与脚本注入 | 校验允许的事件名和载荷;绑定订阅生命周期,按需向当前文档投递 | 主动事件遵守独立订阅协议;只有契约要求时才做确认回执;退出时解绑 | 订阅前触发、重复注册、重载、退出后收到事件 |
|
|
21
|
+
|
|
22
|
+
## 异步协议示例
|
|
23
|
+
|
|
24
|
+
```text
|
|
25
|
+
网页:先注册 onHostResult,再发送 requestId、operation、payload
|
|
26
|
+
宿主:校验来源、操作和参数,记录 Web 实例、文档代次和请求号
|
|
27
|
+
宿主:调用已有原生能力,按结果完成对应请求
|
|
28
|
+
宿主:以固定函数名回传序列化载荷,只投递给仍有效的发起文档
|
|
29
|
+
网页:按 requestId 结算一次,清理等待状态并处理对应分支
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
```jsonl
|
|
33
|
+
{"requestId":"demo-7","operation":"pickAttachment","payload":{"mime":["image/png"],"multiple":false}}
|
|
34
|
+
{"requestId":"demo-7","status":"ok","data":{"name":"sample.png"}}
|
|
35
|
+
{"requestId":"demo-7","status":"cancelled","reason":"userDismissed"}
|
|
36
|
+
{"requestId":"demo-7","status":"error","error":{"code":"permissionDenied","retryable":false}}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
后三行是同一请求可能产生的三种互斥响应。旧网页如果要求位置参数或 JSON 字符串,由边界适配层保持其格式。旧式动态回调名须匹配允许列表,再通过安全序列化传入参数。
|
|
40
|
+
|
|
41
|
+
- **参数验证**。检查缺字段、空字符串、错误类型、非法枚举、越界和特殊字符。来源拒绝时遵循权限边界。受信页面参数非法时按其约定反馈,可识别请求号时带回请求号。
|
|
42
|
+
- **重复请求与并发**。对同一文档的重复请求号采用明确策略,避免重复发起原生操作或提前完成原请求。对于只支持一个系统弹窗的能力,定义排队或返回忙碌。两个独立请求的结果不得串线。
|
|
43
|
+
- **终态与超时**。成功、主动取消、权限拒绝、系统失败与超时各走明确分支。网页超时和原生结果竞态时只结算一次。离开或重载清理待处理状态,能够取消底层操作时按项目能力取消。
|
|
44
|
+
- **交付验收**。从实际网页调用入口触发,记录网页收到的参数和结果状态、原生副作用与响应次数。加测加载前调用、格式错误、取消后重试、异步期间换页、原生迟到结果,以及旧版网页与新宿主往返。
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# 迁移示例
|
|
2
|
+
|
|
3
|
+
以下名称、地址和载荷均为虚构。流程块描述行为,便于映射到项目现有接口。
|
|
4
|
+
|
|
5
|
+
## 远程预约页与弹层共用能力
|
|
6
|
+
|
|
7
|
+
预约页调用 `window.SampleHost.openReservation("R-42", "req-7")`。方法返回后网页等待固定结果入口。全屏页面和活动弹层均接入同一个预约处理器,各自维护 Web 实例、文档代次和退出逻辑。
|
|
8
|
+
|
|
9
|
+
```text
|
|
10
|
+
网页注册结果监听并生成请求号 → 调用 SampleHost.openReservation
|
|
11
|
+
宿主校验来源、预约号和请求号 → 打开原生预约详情
|
|
12
|
+
详情返回 → 在同一文档仍有效时向 onReservationResult 发送结果
|
|
13
|
+
网页按请求号完成一次,成功时刷新,取消时保留原状态
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
结果可以是 `{"requestId":"req-7","status":"ok"}`。宿主通过固定函数名和 JSON 序列化传递参数,按实际网页契约区分对象与字符串。若旧网页只认识原平台的对象名,按目标工程的兼容策略为同一契约提供别名,测试旧网页能否完成往返。弹层根页关闭和内部子页返回分别测试。
|
|
17
|
+
|
|
18
|
+
## 增量支持上传附件
|
|
19
|
+
|
|
20
|
+
先确定网页使用 `<input type="file">` 还是显式桥请求。前者通过 ArkWeb 文件选择事件接入系统选择器,并将选择结果交回该次 Web 请求;后者通过对应桥处理器按约定回传数据。可以复用选择服务,结果通道保持各自独立。
|
|
21
|
+
|
|
22
|
+
核对 MIME 类型、多选、取消、临时 URI 可读性及文件大小。两个入口连续触发时按请求关联结果,避免上一请求覆盖下一请求。测试网页最终显示文件名并能提交,取消后还能发起下一次选择。
|
|
23
|
+
|
|
24
|
+
## 公告展示和本地编辑
|
|
25
|
+
|
|
26
|
+
公告入口收到空值时呈现原生空态;可信链接按产品约定直接加载或传入既有包装页;原始 HTML 在控制器附着后交给 `loadData`,由内容来源决定是否清洗及允许脚本。假设包装页地址为 `https://reader.example.invalid/view`,将嵌套链接作为独立查询参数编码,测试原链接包含查询参数和片段时仍可正确解析。若 HTML 带相对图片,按资源实际位置提供 base URL 并验证加载。
|
|
27
|
+
|
|
28
|
+
编辑器用本地资源承载可编辑区域。原生工具栏发送格式命令,网页在就绪后接受命令并报告内容变化。迁移时保持输入法组合、选区、撤销与保存一致,验证脚本未就绪时的行为及退出重进后的草稿恢复。
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# 场景实施与验收
|
|
2
|
+
|
|
3
|
+
为每个入口和能力标记「复用 / 扩展 / 新增 / 待确认 / 不适用」。同一能力有多个宿主时,在每个使用它的入口验证。网页加载成功只覆盖渲染步骤。
|
|
4
|
+
|
|
5
|
+
## 容器、页面和业务流
|
|
6
|
+
|
|
7
|
+
| 场景 | Android 识别特征 | HarmonyOS 实现 | 验收用例 |
|
|
8
|
+
|---|---|---|---|
|
|
9
|
+
| 通用全屏远程页 | 路由或菜单传入 URL,Activity 内调用 loadUrl | 复用入口、导航栏和错误视图,按契约初始化身份与平台信息 | 首屏、刷新、主框架错误、标题变化、系统返回 |
|
|
10
|
+
| Tab 内嵌页 | Fragment 或 Tab 布局持有 WebView,监听显隐与刷新 | 明确切换时保活或重建,协调父层手势与 Web 滚动 | 反复切换、刷新、滚动位置、退到后台再恢复 |
|
|
11
|
+
| 弹窗和底部半屏 | Dialog/BottomSheet 布局持有 WebView,监听 dismiss | 由弹层宿主处理遮罩、关闭、键盘和高度,能力处理器可复用 | 网页主动关闭、遮罩关闭、系统返回、回传和键盘收起 |
|
|
12
|
+
| 工作台与多级 Web 页 | 路由启动多个 Web Activity,或工作台内显式管理子页 | 为每页维护控制器及请求归属,分开根页退出和子页出栈 | 多层返回、替换当前页、子页取消及回传一次 |
|
|
13
|
+
| 详情富文本、公告、车型介绍 | 详情字段含 HTML 或 URL,使用 loadDataWithBaseURL 或包装页 | 分流空值、URL、包装页和 HTML,明确相对资源与滚动策略 | 空态、富文本内图片与链接、长内容、混合编码 |
|
|
14
|
+
| 预约、订单与支付 | 订单或预约按钮启动支付 SDK/外部应用,结果监听触发查询 | 沿用业务服务及原生支付入口,回到页面后按订单号刷新真实状态 | 成功、取消、失败、重复回跳、切后台和冷启动 |
|
|
15
|
+
| 车辆、维保、附近和地图页 | 业务页面拼装带上下文的 URL,监听权限或定位结果 | 在宿主检查登录、车辆绑定、定位等前置条件,缺失时按契约降级 | 未登录、无绑定、拒绝定位、坐标回传及地图返回 |
|
|
16
|
+
| 协议、隐私与帮助页 | assets 内多语言 HTML,或固定文档 URL | 按项目的语言和版本规则选择资源,离线场景走本地资源 | 首次启动、断网、语言切换、页面内链接 |
|
|
17
|
+
| 本地编辑器 | 本地 HTML、contenteditable 与 evaluateJavascript 配对 | 保持资源相对路径与网页就绪协议,复用原生工具栏和保存服务 | 输入法、格式操作、图片、草稿恢复、退出重进 |
|
|
18
|
+
| 推送、扫码和外部链接 | Intent data、推送回调或扫码结果进入路由分发 | 统一经过现有路由及 URL 校验,明确冷启动和登录后续跳 | 冷/热启动、重复触发、非法参数、登录取消 |
|
|
19
|
+
|
|
20
|
+
## 原生能力接入
|
|
21
|
+
|
|
22
|
+
| 能力 | Android 识别特征 | HarmonyOS 实现 | 验收用例 |
|
|
23
|
+
|---|---|---|---|
|
|
24
|
+
| 登录与身份 | CookieManager、URL 拼参、平台变量注入或登录桥 | 按来源和账号隔离会话,明确 URL、Cookie、存储或桥的供给时机 | 首次登录、重新加载、过期、退出、切换账号 |
|
|
25
|
+
| 返回、标题和安全区 | onKeyDown、canGoBack、标题按钮和安全区桥 | 将按钮、系统返回、Web 历史及关闭结果接入同一宿主规则;页面销毁时恢复外壳状态 | 网页拦截、网页有/无历史、标题按钮回调、页面切换 |
|
|
26
|
+
| 跳转结果和全局事件 | startActivityForResult 或结果监听、事件总线分发 | 区分发给发起页的响应与发给应用订阅者的事件 | 原页面刷新或退出、子页取消、重复事件 |
|
|
27
|
+
| 选择附件、拍照、上传 | onShowFileChooser 或 JS 桥触发拍照/相册,监听选择结果 | 区分网页文件输入和显式桥;复用选择或拍摄服务,按原通道完成请求 | MIME、单多选、拒权、取消、URI 可读、过大文件、并发 |
|
|
28
|
+
| 图片预览、保存与下载 | 图片预览或保存桥、下载监听器及原生下载服务 | 校验来源和类型,按载荷选择应用内预览、保存或下载服务 | 权限拒绝、断网、中断、异常文件名、已保存后的用户反馈 |
|
|
29
|
+
| 定位与设备能力 | 地理位置提示回调、定位桥、地图 Intent 或设备信息读取 | 分开网页来源授权、应用权限及设备服务状态;以契约规定精度和格式回传 | 拒绝、服务关闭、超时、坐标格式、退出后的迟到结果 |
|
|
30
|
+
| 分享、拨号和外部应用 | 分享 SDK 回调、拨号 Intent 或 scheme 拦截 | 白名单路由或受限 scheme,复用项目能力,处理外部应用不可用 | 成功、取消、目标缺失、回到原容器 |
|
|
31
|
+
| 网页摄像头与麦克风 | WebChromeClient.onPermissionRequest 与系统权限结果 | 按来源、请求资源和系统授权做决策,在关闭时结束待处理请求 | 摄像头/麦克风分别授权、拒绝、离开和再次进入 |
|
|
32
|
+
| 截屏与系统栏 | 窗口截图标志、系统栏颜色或可见性处理 | 由宿主按现有策略应用和恢复页面级设置 | 进入、返回、弹层覆盖、切换到其他页面 |
|
|
33
|
+
| 外链、重定向、iframe 与新窗口 | shouldOverrideUrlLoading、窗口创建回调和 iframe 来源 | 逐跳按来源分类,明确当前页、新容器或系统处理,复查桥与会话暴露范围 | 可信跳转、外域跳转、子框架请求、回退 |
|
|
34
|
+
| 网络异常 | onReceivedError/onReceivedHttpError 与主框架判断 | 按主文档和子资源处理错误,重试时重建加载状态并关联新文档 | 离线、HTTP 错误、子资源失败、重试成功、连续重载 |
|
|
35
|
+
|
|
36
|
+
## 三个增量改动示例
|
|
37
|
+
|
|
38
|
+
- **给帮助页新增「拨打服务电话」**。网页提交约定格式的号码,宿主校验格式与调用来源,调用现有拨号入口。检查普通外链无法调用该能力,验证取消拨号后仍留在帮助页。
|
|
39
|
+
- **订单页收到支付回跳**。宿主以当前预约号关联请求,回跳后查询业务状态,再通知仍有效的页面。用「支付取消」「重复回跳」「页面已关闭」检查状态和回调归属。
|
|
40
|
+
- **公告页新增外链打开**。保持包装页和正文的相对资源行为,单独对用户点击的链接做导航分类。以虚构的跨域帮助链接测试打开和返回,并检查外链容器的桥暴露范围。
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
# ArkWeb 实现用例
|
|
2
|
+
|
|
3
|
+
以下 ArkTS 和 HTML 为独立编写的虚构示例。按目标 SDK 的接口签名和项目路由约定调整,并在目标设备编译和运行。已有公共 Web 容器时,优先把这些行为接入该容器。两个用例均使用 `@ComponentV2`,只有驱动界面刷新的加载和失败状态使用 `@Local`。
|
|
4
|
+
|
|
5
|
+
## 用例一:只读帮助页
|
|
6
|
+
|
|
7
|
+
Android 侧的识别特征是路由传入网页地址,页面通过 `loadUrl` 显示内容,原生返回先检查 Web 历史。HarmonyOS 侧用 `Web` 和 `WebviewController` 复现加载、错误重试和返回。示例入口 URL 为保留域名,试跑时替换为自有测试页。此用例假设页面无需 JS,且应用在正式接入时会按已有策略校验入口和后续导航。
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
import webview from '@ohos.web.webview'
|
|
11
|
+
|
|
12
|
+
@Entry
|
|
13
|
+
@ComponentV2
|
|
14
|
+
struct SampleHelpPage {
|
|
15
|
+
private controller: webview.WebviewController = new webview.WebviewController()
|
|
16
|
+
private attached: boolean = false
|
|
17
|
+
@Local loading: boolean = true
|
|
18
|
+
@Local failed: boolean = false
|
|
19
|
+
|
|
20
|
+
onBackPress(): boolean {
|
|
21
|
+
if (this.attached && this.controller.accessBackward()) {
|
|
22
|
+
this.controller.backward()
|
|
23
|
+
return true
|
|
24
|
+
}
|
|
25
|
+
return false
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
build() {
|
|
29
|
+
Column() {
|
|
30
|
+
Web({ src: 'https://help.example.invalid/start', controller: this.controller })
|
|
31
|
+
.id('tc_sample_help_web')
|
|
32
|
+
.layoutWeight(1)
|
|
33
|
+
.javaScriptAccess(false)
|
|
34
|
+
.onControllerAttached(() => {
|
|
35
|
+
this.attached = true
|
|
36
|
+
})
|
|
37
|
+
.onPageBegin(() => {
|
|
38
|
+
this.loading = true
|
|
39
|
+
this.failed = false
|
|
40
|
+
})
|
|
41
|
+
.onPageEnd(() => {
|
|
42
|
+
this.loading = false
|
|
43
|
+
})
|
|
44
|
+
.onErrorReceive((event) => {
|
|
45
|
+
if (event?.request.isMainFrame()) {
|
|
46
|
+
this.loading = false
|
|
47
|
+
this.failed = true
|
|
48
|
+
}
|
|
49
|
+
})
|
|
50
|
+
.onHttpErrorReceive((event) => {
|
|
51
|
+
if (event?.request.isMainFrame()) {
|
|
52
|
+
this.loading = false
|
|
53
|
+
this.failed = true
|
|
54
|
+
}
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
if (this.failed) {
|
|
58
|
+
Button('重新加载')
|
|
59
|
+
.id('tc_sample_help_retry')
|
|
60
|
+
.onClick(() => {
|
|
61
|
+
if (this.attached) {
|
|
62
|
+
this.controller.refresh()
|
|
63
|
+
}
|
|
64
|
+
})
|
|
65
|
+
} else if (this.loading) {
|
|
66
|
+
LoadingProgress().width(28).height(28)
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
.width('100%')
|
|
70
|
+
.height('100%')
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
接入项目路由后,标题栏返回也应走同一套 Web 历史判断,无历史时由宿主退出。需要支持外链时,按项目策略在导航拦截处分流,并覆盖重定向。若页面容许快速并行导航,错误和结束事件还需要关联当前主文档,避免旧请求改变当前加载状态。
|
|
76
|
+
|
|
77
|
+
| 操作 | 预期 |
|
|
78
|
+
|---|---|
|
|
79
|
+
| 打开可访问的测试页 | 正文显示,加载提示结束 |
|
|
80
|
+
| 主文档断网或返回 HTTP 错误 | 出现重试按钮,恢复后重试可显示正文 |
|
|
81
|
+
| 正文内仅一张图片加载失败 | 保留正文,页面级错误状态不出现 |
|
|
82
|
+
| 从帮助页打开站内子页,再按返回 | 先回到帮助页,历史耗尽后退出宿主 |
|
|
83
|
+
|
|
84
|
+
## 用例二:本地 Web 页面调用只读 JSBridge
|
|
85
|
+
|
|
86
|
+
Android 侧从本地 asset、`addJavascriptInterface` 和同步返回值识别契约。HarmonyOS 侧把静态 HTML 放入模块的 `resources/rawfile`,通过 `javaScriptProxy` 只注册所需方法。示例约定 `SampleHost.readLabel(key)` 接收字符串并同步返回 JSON 字符串。选择或上传等需要等待用户的操作应使用异步协议,参见 [JSBridge 契约](bridge-contracts.md)。
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
import webview from '@ohos.web.webview'
|
|
90
|
+
|
|
91
|
+
class SampleLabelBridge {
|
|
92
|
+
readLabel(key: string): string {
|
|
93
|
+
if (key === 'section') {
|
|
94
|
+
return JSON.stringify({ status: 'ok', label: '示例帮助' })
|
|
95
|
+
}
|
|
96
|
+
return JSON.stringify({ status: 'error', code: 'unknownKey' })
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
@ComponentV2
|
|
101
|
+
struct SampleLocalPanel {
|
|
102
|
+
private controller: webview.WebviewController = new webview.WebviewController()
|
|
103
|
+
private bridge: SampleLabelBridge = new SampleLabelBridge()
|
|
104
|
+
|
|
105
|
+
build() {
|
|
106
|
+
Web({ src: $rawfile('sample-panel.html'), controller: this.controller })
|
|
107
|
+
.id('tc_sample_local_web')
|
|
108
|
+
.javaScriptAccess(true)
|
|
109
|
+
.javaScriptProxy({
|
|
110
|
+
object: this.bridge,
|
|
111
|
+
name: 'SampleHost',
|
|
112
|
+
methodList: ['readLabel'],
|
|
113
|
+
controller: this.controller
|
|
114
|
+
})
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
```html
|
|
120
|
+
<!doctype html>
|
|
121
|
+
<meta charset="utf-8">
|
|
122
|
+
<button id="read">读取栏目名称</button>
|
|
123
|
+
<p id="result" role="status"></p>
|
|
124
|
+
<script>
|
|
125
|
+
document.getElementById('read').addEventListener('click', () => {
|
|
126
|
+
const output = document.getElementById('result')
|
|
127
|
+
try {
|
|
128
|
+
const response = JSON.parse(window.SampleHost.readLabel('section'))
|
|
129
|
+
output.textContent = response.status === 'ok' ? response.label : '读取失败'
|
|
130
|
+
} catch {
|
|
131
|
+
output.textContent = '宿主能力不可用'
|
|
132
|
+
}
|
|
133
|
+
})
|
|
134
|
+
</script>
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
该 Web 实例只承载应用打包的静态资源。若扩展到外链,将远程网页交给独立的普通容器,并验证本地页面中的导航无法把代理带给其他文档。
|
|
138
|
+
|
|
139
|
+
| 操作 | 预期 |
|
|
140
|
+
|---|---|
|
|
141
|
+
| 点击按钮 | 页面显示「示例帮助」 |
|
|
142
|
+
| 测试页传入未知键 | 同步收到 `unknownKey`,页面显示失败提示 |
|
|
143
|
+
| 在普通浏览器打开 HTML | 页面显示宿主能力不可用 |
|
|
144
|
+
| 关闭后重新打开组件并点击 | 新实例可以正常读取,无需沿用上一页控制器 |
|
|
@@ -29,7 +29,6 @@ droid2hmos progress init <ANDROID_PROJECT>
|
|
|
29
29
|
4. HarmonyOS 工程架构设计(`harmony-architecture`)
|
|
30
30
|
5. spec 设计与生成(`spec-design-generation`)
|
|
31
31
|
6. 代码转换(`code-conversion`)
|
|
32
|
-
7. 测试与交付(`testing-delivery`)
|
|
33
32
|
|
|
34
33
|
每个阶段记录 `status`、`startedAt`、`endedAt`、`completed`、`lastUpdatedAt`、`details` 和 `blockers`;顶层 `summary` 汇总总数及 `pending/in_progress/blocked/completed` 数量和当前阶段。所有时间使用带时区偏移的 ISO 8601。初始化时“初始化工程”为 `in_progress`,其余阶段为 `pending`。
|
|
35
34
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
.section-index[data-v-05ad7363]{color:#4c77dc;background:#eaf1ff;border-radius:6px;justify-content:center;align-items:center;min-width:22px;height:22px;margin-right:8px;padding:0 6px;font-size:12px;display:inline-flex}.compare-table[data-v-05ad7363]{border-collapse:collapse;width:100%;margin:16px 0;font-size:13px}.compare-table th[data-v-05ad7363],.compare-table td[data-v-05ad7363]{text-align:left;border-bottom:1px solid #edf0f4;padding:10px 12px}.compare-table thead th[data-v-05ad7363]{color:var(--muted);letter-spacing:.5px;background:#f7f9fc;border-bottom:2px solid #e3e9f2;font-size:11px;font-weight:600}.compare-table tbody tr:last-child td[data-v-05ad7363]{border-bottom:0}.compare-table tbody tr:hover td[data-v-05ad7363]{background:#f8faff}.compare-label[data-v-05ad7363]{color:#34445c;width:40%;font-weight:600}.compare-value[data-v-05ad7363]{white-space:nowrap;font-size:18px;font-weight:650}.android-value[data-v-05ad7363]{color:#3766dc}.harmony-value[data-v-05ad7363]{color:#168168}.meta-list[data-v-05ad7363]{gap:2px;margin-top:4px;display:grid}.meta-item[data-v-05ad7363]{border-top:1px solid #edf0f4;gap:16px;padding:7px 0;font-size:13px;display:flex}.meta-item[data-v-05ad7363]:first-child{border-top:0}.meta-item small[data-v-05ad7363]{flex-shrink:0;width:80px}.meta-value[data-v-05ad7363]{color:#34445c;overflow-wrap:anywhere}.side-panel[data-v-05ad7363]{border-top:3px solid #65a7a3}.summary-counts[data-v-05ad7363]{grid-template-columns:repeat(5,1fr);gap:8px;margin:16px 0;display:grid}.summary-counts strong[data-v-05ad7363]{font-size:24px;font-weight:650;display:block}.summary-counts small[data-v-05ad7363]{font-size:11px}.summary-counts>div[data-v-05ad7363]{background:#f4f6fa;border-radius:8px;padding:8px 10px}.module-pills[data-v-05ad7363],.ext-pills[data-v-05ad7363]{flex-wrap:wrap;gap:7px;margin:4px 0 14px;display:flex}.module-tag[data-v-05ad7363]{color:#48736e;background:#edf5f2}.ext-tag[data-v-05ad7363]{color:#61728a;background:#f1f3f7}.block-label[data-v-05ad7363]{color:var(--muted);letter-spacing:1px;margin:18px 0 8px;font-size:11px;display:block}.lang-table[data-v-05ad7363]{gap:6px;display:grid}.lang-row[data-v-05ad7363]{grid-template-columns:110px 90px 90px 1fr;align-items:center;gap:10px;font-size:13px;display:grid}.lang-name[data-v-05ad7363]{color:#34445c;font-weight:600}.lang-files[data-v-05ad7363],.lang-lines[data-v-05ad7363]{color:#61728a;font-size:12px}.lang-bar[data-v-05ad7363]{background:#edf1f7;border-radius:8px;height:8px;overflow:hidden}.lang-bar i[data-v-05ad7363]{background:var(--blue);border-radius:8px;height:100%;display:block}.dep-list[data-v-05ad7363]{display:grid}.dep-group[data-v-05ad7363]{border:1px solid #edf0f4;border-radius:8px;margin-top:18px;overflow:hidden}.dep-group>summary[data-v-05ad7363]{cursor:pointer;color:#34445c;background:#f7f9fc;align-items:center;gap:10px;padding:11px 14px;font-size:13px;font-weight:650;list-style:none;display:flex}.dep-group>summary[data-v-05ad7363]::-webkit-details-marker{display:none}.dep-group>summary[data-v-05ad7363]:before{content:"▸";color:#8191a8;font-size:13px;transition:transform .15s}.dep-group[open]>summary[data-v-05ad7363]:before{transform:rotate(90deg)}.dep-group>summary[data-v-05ad7363]:hover{color:var(--blue)}.dep-group-label[data-v-05ad7363]{min-width:0}.dep-group .dep-list[data-v-05ad7363]{padding:4px 14px 10px}.dep-item[data-v-05ad7363]{border-top:1px solid #edf0f4;padding:6px 0}.dep-item[data-v-05ad7363]:first-child{border-top:0}.dep-item summary[data-v-05ad7363]{cursor:pointer;color:#34445c;align-items:center;gap:8px;padding:6px 4px;font-size:13px;list-style:none;display:flex}.dep-item summary[data-v-05ad7363]::-webkit-details-marker{display:none}.dep-item summary[data-v-05ad7363]:before{content:"▸";color:#8191a8;font-size:12px;transition:transform .15s}.dep-item[open] summary[data-v-05ad7363]:before{transform:rotate(90deg)}.dep-item summary[data-v-05ad7363]:hover{color:var(--blue)}.dep-item summary code[data-v-05ad7363]{color:#2d59c2;overflow-wrap:anywhere;font-size:12px}.dep-decls[data-v-05ad7363]{gap:4px;padding:0 4px 8px 24px;display:grid}.dep-decl[data-v-05ad7363]{color:#61728a;overflow-wrap:anywhere;font-size:12px}.muted-tag[data-v-05ad7363]{color:#61728a;background:#f1f3f7}.oversized-list[data-v-05ad7363]{gap:6px;display:grid}.oversized-item[data-v-05ad7363]{align-items:center;gap:10px;font-size:13px;display:flex}.oversized-item code[data-v-05ad7363]{color:#b54545;overflow-wrap:anywhere}.question-list[data-v-05ad7363]{color:#48586f;margin:4px 0 0;padding-left:18px;font-size:13px;line-height:1.7}.question-list li[data-v-05ad7363]{overflow-wrap:anywhere;margin:4px 0}.empty-inline[data-v-05ad7363]{color:var(--muted);font-size:13px}@media (width<=700px){.summary-counts[data-v-05ad7363]{grid-template-columns:repeat(2,1fr)}.lang-row[data-v-05ad7363]{grid-template-columns:90px 70px 70px 1fr;gap:6px}.compare-table th[data-v-05ad7363],.compare-table td[data-v-05ad7363]{padding:8px 9px}.compare-value[data-v-05ad7363]{font-size:15px}}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{O as e,X as t,Z as n,_ as r,a as i,c as a,d as o,f as s,i as c,j as l,n as u,p as d,s as f,t as p,v as ee,x as m,y as h}from"./_plugin-vue_export-helper-B9l48Cov.js";import{i as g,t as te}from"./index-B3nfIPBm.js";import{t as ne}from"./PageHeading-B5I3tpO8.js";import{i as re,r as _}from"./datetime-CHrzCsjX.js";var v={key:0,class:`panel placeholder`},y={class:`panel`},b={class:`row`},x={class:`tag`},S={class:`compare-table`},C={class:`compare-label`},w={class:`compare-value android-value`},T={class:`compare-value harmony-value`},E={class:`meta-list`},D={class:`meta-value`},O={class:`row`},k={class:`section-index`},A={class:`tag`},j={class:`summary-counts`},M={class:`module-pills`},N={class:`lang-table`},P={class:`lang-name`},F={class:`lang-files`},I={class:`lang-lines`},L={class:`lang-bar`},R={class:`ext-pills`},z=[`open`],ie={class:`tag muted-tag`},B={class:`dep-list`},V={class:`tag muted-tag`},H={class:`dep-decls`},U={key:1,class:`tag muted-tag`},W={class:`oversized-list`},G={class:`tag orange`},K={key:4,class:`empty-inline`},q={class:`panel`},J={class:`row`},Y={class:`section-index`},ae={key:0,class:`tag orange`},oe={key:0,class:`question-list`},se={key:1,class:`empty-inline`},X=p(d({__name:`CodeAudit`,setup(d){let p=te.codeStats,X=e(null),Z=e(null),Q;r(()=>{Q=re(p,(e,t)=>{X.value=e,Z.value=t.mtimeMs??null})}),ee(()=>Q?.());let ce=c(()=>_(X.value,Z.value)),le=[`android`,`harmony`],$=c(()=>X.value?.sides?le.filter(e=>X.value?.sides[e]).map(e=>({key:e,...X.value.sides[e]})):[]),ue=e=>X.value?.repositories.find(t=>t.id===e)?.label??(e===`android`?`Android`:`HarmonyOS`),de=e=>e?`${e.code.total_files} 文件 / ${e.code.total_lines} 行`:g,fe=(e,t)=>{let n=Math.max(1,...e.code.by_language.map(e=>e.lines));return`${Math.round(100*t/n)}%`},pe=c(()=>{let e=X.value?.comparison;return e?[{label:`模块数`,values:[e.modules.android,e.modules.harmony]},{label:`三方依赖`,values:[e.third_party_dependencies.android,e.third_party_dependencies.harmony]},{label:`原生库`,values:[e.native_libraries.android,e.native_libraries.harmony]},{label:`物理行数`,values:[e.total_lines.android,e.total_lines.harmony]},{label:`超大文件(≥${X.value.thresholds.oversized_file_lines} 行)`,values:[e.oversized.android_count,e.oversized.harmony_count]}]:[]});return(e,r)=>(h(),a(u,null,[s(ne,{kicker:`D2H / code-audit`,title:`代码审计`,note:`双端代码规模 · 模块 · 依赖 · 超大文件 · ${l(p)} 实时渲染`},null,8,[`note`]),X.value?(h(),a(u,{key:1},[i(`section`,y,[i(`div`,b,[r[2]||=i(`h2`,null,[i(`span`,{class:`section-index`},`01`),o(`双端对照`)],-1),i(`span`,x,`更新于 `+n(ce.value),1)]),i(`table`,S,[r[3]||=i(`thead`,null,[i(`tr`,null,[i(`th`,null,`指标`),i(`th`,null,`Android`),i(`th`,null,`HarmonyOS`)])],-1),i(`tbody`,null,[(h(!0),a(u,null,m(pe.value,e=>(h(),a(`tr`,{key:e.label},[i(`td`,C,n(e.label),1),i(`td`,w,n(e.values[0]),1),i(`td`,T,n(e.values[1]),1)]))),128))])]),i(`div`,E,[(h(!0),a(u,null,m(X.value.repositories,e=>(h(),a(`div`,{key:e.id,class:`meta-item`},[i(`small`,null,n(e.label),1),i(`span`,D,n(e.path)+` · rev `+n(e.revision||l(`unknown`)),1)]))),128))])]),(h(!0),a(u,null,m($.value,(e,s)=>(h(),a(`section`,{key:e.key,class:`panel side-panel`},[i(`div`,O,[i(`h2`,null,[i(`span`,k,n(String(s+2).padStart(2,`0`)),1),o(n(ue(e.key))+` 代码规模`,1)]),i(`span`,A,n(de(e)),1)]),i(`div`,j,[i(`div`,null,[i(`strong`,null,n(e.code.total_files),1),r[4]||=i(`small`,null,`总文件`,-1)]),i(`div`,null,[i(`strong`,null,n(e.code.total_lines),1),r[5]||=i(`small`,null,`总行数`,-1)]),i(`div`,null,[i(`strong`,null,n(e.module_count),1),r[6]||=i(`small`,null,`模块`,-1)]),i(`div`,null,[i(`strong`,null,n(e.third_party_dependency_count),1),r[7]||=i(`small`,null,`三方依赖`,-1)]),i(`div`,null,[i(`strong`,null,n(e.native_library_count),1),r[8]||=i(`small`,null,`原生库`,-1)])]),i(`div`,M,[(h(!0),a(u,null,m(e.modules,e=>(h(),a(`span`,{key:e.name,class:`tag module-tag`},n(e.name)+` · `+n(e.kind),1))),128))]),e.code.by_language.length?(h(),a(u,{key:0},[r[9]||=i(`small`,{class:`block-label`},`按语言`,-1),i(`div`,N,[(h(!0),a(u,null,m(e.code.by_language,r=>(h(),a(`div`,{key:r.language,class:`lang-row`},[i(`span`,P,n(r.language),1),i(`span`,F,n(r.files)+` 文件`,1),i(`span`,I,n(r.lines)+` 行`,1),i(`div`,L,[i(`i`,{style:t({width:fe(e,r.lines)})},null,4)])]))),128))])],64)):f(``,!0),e.code.other_extensions.length?(h(),a(u,{key:1},[r[10]||=i(`small`,{class:`block-label`},`其他扩展名(未映射到核心语言桶)`,-1),i(`div`,R,[(h(!0),a(u,null,m(e.code.other_extensions,e=>(h(),a(`span`,{key:e.extension,class:`tag ext-tag`},n(e.extension||`(无扩展名)`)+` · `+n(e.files)+` 文件 / `+n(e.lines)+` 行 `,1))),128))])],64)):f(``,!0),e.third_party_dependencies.length?(h(),a(`details`,{key:2,class:`dep-group`,open:e.key===`android`},[i(`summary`,null,[r[11]||=i(`span`,{class:`dep-group-label`},`三方依赖`,-1),i(`span`,ie,n(e.third_party_dependency_count),1)]),i(`div`,B,[(h(!0),a(u,null,m(e.third_party_dependencies,e=>(h(),a(`details`,{key:e.name,class:`dep-item`},[i(`summary`,null,[i(`code`,null,n(e.name),1),r[12]||=o(),i(`span`,V,n(e.version),1)]),i(`div`,H,[(h(!0),a(u,null,m(e.declarations,(e,t)=>(h(),a(`div`,{key:t,class:`dep-decl`},[o(n(e.path),1),e.line_start?(h(),a(u,{key:0},[o(`:`+n(e.line_start),1)],64)):f(``,!0),e.scope?(h(),a(`span`,U,n(e.scope),1)):f(``,!0)]))),128))])]))),128))])],8,z)):f(``,!0),e.oversized_files.length?(h(),a(u,{key:3},[r[14]||=i(`small`,{class:`block-label`},`超大文件`,-1),i(`div`,W,[(h(!0),a(u,null,m(e.oversized_files,e=>(h(),a(`div`,{key:e.path,class:`oversized-item`},[i(`code`,null,n(e.path),1),r[13]||=o(),i(`span`,G,n(e.lines)+` 行`,1)]))),128))])],64)):(h(),a(`small`,K,`无超大文件(阈值 `+n(X.value.thresholds.oversized_file_lines)+` 行)`,1))]))),128)),i(`section`,q,[i(`div`,J,[i(`h2`,null,[i(`span`,Y,n(String($.value.length+2).padStart(2,`0`)),1),r[15]||=o(`注意事项`,-1)]),X.value.notes.length?(h(),a(`span`,ae,n(X.value.notes.length)+` 项`,1)):f(``,!0)]),X.value.notes.length?(h(),a(`ul`,oe,[(h(!0),a(u,null,m(X.value.notes,(e,t)=>(h(),a(`li`,{key:t},n(e),1))),128))])):(h(),a(`div`,se,`无注意事项`))])],64)):(h(),a(`section`,v,[r[0]||=i(`span`,{class:`glyph`},`∑`,-1),r[1]||=i(`strong`,null,`等待数据`,-1),i(`small`,null,`正在读取 `+n(l(p))+`…(尚未生成代码审计报告时此页为空)`,1)]))],64))}}),[[`__scopeId`,`data-v-05ad7363`]]);export{X as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
.status-overview[data-v-56d6514c]{background:linear-gradient(110deg,#fbfcff,#fff 65%);border-top:3px solid #6285df;padding-bottom:0}.status-overview>.row h2[data-v-56d6514c]{margin:0}.total-time[data-v-56d6514c]{background:#f0f4fc;border-radius:7px;align-items:center;gap:10px;padding:5px 11px;display:flex}.total-time-group[data-v-56d6514c]{flex-wrap:wrap;align-items:center;gap:8px;display:flex}.total-time strong[data-v-56d6514c]{color:#4d638b;font-size:14px}.phase-track[data-v-56d6514c]{grid-template-columns:repeat(7,minmax(0,1fr));gap:8px;margin:20px 0;display:grid}.phase-cell[data-v-56d6514c]{text-align:left;background:#f7f9fc;border:1px solid #e5eaf3;border-radius:7px;min-width:0;padding:13px 14px}.phase-cell[data-v-56d6514c]:hover{background:#f0f4fd;border-color:#adc1ea}.phase-cell strong[data-v-56d6514c],.phase-cell small[data-v-56d6514c]{display:block}.phase-cell strong[data-v-56d6514c]{margin:6px 0;font-size:12px;font-weight:500}.phase-cell small[data-v-56d6514c]{font-size:11px}.phase-label[data-v-56d6514c]{color:#34445c;font-size:13px;font-weight:650}.phase-cell strong[data-v-56d6514c],.phase-cell small[data-v-56d6514c],.phase-label[data-v-56d6514c]{overflow-wrap:anywhere}.phase-active[data-v-56d6514c]{background:#eaf1ff;border-color:#b5c9f7;box-shadow:inset 0 3px #4c77dc}.phase-active .phase-label[data-v-56d6514c],.phase-active strong[data-v-56d6514c]{color:#2858c4}.phase-done[data-v-56d6514c]{background:#edf8f3;border-color:#c6e8d9;box-shadow:inset 0 3px #55a68a}.phase-done .phase-label[data-v-56d6514c],.phase-done strong[data-v-56d6514c]{color:#177657}.phase-error[data-v-56d6514c]{background:#fff0f0;border-color:#f0c8c8;box-shadow:inset 0 3px #d26969}.phase-error .phase-label[data-v-56d6514c],.phase-error strong[data-v-56d6514c]{color:#b54545}.live-dot[data-v-56d6514c]{background:var(--blue);border-radius:50%;width:7px;height:7px;margin-right:6px;display:inline-block}.overview-sentence[data-v-56d6514c]{background:#f0f4fc;border-top:1px solid #e0e8f7;border-radius:0 0 10px 10px;justify-content:space-between;align-items:center;gap:14px;margin:0 -22px;padding:14px 22px;display:flex}.overview-sentence strong[data-v-56d6514c]{color:#3b5279;overflow-wrap:anywhere;font-size:13px;font-weight:500}.overview-sentence small[data-v-56d6514c]{overflow-wrap:anywhere;margin-top:3px;font-size:11px;display:block}.overview-grid[data-v-56d6514c]{grid-template-columns:repeat(12,minmax(0,1fr));gap:16px;display:grid}.overview-grid .panel[data-v-56d6514c]{min-width:0;margin:0}.span-3[data-v-56d6514c]{grid-column:span 3}.span-4[data-v-56d6514c]{grid-column:span 4}.span-6[data-v-56d6514c]{grid-column:span 6}.span-8[data-v-56d6514c]{grid-column:span 8}.task-overview[data-v-56d6514c],.project-overview[data-v-56d6514c]{margin-bottom:18px}.task-overview .panel[data-v-56d6514c],.project-overview .panel[data-v-56d6514c]{padding:20px}.task-overview>.panel[data-v-56d6514c]:first-child{background:linear-gradient(125deg,#f8fbff,#fff 70%);border-top:3px solid #5e85dc}.task-overview>.panel[data-v-56d6514c]:nth-child(2){border-top:3px solid #8c85c2}.task-overview>.panel[data-v-56d6514c]:nth-child(3){border-top:3px solid #61a6a1}.summary-counts[data-v-56d6514c]{grid-template-columns:repeat(3,1fr);gap:6px;margin:20px 0 14px;display:grid}.summary-counts strong[data-v-56d6514c]{font-size:26px;font-weight:650;display:block}.summary-counts small[data-v-56d6514c]{font-size:11px}.summary-counts>div:last-child strong[data-v-56d6514c]{color:#66768b}.blue-number[data-v-56d6514c]{color:#3766dc}.orange-number[data-v-56d6514c]{color:#986221}.green-number[data-v-56d6514c]{color:#168168}.current-brief[data-v-56d6514c]{padding-top:5px}.current-brief+.current-brief[data-v-56d6514c]{margin-top:12px}.current-title[data-v-56d6514c]{text-align:left;font-size:14px;font-weight:600}.current-brief small[data-v-56d6514c]{overflow-wrap:anywhere;margin-top:2px;display:block}.activity-rail[data-v-56d6514c]{background:#edf1f7;border-radius:8px;height:7px;margin:12px 0 4px;overflow:hidden}.activity-rail i[data-v-56d6514c]{background:var(--blue);border-radius:8px;height:100%;display:block}.activity-rail.is-indeterminate i[data-v-56d6514c]{opacity:0;width:35%}.activity-rail.is-active.is-indeterminate i[data-v-56d6514c]{opacity:1;animation:1.5s ease-in-out infinite d2h-indeterminate-56d6514c}@keyframes d2h-indeterminate-56d6514c{0%{transform:translate(-110%)}to{transform:translate(390%)}}@media (prefers-reduced-motion:reduce){.activity-rail i[data-v-56d6514c]{animation:none!important;transform:none!important}}.idle-task[data-v-56d6514c]{color:#65758d;flex-direction:column;justify-content:center;gap:7px;min-height:92px;padding-top:10px;display:flex}.running-tasks[data-v-56d6514c]{border-top:1px solid #edf0f4;margin-top:12px;padding-top:10px}.running-label[data-v-56d6514c]{color:var(--muted);letter-spacing:1px;margin-bottom:4px;font-size:11px;display:block}.running-task[data-v-56d6514c]{text-align:left;color:#34445c;background:0 0;border:0;border-radius:7px;align-items:center;gap:8px;width:100%;margin:0;padding:7px 8px;font-size:12px;display:flex}.running-task[data-v-56d6514c]:hover{background:#f0f5ff;border-color:#0000}.running-id[data-v-56d6514c]{color:var(--blue);flex-shrink:0;font-size:12px;font-weight:600}.running-name[data-v-56d6514c]{text-overflow:ellipsis;white-space:nowrap;color:#41536e;flex:1;min-width:0;overflow:hidden}.project-overview>.panel[data-v-56d6514c]:first-child{background:linear-gradient(125deg,#f6fbfa,#fff 70%);border-top:3px solid #65a7a3}.project-overview>.panel:first-child .section-index[data-v-56d6514c]{color:#39867f;background:#e7f5f1}.project-overview>.panel[data-v-56d6514c]:last-child{border-top:3px solid #95a4b9}.project-metrics[data-v-56d6514c],.environment-summary[data-v-56d6514c]{grid-template-columns:repeat(3,1fr);gap:12px;margin:15px 0;display:grid}.environment-summary[data-v-56d6514c]{grid-template-columns:repeat(4,1fr)}.dual-metrics[data-v-56d6514c]{grid-template-columns:repeat(auto-fit,minmax(min(220px,100%),1fr));gap:12px;margin:15px 0;display:grid}.dual-metric[data-v-56d6514c]{border:1px solid var(--line);background:#f9fbfe;border-radius:8px;min-width:0;padding:12px}.dual-metric>small[data-v-56d6514c]{color:#39867f;margin-bottom:10px;font-size:11px;font-weight:600;display:block}.dual-metric .metric-row[data-v-56d6514c]{align-items:baseline;gap:8px;min-width:0;padding:3px 0;display:flex}.dual-metric .metric-row strong[data-v-56d6514c]{color:#34445c;flex-shrink:0;min-width:52px;font-size:20px;font-weight:650}.dual-metric .metric-row em[data-v-56d6514c]{color:#61728a;white-space:nowrap;text-overflow:ellipsis;font-size:11px;font-style:normal;overflow:hidden}.project-metrics strong[data-v-56d6514c],.environment-summary strong[data-v-56d6514c]{font-size:24px;font-weight:600;display:block}.project-metrics small[data-v-56d6514c],.environment-summary small[data-v-56d6514c]{font-size:11px}.stack-pills[data-v-56d6514c]{flex-wrap:wrap;gap:7px;margin:14px 0 8px;display:flex}.stack-pills .tag[data-v-56d6514c]{color:#48736e;background:#edf5f2}.environment-summary>div[data-v-56d6514c]{background:#f4f6fa;border-radius:7px;padding:7px 9px}.environment-summary>div[data-v-56d6514c]:first-child{background:#edf8f2}.environment-summary>div:first-child strong[data-v-56d6514c]{color:#168168}.environment-summary>div:nth-child(2) strong[data-v-56d6514c]{color:#bc4a47}.environment-summary>div:nth-child(3) strong[data-v-56d6514c]{color:#a96825}.environment-summary>div:nth-child(4) strong[data-v-56d6514c]{color:#7c8798}.env-foot[data-v-56d6514c]{align-items:flex-start;min-width:0}.env-foot small[data-v-56d6514c]{overflow-wrap:anywhere;min-width:0;color:var(--muted);flex:1;font-size:12px}.env-foot .tag[data-v-56d6514c]{flex-shrink:0}.blockers-overview[data-v-56d6514c]{background:linear-gradient(110deg,#fffcf6,#fff 75%);border-top:3px solid #d6a25a}.blockers-overview .section-index[data-v-56d6514c]{color:#9d7239;background:#fff0d9}.blockers-overview .blocker-item[data-v-56d6514c]{border-top-color:#f0e6d7}.blockers-overview .blocker-item strong[data-v-56d6514c]{color:#6c5435}.blockers-overview .blocker-dot[data-v-56d6514c]{background:#cc8e39}.blockers-overview.all-clear[data-v-56d6514c]{border-top:3px solid #78ad97}.blockers-overview.all-clear .section-index[data-v-56d6514c]{color:#417e62;background:#eaf6ef}.blocker-list[data-v-56d6514c]{display:grid}.blocker-item[data-v-56d6514c]{border-top:1px solid #edf0f4;align-items:flex-start;gap:12px;padding:14px 0;display:flex}.blocker-item>div[data-v-56d6514c]{flex:1;min-width:0}.blocker-item strong[data-v-56d6514c]{overflow-wrap:anywhere;font-size:12px}.blocker-dot[data-v-56d6514c]{background:#d9993a;border-radius:50%;flex-shrink:0;width:6px;height:6px;margin-top:9px}.clear-blockers[data-v-56d6514c]{color:#547064;font-size:13px}.clear-blockers small[data-v-56d6514c]{margin-top:5px;display:block}@media (width<=1100px){.span-3[data-v-56d6514c],.span-4[data-v-56d6514c]{grid-column:span 6}.span-8[data-v-56d6514c],.task-overview .span-6[data-v-56d6514c]{grid-column:span 12}.phase-track[data-v-56d6514c]{grid-template-columns:repeat(4,minmax(0,1fr))}}@media (width<=900px){.phase-track[data-v-56d6514c]{grid-template-columns:repeat(3,minmax(0,1fr))}.environment-summary[data-v-56d6514c]{grid-template-columns:repeat(2,1fr)}}@media (width<=760px){.overview-sentence[data-v-56d6514c]{display:block}.overview-sentence>.tag[data-v-56d6514c]{margin-top:10px;display:inline-block}}@media (width<=700px){.span-3[data-v-56d6514c],.span-4[data-v-56d6514c],.span-6[data-v-56d6514c],.span-8[data-v-56d6514c]{grid-column:span 12}.overview-sentence[data-v-56d6514c]{margin:0 -14px;padding:14px}.summary-counts[data-v-56d6514c],.project-metrics[data-v-56d6514c]{grid-template-columns:repeat(3,1fr)}.dual-metrics[data-v-56d6514c]{grid-template-columns:1fr}}@media (width<=480px){.phase-track[data-v-56d6514c]{grid-template-columns:repeat(2,minmax(0,1fr))}.summary-counts[data-v-56d6514c]{grid-template-columns:repeat(3,1fr);gap:4px}.summary-counts strong[data-v-56d6514c]{font-size:20px}.environment-summary[data-v-56d6514c]{grid-template-columns:repeat(2,1fr)}}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./index-B3nfIPBm.js";var t=1e4,n=`/api/data`,r=null,i=new Set;function a(){r||typeof EventSource>`u`||(r=new EventSource(`${n}/events`),r.onmessage=e=>{try{let{files:t}=JSON.parse(e.data);if(!Array.isArray(t))return;for(let e of i)t.includes(e.relPath)&&e.trigger()}catch{}})}function o(e){return e.toLowerCase().endsWith(`.jsonl`)}function s(e){let t=[];for(let n of e.split(/\r?\n/)){let e=n.trim();if(e)try{t.push(JSON.parse(e))}catch{}}return t}async function c(e,t){let r=`${n}/file?p=${encodeURIComponent(e)}`,i=await fetch(r,{cache:`no-store`,signal:t});if(i.status===404)throw Error(`数据文件不存在: ${e}`);if(!i.ok)throw Error(`读取失败 (HTTP ${i.status}): ${e}`);return i.arrayBuffer()}async function l(e,t){return d(e,t)}async function u(e,t,r){let i=`${n}/file?p=${encodeURIComponent(e)}`,a=await fetch(i,{method:`POST`,headers:{"Content-Type":`application/json`},cache:`no-store`,signal:r,body:JSON.stringify(t)});if(a.status===409)throw Error(`数据已变化,请刷新后重试`);if(a.status===403)throw Error(`该文件不可写`);if(!a.ok)throw Error(`写入失败 (HTTP ${a.status})`);return a.json()}async function d(e,t){let r=`${n}/file?p=${encodeURIComponent(e)}`,i=await fetch(r,{cache:`no-store`,signal:t});if(i.status===404)throw Error(`数据文件不存在: ${e}`);if(!i.ok)throw Error(`读取失败 (HTTP ${i.status}): ${e}`);return i.text()}function f(e,r,o={}){let{pollMs:s=t,immediate:l=!0}=o,u=!1,d=null,f=null,p=null,m=async(t,n)=>{if(!u)try{let i=await c(e,t);if(u)return;await r(i,{relPath:e,fetchedAt:Date.now(),mtimeMs:n})}catch(t){if(u)return;console.warn(`[JsonOperateUtils] 读取 ${e} 失败:`,t)}},h=async()=>{if(!u){d?.abort(),d=new AbortController;try{let t=await fetch(`${n}/manifest`,{cache:`no-store`,signal:d.signal});if(!t.ok)return;let r=(await t.json()).files[e];if(!r||f&&f.mtimeMs===r.mtimeMs&&f.size===r.size)return;f=r,await m(d.signal,r.mtimeMs)}catch{}}},g={relPath:e,trigger:()=>void h()};return i.add(g),a(),l&&h(),p=setInterval(()=>void h(),s),()=>{u=!0,i.delete(g),p&&clearInterval(p),d?.abort()}}function p(e,t,n={}){return f(e,async(n,r)=>{let i=new TextDecoder().decode(n),a;if(o(e))a=s(i);else try{a=JSON.parse(i)}catch{throw Error(`JSON 解析失败: ${e}`)}t(a,r)},n)}var m=e=>String(e).padStart(2,`0`);function h(t,n=e){if(!t)return n;let r=new Date(t);return Number.isNaN(r.getTime())?n:`${r.getFullYear()}-${m(r.getMonth()+1)}-${m(r.getDate())} ${m(r.getHours())}:${m(r.getMinutes())}:${m(r.getSeconds())}`}function g(t,n=e){if(!Number.isFinite(t)||(t??0)<0)return n;let r=Math.floor((t??0)/1e3),i=Math.floor(r/3600),a=Math.floor(r%3600/60),o=r%60;return i>0?`${i} 小时 ${a} 分`:a>0?`${a} 分 ${o} 秒`:`${o} 秒`}var _=[`updated_at`,`updatedAt`,`generated_at`,`generatedAt`,`created_at`,`createdAt`];function v(t,n){if(t&&typeof t==`object`){let e=t;for(let t of _){let n=e[t];if(typeof n==`string`&&n&&!Number.isNaN(Date.parse(n)))return h(n)}}return typeof n==`number`&&Number.isFinite(n)?h(new Date(n).toISOString()):e}export{l as a,p as i,h as n,u as o,v as r,g as t};
|