@cobola/dsh-geo 0.0.0-stage → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/publish.yml +65 -0
- package/CHANGELOG.md +27 -0
- package/CONTRIBUTING.md +86 -0
- package/LICENSE +176 -0
- package/NOTICE +14 -0
- package/README.md +228 -2
- package/SECURITY.md +46 -0
- package/bin/dsh-geo.js +381 -0
- package/client.js +707 -0
- package/cordis.patch.yml +4 -0
- package/docs/.nojekyll +0 -0
- package/docs/CI.md +118 -0
- package/docs/GOOGLE.md +57 -0
- package/docs/NPM-TRUSTED-PUBLISHING.md +69 -0
- package/docs/PROFILES.md +51 -0
- package/docs/RULES.md +108 -0
- package/docs/icons/geo.svg +8 -0
- package/docs/index.json +41 -0
- package/icon.svg +8 -0
- package/index.js +381 -0
- package/lib/audit.js +62 -0
- package/lib/fetch.js +650 -0
- package/lib/html.js +651 -0
- package/lib/platforms/bing.js +95 -0
- package/lib/platforms/index.js +70 -0
- package/lib/profiles.js +62 -0
- package/lib/report.js +404 -0
- package/lib/robots.js +209 -0
- package/lib/rules.js +939 -0
- package/lib/scan.js +604 -0
- package/lib/score.js +145 -0
- package/lib/store.js +283 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +77 -4
package/client.js
ADDED
|
@@ -0,0 +1,707 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser half of dsh-geo: a Settings section that edits the plugin's live
|
|
3
|
+
* defaults (crawl budget, robots policy, rate/size limits, report directory).
|
|
4
|
+
*
|
|
5
|
+
* Hand-written lazy factory in the client module format. It uses only React
|
|
6
|
+
* from the page module table, the host theme tokens, and the generic
|
|
7
|
+
* `ctx.remote.settings` form service — no Harness client package imports.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
window.__ModuleLoader__.load({
|
|
11
|
+
id: '@cobola/dsh-geo',
|
|
12
|
+
factory(require) {
|
|
13
|
+
const React = require('react');
|
|
14
|
+
const h = React.createElement;
|
|
15
|
+
|
|
16
|
+
const NS = 'dsh-geo';
|
|
17
|
+
const TOOLS = 'geo_scan / geo_fix_plan';
|
|
18
|
+
|
|
19
|
+
const DICT = {
|
|
20
|
+
zh: {
|
|
21
|
+
nav: '网站可见性体检',
|
|
22
|
+
title: '网站可见性体检设置',
|
|
23
|
+
lede: '这些设置控制扫描范围、安全边界、速度和报告位置;不改变评分规则。geo_fix_plan 会跟随报告目录。改动立即生效。',
|
|
24
|
+
tools: '可用工具',
|
|
25
|
+
toolsHint: '在对话里让 agent 扫描站点、生成修复清单,改完代码后再扫一次对比分数。报告写入工作区里配置的报告目录(默认 .dsh-geo/)。',
|
|
26
|
+
crawl: '抓取',
|
|
27
|
+
maxPages: '抓取页数上限',
|
|
28
|
+
maxPagesHint: '1–50,默认 6。页数越多耗时越长,不会让分数自动变高。',
|
|
29
|
+
respectRobots: '遵守 robots.txt',
|
|
30
|
+
respectRobotsHint: '默认开启。关闭只适用于你自己拥有、且确认可以绕过 robots 的站点。',
|
|
31
|
+
rateLimitMs: '同主机请求间隔(毫秒)',
|
|
32
|
+
rateLimitMsHint: '默认 250。robots.txt 的 Crawl-delay 只会把间隔调大(上限 5 秒)。',
|
|
33
|
+
timeoutMs: '单请求超时(毫秒)',
|
|
34
|
+
timeoutMsHint: '默认 10000。这是单个请求的整体截止时间(含慢速正文),不是整次扫描的上限。',
|
|
35
|
+
maxBytes: '单响应体积上限(字节)',
|
|
36
|
+
maxBytesHint: '默认 1500000(约 1.5 MB)。超出会截断并标记 truncated。',
|
|
37
|
+
reportDir: '报告目录',
|
|
38
|
+
reportDirHint: '相对工作区,必须位于 .dsh-geo/ 内。默认 .dsh-geo。',
|
|
39
|
+
targets: '目标范围',
|
|
40
|
+
permitPrivate: '允许本机 / 私网目标',
|
|
41
|
+
permitPrivateHint: '默认关闭。开启后,工具调用仍需显式传入 allow_private,才会扫描回环或私网地址。',
|
|
42
|
+
permitPrivateWarning: '仅对你自己拥有的开发/预发站点开启;云元数据地址始终拒绝。',
|
|
43
|
+
save: '保存设置',
|
|
44
|
+
saving: '保存中…',
|
|
45
|
+
loading: '读取中…',
|
|
46
|
+
saved: '已保存。下一次工具调用会使用新设置。',
|
|
47
|
+
invalidNumber: '请填写有效数字(范围见提示)。',
|
|
48
|
+
invalidDir: '报告目录必须是 .dsh-geo 或 .dsh-geo/ 下的子目录。',
|
|
49
|
+
noChanges: '没有需要保存的改动。',
|
|
50
|
+
conflictReloaded: '设置已在别处被修改,已重新读取最新值;请确认后再次保存。',
|
|
51
|
+
reload: '重新读取',
|
|
52
|
+
readOnly: '当前配置文件不接受写入,设置只能通过 cordis.patch.yml 修改。',
|
|
53
|
+
loadError: '读取设置失败',
|
|
54
|
+
saveError: '保存失败',
|
|
55
|
+
unavailable: '设置服务不可用,无法在面板中修改。',
|
|
56
|
+
badge: '可复现规则评分 · 不预测排名',
|
|
57
|
+
navDashboard: '可见性效果看板',
|
|
58
|
+
dashTitle: '可见性效果看板',
|
|
59
|
+
dashLede: '基于本地 .dsh-geo/ 历史:总分趋势、五维变化、修复与回归。这里不是 GSC / Perplexity 流量数据,流量请用 Search Console。',
|
|
60
|
+
dashScore: '总分',
|
|
61
|
+
dashDelta: '较上次',
|
|
62
|
+
dashDimensions: '五维',
|
|
63
|
+
dashTrend: '分数趋势',
|
|
64
|
+
dashRecent: '最近扫描',
|
|
65
|
+
dashFixed: '已修复',
|
|
66
|
+
dashRegressed: '回归',
|
|
67
|
+
dashStill: '仍未通过',
|
|
68
|
+
dashActions: '优先修复',
|
|
69
|
+
dashEmpty: '还没有体检记录',
|
|
70
|
+
dashEmptyHint: '在会话里让 agent 运行 geo_scan,或执行 dsh-geo scan --save;之后这里会显示分数趋势与五维变化。',
|
|
71
|
+
dashNoSession: '没有可用的会话工作区',
|
|
72
|
+
dashNoSessionHint: '先打开一个会话,在其中运行 geo_scan。',
|
|
73
|
+
dashError: '读取看板失败',
|
|
74
|
+
dashRefresh: '刷新',
|
|
75
|
+
dashWorkspace: '工作区',
|
|
76
|
+
dashUpdated: '更新于',
|
|
77
|
+
dashNoData: '暂无数据',
|
|
78
|
+
dashScans: '次扫描',
|
|
79
|
+
dashPlatforms: '平台适配(参考,不计入总分)',
|
|
80
|
+
},
|
|
81
|
+
en: {
|
|
82
|
+
nav: 'Website visibility audit',
|
|
83
|
+
title: 'Website visibility audit settings',
|
|
84
|
+
lede: 'These settings control scan scope, safety, speed, and report location; they do not change the rubric. geo_fix_plan follows the report directory.',
|
|
85
|
+
tools: 'Tools',
|
|
86
|
+
toolsHint: 'Ask the agent to audit a site, generate a fix plan, then audit again after the code changes. Reports live in the configured report directory (default .dsh-geo/).',
|
|
87
|
+
crawl: 'Crawl',
|
|
88
|
+
maxPages: 'Page budget',
|
|
89
|
+
maxPagesHint: '1–50, default 6. More pages take longer; this does not improve a score by itself.',
|
|
90
|
+
respectRobots: 'Respect robots.txt',
|
|
91
|
+
respectRobotsHint: 'On by default. Turn it off only for sites you own where you have confirmed the audit may bypass robots.',
|
|
92
|
+
rateLimitMs: 'Per-host request interval (ms)',
|
|
93
|
+
rateLimitMsHint: 'Default 250. A robots.txt Crawl-delay can only widen the interval (capped at 5s).',
|
|
94
|
+
timeoutMs: 'Per-request timeout (ms)',
|
|
95
|
+
timeoutMsHint: 'Default 10000. This bounds one request (including a slow body), not the whole scan.',
|
|
96
|
+
maxBytes: 'Response size cap (bytes)',
|
|
97
|
+
maxBytesHint: 'Default 1500000 (~1.5 MB). Larger bodies are truncated and marked truncated.',
|
|
98
|
+
reportDir: 'Report directory',
|
|
99
|
+
reportDirHint: 'Relative to the workspace and confined to .dsh-geo/. Default .dsh-geo.',
|
|
100
|
+
targets: 'Target scope',
|
|
101
|
+
permitPrivate: 'Allow loopback / private targets',
|
|
102
|
+
permitPrivateHint: 'Off by default. Even when on, a tool call must pass allow_private explicitly.',
|
|
103
|
+
permitPrivateWarning: 'Enable only for development/staging sites you own; cloud metadata stays blocked.',
|
|
104
|
+
save: 'Save',
|
|
105
|
+
saving: 'Saving…',
|
|
106
|
+
loading: 'Loading…',
|
|
107
|
+
saved: 'Saved. The next tool call uses the new values.',
|
|
108
|
+
invalidNumber: 'Enter a valid number within the range shown.',
|
|
109
|
+
invalidDir: 'The report directory must be .dsh-geo or a subdirectory under it.',
|
|
110
|
+
noChanges: 'Nothing to save.',
|
|
111
|
+
conflictReloaded: 'Settings changed elsewhere. The latest values were reloaded; review and save again.',
|
|
112
|
+
reload: 'Reload',
|
|
113
|
+
readOnly: 'This profile refuses writes; edit cordis.patch.yml instead.',
|
|
114
|
+
loadError: 'Could not read settings',
|
|
115
|
+
saveError: 'Could not save',
|
|
116
|
+
unavailable: 'The settings service is unavailable; the panel cannot edit values.',
|
|
117
|
+
badge: 'Reproducible checks · no ranking prediction',
|
|
118
|
+
navDashboard: 'Visibility dashboard',
|
|
119
|
+
dashTitle: 'Visibility dashboard',
|
|
120
|
+
dashLede: 'Built from local .dsh-geo/ history: score trend, five dimensions, fixed and regressed checks. This is not GSC or Perplexity traffic data — use Search Console for that.',
|
|
121
|
+
dashScore: 'Score',
|
|
122
|
+
dashDelta: 'vs previous',
|
|
123
|
+
dashDimensions: 'Dimensions',
|
|
124
|
+
dashTrend: 'Score trend',
|
|
125
|
+
dashRecent: 'Recent scans',
|
|
126
|
+
dashFixed: 'Fixed',
|
|
127
|
+
dashRegressed: 'Regressed',
|
|
128
|
+
dashStill: 'Still failing',
|
|
129
|
+
dashActions: 'Top fixes',
|
|
130
|
+
dashEmpty: 'No audits yet',
|
|
131
|
+
dashEmptyHint: 'Ask the agent to run geo_scan, or run dsh-geo scan --save; the trend and dimension history will appear here.',
|
|
132
|
+
dashNoSession: 'No session workspace available',
|
|
133
|
+
dashNoSessionHint: 'Open a session and run geo_scan there first.',
|
|
134
|
+
dashError: 'Could not read the dashboard',
|
|
135
|
+
dashRefresh: 'Refresh',
|
|
136
|
+
dashWorkspace: 'Workspace',
|
|
137
|
+
dashUpdated: 'Updated',
|
|
138
|
+
dashNoData: 'No data yet',
|
|
139
|
+
dashScans: 'scans',
|
|
140
|
+
dashPlatforms: 'Platform profiles (reference, not in Core score)',
|
|
141
|
+
},
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
const DEFAULT_VALUES = {
|
|
145
|
+
maxPages: 6,
|
|
146
|
+
rateLimitMs: 250,
|
|
147
|
+
timeoutMs: 10000,
|
|
148
|
+
maxBytes: 1500000,
|
|
149
|
+
reportDir: '.dsh-geo',
|
|
150
|
+
respectRobots: true,
|
|
151
|
+
permitPrivateTargets: false,
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
const FIELDS = [
|
|
155
|
+
{ key: 'maxPages', kind: 'number', min: 1, max: 50, label: 'maxPages', hint: 'maxPagesHint' },
|
|
156
|
+
{ key: 'rateLimitMs', kind: 'number', min: 0, max: 60000, label: 'rateLimitMs', hint: 'rateLimitMsHint' },
|
|
157
|
+
{ key: 'timeoutMs', kind: 'number', min: 500, max: 120000, label: 'timeoutMs', hint: 'timeoutMsHint' },
|
|
158
|
+
{ key: 'maxBytes', kind: 'number', min: 65536, max: 20000000, label: 'maxBytes', hint: 'maxBytesHint' },
|
|
159
|
+
{ key: 'reportDir', kind: 'text', label: 'reportDir', hint: 'reportDirHint' },
|
|
160
|
+
{ key: 'respectRobots', kind: 'checkbox', label: 'respectRobots', hint: 'respectRobotsHint' },
|
|
161
|
+
{ key: 'permitPrivateTargets', kind: 'checkbox', label: 'permitPrivateTargets', hint: 'permitPrivateHint' },
|
|
162
|
+
];
|
|
163
|
+
|
|
164
|
+
const styles = {
|
|
165
|
+
page: { padding: '20px 24px 40px', maxWidth: 760, display: 'flex', flexDirection: 'column', gap: 16 },
|
|
166
|
+
title: { margin: 0, fontSize: 18, fontWeight: 600, color: 'var(--dsw-alias-label-primary, #1f2328)' },
|
|
167
|
+
lede: { margin: 0, fontSize: 13, lineHeight: 1.6, color: 'var(--dsw-alias-label-secondary, #59636e)' },
|
|
168
|
+
badge: {
|
|
169
|
+
alignSelf: 'flex-start', padding: '3px 8px', borderRadius: 999, fontSize: 11,
|
|
170
|
+
color: 'var(--dsw-alias-brand-primary, #0969da)',
|
|
171
|
+
background: 'var(--dsw-alias-bg-layer-2, #f6f8fa)',
|
|
172
|
+
border: '1px solid var(--dsw-alias-border-l2, #d0d7de)',
|
|
173
|
+
},
|
|
174
|
+
card: {
|
|
175
|
+
border: '1px solid var(--dsw-alias-border-l2, #d0d7de)',
|
|
176
|
+
borderRadius: 10,
|
|
177
|
+
background: 'var(--dsw-alias-bg-layer-1, #ffffff)',
|
|
178
|
+
padding: '14px 16px',
|
|
179
|
+
},
|
|
180
|
+
sectionLabel: {
|
|
181
|
+
fontSize: 12, fontWeight: 600, letterSpacing: '0.04em', textTransform: 'uppercase',
|
|
182
|
+
color: 'var(--dsw-alias-label-tertiary, #6e7781)', marginBottom: 10,
|
|
183
|
+
},
|
|
184
|
+
row: { display: 'flex', flexDirection: 'column', gap: 4, padding: '10px 0', borderTop: '1px solid var(--dsw-alias-border-l1, #eaeef2)' },
|
|
185
|
+
rowFirst: { display: 'flex', flexDirection: 'column', gap: 4, padding: '0 0 10px' },
|
|
186
|
+
labelLine: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 12 },
|
|
187
|
+
label: { fontSize: 13, fontWeight: 500, color: 'var(--dsw-alias-label-primary, #1f2328)' },
|
|
188
|
+
hint: { fontSize: 12, lineHeight: 1.5, color: 'var(--dsw-alias-label-secondary, #59636e)' },
|
|
189
|
+
input: {
|
|
190
|
+
width: 180, padding: '5px 8px', fontSize: 13, borderRadius: 6,
|
|
191
|
+
border: '1px solid var(--dsw-alias-border-l2, #d0d7de)',
|
|
192
|
+
background: 'var(--dsw-alias-bg-base, #ffffff)',
|
|
193
|
+
color: 'var(--dsw-alias-label-primary, #1f2328)',
|
|
194
|
+
},
|
|
195
|
+
switch: { display: 'inline-flex', alignItems: 'center', gap: 6, fontSize: 13 },
|
|
196
|
+
actions: { display: 'flex', alignItems: 'center', gap: 10 },
|
|
197
|
+
save: {
|
|
198
|
+
padding: '6px 14px', fontSize: 13, fontWeight: 500, borderRadius: 6, cursor: 'pointer',
|
|
199
|
+
border: '1px solid var(--dsw-alias-brand-primary, #0969da)',
|
|
200
|
+
background: 'var(--dsw-alias-brand-primary, #0969da)', color: '#ffffff',
|
|
201
|
+
},
|
|
202
|
+
saveDisabled: { opacity: 0.55, cursor: 'default' },
|
|
203
|
+
ghost: {
|
|
204
|
+
padding: '6px 12px', fontSize: 13, borderRadius: 6, cursor: 'pointer',
|
|
205
|
+
border: '1px solid var(--dsw-alias-border-l2, #d0d7de)',
|
|
206
|
+
background: 'transparent', color: 'var(--dsw-alias-label-primary, #1f2328)',
|
|
207
|
+
},
|
|
208
|
+
ok: { fontSize: 12, color: 'var(--dsw-alias-state-success-primary, #1a7f37)' },
|
|
209
|
+
error: { fontSize: 12, color: 'var(--dsw-alias-state-error-primary, #cf222e)' },
|
|
210
|
+
mono: { fontFamily: 'ui-monospace, SFMono-Regular, Menlo, monospace', fontSize: 12 },
|
|
211
|
+
dashGrid: { display: 'flex', flexWrap: 'wrap', gap: 12 },
|
|
212
|
+
dashCard: {
|
|
213
|
+
flex: '1 1 180px', minWidth: 160, padding: '14px 16px', borderRadius: 10,
|
|
214
|
+
border: '1px solid var(--dsw-alias-border-l2, #d0d7de)',
|
|
215
|
+
background: 'var(--dsw-alias-bg-layer-1, #ffffff)',
|
|
216
|
+
},
|
|
217
|
+
dashValue: { fontSize: 30, fontWeight: 700, lineHeight: 1.1, color: 'var(--dsw-alias-label-primary, #1f2328)' },
|
|
218
|
+
dashCap: { fontSize: 12, color: 'var(--dsw-alias-label-tertiary, #6e7781)', marginBottom: 6 },
|
|
219
|
+
dashDelta: { fontSize: 12, marginTop: 4 },
|
|
220
|
+
barTrack: {
|
|
221
|
+
height: 8, borderRadius: 999, overflow: 'hidden',
|
|
222
|
+
background: 'var(--dsw-alias-bg-layer-2, #f6f8fa)', width: '100%',
|
|
223
|
+
},
|
|
224
|
+
barFill: { height: '100%', borderRadius: 999, background: 'var(--dsw-alias-brand-primary, #0969da)' },
|
|
225
|
+
dashRow: { display: 'grid', gridTemplateColumns: '88px 1fr 72px', gap: 10, alignItems: 'center', padding: '5px 0' },
|
|
226
|
+
dashList: { display: 'flex', flexDirection: 'column', gap: 6 },
|
|
227
|
+
dashItem: { fontSize: 12, lineHeight: 1.5, color: 'var(--dsw-alias-label-secondary, #59636e)' },
|
|
228
|
+
dashStrong: { fontWeight: 600, color: 'var(--dsw-alias-label-primary, #1f2328)' },
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
function Field(props) {
|
|
232
|
+
const { t, field, value, disabled, onChange } = props;
|
|
233
|
+
const label = t(field.label);
|
|
234
|
+
const hint = t(field.hint);
|
|
235
|
+
if (field.kind === 'checkbox') {
|
|
236
|
+
return h('div', { style: props.first ? styles.rowFirst : styles.row },
|
|
237
|
+
h('label', { style: styles.labelLine },
|
|
238
|
+
h('span', { style: styles.label }, label),
|
|
239
|
+
h('input', {
|
|
240
|
+
type: 'checkbox',
|
|
241
|
+
checked: Boolean(value),
|
|
242
|
+
disabled,
|
|
243
|
+
'aria-label': label,
|
|
244
|
+
onChange: (event) => onChange(event.target.checked),
|
|
245
|
+
})),
|
|
246
|
+
h('span', { style: styles.hint }, hint));
|
|
247
|
+
}
|
|
248
|
+
return h('div', { style: props.first ? styles.rowFirst : styles.row },
|
|
249
|
+
h('label', { style: styles.labelLine },
|
|
250
|
+
h('span', { style: styles.label }, label),
|
|
251
|
+
h('input', {
|
|
252
|
+
type: field.kind === 'number' ? 'number' : 'text',
|
|
253
|
+
style: styles.input,
|
|
254
|
+
value: value === undefined || value === null ? '' : String(value),
|
|
255
|
+
min: field.min,
|
|
256
|
+
max: field.max,
|
|
257
|
+
step: field.kind === 'number' ? 1 : undefined,
|
|
258
|
+
disabled,
|
|
259
|
+
'aria-label': label,
|
|
260
|
+
onChange: (event) => onChange(field.kind === 'number'
|
|
261
|
+
? (event.target.value === '' ? '' : Number(event.target.value))
|
|
262
|
+
: event.target.value),
|
|
263
|
+
})),
|
|
264
|
+
h('span', { style: styles.hint }, hint));
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
function GeoPanel(props) {
|
|
268
|
+
const t = typeof props.t === 'function' ? props.t : (key) => key;
|
|
269
|
+
const [state, setState] = React.useState({ status: 'loading', error: null, revision: 0, values: {}, writable: false });
|
|
270
|
+
const [saving, setSaving] = React.useState(false);
|
|
271
|
+
const [message, setMessage] = React.useState(null);
|
|
272
|
+
|
|
273
|
+
const load = React.useCallback(async () => {
|
|
274
|
+
setMessage(null);
|
|
275
|
+
setState((previous) => ({ ...previous, status: previous.status === 'ready' ? 'ready' : 'loading', error: null }));
|
|
276
|
+
try {
|
|
277
|
+
const values = await props.load();
|
|
278
|
+
setState({
|
|
279
|
+
status: 'ready',
|
|
280
|
+
error: null,
|
|
281
|
+
revision: values.revision,
|
|
282
|
+
values: { ...DEFAULT_VALUES, ...values.values },
|
|
283
|
+
writable: values.writable,
|
|
284
|
+
});
|
|
285
|
+
} catch (error) {
|
|
286
|
+
const message = error && error.message ? error.message : String(error);
|
|
287
|
+
setState((previous) => previous.status === 'ready'
|
|
288
|
+
? { ...previous, error: message }
|
|
289
|
+
: { status: 'error', error: message, revision: 0, values: {}, writable: false });
|
|
290
|
+
}
|
|
291
|
+
}, [props]);
|
|
292
|
+
|
|
293
|
+
// Load once; the face is re-read by the explicit reload button.
|
|
294
|
+
React.useEffect(() => { void load(); }, []);
|
|
295
|
+
|
|
296
|
+
const setField = (key, value) => {
|
|
297
|
+
setMessage(null);
|
|
298
|
+
setState((previous) => ({ ...previous, values: { ...previous.values, [key]: value } }));
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
const onSave = async () => {
|
|
302
|
+
for (const field of FIELDS) {
|
|
303
|
+
if (field.kind !== 'number') continue;
|
|
304
|
+
const value = Number(state.values[field.key]);
|
|
305
|
+
if (!Number.isFinite(value) || value < field.min || value > field.max) {
|
|
306
|
+
setMessage({ kind: 'error', text: `${t(field.label)}: ${t('invalidNumber')}` });
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
const reportDir = String(state.values.reportDir ?? '').trim();
|
|
311
|
+
if (reportDir !== '.dsh-geo' && !reportDir.startsWith('.dsh-geo/')) {
|
|
312
|
+
setMessage({ kind: 'error', text: t('invalidDir') });
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
setSaving(true);
|
|
316
|
+
setMessage(null);
|
|
317
|
+
try {
|
|
318
|
+
const saved = await props.save(state.values, state.revision);
|
|
319
|
+
setState({ status: 'ready', error: null, revision: saved.revision, values: saved.values, writable: saved.writable });
|
|
320
|
+
setMessage({ kind: 'ok', text: t('saved') });
|
|
321
|
+
} catch (error) {
|
|
322
|
+
const text = error && error.message ? error.message : String(error);
|
|
323
|
+
if (/conflict|revision/i.test(text)) {
|
|
324
|
+
await load();
|
|
325
|
+
setMessage({ kind: 'error', text: t('conflictReloaded') });
|
|
326
|
+
} else {
|
|
327
|
+
setMessage({ kind: 'error', text: `${t('saveError')}: ${text}` });
|
|
328
|
+
}
|
|
329
|
+
} finally {
|
|
330
|
+
setSaving(false);
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
|
|
334
|
+
const children = [];
|
|
335
|
+
|
|
336
|
+
children.push(h('div', { key: 'head', style: { display: 'flex', flexDirection: 'column', gap: 8 } },
|
|
337
|
+
h('h2', { style: styles.title }, t('title')),
|
|
338
|
+
h('p', { style: styles.lede }, t('lede')),
|
|
339
|
+
h('span', { style: styles.badge }, t('badge'))));
|
|
340
|
+
|
|
341
|
+
children.push(h('div', { key: 'tools', style: styles.card },
|
|
342
|
+
h('div', { style: styles.sectionLabel }, t('tools')),
|
|
343
|
+
h('div', { style: { ...styles.label, ...styles.mono } }, TOOLS),
|
|
344
|
+
h('p', { style: { ...styles.hint, margin: '6px 0 0' } }, t('toolsHint'))));
|
|
345
|
+
|
|
346
|
+
if (state.status === 'loading') {
|
|
347
|
+
children.push(h('div', { key: 'loading', style: { ...styles.hint, padding: 8 } }, t('loading')));
|
|
348
|
+
} else if (state.status === 'error') {
|
|
349
|
+
children.push(h('div', {
|
|
350
|
+
key: 'load-error',
|
|
351
|
+
role: 'alert',
|
|
352
|
+
style: { ...styles.card, ...styles.error },
|
|
353
|
+
}, `${t('loadError')}: ${state.error}`));
|
|
354
|
+
} else {
|
|
355
|
+
if (state.error) {
|
|
356
|
+
children.push(h('div', {
|
|
357
|
+
key: 'stale-error',
|
|
358
|
+
role: 'alert',
|
|
359
|
+
style: { ...styles.card, ...styles.error },
|
|
360
|
+
}, `${t('loadError')}: ${state.error}`));
|
|
361
|
+
}
|
|
362
|
+
const rows = [];
|
|
363
|
+
rows.push(h('div', { key: 'section-label', style: styles.sectionLabel }, t('crawl')));
|
|
364
|
+
FIELDS.forEach((field, index) => {
|
|
365
|
+
if (field.key === 'permitPrivateTargets') return;
|
|
366
|
+
rows.push(h(Field, {
|
|
367
|
+
key: field.key,
|
|
368
|
+
t,
|
|
369
|
+
field,
|
|
370
|
+
first: index === 0,
|
|
371
|
+
value: state.values[field.key],
|
|
372
|
+
disabled: !state.writable || saving,
|
|
373
|
+
onChange: (value) => setField(field.key, value),
|
|
374
|
+
}));
|
|
375
|
+
});
|
|
376
|
+
rows.push(h('div', { key: 'target-label', style: { ...styles.sectionLabel, marginTop: 16 } }, t('targets')));
|
|
377
|
+
rows.push(h(Field, {
|
|
378
|
+
key: 'permitPrivateTargets',
|
|
379
|
+
t,
|
|
380
|
+
field: FIELDS.find((field) => field.key === 'permitPrivateTargets'),
|
|
381
|
+
first: true,
|
|
382
|
+
value: state.values.permitPrivateTargets,
|
|
383
|
+
disabled: !state.writable || saving,
|
|
384
|
+
onChange: (value) => setField('permitPrivateTargets', value),
|
|
385
|
+
}));
|
|
386
|
+
if (state.values.permitPrivateTargets) {
|
|
387
|
+
rows.push(h('div', {
|
|
388
|
+
key: 'private-warning',
|
|
389
|
+
style: { ...styles.hint, color: 'var(--dsw-alias-state-warn-primary, #9a6700)' },
|
|
390
|
+
}, t('permitPrivateWarning')));
|
|
391
|
+
}
|
|
392
|
+
children.push(h('div', { key: 'form', style: styles.card }, rows));
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
if (state.status === 'ready' && !state.writable) {
|
|
396
|
+
children.push(h('div', { key: 'readonly', style: { ...styles.hint, color: 'var(--dsw-alias-state-warn-primary, #9a6700)' } }, t('readOnly')));
|
|
397
|
+
}
|
|
398
|
+
if (message) {
|
|
399
|
+
children.push(h('div', {
|
|
400
|
+
key: 'message',
|
|
401
|
+
role: message.kind === 'ok' ? 'status' : 'alert',
|
|
402
|
+
'aria-live': message.kind === 'ok' ? 'polite' : 'assertive',
|
|
403
|
+
style: message.kind === 'ok' ? styles.ok : styles.error,
|
|
404
|
+
}, message.text));
|
|
405
|
+
}
|
|
406
|
+
children.push(h('div', { key: 'actions', style: styles.actions },
|
|
407
|
+
h('button', {
|
|
408
|
+
type: 'button',
|
|
409
|
+
style: { ...styles.save, ...(saving || state.status !== 'ready' || !state.writable ? styles.saveDisabled : {}) },
|
|
410
|
+
disabled: saving || state.status !== 'ready' || !state.writable,
|
|
411
|
+
onClick: () => { void onSave(); },
|
|
412
|
+
}, saving ? t('saving') : t('save')),
|
|
413
|
+
h('button', {
|
|
414
|
+
type: 'button',
|
|
415
|
+
style: styles.ghost,
|
|
416
|
+
disabled: saving,
|
|
417
|
+
onClick: () => { void load(); },
|
|
418
|
+
}, t('reload'))));
|
|
419
|
+
|
|
420
|
+
return h('div', { style: styles.page }, children);
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
function formatTime(value) {
|
|
424
|
+
if (!value) return '—';
|
|
425
|
+
return String(value).replace('T', ' ').replace(/\.\d+Z$/, ' UTC').replace(/Z$/, ' UTC');
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
function signed(value) {
|
|
429
|
+
if (value === 0) return '0';
|
|
430
|
+
return value > 0 ? `+${value}` : String(value);
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
function Sparkline(props) {
|
|
434
|
+
const { trend, label } = props;
|
|
435
|
+
const values = trend.map((entry) => entry.total);
|
|
436
|
+
if (values.length < 2) {
|
|
437
|
+
return h('div', { style: { ...styles.hint, padding: '18px 0' } }, props.emptyLabel);
|
|
438
|
+
}
|
|
439
|
+
const width = 640;
|
|
440
|
+
const height = 160;
|
|
441
|
+
const pad = 18;
|
|
442
|
+
const x = (index) => pad + (index * (width - pad * 2)) / (values.length - 1);
|
|
443
|
+
const y = (value) => height - pad - (Math.max(0, Math.min(100, value)) / 100) * (height - pad * 2);
|
|
444
|
+
const points = values.map((value, index) => `${x(index).toFixed(1)},${y(value).toFixed(1)}`).join(' ');
|
|
445
|
+
const area = `M ${pad},${height - pad} L ${points.replaceAll(' ', ' L ')} L ${width - pad},${height - pad} Z`;
|
|
446
|
+
const first = trend[0];
|
|
447
|
+
const last = trend[trend.length - 1];
|
|
448
|
+
const children = [
|
|
449
|
+
h('path', { key: 'area', d: area, fill: 'var(--dsw-alias-brand-primary, #0969da)', opacity: 0.12 }),
|
|
450
|
+
h('polyline', {
|
|
451
|
+
key: 'line', points, fill: 'none',
|
|
452
|
+
stroke: 'var(--dsw-alias-brand-primary, #0969da)', strokeWidth: 2.5,
|
|
453
|
+
strokeLinejoin: 'round', strokeLinecap: 'round',
|
|
454
|
+
}),
|
|
455
|
+
h('circle', { key: 'dot', cx: x(values.length - 1), cy: y(last.total), r: 4, fill: 'var(--dsw-alias-brand-primary, #0969da)' }),
|
|
456
|
+
h('text', { key: 'start', x: pad, y: height - 2, fontSize: 10, fill: 'var(--dsw-alias-label-tertiary, #6e7781)' }, formatTime(first.scannedAt).slice(0, 10)),
|
|
457
|
+
h('text', { key: 'end', x: width - pad, y: height - 2, textAnchor: 'end', fontSize: 10, fill: 'var(--dsw-alias-label-tertiary, #6e7781)' }, formatTime(last.scannedAt).slice(0, 10)),
|
|
458
|
+
h('text', { key: 'value', x: width - pad, y: 14, textAnchor: 'end', fontSize: 11, fill: 'var(--dsw-alias-label-secondary, #59636e)' }, `${last.total} / 100`),
|
|
459
|
+
];
|
|
460
|
+
return h('svg', {
|
|
461
|
+
viewBox: `0 0 ${width} ${height}`,
|
|
462
|
+
role: 'img',
|
|
463
|
+
'aria-label': label,
|
|
464
|
+
style: { width: '100%', height: 160, display: 'block' },
|
|
465
|
+
}, children);
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
function GeoDashboard(props) {
|
|
469
|
+
const t = typeof props.t === 'function' ? props.t : (key) => key;
|
|
470
|
+
const [state, setState] = React.useState({ status: 'loading', data: null, error: null, session: null, workspace: null });
|
|
471
|
+
const [refreshing, setRefreshing] = React.useState(false);
|
|
472
|
+
|
|
473
|
+
const load = React.useCallback(async (manual = false) => {
|
|
474
|
+
if (manual) setRefreshing(true);
|
|
475
|
+
try {
|
|
476
|
+
const next = await props.loadDashboard();
|
|
477
|
+
setState(next);
|
|
478
|
+
} catch (error) {
|
|
479
|
+
setState((previous) => ({ ...previous, status: 'error', error: error && error.message ? error.message : String(error) }));
|
|
480
|
+
} finally {
|
|
481
|
+
if (manual) setRefreshing(false);
|
|
482
|
+
}
|
|
483
|
+
}, [props]);
|
|
484
|
+
|
|
485
|
+
React.useEffect(() => {
|
|
486
|
+
void load();
|
|
487
|
+
const timer = setInterval(() => { void load(); }, 15000);
|
|
488
|
+
return () => clearInterval(timer);
|
|
489
|
+
}, []);
|
|
490
|
+
|
|
491
|
+
const children = [];
|
|
492
|
+
children.push(h('div', { key: 'head', style: { display: 'flex', flexDirection: 'column', gap: 8 } },
|
|
493
|
+
h('div', { style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 12 } },
|
|
494
|
+
h('h2', { style: styles.title }, t('dashTitle')),
|
|
495
|
+
h('button', {
|
|
496
|
+
type: 'button', style: styles.ghost, disabled: refreshing,
|
|
497
|
+
onClick: () => { void load(true); },
|
|
498
|
+
}, refreshing ? t('loading') : t('dashRefresh'))),
|
|
499
|
+
h('p', { style: styles.lede }, t('dashLede')),
|
|
500
|
+
state.session && state.session.cwd
|
|
501
|
+
? h('div', { style: styles.hint },
|
|
502
|
+
`${t('dashWorkspace')}: `,
|
|
503
|
+
h('span', { style: styles.mono }, state.session.cwd.split('/').filter(Boolean).pop() || state.session.cwd))
|
|
504
|
+
: null));
|
|
505
|
+
|
|
506
|
+
if (state.status === 'loading' && !state.data) {
|
|
507
|
+
children.push(h('div', { key: 'loading', style: { ...styles.hint, padding: 8 } }, t('loading')));
|
|
508
|
+
return h('div', { style: styles.page }, children);
|
|
509
|
+
}
|
|
510
|
+
if (state.status === 'error') {
|
|
511
|
+
children.push(h('div', { key: 'error', role: 'alert', style: { ...styles.card, ...styles.error } },
|
|
512
|
+
`${t('dashError')}: ${state.error}`));
|
|
513
|
+
return h('div', { style: styles.page }, children);
|
|
514
|
+
}
|
|
515
|
+
if (state.status === 'no-session') {
|
|
516
|
+
children.push(h('div', { key: 'no-session', style: styles.card },
|
|
517
|
+
h('div', { style: { ...styles.label, marginBottom: 4 } }, t('dashNoSession')),
|
|
518
|
+
h('div', { style: styles.hint }, t('dashNoSessionHint'))));
|
|
519
|
+
return h('div', { style: styles.page }, children);
|
|
520
|
+
}
|
|
521
|
+
if (state.status === 'empty') {
|
|
522
|
+
children.push(h('div', { key: 'empty', style: styles.card },
|
|
523
|
+
h('div', { style: { ...styles.label, marginBottom: 4 } }, t('dashEmpty')),
|
|
524
|
+
h('div', { style: styles.hint }, t('dashEmptyHint'))));
|
|
525
|
+
return h('div', { style: styles.page }, children);
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
const dashboard = state.data;
|
|
529
|
+
const current = dashboard.current;
|
|
530
|
+
const delta = dashboard.delta;
|
|
531
|
+
const moduleCard = (key, caption, value, extra) => h('div', { key, style: styles.dashCard },
|
|
532
|
+
h('div', { style: styles.dashCap }, caption),
|
|
533
|
+
h('div', { style: styles.dashValue }, value),
|
|
534
|
+
extra ?? null);
|
|
535
|
+
|
|
536
|
+
children.push(h('div', { key: 'cards', style: styles.dashGrid },
|
|
537
|
+
moduleCard('score', t('dashScore'), `${current.total} / 100`, h('div', {
|
|
538
|
+
style: { ...styles.dashDelta, color: delta && delta.total !== 0 ? (delta.total > 0 ? 'var(--dsw-alias-state-success-primary, #1a7f37)' : 'var(--dsw-alias-state-error-primary, #cf222e)') : 'var(--dsw-alias-label-tertiary, #6e7781)' },
|
|
539
|
+
}, `${current.grade} · ${delta ? `${t('dashDelta')} ${signed(delta.total)}` : t('dashNoData')}`)),
|
|
540
|
+
moduleCard('fixed', t('dashFixed'), delta ? String(delta.fixed.length) : '—'),
|
|
541
|
+
moduleCard('regressed', t('dashRegressed'), delta ? String(delta.regressed.length) : '—'),
|
|
542
|
+
moduleCard('still', t('dashStill'), delta ? String(delta.stillFailing) : '—')));
|
|
543
|
+
|
|
544
|
+
children.push(h('div', { key: 'trend', style: styles.card },
|
|
545
|
+
h('div', { style: styles.sectionLabel }, t('dashTrend')),
|
|
546
|
+
h(Sparkline, {
|
|
547
|
+
trend: dashboard.trend ?? [],
|
|
548
|
+
label: t('dashTrend'),
|
|
549
|
+
emptyLabel: t('dashNoData'),
|
|
550
|
+
}),
|
|
551
|
+
h('div', { style: { ...styles.hint, marginTop: 4 } }, `${(dashboard.trend ?? []).length} ${t('dashScans')}`)));
|
|
552
|
+
|
|
553
|
+
const dimensionMap = new Map((dashboard.previous?.dimensions ?? []).map((dimension) => [dimension.id, dimension]));
|
|
554
|
+
children.push(h('div', { key: 'dimensions', style: styles.card },
|
|
555
|
+
h('div', { style: styles.sectionLabel }, t('dashDimensions')),
|
|
556
|
+
(current.dimensions ?? []).map((dimension) => {
|
|
557
|
+
const before = dimensionMap.get(dimension.id);
|
|
558
|
+
const diff = before ? before.after - before.before : null;
|
|
559
|
+
return h('div', { key: dimension.id, style: styles.dashRow },
|
|
560
|
+
h('span', { style: styles.label }, dimension.title),
|
|
561
|
+
h('div', { style: styles.barTrack },
|
|
562
|
+
h('div', { style: { ...styles.barFill, width: `${Math.max(0, Math.min(100, dimension.score))}%` } })),
|
|
563
|
+
h('span', { style: { ...styles.hint, textAlign: 'right' } },
|
|
564
|
+
dimension.scored === false ? '—' : `${dimension.score}`,
|
|
565
|
+
diff === null || dimension.scored === false ? '' : ` (${signed(diff)})`));
|
|
566
|
+
})));
|
|
567
|
+
|
|
568
|
+
if ((current.platforms ?? []).length > 0) {
|
|
569
|
+
children.push(h('div', { key: 'platforms', style: styles.card },
|
|
570
|
+
h('div', { style: styles.sectionLabel }, t('dashPlatforms')),
|
|
571
|
+
current.platforms.map((platform) => h('div', { key: platform.id, style: styles.dashRow },
|
|
572
|
+
h('span', { style: styles.label }, platform.title),
|
|
573
|
+
h('div', { style: styles.barTrack },
|
|
574
|
+
h('div', { style: { ...styles.barFill, width: `${Math.max(0, Math.min(100, platform.total))}%` } })),
|
|
575
|
+
h('span', { style: { ...styles.hint, textAlign: 'right' } }, `${platform.total}`)))));
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
if ((dashboard.actions ?? []).length > 0) {
|
|
579
|
+
children.push(h('div', { key: 'actions', style: styles.card },
|
|
580
|
+
h('div', { style: styles.sectionLabel }, t('dashActions')),
|
|
581
|
+
h('div', { style: styles.dashList },
|
|
582
|
+
dashboard.actions.map((action) => h('div', { key: action.ruleId, style: styles.dashItem },
|
|
583
|
+
h('span', { style: styles.dashStrong }, `${action.dimensionTitle} · ${action.title}`),
|
|
584
|
+
` — ${action.evidence}`)))));
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
const recent = [...(dashboard.trend ?? [])].reverse().slice(0, 8);
|
|
588
|
+
if (recent.length > 0) {
|
|
589
|
+
children.push(h('div', { key: 'recent', style: styles.card },
|
|
590
|
+
h('div', { style: styles.sectionLabel }, t('dashRecent')),
|
|
591
|
+
h('div', { style: styles.dashList },
|
|
592
|
+
recent.map((entry) => h('div', { key: `${entry.scannedAt}-${entry.total}`, style: { ...styles.dashItem, display: 'flex', justifyContent: 'space-between', gap: 12 } },
|
|
593
|
+
h('span', null, formatTime(entry.scannedAt)),
|
|
594
|
+
h('span', null, h('span', { style: styles.dashStrong }, `${entry.total}`), ` ${entry.grade}`))))));
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
return h('div', { style: styles.page }, children);
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
function remoteSettings(ctx) {
|
|
601
|
+
const remote = ctx.remote;
|
|
602
|
+
if (!remote || !remote.settings) throw new Error('settings service unavailable');
|
|
603
|
+
return remote.settings;
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
function isNotFound(error) {
|
|
607
|
+
const text = `${error && error.code ? error.code : ''} ${error && error.message ? error.message : ''}`;
|
|
608
|
+
return /not.?found|ENOENT|lookup-not-found/i.test(text);
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
async function readDashboard(ctx) {
|
|
612
|
+
if (!ctx.remote || !ctx.remote.workspaceFiles || !ctx.sessions) {
|
|
613
|
+
throw new Error('workspace file service unavailable');
|
|
614
|
+
}
|
|
615
|
+
const snapshot = ctx.sessions.list.getSnapshot();
|
|
616
|
+
const sessions = Object.values(snapshot.byId)
|
|
617
|
+
.filter((session) => session.cwd)
|
|
618
|
+
.sort((a, b) => b.updatedAt - a.updatedAt)
|
|
619
|
+
.slice(0, 6);
|
|
620
|
+
if (sessions.length === 0) return { status: 'no-session', data: null, error: null, session: null };
|
|
621
|
+
|
|
622
|
+
let lastError = null;
|
|
623
|
+
for (const session of sessions) {
|
|
624
|
+
const result = await ctx.remote.workspaceFiles.readBytes(session.id, '.dsh-geo/dashboard.json', {});
|
|
625
|
+
if (!result || result.ok !== true) {
|
|
626
|
+
lastError = result && result.error ? result.error : { message: 'workspace read failed' };
|
|
627
|
+
if (isNotFound(lastError)) continue;
|
|
628
|
+
throw new Error(lastError.message || 'workspace read failed');
|
|
629
|
+
}
|
|
630
|
+
const bytes = result.value && result.value.data !== undefined ? result.value.data : result.value;
|
|
631
|
+
const text = new TextDecoder().decode(bytes);
|
|
632
|
+
return {
|
|
633
|
+
status: 'ready',
|
|
634
|
+
data: JSON.parse(text),
|
|
635
|
+
error: null,
|
|
636
|
+
session: { id: session.id, cwd: session.cwd },
|
|
637
|
+
};
|
|
638
|
+
}
|
|
639
|
+
return {
|
|
640
|
+
status: 'empty',
|
|
641
|
+
data: null,
|
|
642
|
+
error: lastError ? lastError.message : null,
|
|
643
|
+
session: { id: sessions[0].id, cwd: sessions[0].cwd },
|
|
644
|
+
};
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
async function readNamespace(ctx) {
|
|
648
|
+
const result = await remoteSettings(ctx).describe();
|
|
649
|
+
if (!result || result.ok !== true) {
|
|
650
|
+
throw new Error(result && result.error ? result.error.message : 'settings describe failed');
|
|
651
|
+
}
|
|
652
|
+
const value = result.value;
|
|
653
|
+
const namespace = value.namespaces.find((entry) => entry.ns === NS);
|
|
654
|
+
if (!namespace) {
|
|
655
|
+
throw new Error(`settings namespace "${NS}" not found — if the plugin was just installed, restart DSH`);
|
|
656
|
+
}
|
|
657
|
+
return {
|
|
658
|
+
writable: Boolean(value.writable),
|
|
659
|
+
revision: namespace.revision,
|
|
660
|
+
values: namespace.value ?? {},
|
|
661
|
+
};
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
async function writeNamespace(ctx, patch, revision) {
|
|
665
|
+
const result = await remoteSettings(ctx).update(NS, patch, revision);
|
|
666
|
+
if (!result || result.ok !== true) {
|
|
667
|
+
throw new Error(result && result.error ? result.error.message : 'settings update failed');
|
|
668
|
+
}
|
|
669
|
+
const view = result.value;
|
|
670
|
+
if (view && view.value) {
|
|
671
|
+
return { writable: true, revision: view.revision, values: view.value };
|
|
672
|
+
}
|
|
673
|
+
return readNamespace(ctx);
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
return {
|
|
677
|
+
inject: ['slots', 'locale', 'remote', 'remote.settings', 'sessions', 'remote.workspaceFiles'],
|
|
678
|
+
apply(ctx) {
|
|
679
|
+
ctx.effect(() => ctx.locale.register(NS, DICT), 'dsh-geo: settings dictionaries');
|
|
680
|
+
const t = ctx.locale.bind(NS);
|
|
681
|
+
|
|
682
|
+
ctx.slots.inject('settings.section', () => ctx.slots.register({
|
|
683
|
+
name: 'settings.section',
|
|
684
|
+
id: 'geo-dashboard',
|
|
685
|
+
order: 34,
|
|
686
|
+
label: () => t('navDashboard'),
|
|
687
|
+
locale: NS,
|
|
688
|
+
inject: () => ({
|
|
689
|
+
loadDashboard: () => readDashboard(ctx),
|
|
690
|
+
}),
|
|
691
|
+
}, GeoDashboard));
|
|
692
|
+
|
|
693
|
+
ctx.slots.inject('settings.section', () => ctx.slots.register({
|
|
694
|
+
name: 'settings.section',
|
|
695
|
+
id: NS,
|
|
696
|
+
order: 35,
|
|
697
|
+
label: () => t('nav'),
|
|
698
|
+
locale: NS,
|
|
699
|
+
inject: () => ({
|
|
700
|
+
load: () => readNamespace(ctx),
|
|
701
|
+
save: (patch, revision) => writeNamespace(ctx, patch, revision),
|
|
702
|
+
}),
|
|
703
|
+
}, GeoPanel));
|
|
704
|
+
},
|
|
705
|
+
};
|
|
706
|
+
},
|
|
707
|
+
});
|