@chendb888/dsh-project-steward 0.0.0-stage → 0.1.1

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/CHANGELOG.md ADDED
@@ -0,0 +1,50 @@
1
+ # Changelog
2
+
3
+ 本文件记录 `@chendb888/dsh-project-steward`(项目管家)逐版本变更。
4
+ 格式参考 [Keep a Changelog](https://keepachangelog.com/),版本遵循 [SemVer](https://semver.org/)。
5
+
6
+ ## [0.1.0] - 2026-11-23
7
+
8
+ ### Added
9
+ - **百货分区货架**:按项目类型分区域 + 区域内按上架状态分货架;商品卡片 ⬇下载 👁浏览 💬留言 💰收入;分类切换(类型/渠道/状态)。
10
+ - **店铺概况**:在售商品(唯一项目数)/总下载/总浏览/新留言/累计收入数据卡 + 待处理异常 + 商品分类。
11
+ - **常驻「店铺」页签**:conversation.view 注册,同看板插件常驻机制。
12
+ - **从发布渠道导入**:扫描 npm maintainer / GitHub 账号发现已上架商品,勾选导入为纳管项目 + listed 上架记录。
13
+ - **全自动发布流水线**:6 类模板(dsh-plugin/game/business-system/web-app/engine/host);守卫链 + 阻断传播 + 豁免;自动 bump patch;auto-publish(npm/镜像/GitHub/市场PR/itch/docker)。
14
+ - **发布说明硬门禁**:readme-exists + changelog-nonempty 检查,缺 README/CHANGELOG 阻断发布。
15
+ - **定时运营采集**:60min 调度 + 退避 + stale;npm 下载 / GitHub traffic 浏览/克隆 独立口径;留言/付款增量事件 + 紧急推送。
16
+ - **市场竞品情报**:竞品发现 + 功能逐项对比矩阵 + 多维雷达图(真实文档质量/功能广度)+ 多因子市场空白研判(实搜 npm/GitHub 供给/需求/竞争)。
17
+ - **全项目文档标准**:doc_check/doc_scaffold/doc_complete/maintenance_report + **doc_update_image**(逐版本更新位置标注图 SVG→PNG 推 GitHub)。
18
+ - **渠道 CRUD**:增删改查 + 候选库导入(内容类排除)+ 软删除守卫。
19
+ - **生产实例保护**:readOnly 渠道零写操作(ILLEGAL_ON_PROTECTED)。
20
+ - **journal 审计**:append-only 事实源 + 原子写 + 损坏重放重建 + 凭据脱敏。
21
+
22
+ ### 更新位置
23
+ ![0.1.0 更新位置](https://raw.githubusercontent.com/chendb888/dsh-project-steward/main/docs/images/update-0.1.0.png)
24
+
25
+ ① 店铺导航 + 从发布渠道导入;② 分区货架商品卡(四数字);③ 市场情报竞品对比。红虚线框 = 核心界面区域。
26
+
27
+ ---
28
+
29
+ ## 维护说明(Maintenance)
30
+
31
+ ### 版本发布流程
32
+ 1. `node --test`(59 绿)。
33
+ 2. 更新 CHANGELOG + README 版本更新说明 + 生成版本更新位置图(`steward_doc_update_image`)。
34
+ 3. bump `package.json` version(SemVer)。
35
+ 4. staging 公开包 `@chendb888/dsh-project-steward`(去 private),`npm pack --dry-run` 核对文件(须含 README/CHANGELOG/locale/icon/src/index/client)。
36
+ 5. `npm publish --registry=https://registry.npmjs.org --access public`。
37
+ 6. 推 GitHub + 更新官方市场条目(awesome-dsh-plugin,PR 合并即上架)。
38
+ 7. 核实 npm readme 非空、镜像同步、市场条目完整。
39
+
40
+ ### 上架材料硬门禁
41
+ README + CHANGELOG + locale(en/zh) + icon 必备,缺失不得发布。
42
+
43
+ ### 数据与安全
44
+ - 台账本地落盘 `data/`(JSON + journal.jsonl append-only,可重放重建)。
45
+ - 凭据只存引用,不落明文;G3/G4 动作需显式确认;readOnly 生产实例零写操作。
46
+ - 投影/工具依赖字段须为数组(防御规范化)。
47
+
48
+ ## 许可
49
+
50
+ MIT
package/README.md CHANGED
@@ -1,3 +1,65 @@
1
- # Temporary Holding Version
1
+ # 项目管家 · Project Steward
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ ![项目管家封面](https://raw.githubusercontent.com/chendb888/dsh-project-steward/main/docs/images/cover.png)
4
+
5
+ > 像经营百货商店一样管理你全部**软件项目**的发布、上架与运营。一个 DSH 插件:分区货架看板 + 全自动发布 + 定时运营采集 + 市场竞品情报 + 全项目文档标准。
6
+
7
+ ## 功能特性
8
+
9
+ - **🏬 百货分区货架**:按项目类型分区域(插件/游戏/应用/引擎工具/宿主),区域内按上架状态分货架(在售/审核中/待上架/已下架),商品卡片显示 ⬇下载 👁浏览 💬留言 💰收入。分类可切换(类型/渠道/状态)。
10
+ - **🔌 从发布渠道导入**:扫描 npm/GitHub 账号发现已上架商品,一键导入货架(不扫本地文件);本地扫描纳管为可选辅助。
11
+ - **⚡ 全自动发布**:构建→测试→检查→自动 bump patch→发布→上架一条龙;失败阻断并通知;**发布说明硬门禁**(README+CHANGELOG 必备)。
12
+ - **📊 定时运营采集**:默认 60min 拉取各平台真实数据;下载量(npm)与浏览量(GitHub traffic)独立口径;新留言/付款事件提醒。
13
+ - **🔍 市场竞品情报**:按本项目功能逐项对比竞品 + 多维雷达图 + 真实多因子市场空白研判。
14
+ - **📝 全项目文档标准**:完整 CHANGELOG + README + 维护说明 + **逐版本更新位置标注图**(一键生成)。
15
+ - **🔒 生产实例保护**:readOnly 实例(如阿里云内测)严格只读,禁止写操作。
16
+
17
+ ## 安装
18
+
19
+ ```bash
20
+ dsh plugin --profile web add @chendb888/dsh-project-steward
21
+ ```
22
+
23
+ 或在 DSH 插件管理器安装 `@chendb888/dsh-project-steward`。
24
+
25
+ ## 使用
26
+
27
+ 1. 打开「店铺」视图页签(常驻,同看板插件机制)。
28
+ 2. 「🔌 从发布渠道导入」扫描你的 npm/GitHub 已上架商品 → 勾选导入货架。
29
+ 3. 「🛒 商品货架」查看分区货架;点商品看详情(上架渠道/发布记录/竞品研判)。
30
+ 4. 「📊 市场情报」扫描对比竞品 + 市场空白。
31
+ 5. 对话中可用 `steward_*` 工具:`steward_release_start`(全自动发布)、`steward_doc_update_image`(生成版本更新图)、`steward_market_compare`(竞品研判)等。
32
+
33
+ ## 版本更新说明
34
+
35
+ ### 0.1.0(2026-11-23)
36
+ - 🎉 首次正式发布。
37
+ - 百货分区货架 + 店铺概况数据卡 + 常驻「店铺」页签。
38
+ - 从发布渠道导入商品(npm/GitHub 账号扫描)。
39
+ - 全自动发布流水线(6 类模板 + 发布说明硬门禁 + 自动 bump patch)。
40
+ - 定时运营采集(下载/浏览独立口径 + 克隆量 + 留言/付款事件)。
41
+ - 市场竞品情报(功能逐项对比 + 雷达图 + 多因子空白研判)。
42
+ - 全项目文档标准(CHANGELOG/README/维护说明 + 逐版本更新位置标注图生成)。
43
+ - 渠道 CRUD + 候选库导入;生产实例只读保护;journal 审计。
44
+
45
+ **更新位置示意**(红虚线框标注核心界面区域):
46
+
47
+ ![0.1.0 更新位置](https://raw.githubusercontent.com/chendb888/dsh-project-steward/main/docs/images/update-0.1.0.png)
48
+
49
+ > ① 店铺导航 + 从发布渠道导入;② 分区货架商品卡(四数字);③ 市场情报竞品对比。
50
+
51
+ ## 维护说明
52
+
53
+ - **发布流程**:`node --test`(59 绿)→ 更新 CHANGELOG/README → bump version → staging 公开包(`npm pack --dry-run` 核对含 README/CHANGELOG/locale/icon/src)→ `npm publish --registry=https://registry.npmjs.org` → 推 GitHub + 更新市场条目 → 核实 npm readme 非空。
54
+ - **上架材料硬门禁**:README + CHANGELOG + locale(en/zh) + icon 必备。
55
+ - **数据**:全部本地落盘 `data/`(JSON 台账 + journal.jsonl append-only 审计,可重放重建);凭据只存引用不落明文。
56
+ - **安全**:G3/G4 动作(下架/归档/豁免/软删除)需显式确认;readOnly 生产实例零写操作;竞品/留言文本作不可信数据。
57
+
58
+ ## 数据与隐私
59
+
60
+ - 台账落盘项目目录 `data/`;凭据仅存引用位置(npmrc/gh CLI/skill/server-env),不落明文。
61
+ - 卸载不删除 `data/` 台账。
62
+
63
+ ## 许可
64
+
65
+ MIT
package/client.js ADDED
@@ -0,0 +1,417 @@
1
+ /** Client 半:项目管家 · 商家后台风格(参考淘宝商家后台)+ 真实货架视觉。
2
+ * 仅 require('react')。容器继承宿主 --dsw-alias-* 令牌;店铺品牌色用固定橙( artwork 自有色)。
3
+ * conversation.view 货架页签 + conversation.input.dock 常驻迷你条。 */
4
+ window.__ModuleLoader__.load({
5
+ id: '@local/dsh-project-steward',
6
+ factory(require) {
7
+ const React = require('react')
8
+ const { useState, useEffect, useCallback } = React
9
+ const h = React.createElement
10
+
11
+ const BRAND = '#ff5000' // 淘宝橙
12
+ const BRAND_SOFT = 'rgba(255,80,0,.1)'
13
+ const WOOD = '#c9a06a' // 货架木板
14
+ const WOOD_DARK = '#a97e44'
15
+ const C = {
16
+ listed: '#22a06b', reviewing: '#f5a623', submitted: '#f5a623',
17
+ draft: '#8c8c8c', rejected: '#e5484d', delisted: '#b0b0b0',
18
+ }
19
+ const TYPE_META = {
20
+ 'dsh-plugin': { icon: '🧩', label: '插件区', color: '#5b6cff' },
21
+ game: { icon: '🎮', label: '游戏区', color: '#22a06b' },
22
+ 'web-app': { icon: '🖥️', label: '应用区', color: '#0ea5e9' },
23
+ 'business-system': { icon: '🏢', label: '应用区', color: '#0ea5e9' },
24
+ engine: { icon: '⚙️', label: '引擎工具区', color: '#a855f7' },
25
+ research: { icon: '🔬', label: '引擎工具区', color: '#a855f7' },
26
+ host: { icon: '🏠', label: '宿主专区', color: '#8c8c8c' },
27
+ }
28
+ const STATUS_LABEL = { listed: '出售中', reviewing: '审核中', submitted: '审核中', draft: '待上架', rejected: '审核拒绝', delisted: '已下架' }
29
+ const fmt = n => n == null ? '0' : (n >= 10000 ? (n / 10000).toFixed(1) + 'w' : n >= 1000 ? (n / 1000).toFixed(1) + 'k' : String(n))
30
+ const money = n => '¥' + (n == null ? '0' : Number(n).toLocaleString())
31
+ const bg = 'var(--dsw-alias-bg-base)', layer = 'var(--dsw-alias-bg-layer-1)', layer2 = 'var(--dsw-alias-bg-layer-2)'
32
+ const border = 'var(--dsw-alias-border-l1)', text = 'var(--dsw-alias-label-primary)', sub = 'var(--dsw-alias-label-secondary)'
33
+
34
+ const T = {
35
+ app: { display: 'flex', height: '100%', background: bg, color: text, fontSize: '13px', fontFamily: '-apple-system,"Segoe UI","Microsoft YaHei",sans-serif' },
36
+ side: { width: '200px', flexShrink: 0, background: layer, borderRight: '1px solid ' + border, display: 'flex', flexDirection: 'column', padding: '12px 8px' },
37
+ shop: { display: 'flex', alignItems: 'center', gap: '8px', padding: '8px', marginBottom: '12px' },
38
+ shopAvatar: { width: '36px', height: '36px', borderRadius: '8px', background: BRAND, color: '#fff', display: 'flex', alignItems: 'center', justifyContent: 'center', fontSize: '18px', flexShrink: 0 },
39
+ navItem: { display: 'flex', alignItems: 'center', gap: '8px', padding: '9px 12px', borderRadius: '8px', cursor: 'pointer', fontSize: '13px', marginBottom: '2px', color: text },
40
+ body: { flex: 1, minWidth: 0, display: 'flex', flexDirection: 'column', overflow: 'hidden' },
41
+ header: { display: 'flex', alignItems: 'center', gap: '12px', padding: '12px 20px', borderBottom: '1px solid ' + border, background: layer },
42
+ hTitle: { fontSize: '16px', fontWeight: 700 },
43
+ search: { flex: 1, maxWidth: '320px', padding: '7px 12px', borderRadius: '18px', border: '1px solid ' + border, background: bg, color: text, fontSize: '12px', outline: 'none' },
44
+ btn: { padding: '7px 16px', borderRadius: '18px', background: BRAND, color: '#fff', cursor: 'pointer', fontSize: '12px', fontWeight: 600, border: 'none', whiteSpace: 'nowrap' },
45
+ btnGhost: { padding: '6px 14px', borderRadius: '18px', border: '1px solid ' + border, background: layer, color: text, cursor: 'pointer', fontSize: '12px' },
46
+ content: { flex: 1, overflowY: 'auto', padding: '20px' },
47
+ cards: { display: 'grid', gridTemplateColumns: 'repeat(auto-fit,minmax(160px,1fr))', gap: '14px', marginBottom: '20px' },
48
+ stat: { background: layer, border: '1px solid ' + border, borderRadius: '12px', padding: '16px' },
49
+ statNum: { fontSize: '26px', fontWeight: 800, fontVariantNumeric: 'tabular-nums', lineHeight: 1.2 },
50
+ statLabel: { fontSize: '12px', color: sub, marginTop: '4px' },
51
+ statIcon: { fontSize: '20px', float: 'right', opacity: .8 },
52
+ panel: { background: layer, border: '1px solid ' + border, borderRadius: '12px', padding: '16px', marginBottom: '16px' },
53
+ panelTitle: { fontSize: '14px', fontWeight: 700, marginBottom: '12px', display: 'flex', alignItems: 'center', gap: '8px' },
54
+ tabs: { display: 'flex', gap: '4px', borderBottom: '1px solid ' + border, marginBottom: '16px' },
55
+ tab: { padding: '8px 16px', cursor: 'pointer', fontSize: '13px', borderBottom: '2px solid transparent', color: sub, marginBottom: '-1px' },
56
+ tabActive: { color: BRAND, borderBottomColor: BRAND, fontWeight: 600 },
57
+ toolbar: { display: 'flex', gap: '10px', alignItems: 'center', marginBottom: '16px', flexWrap: 'wrap' },
58
+ select: { padding: '6px 10px', borderRadius: '8px', border: '1px solid ' + border, background: layer, color: text, fontSize: '12px' },
59
+ // 真实货架
60
+ shelfUnit: { marginBottom: '24px' },
61
+ shelfSign: { display: 'inline-flex', alignItems: 'center', gap: '8px', background: layer2, padding: '5px 14px', borderRadius: '6px 6px 0 0', fontSize: '13px', fontWeight: 700, border: '1px solid ' + border, borderBottom: 'none' },
62
+ shelfBody: { border: '1px solid ' + border, borderRadius: '0 8px 8px 8px', background: 'linear-gradient(180deg,' + layer + ',' + layer2 + ')', padding: '0 16px' },
63
+ plank: { display: 'flex', flexWrap: 'wrap', gap: '18px', alignItems: 'flex-end', padding: '18px 8px 0', position: 'relative', borderBottom: '7px solid ' + WOOD, boxShadow: '0 6px 8px -4px rgba(0,0,0,.35)', marginBottom: '10px', background: 'repeating-linear-gradient(90deg,transparent,transparent 60px,rgba(0,0,0,.02) 60px,rgba(0,0,0,.02) 61px)' },
64
+ plankEdge: { position: 'absolute', left: 0, right: 0, bottom: '-7px', height: '7px', background: 'linear-gradient(180deg,' + WOOD + ',' + WOOD_DARK + ')' },
65
+ product: { width: '132px', cursor: 'pointer', display: 'flex', flexDirection: 'column', alignItems: 'center', paddingBottom: '2px' },
66
+ thumb: { width: '104px', height: '104px', borderRadius: '10px', display: 'flex', alignItems: 'center', justifyContent: 'center', fontSize: '44px', boxShadow: '0 3px 6px rgba(0,0,0,.25)', border: '1px solid rgba(255,255,255,.15)', position: 'relative' },
67
+ pName: { fontSize: '12px', fontWeight: 600, marginTop: '8px', textAlign: 'center', width: '100%', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' },
68
+ priceTag: { fontSize: '13px', fontWeight: 800, color: BRAND, marginTop: '2px' },
69
+ pMeta: { fontSize: '10px', color: sub, marginTop: '1px' },
70
+ statusDot: { position: 'absolute', top: '6px', right: '6px', width: '10px', height: '10px', borderRadius: '50%', border: '2px solid #fff' },
71
+ // 列表
72
+ table: { width: '100%', borderCollapse: 'collapse', fontSize: '12px' },
73
+ th: { textAlign: 'left', padding: '10px 12px', borderBottom: '1px solid ' + border, color: sub, fontWeight: 600, background: layer2 },
74
+ td: { padding: '10px 12px', borderBottom: '1px solid ' + border, verticalAlign: 'middle' },
75
+ badge: { display: 'inline-block', fontSize: '11px', padding: '2px 8px', borderRadius: '10px', fontWeight: 600 },
76
+ mini: { display: 'flex', alignItems: 'center', gap: '14px', padding: '6px 16px', borderTop: '1px solid ' + border, background: layer, fontSize: '12px', color: sub, cursor: 'pointer', width: '100%', boxSizing: 'border-box' },
77
+ miniNum: { fontWeight: 800, color: text, fontVariantNumeric: 'tabular-nums' },
78
+ empty: { padding: '50px', textAlign: 'center', color: sub },
79
+ overlay: { position: 'fixed', inset: 0, background: 'rgba(0,0,0,.45)', display: 'flex', alignItems: 'center', justifyContent: 'center', zIndex: 1000 },
80
+ modal: { width: '600px', maxWidth: '92vw', maxHeight: '82vh', overflowY: 'auto', background: bg, border: '1px solid ' + border, borderRadius: '12px', padding: '20px' },
81
+ drawer: { width: '440px', maxWidth: '92vw', height: '100%', background: bg, borderLeft: '1px solid ' + border, padding: '20px', overflowY: 'auto' },
82
+ input: { padding: '7px 10px', borderRadius: '8px', border: '1px solid ' + border, background: layer, color: text, fontSize: '12px', outline: 'none' },
83
+ }
84
+
85
+ async function api(path) { const r = await fetch(path); return r.json() }
86
+ async function post(path, body) { const r = await fetch(path, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body || {}) }); return r.json() }
87
+
88
+ function useData() {
89
+ const [data, setData] = useState({ projects: [], channels: [], summary: null, overview: null, gaps: [] })
90
+ const reload = useCallback(async () => {
91
+ try {
92
+ const [pj, sum, ov, gaps] = await Promise.all([api('/project-steward/api/projects'), api('/project-steward/api/summary'), api('/project-steward/api/overview'), api('/project-steward/api/market/gaps')])
93
+ setData({ projects: pj.projects || [], channels: pj.channels || [], summary: sum, overview: ov, gaps: gaps.gaps || [] })
94
+ } catch {}
95
+ }, [])
96
+ useEffect(() => { reload(); const id = setInterval(reload, 60000); return () => clearInterval(id) }, [reload])
97
+ return { data, reload }
98
+ }
99
+
100
+ const statusOf = p => { const ls = p.listings || []; if (ls.some(l => l.status === 'listed')) return 'listed'; if (ls.some(l => l.status === 'reviewing' || l.status === 'submitted')) return 'reviewing'; if (ls.some(l => l.status === 'rejected')) return 'rejected'; if (ls.some(l => l.status === 'delisted')) return 'delisted'; return 'draft' }
101
+ const Thumb = ({ p, size }) => { const m = TYPE_META[p.type] || { icon: '📦', color: '#8c8c8c' }; const st = statusOf(p); return h('div', { style: { ...T.thumb, width: size || 104, height: size || 104, background: 'linear-gradient(135deg,' + m.color + ',' + m.color + 'cc)' } }, m.icon, h('span', { style: { ...T.statusDot, background: C[st] } })) }
102
+
103
+ // ---- 店铺概况 ----
104
+ function Dashboard({ data, goShelf }) {
105
+ const t = data.summary?.totals || {}, ov = data.overview || {}
106
+ const stats = [
107
+ { label: '在售商品', value: ov.counts?.listed ?? 0, sub: (ov.counts?.listedListings ?? 0) + ' 个渠道上架', icon: '🏪', color: BRAND },
108
+ { label: '总下载量', value: fmt(t.downloads), sub: 'npm·含自动化', icon: '⬇️', color: '#5b6cff' },
109
+ { label: '总浏览量', value: fmt(t.views), icon: '👁️', color: '#0ea5e9' },
110
+ { label: '新留言', value: fmt(t.comments), icon: '💬', color: '#22a06b' },
111
+ { label: '累计收入', value: money(t.revenue), icon: '💰', color: '#f5a623' },
112
+ ]
113
+ const anomalies = ov.anomalies || []
114
+ return h('div', null,
115
+ h('div', { style: T.cards }, stats.map(s => h('div', { key: s.label, style: T.stat }, h('span', { style: T.statIcon }, s.icon), h('div', { style: { ...T.statNum, color: s.color } }, s.value), h('div', { style: T.statLabel }, s.label), s.sub ? h('div', { style: { fontSize: '10px', color: sub, marginTop: '2px' } }, s.sub) : null))),
116
+ h('div', { style: T.panel }, h('div', { style: T.panelTitle }, '⚠️ 待处理异常', anomalies.length ? h('span', { style: { ...T.badge, background: 'rgba(229,72,77,.12)', color: C.rejected } }, anomalies.length) : null),
117
+ anomalies.length === 0 ? h('div', { style: { color: sub, fontSize: '12px' } }, '一切正常,暂无异常 🎉') :
118
+ anomalies.map((a, i) => h('div', { key: i, style: { display: 'flex', gap: '8px', padding: '6px 0', borderBottom: '1px solid ' + border, fontSize: '12px' } }, h('span', { style: { color: C.rejected } }, '●'), h('span', null, { 'blocked-run': '发布阻断', 'rejected-listing': '上架被拒', 'expired-reminder': '提醒过期' }[a.kind] || a.kind), h('span', { style: { color: sub, marginLeft: 'auto' } }, a.projectId)))),
119
+ h('div', { style: T.panel }, h('div', { style: T.panelTitle }, '📦 商品分类'),
120
+ h('div', { style: { display: 'flex', gap: '12px', flexWrap: 'wrap' } }, Object.entries(ov.counts?.byType || {}).map(([type, n]) => { const m = TYPE_META[type] || { icon: '📦', label: type }; return h('div', { key: type, style: { ...T.stat, flex: '1', minWidth: '120px', cursor: 'pointer' }, onClick: goShelf }, h('div', { style: { fontSize: '22px' } }, m.icon), h('div', { style: { fontWeight: 700, marginTop: '4px' } }, m.label), h('div', { style: T.statLabel }, n + ' 件商品')) }))))
121
+ }
122
+
123
+ // ---- 真实货架视图 ----
124
+ function ShelfVisual({ projects, channels, onOpen }) {
125
+ const groups = {}
126
+ for (const p of projects) { const key = (TYPE_META[p.type] || {}).label || '其他区'; (groups[key] = groups[key] || []).push(p) }
127
+ if (!Object.keys(groups).length) return h('div', { style: T.empty }, '货架空空如也。点右上角「+ 扫描纳管」把项目摆上货架。')
128
+ return h('div', null, Object.entries(groups).map(([name, ps]) => {
129
+ const m = Object.values(TYPE_META).find(x => x.label === name) || { icon: '📦' }
130
+ // 每层货架放 6 件
131
+ const planks = []
132
+ for (let i = 0; i < ps.length; i += 6) planks.push(ps.slice(i, i + 6))
133
+ return h('div', { key: name, style: T.shelfUnit },
134
+ h('div', { style: T.shelfSign }, m.icon + ' ' + name, h('span', { style: { color: sub, fontWeight: 400, fontSize: '11px' } }, ps.length + ' 件')),
135
+ h('div', { style: T.shelfBody }, planks.map((plank, pi) => h('div', { key: pi, style: T.plank },
136
+ plank.map(p => h('div', { key: p.id, style: T.product, onClick: () => onOpen(p), title: p.name },
137
+ h(Thumb, { p }),
138
+ h('div', { style: T.pName }, p.name),
139
+ h('div', { style: T.priceTag }, money(p.metrics?.revenue)),
140
+ h('div', { style: T.pMeta }, '⬇' + fmt(p.metrics?.downloads) + ' · 👁' + fmt(p.metrics?.views)),
141
+ h('div', { style: { ...T.badge, background: (C[statusOf(p)] || C.draft) + '22', color: C[statusOf(p)] || C.draft, marginTop: '3px' } }, STATUS_LABEL[statusOf(p)]))),
142
+ h('div', { style: T.plankEdge })))))
143
+ }))
144
+ }
145
+
146
+ // ---- 列表视图(淘宝商品管理风格)----
147
+ function ListView({ projects, channels, onOpen }) {
148
+ const chName = id => (channels.find(c => c.id === id) || {}).name || id
149
+ if (!projects.length) return h('div', { style: T.empty }, '暂无商品')
150
+ return h('table', { style: T.table }, h('thead', null, h('tr', null, ['商品', '类型', '版本', '渠道', '⬇下载', '👁浏览', '💬留言', '💰收入', '状态', '操作'].map(x => h('th', { key: x, style: T.th }, x)))),
151
+ h('tbody', null, projects.map(p => { const st = statusOf(p); const m = TYPE_META[p.type] || { icon: '📦', label: p.type }; return h('tr', { key: p.id },
152
+ h('td', { style: T.td }, h('div', { style: { display: 'flex', alignItems: 'center', gap: '10px' } }, h(Thumb, { p, size: 40 }), h('span', { style: { fontWeight: 600 } }, p.name))),
153
+ h('td', { style: T.td }, m.icon + ' ' + m.label),
154
+ h('td', { style: T.td }, (p.lastRelease && p.lastRelease.version) || '—'),
155
+ h('td', { style: T.td }, (p.channels || []).map(c => chName(c.channelId)).join(', ') || '—'),
156
+ h('td', { style: T.td }, fmt(p.metrics?.downloads)),
157
+ h('td', { style: T.td }, fmt(p.metrics?.views)),
158
+ h('td', { style: T.td }, fmt(p.metrics?.comments)),
159
+ h('td', { style: { ...T.td, color: BRAND, fontWeight: 700 } }, money(p.metrics?.revenue)),
160
+ h('td', { style: T.td }, h('span', { style: { ...T.badge, background: (C[st] || C.draft) + '22', color: C[st] || C.draft } }, STATUS_LABEL[st])),
161
+ h('td', { style: T.td }, h('span', { style: { color: BRAND, cursor: 'pointer' }, onClick: () => onOpen(p) }, '管理'))) })))
162
+ }
163
+
164
+ // ---- 商品货架页 ----
165
+ function ProductsPage({ data, onOpen, onScan }) {
166
+ const [tab, setTab] = useState('all')
167
+ const [mode, setMode] = useState('shelf')
168
+ const [q, setQ] = useState('')
169
+ const [cat, setCat] = useState('all')
170
+ const all = data.projects
171
+ const counts = { all: all.length, listed: 0, reviewing: 0, draft: 0, delisted: 0, rejected: 0 }
172
+ for (const p of all) counts[statusOf(p)] = (counts[statusOf(p)] || 0) + 1
173
+ let ps = all
174
+ if (tab !== 'all') ps = ps.filter(p => tab === 'reviewing' ? (statusOf(p) === 'reviewing') : statusOf(p) === tab)
175
+ if (cat !== 'all') ps = ps.filter(p => (TYPE_META[p.type] || {}).label === cat)
176
+ if (q) ps = ps.filter(p => p.name.toLowerCase().includes(q.toLowerCase()))
177
+ const cats = [...new Set(all.map(p => (TYPE_META[p.type] || {}).label || '其他区'))]
178
+ const TABS = [['all', '全部'], ['listed', '出售中'], ['reviewing', '审核中'], ['draft', '待上架'], ['rejected', '审核拒绝'], ['delisted', '已下架']]
179
+ return h('div', null,
180
+ h('div', { style: T.tabs }, TABS.map(([k, label]) => h('div', { key: k, style: { ...T.tab, ...(tab === k ? T.tabActive : {}) }, onClick: () => setTab(k) }, label + (counts[k] ? ' ' + counts[k] : '')))),
181
+ h('div', { style: T.toolbar },
182
+ h('input', { style: { ...T.search, maxWidth: '240px' }, placeholder: '搜索商品名称…', value: q, onChange: e => setQ(e.target.value) }),
183
+ h('select', { style: T.select, value: cat, onChange: e => setCat(e.target.value) }, h('option', { value: 'all' }, '全部分类'), cats.map(c => h('option', { key: c, value: c }, c))),
184
+ h('div', { style: { marginLeft: 'auto', display: 'flex', gap: '6px' } },
185
+ h('span', { style: { ...T.btnGhost, ...(mode === 'shelf' ? { borderColor: BRAND, color: BRAND } : {}) }, onClick: () => setMode('shelf') }, '🛒 货架视图'),
186
+ h('span', { style: { ...T.btnGhost, ...(mode === 'list' ? { borderColor: BRAND, color: BRAND } : {}) }, onClick: () => setMode('list') }, '☰ 列表视图'))),
187
+ mode === 'shelf' ? h(ShelfVisual, { projects: ps, channels: data.channels, onOpen }) : h(ListView, { projects: ps, channels: data.channels, onOpen }))
188
+ }
189
+
190
+ // ---- 雷达图(多维对比形状图)----
191
+ function RadarChart({ radar }) {
192
+ if (!radar || !radar.dimensions?.length) return null
193
+ const dims = radar.dimensions, N = dims.length
194
+ const cx = 150, cy = 150, R = 105
195
+ const pt = (i, v) => { const a = (-90 + i * 360 / N) * Math.PI / 180; return [cx + v * R * Math.cos(a), cy + v * R * Math.sin(a)] }
196
+ const poly = vals => vals.map((v, i) => pt(i, Math.max(0.02, v)).join(',')).join(' ')
197
+ const grid = [0.25, 0.5, 0.75, 1].map(l => h('polygon', { key: l, points: poly(dims.map(() => l)), fill: 'none', stroke: 'var(--dsw-alias-border-l1)', strokeWidth: 1 }))
198
+ const axes = dims.map((d, i) => { const [x, y] = pt(i, 1); const [lx, ly] = pt(i, 1.18); return h('g', { key: i }, h('line', { x1: cx, y1: cy, x2: x, y2: y, stroke: 'var(--dsw-alias-border-l1)', strokeWidth: 1 }), h('text', { x: lx, y: ly, fontSize: 11, fill: 'var(--dsw-alias-label-secondary)', textAnchor: 'middle', dominantBaseline: 'middle' }, d)) })
199
+ const colors = ['#ff5000', '#5b6cff', '#22a06b', '#a855f7', '#0ea5e9', '#f5a623']
200
+ const series = (radar.series || []).slice(0, 6).map((s, si) => h('polygon', { key: si, points: poly(s.values), fill: colors[si] + (s.isMine ? '55' : '22'), stroke: colors[si], strokeWidth: s.isMine ? 2.5 : 1.5 }))
201
+ const legend = (radar.series || []).slice(0, 6).map((s, si) => h('span', { key: si, style: { display: 'inline-flex', alignItems: 'center', gap: '4px', fontSize: '11px', marginRight: '10px', fontWeight: s.isMine ? 700 : 400 } }, h('span', { style: { width: 10, height: 10, borderRadius: 2, background: colors[si], display: 'inline-block' } }), s.name + (s.isMine ? '(我的)' : '')))
202
+ return h('div', null, h('svg', { viewBox: '0 0 300 300', style: { width: '100%', maxWidth: '340px', display: 'block', margin: '0 auto' } }, grid, axes, series), h('div', { style: { textAlign: 'center', marginTop: '6px' } }, legend))
203
+ }
204
+
205
+ // ---- 功能逐项对比矩阵 ----
206
+ function FeatureMatrix({ fc }) {
207
+ if (!fc || !fc.matrix?.length) return null
208
+ const rows = fc.rows?.length ? fc.rows : Object.keys(fc.matrix[0].caps || {})
209
+ return h('table', { style: T.table },
210
+ h('thead', null, h('tr', null, h('th', { style: T.th }, '功能(按我的插件逐项)'), fc.matrix.map((m, i) => h('th', { key: i, style: { ...T.th, textAlign: 'center', color: m.isMine ? BRAND : sub, fontWeight: m.isMine ? 800 : 600 } }, m.isMine ? '★ ' + m.name : m.name)))),
211
+ h('tbody', null, rows.map(cap => h('tr', { key: cap },
212
+ h('td', { style: { ...T.td, fontWeight: 600 } }, cap),
213
+ fc.matrix.map((m, i) => h('td', { key: i, style: { ...T.td, textAlign: 'center', background: m.isMine ? BRAND_SOFT : 'transparent' } }, m.caps?.[cap] ? h('span', { style: { color: C.listed, fontWeight: 800 } }, '✓') : h('span', { style: { color: sub } }, '—')))))))
214
+ }
215
+
216
+ // ---- 市场空白表(多因子)----
217
+ function GapTable({ gaps }) {
218
+ if (!gaps.length) return h('div', { style: { color: sub, fontSize: '12px' } }, '暂无空白数据。点「刷新空白」实搜各细分市场的供给/需求/竞争。')
219
+ const head = ['细分市场', '市场供给', '需求(star)', '竞争强度', '空白分', '研判与依据']
220
+ const rows = gaps.map(g => {
221
+ const evText = g.evidence && g.evidence.length ? '头部: ' + g.evidence.slice(0, 3).map(e => e.name).join(', ') : ''
222
+ const scoreColor = g.gapScore >= 25 ? C.listed : g.gapScore >= 10 ? C.reviewing : sub
223
+ return h('tr', { key: g.id },
224
+ h('td', { style: { ...T.td, fontWeight: 600 } }, g.niche || g.category),
225
+ h('td', { style: T.td }, g.supplyCount),
226
+ h('td', { style: T.td }, g.demandSignal),
227
+ h('td', { style: T.td }, g.competition ?? '—'),
228
+ h('td', { style: { ...T.td, fontWeight: 800, color: scoreColor } }, g.gapScore),
229
+ h('td', { style: { ...T.td, fontSize: '11px' } }, g.opportunity, evText ? h('div', { style: { color: sub, marginTop: '2px' } }, evText) : null))
230
+ })
231
+ return h('div', null,
232
+ h('div', { style: { fontSize: '11px', color: sub, marginBottom: '8px' } }, '多因子研判:空白分 = 需求强度 × 供给稀缺度 × 竞争弱度(实搜 npm+GitHub,非简单比值)。头部产品 star 为需求代理。'),
233
+ h('table', { style: T.table }, h('thead', null, h('tr', null, head.map(x => h('th', { key: x, style: T.th }, x)))), h('tbody', null, rows)))
234
+ }
235
+
236
+ // ---- 市场情报(竞品对比 + 市场空白)----
237
+ function MarketPage({ data, reload }) {
238
+ const projects = data.projects || []
239
+ const [pid, setPid] = useState(projects[0]?.id || '')
240
+ const [report, setReport] = useState(null)
241
+ const [busy, setBusy] = useState(false)
242
+ const gaps = data.gaps || []
243
+ useEffect(() => { if (pid) api('/project-steward/api/market/report?id=' + encodeURIComponent(pid)).then(j => setReport(j.report)).catch(() => {}) }, [pid])
244
+ const scan = async () => { if (!pid) return; setBusy(true); try { await post('/project-steward/api/market/scan', { projectId: pid }); const j = await api('/project-steward/api/market/report?id=' + encodeURIComponent(pid)); setReport(j.report); await post('/project-steward/api/market/gaps', {}); await reload() } finally { setBusy(false) } }
245
+ const vl = { 'worth-continuing': ['🟢 值得继续', C.listed], 'needs-differentiation': ['🟡 需差异化', C.reviewing], 'red-ocean-caution': ['🔴 红海慎入', C.rejected] }
246
+ const scanGaps = async () => { setBusy(true); try { await post('/project-steward/api/market/gaps', {}); await reload() } finally { setBusy(false) } }
247
+ return h('div', null,
248
+ h('div', { style: T.panel },
249
+ h('div', { style: T.panelTitle }, '🔍 竞品扫描对比',
250
+ h('select', { style: { ...T.select, marginLeft: 'auto' }, value: pid, onChange: e => setPid(e.target.value) }, projects.map(p => h('option', { key: p.id, value: p.id }, p.name))),
251
+ h('span', { style: T.btn, onClick: scan }, busy ? '扫描中…' : '扫描对比竞品')),
252
+ !report ? h('div', { style: { color: sub, fontSize: '12px', padding: '12px 0' } }, projects.length ? '选择商品后点「扫描对比竞品」,发现同类并研判比较优势。' : '请先纳管项目。') :
253
+ h('div', null,
254
+ h('div', { style: { display: 'flex', alignItems: 'center', gap: '12px', marginBottom: '12px' } },
255
+ h('span', { style: { ...T.badge, fontSize: '14px', padding: '4px 12px', background: (vl[report.verdict]?.[1] || C.draft) + '22', color: vl[report.verdict]?.[1] || C.draft } }, vl[report.verdict]?.[0] || report.verdict),
256
+ h('span', { style: { fontSize: '12px', color: sub } }, '对比 ' + (report.competitors?.length || 0) + ' 个同类竞品'),
257
+ h('span', { style: { fontSize: '11px', color: sub, marginLeft: 'auto' } }, '生成于 ' + (report.generatedAt || '').slice(0, 16).replace('T', ' '))),
258
+ h('div', { style: { fontSize: '12px', color: sub, marginBottom: '12px' } }, report.summary),
259
+ (report.strengths?.length || report.weaknesses?.length) ? h('div', { style: { display: 'flex', gap: '16px', marginBottom: '12px', flexWrap: 'wrap' } },
260
+ report.strengths?.length ? h('div', { style: { flex: 1, minWidth: '200px' } }, h('div', { style: { fontWeight: 600, color: C.listed, fontSize: '12px', marginBottom: '4px' } }, '✓ 优势'), report.strengths.map((s, i) => h('div', { key: i, style: { fontSize: '12px', padding: '2px 0' } }, '· ' + s))) : null,
261
+ report.weaknesses?.length ? h('div', { style: { flex: 1, minWidth: '200px' } }, h('div', { style: { fontWeight: 600, color: C.rejected, fontSize: '12px', marginBottom: '4px' } }, '✗ 短板'), report.weaknesses.map((s, i) => h('div', { key: i, style: { fontSize: '12px', padding: '2px 0' } }, '· ' + s))) : null) : null,
262
+ report.featureComparison?.radar ? h('div', { style: { marginBottom: '16px' } }, h('div', { style: { fontWeight: 600, fontSize: '12px', marginBottom: '6px' } }, '🕸️ 多维对比雷达图(我的项目 vs 竞品)'), h(RadarChart, { radar: report.featureComparison.radar })) : null,
263
+ report.featureComparison?.matrix?.length ? h('div', { style: { marginBottom: '16px', overflowX: 'auto' } }, h('div', { style: { fontWeight: 600, fontSize: '12px', marginBottom: '6px' } }, '📋 功能逐项对比(✓ 具备 / — 未识别)'), h(FeatureMatrix, { fc: report.featureComparison })) : null,
264
+ h('div', { style: { fontWeight: 600, fontSize: '12px', marginBottom: '6px' } }, '同类竞品(' + (report.competitors?.length || 0) + ')'),
265
+ h('table', { style: T.table }, h('thead', null, h('tr', null, ['竞品', '⭐star', '⬇下载/fork', '最近更新', '链接'].map(x => h('th', { key: x, style: T.th }, x)))),
266
+ h('tbody', null, (report.competitors || []).slice(0, 20).map(c => h('tr', { key: c.id },
267
+ h('td', { style: { ...T.td, fontWeight: 600 } }, c.name),
268
+ h('td', { style: T.td }, c.stars ?? '—'),
269
+ h('td', { style: T.td }, c.downloads ?? '—'),
270
+ h('td', { style: T.td }, (c.lastUpdate || '').slice(0, 10) || '—'),
271
+ h('td', { style: T.td }, h('a', { href: c.url, target: '_blank', rel: 'noreferrer', style: { color: BRAND, fontSize: '11px' } }, '打开')))))))),
272
+ h('div', { style: T.panel }, h('div', { style: T.panelTitle }, '📊 市场空白机会', h('span', { style: { ...T.btnGhost, marginLeft: 'auto' }, onClick: scanGaps }, '刷新空白')),
273
+ h(GapTable, { gaps })))
274
+ }
275
+
276
+ // ---- 渠道管理 ----
277
+ function ChannelsPage({ data }) {
278
+ const chs = data.channels || []
279
+ return h('div', { style: T.panel }, h('div', { style: T.panelTitle }, '🔌 发布渠道(' + chs.length + ')'),
280
+ h('table', { style: T.table }, h('thead', null, h('tr', null, ['渠道', '类别', '状态', '适用类型', '只读保护'].map(x => h('th', { key: x, style: T.th }, x)))),
281
+ h('tbody', null, chs.map(c => h('tr', { key: c.id }, h('td', { style: { ...T.td, fontWeight: 600 } }, c.name), h('td', { style: T.td }, c.category), h('td', { style: T.td }, h('span', { style: { ...T.badge, background: c.status === 'active' ? 'rgba(34,160,107,.12)' : layer2, color: c.status === 'active' ? C.listed : sub } }, c.status)), h('td', { style: T.td }, (c.appliesToTypes || []).join(', ') || '—'), h('td', { style: T.td }, c.readOnly ? '🔒 是' : '—'))))))
282
+ }
283
+
284
+ // ---- 扫描纳管对话框 ----
285
+ function ScanDialog({ onClose, onDone }) {
286
+ const [roots, setRoots] = useState('')
287
+ const [candidates, setCandidates] = useState(null)
288
+ const [selected, setSelected] = useState({})
289
+ const [busy, setBusy] = useState(false)
290
+ const [msg, setMsg] = useState('')
291
+ const scan = async () => { if (!roots.trim()) { setMsg('请先输入要扫描的本地目录'); return } setBusy(true); setMsg(''); try { const j = await post('/project-steward/api/scan', { roots: roots.split(/[;,]/).map(s => s.trim()).filter(Boolean) }); if (j.ok) { setCandidates(j.candidates); const sel = {}; j.candidates.forEach(c => { if (!c.alreadyRegistered) sel[c.rootPath] = true }); setSelected(sel) } else setMsg(j.error?.message || '扫描失败') } catch (e) { setMsg(String(e)) } finally { setBusy(false) } }
292
+ const register = async () => { setBusy(true); setMsg(''); const chosen = (candidates || []).filter(c => selected[c.rootPath]); let ok = 0, fail = 0; for (const c of chosen) { try { const j = await post('/project-steward/api/register', { name: c.name, rootPath: c.rootPath, type: c.suggestedType }); if (j.ok) ok++; else fail++ } catch { fail++ } } setMsg(`纳管完成:成功 ${ok}${fail ? ',失败 ' + fail : ''}`); await onDone(); setBusy(false) }
293
+ return h('div', { style: T.overlay, onClick: onClose }, h('div', { style: T.modal, onClick: e => e.stopPropagation() },
294
+ h('div', { style: { fontWeight: 700, fontSize: '16px', marginBottom: '6px' } }, '+ 纳管本地项目(货源)'),
295
+ h('div', { style: { fontSize: '12px', color: sub, marginBottom: '12px' } }, '扫描你指定的本地目录,找出项目登记成商品。发布渠道(npm/itch/GitHub 等平台)在左侧「发布渠道」页管理,与此无关。'),
296
+ h('div', { style: { display: 'flex', gap: '8px', marginBottom: '12px' } }, h('input', { style: { ...T.input, flex: 1 }, value: roots, onChange: e => setRoots(e.target.value), placeholder: '输入要扫描的本地目录,如 E:\\游戏(多个用逗号分隔)' }), h('span', { style: T.btn, onClick: scan }, busy ? '扫描中…' : '扫描')),
297
+ msg ? h('div', { style: { fontSize: '12px', color: sub, marginBottom: '8px' } }, msg) : null,
298
+ candidates ? (candidates.length === 0 ? h('div', { style: T.empty }, '未发现候选项目') : h('div', null, candidates.map(c => h('label', { key: c.rootPath, style: { display: 'flex', alignItems: 'center', gap: '10px', padding: '8px 4px', borderBottom: '1px solid ' + border, fontSize: '12px', opacity: c.alreadyRegistered ? 0.5 : 1 } }, h('input', { type: 'checkbox', checked: !!selected[c.rootPath], disabled: c.alreadyRegistered, onChange: e => setSelected({ ...selected, [c.rootPath]: e.target.checked }) }), h('span', { style: { fontWeight: 600 } }, c.name), h('span', { style: { ...T.badge, background: BRAND_SOFT, color: BRAND } }, c.suggestedType), h('span', { style: { fontSize: '11px', color: sub, marginLeft: 'auto' } }, c.alreadyRegistered ? '已纳管' : c.rootPath))))) : h('div', { style: { fontSize: '12px', color: sub } }, '输入目录后点「扫描」,勾选要纳管的项目。'),
299
+ h('div', { style: { display: 'flex', gap: '8px', marginTop: '16px', justifyContent: 'flex-end' } }, h('span', { style: T.btnGhost, onClick: onClose }, '关闭'), candidates && candidates.some(c => selected[c.rootPath]) ? h('span', { style: T.btn, onClick: register }, busy ? '纳管中…' : '纳管选中') : null)))
300
+ }
301
+
302
+ // ---- 商品详情抽屉 ----
303
+ function DetailDrawer({ p, onClose }) {
304
+ const [detail, setDetail] = useState(null)
305
+ useEffect(() => { api('/project-steward/api/project?id=' + encodeURIComponent(p.id)).then(setDetail).catch(() => {}) }, [p.id])
306
+ const vl = { 'worth-continuing': '🟢 值得继续', 'needs-differentiation': '🟡 需差异化', 'red-ocean-caution': '🔴 红海慎入' }
307
+ const st = statusOf(p)
308
+ return h('div', { style: { ...T.overlay, justifyContent: 'flex-end' }, onClick: onClose }, h('div', { style: T.drawer, onClick: e => e.stopPropagation() },
309
+ h('div', { style: { display: 'flex', gap: '12px', alignItems: 'center', marginBottom: '16px' } }, h(Thumb, { p, size: 56 }), h('div', null, h('div', { style: { fontWeight: 700, fontSize: '16px' } }, p.name), h('div', { style: { fontSize: '12px', color: sub } }, (TYPE_META[p.type] || {}).label + ' · ' + ((p.lastRelease && p.lastRelease.version) || '未发布'))), h('span', { style: { ...T.btnGhost, marginLeft: 'auto' }, onClick: onClose }, '✕')),
310
+ h('div', { style: { ...T.badge, background: (C[st] || C.draft) + '22', color: C[st] || C.draft, marginBottom: '16px' } }, STATUS_LABEL[st]),
311
+ !detail ? h('div', { style: T.empty }, '加载中…') : h('div', null,
312
+ h('div', { style: T.panelTitle }, '上架渠道'), detail.listings.length ? detail.listings.map(l => h('div', { key: l.id, style: { fontSize: '12px', padding: '4px 0' } }, l.channelId + ' · ' + (STATUS_LABEL[l.status] || l.status))) : h('div', { style: { fontSize: '12px', color: sub } }, '尚未上架'),
313
+ h('div', { style: T.panelTitle }, '发布记录'), detail.runs.length ? detail.runs.map(r => h('div', { key: r.id, style: { fontSize: '12px', padding: '4px 0' } }, r.version + ' · ' + r.status)) : h('div', { style: { fontSize: '12px', color: sub } }, '暂无发布 run'),
314
+ h('div', { style: T.panelTitle }, '竞品研判'), detail.marketReport ? h('div', null, h('div', { style: { fontWeight: 700 } }, vl[detail.marketReport.verdict] || detail.marketReport.verdict), h('div', { style: { fontSize: '12px', color: sub, marginTop: '4px' } }, detail.marketReport.summary)) : h('div', { style: { fontSize: '12px', color: sub } }, '尚未扫描竞品'),
315
+ h('div', { style: T.panelTitle }, '最近事件'), detail.events.slice(0, 8).map(e => h('div', { key: e.id, style: { fontSize: '11px', padding: '3px 0', color: sub } }, e.kind + ' · ' + e.text)))))
316
+ }
317
+
318
+ // ---- 设置页 ----
319
+ function SettingsPage({ data }) {
320
+ const rows = [
321
+ ['台账数据目录', 'E:\\项目管家\\data'],
322
+ ['定时采集间隔', '60 分钟(R13)'],
323
+ ['发布说明硬门禁', '✅ 启用(FR2.9:README+CHANGELOG 必备,缺失阻断发布)'],
324
+ ['谨慎模式 confirmGates', '关闭(全自动 R8;G3/G4 仍需确认)'],
325
+ ['常驻方式', 'conversation.view「店铺」页签(迷你条已移除 R25)'],
326
+ ['生产实例保护', '阿里云货运险 readOnly(R6,禁止写操作)'],
327
+ ['发布渠道数', (data.channels || []).length + ' 个'],
328
+ ['纳管商品数', (data.projects || []).length + ' 件'],
329
+ ]
330
+ return h('div', null,
331
+ h('div', { style: T.panel }, h('div', { style: T.panelTitle }, '⚙️ 店铺设置'),
332
+ h('table', { style: T.table }, h('tbody', null, rows.map(([k, v]) => h('tr', { key: k }, h('td', { style: { ...T.td, fontWeight: 600, width: '200px' } }, k), h('td', { style: T.td }, v)))))),
333
+ h('div', { style: T.panel }, h('div', { style: T.panelTitle }, '🔒 危险动作确认(G3/G4)'),
334
+ h('div', { style: { fontSize: '12px', color: sub } }, '下架(delisted)、归档、豁免阻断、渠道软删除等不可逆动作需显式确认并填写理由,任何配置不可关闭此闸门。')))
335
+ }
336
+
337
+ // ---- 通用确认浮层(G3/G4)----
338
+ function ConfirmDialog({ title, detail, requireReason, onConfirm, onCancel }) {
339
+ const [reason, setReason] = useState('')
340
+ return h('div', { style: T.overlay, onClick: onCancel }, h('div', { style: { ...T.modal, width: '440px' }, onClick: e => e.stopPropagation() },
341
+ h('div', { style: { fontWeight: 700, fontSize: '15px', color: C.rejected, marginBottom: '10px' } }, '⚠️ ' + title),
342
+ h('div', { style: { fontSize: '12px', color: sub, marginBottom: '12px' } }, detail),
343
+ requireReason ? h('input', { style: { ...T.input, width: '100%', boxSizing: 'border-box', marginBottom: '12px' }, placeholder: '必填理由(G4)', value: reason, onChange: e => setReason(e.target.value) }) : null,
344
+ h('div', { style: { display: 'flex', gap: '8px', justifyContent: 'flex-end' } },
345
+ h('span', { style: T.btnGhost, onClick: onCancel }, '取消'),
346
+ h('span', { style: { ...T.btn, background: C.rejected, opacity: requireReason && !reason.trim() ? 0.5 : 1 }, onClick: () => { if (!requireReason || reason.trim()) onConfirm(reason) } }, '确认执行'))))
347
+ }
348
+
349
+ // ---- 从发布渠道导入对话框(扫描平台,不扫本地)----
350
+ function ChannelImportDialog({ onClose, onDone }) {
351
+ const [candidates, setCandidates] = useState(null)
352
+ const [selected, setSelected] = useState({})
353
+ const [busy, setBusy] = useState(false)
354
+ const [msg, setMsg] = useState('')
355
+ const scan = async () => { setBusy(true); setMsg(''); try { const j = await post('/project-steward/api/channel/scan', {}); if (j.ok) { setCandidates(j.candidates); const sel = {}; j.candidates.forEach(c => { if (!c.alreadyRegistered) sel[c.url] = true }); setSelected(sel) } else setMsg(j.error?.message || '扫描失败') } catch (e) { setMsg(String(e)) } finally { setBusy(false) } }
356
+ const doImport = async () => { setBusy(true); setMsg(''); const chosen = (candidates || []).filter(c => selected[c.url]); let ok = 0, fail = 0; for (const c of chosen) { try { const j = await post('/project-steward/api/channel/import', { candidate: c }); if (j.ok) ok++; else fail++ } catch { fail++ } } setMsg(`导入完成:成功 ${ok}${fail ? ',失败 ' + fail : ''}`); await onDone(); setBusy(false) }
357
+ const srcLabel = { npm: 'npm', github: 'GitHub' }
358
+ return h('div', { style: T.overlay, onClick: onClose }, h('div', { style: T.modal, onClick: e => e.stopPropagation() },
359
+ h('div', { style: { fontWeight: 700, fontSize: '16px', marginBottom: '6px' } }, '🔌 从发布渠道导入商品'),
360
+ h('div', { style: { fontSize: '12px', color: sub, marginBottom: '12px' } }, '扫描你的发布渠道账号(npm/GitHub),发现已上架的商品直接导入货架——不需要选本地文件。'),
361
+ h('div', { style: { marginBottom: '12px' } }, h('span', { style: T.btn, onClick: scan }, busy ? '扫描渠道中…' : '扫描发布渠道')),
362
+ msg ? h('div', { style: { fontSize: '12px', color: sub, marginBottom: '8px' } }, msg) : null,
363
+ candidates ? (candidates.length === 0 ? h('div', { style: T.empty }, '渠道上未发现商品') : h('div', { style: { maxHeight: '40vh', overflowY: 'auto' } }, candidates.map(c => h('label', { key: c.url, style: { display: 'flex', alignItems: 'center', gap: '10px', padding: '8px 4px', borderBottom: '1px solid ' + border, fontSize: '12px', opacity: c.alreadyRegistered ? 0.5 : 1 } }, h('input', { type: 'checkbox', checked: !!selected[c.url], disabled: c.alreadyRegistered, onChange: e => setSelected({ ...selected, [c.url]: e.target.checked }) }), h('span', { style: { ...T.badge, background: BRAND_SOFT, color: BRAND } }, srcLabel[c.source] || c.source), h('span', { style: { fontWeight: 600 } }, c.name), c.version ? h('span', { style: { color: sub } }, 'v' + c.version) : null, h('span', { style: { fontSize: '11px', color: sub, marginLeft: 'auto' } }, c.alreadyRegistered ? '已纳管' : (c.localRoot ? '有本地源' : '仅远程')))))) : h('div', { style: { fontSize: '12px', color: sub } }, '点「扫描发布渠道」发现你在 npm/GitHub 上已发布的商品。'),
364
+ h('div', { style: { display: 'flex', gap: '8px', marginTop: '16px', justifyContent: 'flex-end' } }, h('span', { style: T.btnGhost, onClick: onClose }, '关闭'), candidates && candidates.some(c => selected[c.url]) ? h('span', { style: T.btn, onClick: doImport }, busy ? '导入中…' : '导入选中') : null)))
365
+ }
366
+
367
+ // ---- 主页面 ----
368
+ function ShelfPage() {
369
+ const { data, reload } = useData()
370
+ const [page, setPage] = useState('dashboard')
371
+ const [open, setOpen] = useState(null)
372
+ const [scanOpen, setScanOpen] = useState(false)
373
+ const [chImportOpen, setChImportOpen] = useState(false)
374
+ const NAV = [['dashboard', '🏬', '店铺概况'], ['products', '🛒', '商品货架'], ['market', '📊', '市场情报'], ['channels', '🔌', '发布渠道'], ['settings', '⚙️', '设置']]
375
+ const titles = { dashboard: '店铺概况', products: '商品货架', market: '市场情报', channels: '发布渠道', settings: '设置' }
376
+ return h('div', { style: T.app },
377
+ h('div', { style: T.side },
378
+ h('div', { style: T.shop }, h('div', { style: T.shopAvatar }, '🏪'), h('div', null, h('div', { style: { fontWeight: 700, fontSize: '14px' } }, '我的店铺'), h('div', { style: { fontSize: '11px', color: sub } }, '项目管家'))),
379
+ NAV.map(([k, icon, label]) => h('div', { key: k, style: { ...T.navItem, ...(page === k ? { background: BRAND_SOFT, color: BRAND, fontWeight: 700 } : {}) }, onClick: () => setPage(k) }, h('span', null, icon), label)),
380
+ h('div', { style: { ...T.navItem, marginTop: 'auto', color: sub }, onClick: reload }, '⟳ 刷新数据')),
381
+ h('div', { style: T.body },
382
+ h('div', { style: T.header }, h('span', { style: T.hTitle }, titles[page]), h('input', { style: T.search, placeholder: '搜索商品…(商品货架页可用)' }), h('span', { style: { ...T.btn, marginLeft: 'auto' }, onClick: () => setChImportOpen(true) }, '🔌 从发布渠道导入'), h('span', { style: T.btnGhost, onClick: () => setScanOpen(true) }, '纳管本地项目')),
383
+ h('div', { style: T.content },
384
+ page === 'dashboard' ? h(Dashboard, { data, goShelf: () => setPage('products') }) :
385
+ page === 'products' ? h(ProductsPage, { data, onOpen: setOpen, onScan: () => setScanOpen(true) }) :
386
+ page === 'market' ? h(MarketPage, { data, reload }) :
387
+ page === 'settings' ? h(SettingsPage, { data }) : h(ChannelsPage, { data }))),
388
+ open ? h(DetailDrawer, { p: open, onClose: () => setOpen(null) }) : null,
389
+ scanOpen ? h(ScanDialog, { onClose: () => setScanOpen(false), onDone: reload }) : null,
390
+ chImportOpen ? h(ChannelImportDialog, { onClose: () => setChImportOpen(false), onDone: reload }) : null)
391
+ }
392
+
393
+ function MiniBar({ ctx }) {
394
+ const [sum, setSum] = useState(null), [ov, setOv] = useState(null)
395
+ useEffect(() => { const load = async () => { try { setSum(await api('/project-steward/api/summary')); setOv(await api('/project-steward/api/overview')) } catch {} }; load(); const id = setInterval(load, 60000); return () => clearInterval(id) }, [])
396
+ const t = sum?.totals || {}, anomalies = (ov?.anomalies || []).length
397
+ const go = () => { try { ctx.layout.selectPanel('steward') } catch {} }
398
+ return h('div', { style: T.mini, onClick: go, title: '点击打开项目管家店铺' },
399
+ h('span', { style: { color: BRAND, fontWeight: 700 } }, '🏪 我的店铺'),
400
+ h('span', null, '在售'), h('span', { style: T.miniNum }, ov?.counts?.listed ?? 0),
401
+ h('span', null, '⬇'), h('span', { style: T.miniNum }, fmt(t.downloads)),
402
+ h('span', null, '👁'), h('span', { style: T.miniNum }, fmt(t.views)),
403
+ h('span', null, '💬'), h('span', { style: T.miniNum }, fmt(t.comments)),
404
+ h('span', null, '💰'), h('span', { style: { ...T.miniNum, color: BRAND } }, money(t.revenue)),
405
+ anomalies ? h('span', { style: { color: C.rejected, fontWeight: 800 } }, '⚠️' + anomalies) : null,
406
+ h('span', { style: { marginLeft: 'auto', color: BRAND } }, '进入店铺 →'))
407
+ }
408
+
409
+ return {
410
+ inject: ['slots', 'layout'],
411
+ apply(ctx) {
412
+ // 常驻方式与看板插件一致:注册 conversation.view 视图页签(不再用 input.dock 迷你条)
413
+ ctx.slots.inject('conversation.view', () => ctx.slots.register({ name: 'conversation.view', id: 'steward-shelf', order: 0, label: () => '店铺' }, ShelfPage))
414
+ },
415
+ }
416
+ },
417
+ })
@@ -0,0 +1,7 @@
1
+ - insert:
2
+ - id: project-steward
3
+ name: '@local/dsh-project-steward'
4
+ config:
5
+ dataDir: 'E:\项目管家\data'
6
+ collectIntervalMinutes: 60
7
+ confirmGates: false
Binary file
Binary file
Binary file
package/icon.svg ADDED
@@ -0,0 +1,14 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" font-family="Segoe UI, sans-serif">
2
+ <defs><linearGradient id="g" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="#ff6a00"/><stop offset="1" stop-color="#ffa028"/></linearGradient></defs>
3
+ <rect width="256" height="256" rx="56" fill="url(#g)"/>
4
+ <circle cx="200" cy="56" r="60" fill="#ffffff" opacity="0.08"/>
5
+ <g>
6
+ <rect x="60.8" y="100" width="134.4" height="83.2" rx="8" fill="#ffffff" opacity="0.92"/>
7
+ <path d="M 54.4 100 L 67.2 68 L 188.8 68 L 201.6 100 Z" fill="#ffffff"/>
8
+ <path d="M 54.4 100 q 12.32 19.2 24.64 0 q 12.32 19.2 24.64 0 q 12.32 19.2 24.64 0 q 12.32 19.2 24.64 0 q 12.32 19.2 24.64 0 q 12.32 19.2 24.64 0" fill="#ffd166"/>
9
+ <rect x="73.6" y="122.4" width="32" height="25.6" rx="3.2" fill="#ffd166"/>
10
+ <rect x="112" y="122.4" width="32" height="25.6" rx="3.2" fill="#cbd5e1"/>
11
+ <rect x="150.4" y="122.4" width="32" height="48" rx="3.2" fill="#94a3b8"/>
12
+ <rect x="73.6" y="154.4" width="70.4" height="16" rx="3.2" fill="#e2e8f0"/>
13
+ </g>
14
+ </svg>