dsh-requirement-dev-workbench 4.5.5 → 4.5.10
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 +37 -0
- package/dsh/index.js +3522 -3018
- package/lib/client.js +560 -30
- package/package.json +65 -65
package/lib/client.js
CHANGED
|
@@ -13,7 +13,7 @@ window.__ModuleLoader__.load({
|
|
|
13
13
|
const { useCallback, useEffect, useMemo, useRef, useState } = React
|
|
14
14
|
|
|
15
15
|
const API = '/api/requirement-dev-workbench'
|
|
16
|
-
const WORKBENCH_VERSION = '4.5.
|
|
16
|
+
const WORKBENCH_VERSION = '4.5.10'
|
|
17
17
|
const STYLE_ID = 'rdw-business-panel-styles'
|
|
18
18
|
|
|
19
19
|
const CSS = `
|
|
@@ -1039,8 +1039,9 @@ window.__ModuleLoader__.load({
|
|
|
1039
1039
|
return `这张表当前 0 条${noun}(已成功读取,表内暂无记录)`
|
|
1040
1040
|
}
|
|
1041
1041
|
|
|
1042
|
-
function TableModule({ state, reloadState, uiWorkspace, table, view, saveView, runs, handOff, onUpdateRun, onOpenTable, onAddModule, expertData, reloadExperts }) {
|
|
1043
|
-
const [
|
|
1042
|
+
function TableModule({ state, reloadState, uiWorkspace, table, view, saveView, runs, handOff, onUpdateRun, onOpenTable, onAddModule, expertData, reloadExperts, settingsOnly = false, onCloseSettings, onSavedSettings }) {
|
|
1043
|
+
const [rawData, setData] = useState({ configured: false, items: [] })
|
|
1044
|
+
const moduleOwned = Boolean(table?.own)
|
|
1044
1045
|
const [schema, setSchema] = useState(null)
|
|
1045
1046
|
const [loading, setLoading] = useState(false)
|
|
1046
1047
|
const [failure, setFailure] = useState(null)
|
|
@@ -1058,6 +1059,11 @@ window.__ModuleLoader__.load({
|
|
|
1058
1059
|
const [dropTarget, setDropTarget] = useState('')
|
|
1059
1060
|
const [progressField, setProgressField] = useState('')
|
|
1060
1061
|
const [pendingWrite, setPendingWrite] = useState(null)
|
|
1062
|
+
// 每个模块自己的「工作区」状态:目录、有没有配源、能不能读表。
|
|
1063
|
+
// 以前这里直接吃全局 settings.projectDir,所以改一个模块的目录,所有模块一起变。
|
|
1064
|
+
const [wsInfo, setWsInfo] = useState(null)
|
|
1065
|
+
const [walletOpen, setWalletOpen] = useState(false)
|
|
1066
|
+
const moduleKey = String(table?.moduleKey ?? '')
|
|
1061
1067
|
// 详情分栏:宽度可拖、可单独收起(收起后列表恢复整宽,选中的记录不丢)
|
|
1062
1068
|
const [detailWidth, setDetailWidth] = useState(() => clampDetailWidth(view?.detailWidth))
|
|
1063
1069
|
const [detailCollapsed, setDetailCollapsed] = useState(() => Boolean(view?.detailCollapsed))
|
|
@@ -1076,6 +1082,8 @@ window.__ModuleLoader__.load({
|
|
|
1076
1082
|
|
|
1077
1083
|
const settings = state?.settings ?? {}
|
|
1078
1084
|
const tableKey = table?.key ?? ''
|
|
1085
|
+
// 这个模块真正生效的工作目录:自己的目录优先,没填才跟随当前项目。
|
|
1086
|
+
const moduleDirNow = String(wsInfo?.projectDir || (moduleOwned ? '' : settings.projectDir) || '')
|
|
1079
1087
|
const tableQuery = tableKey ? `?table=${encodeURIComponent(tableKey)}` : ''
|
|
1080
1088
|
|
|
1081
1089
|
const loadSources = useCallback(async () => {
|
|
@@ -1102,6 +1110,30 @@ window.__ModuleLoader__.load({
|
|
|
1102
1110
|
loadSources()
|
|
1103
1111
|
}, [loadSources, settings.projectDir])
|
|
1104
1112
|
|
|
1113
|
+
// 模块的工作区:每次都向服务端要「这个模块自己的目录/源」,不拿全局设置顶替。
|
|
1114
|
+
const loadWorkspace = useCallback(async () => {
|
|
1115
|
+
if (!moduleKey) {
|
|
1116
|
+
setWsInfo(null)
|
|
1117
|
+
return
|
|
1118
|
+
}
|
|
1119
|
+
try {
|
|
1120
|
+
setWsInfo(await api(`/workspace?module=${encodeURIComponent(moduleKey)}`))
|
|
1121
|
+
} catch {
|
|
1122
|
+
setWsInfo(null)
|
|
1123
|
+
}
|
|
1124
|
+
}, [moduleKey])
|
|
1125
|
+
|
|
1126
|
+
useEffect(() => {
|
|
1127
|
+
void loadWorkspace()
|
|
1128
|
+
}, [loadWorkspace])
|
|
1129
|
+
|
|
1130
|
+
const saveWorkspace = useCallback(async (projectDir) => {
|
|
1131
|
+
if (!moduleKey) throw new Error('这个模块还没有自己的数据来源,先点 🔗 配一张表')
|
|
1132
|
+
const result = await api('/workspace', { method: 'POST', body: JSON.stringify({ moduleKey, projectDir }) })
|
|
1133
|
+
setWsInfo(result?.workspace ?? null)
|
|
1134
|
+
return result
|
|
1135
|
+
}, [moduleKey])
|
|
1136
|
+
|
|
1105
1137
|
useEffect(() => {
|
|
1106
1138
|
if (state?.configured) loadFields()
|
|
1107
1139
|
}, [state?.configured, loadFields])
|
|
@@ -1345,8 +1377,8 @@ window.__ModuleLoader__.load({
|
|
|
1345
1377
|
)
|
|
1346
1378
|
|
|
1347
1379
|
useEffect(() => {
|
|
1348
|
-
if (state?.configured) load()
|
|
1349
|
-
}, [state?.configured, load])
|
|
1380
|
+
if (state?.configured || moduleOwned) load()
|
|
1381
|
+
}, [state?.configured, moduleOwned, load])
|
|
1350
1382
|
|
|
1351
1383
|
useEffect(() => {
|
|
1352
1384
|
if (!selectedId) return undefined
|
|
@@ -1361,6 +1393,9 @@ window.__ModuleLoader__.load({
|
|
|
1361
1393
|
}
|
|
1362
1394
|
}, [selectedId])
|
|
1363
1395
|
|
|
1396
|
+
const data = useMemo(() => (moduleOwned && wsInfo?.moduleSource?.tableId
|
|
1397
|
+
? { ...rawData, source: wsInfo.moduleSource }
|
|
1398
|
+
: rawData), [rawData, moduleOwned, wsInfo])
|
|
1364
1399
|
const schemaFields = schema?.fields ?? []
|
|
1365
1400
|
const optionFields = useMemo(
|
|
1366
1401
|
() => schemaFields.filter((field) => field.options?.length),
|
|
@@ -1409,6 +1444,7 @@ window.__ModuleLoader__.load({
|
|
|
1409
1444
|
await api('/settings', { method: 'POST', body: JSON.stringify(patch) })
|
|
1410
1445
|
notifySettingsChanged(patch)
|
|
1411
1446
|
await reloadState()
|
|
1447
|
+
await onSavedSettings?.(patch)
|
|
1412
1448
|
setToast('已保存')
|
|
1413
1449
|
setShowSettings(false)
|
|
1414
1450
|
load()
|
|
@@ -1429,7 +1465,7 @@ window.__ModuleLoader__.load({
|
|
|
1429
1465
|
|
|
1430
1466
|
const copyInstruction = async () => {
|
|
1431
1467
|
if (!selected) return
|
|
1432
|
-
const text = instruction || buildInstruction(selected, settings, skills, resolveExpertPick(settings, expertData))
|
|
1468
|
+
const text = instruction || buildInstruction(selected, { ...settings, projectDir: moduleDirNow }, skills, resolveExpertPick(settings, expertData))
|
|
1433
1469
|
setInstruction(text)
|
|
1434
1470
|
setInstruction(text)
|
|
1435
1471
|
try {
|
|
@@ -1438,11 +1474,12 @@ window.__ModuleLoader__.load({
|
|
|
1438
1474
|
} catch {
|
|
1439
1475
|
setToast('剪贴板不可用,请手动全选复制下面的指令;这条任务的执行记录只留一条')
|
|
1440
1476
|
}
|
|
1441
|
-
await handOff(selected, '已复制开发指令', tableKey)
|
|
1477
|
+
await handOff(selected, '已复制开发指令', tableKey, moduleDirNow)
|
|
1442
1478
|
}
|
|
1443
1479
|
|
|
1444
1480
|
/** 回写飞书一律先弹页面确认,确认后才真的写。 */
|
|
1445
1481
|
const askWriteBack = (recordId, status, field, title) => {
|
|
1482
|
+
if (table?.readOnly) return
|
|
1446
1483
|
const type = (schemaFields ?? []).find((entry) => entry.name === field)?.type ?? ''
|
|
1447
1484
|
setPendingWrite({ recordId, status, field: field || groupField, fieldType: type, title: title || '', kind: 'status' })
|
|
1448
1485
|
setFailure(null)
|
|
@@ -1455,7 +1492,7 @@ window.__ModuleLoader__.load({
|
|
|
1455
1492
|
try {
|
|
1456
1493
|
await api('/requirement/status', {
|
|
1457
1494
|
method: 'POST',
|
|
1458
|
-
body: JSON.stringify({ recordId: pending.recordId, status: pending.status, field: pending.field, fieldType: pending.fieldType }),
|
|
1495
|
+
body: JSON.stringify({ tableKey, recordId: pending.recordId, status: pending.status, field: pending.field, fieldType: pending.fieldType }),
|
|
1459
1496
|
})
|
|
1460
1497
|
setToast(`已把「${pending.field}」回写为「${pending.status}」`)
|
|
1461
1498
|
} catch (error) {
|
|
@@ -1520,10 +1557,11 @@ window.__ModuleLoader__.load({
|
|
|
1520
1557
|
const settingsView = h(SettingsView, {
|
|
1521
1558
|
settings,
|
|
1522
1559
|
sources,
|
|
1560
|
+
failure: failure?.message,
|
|
1523
1561
|
larkCli: state?.larkCli,
|
|
1524
1562
|
chooseDirectory,
|
|
1525
1563
|
onReloadSources: loadSources,
|
|
1526
|
-
onCancel: () => setShowSettings(false),
|
|
1564
|
+
onCancel: onCloseSettings ?? (() => setShowSettings(false)),
|
|
1527
1565
|
onSave: saveSettings,
|
|
1528
1566
|
})
|
|
1529
1567
|
// 设置页是「提前 return」的独立分支:目录选择弹窗必须挂在这一层,
|
|
@@ -1536,10 +1574,17 @@ window.__ModuleLoader__.load({
|
|
|
1536
1574
|
h(DirectoryPickerDialog, {
|
|
1537
1575
|
initialPath: dirPicker.start,
|
|
1538
1576
|
onPick: (dir) => {
|
|
1577
|
+
// 有模块身份就只写这个模块;设置页(没有模块身份)才写全局项目目录。
|
|
1578
|
+
const resolve = dirPicker.resolve
|
|
1539
1579
|
setDirPicker(null)
|
|
1540
|
-
|
|
1580
|
+
if (typeof resolve === 'function') resolve(dir)
|
|
1581
|
+
else void saveSettings({ projectDir: dir })
|
|
1582
|
+
},
|
|
1583
|
+
onClose: () => {
|
|
1584
|
+
const resolve = dirPicker.resolve
|
|
1585
|
+
setDirPicker(null)
|
|
1586
|
+
if (typeof resolve === 'function') resolve('')
|
|
1541
1587
|
},
|
|
1542
|
-
onClose: () => setDirPicker(null),
|
|
1543
1588
|
}),
|
|
1544
1589
|
)
|
|
1545
1590
|
: settingsView
|
|
@@ -1582,6 +1627,18 @@ window.__ModuleLoader__.load({
|
|
|
1582
1627
|
)
|
|
1583
1628
|
: null,
|
|
1584
1629
|
h('button', { className: 'rdw-btn', onClick: () => setShowSettings(true) }, '设置'),
|
|
1630
|
+
moduleKey
|
|
1631
|
+
? h(
|
|
1632
|
+
'button',
|
|
1633
|
+
{
|
|
1634
|
+
className: 'rdw-btn',
|
|
1635
|
+
title: `这里是「${wsInfo?.projectDir || settings.projectDir || '跟随当前项目'}」;只改这个模块,别的模块不动`,
|
|
1636
|
+
'aria-label': '改这个模块的工作区',
|
|
1637
|
+
onClick: () => setWalletOpen(true),
|
|
1638
|
+
},
|
|
1639
|
+
`📁 ${String(wsInfo?.projectDir || settings.projectDir || '未选项目').split(/[\\/]/).filter(Boolean).pop() || '未选项目'}`,
|
|
1640
|
+
)
|
|
1641
|
+
: null,
|
|
1585
1642
|
),
|
|
1586
1643
|
h(
|
|
1587
1644
|
'div',
|
|
@@ -1891,7 +1948,7 @@ window.__ModuleLoader__.load({
|
|
|
1891
1948
|
instruction,
|
|
1892
1949
|
setInstruction,
|
|
1893
1950
|
copyInstruction,
|
|
1894
|
-
writeBack,
|
|
1951
|
+
writeBack: table?.readOnly ? null : writeBack,
|
|
1895
1952
|
chooseDirectory,
|
|
1896
1953
|
runs: itemRuns,
|
|
1897
1954
|
onUpdateRun,
|
|
@@ -1928,11 +1985,35 @@ window.__ModuleLoader__.load({
|
|
|
1928
1985
|
initialPath: dirPicker.start,
|
|
1929
1986
|
onPick: (dir) => {
|
|
1930
1987
|
setDirPicker(null)
|
|
1931
|
-
|
|
1988
|
+
// 这里是「这个模块」的目录:只写模块自己的记录,别动全局项目设置。
|
|
1989
|
+
if (!moduleKey) {
|
|
1990
|
+
setToast('这个模块还没有自己的数据来源,先点左栏模块名旁的 🔗 配一张表')
|
|
1991
|
+
return
|
|
1992
|
+
}
|
|
1993
|
+
void saveWorkspace(dir).then(() => {
|
|
1994
|
+
setToast(`已把「${table?.label ?? moduleKey}」的工作区设为 ${dir}(其他模块不变)`)
|
|
1995
|
+
setWalletOpen(true)
|
|
1996
|
+
}).catch((error) => setToast(`改工作区失败:${error.message}`))
|
|
1932
1997
|
},
|
|
1933
1998
|
onClose: () => setDirPicker(null),
|
|
1934
1999
|
})
|
|
1935
2000
|
: null,
|
|
2001
|
+
walletOpen
|
|
2002
|
+
? h(WorkspaceDialog, {
|
|
2003
|
+
moduleKey,
|
|
2004
|
+
moduleTitle: table?.label ?? moduleKey,
|
|
2005
|
+
data: wsInfo,
|
|
2006
|
+
chooseDirectory: (start) => new Promise((resolve) => {
|
|
2007
|
+
setDirPicker({ start: String(start ?? ''), resolve })
|
|
2008
|
+
}),
|
|
2009
|
+
onSave: async (projectDir) => {
|
|
2010
|
+
await saveWorkspace(projectDir)
|
|
2011
|
+
setToast(projectDir ? `已把「${table?.label ?? moduleKey}」的工作区设为 ${projectDir}` : '已改为跟随当前项目')
|
|
2012
|
+
await load(true)
|
|
2013
|
+
},
|
|
2014
|
+
onClose: () => setWalletOpen(false),
|
|
2015
|
+
})
|
|
2016
|
+
: null,
|
|
1936
2017
|
),
|
|
1937
2018
|
)
|
|
1938
2019
|
}
|
|
@@ -2107,7 +2188,15 @@ window.__ModuleLoader__.load({
|
|
|
2107
2188
|
)
|
|
2108
2189
|
}
|
|
2109
2190
|
|
|
2110
|
-
function SettingsView({ settings, sources, onCancel, onSave, larkCli, chooseDirectory, onReloadSources }) {
|
|
2191
|
+
function SettingsView({ settings, sources, failure, onCancel, onSave, larkCli, chooseDirectory, onReloadSources }) {
|
|
2192
|
+
const [remoteSource, setRemoteSource] = useState(null)
|
|
2193
|
+
useEffect(() => {
|
|
2194
|
+
let live = true
|
|
2195
|
+
api('/project-source')
|
|
2196
|
+
.then((result) => { if (live) setRemoteSource(result) })
|
|
2197
|
+
.catch(() => { if (live) setRemoteSource(null) })
|
|
2198
|
+
return () => { live = false }
|
|
2199
|
+
}, [])
|
|
2111
2200
|
const [link, setLink] = useState(settings.baseToken ? `${settings.baseToken} ${settings.tableId}` : '')
|
|
2112
2201
|
const [tableId, setTableId] = useState(settings.tableId ?? '')
|
|
2113
2202
|
const [projectDir, setProjectDir] = useState(settings.projectDir ?? '')
|
|
@@ -2136,14 +2225,14 @@ window.__ModuleLoader__.load({
|
|
|
2136
2225
|
h(Field, { label: '项目目录(绝对路径)', value: projectDir, placeholder: 'D:\\workspace\\your-project', onChange: setProjectDir }),
|
|
2137
2226
|
h('div', { className: 'rdw-toolbar', style: { marginTop: 6 } }, h('button', { className: 'rdw-btn', onClick: chooseRoot, disabled: !chooseDirectory }, '用系统目录选择器挑选')),
|
|
2138
2227
|
h('div', { className: 'rdw-note' }, '选好项目后,「技能与规范」会扫描它的 skill;如果项目里已经有需求源配置,会自动认出来。'),
|
|
2139
|
-
h('div', { className: 'rdw-note' }, '
|
|
2228
|
+
h('div', { className: 'rdw-note' }, '优先读取项目根目录的 sino-skill-config.json,未配置的类别仍可使用旧的独立配置文件。'),
|
|
2140
2229
|
// v4.5.3:选到「没有需求源配置」的目录时(比如换成了另一个工程),以前只会在原地打转,
|
|
2141
2230
|
// 看起来像「保存后没返回」。现在明确说清楚为什么看板读不到表,并给两条出路。
|
|
2142
2231
|
sources && !detected.length
|
|
2143
2232
|
? h(
|
|
2144
2233
|
'div',
|
|
2145
2234
|
{ className: 'rdw-note', style: { marginTop: 6, color: 'var(--dsw-alias-label-danger,#ff6b6b)' } },
|
|
2146
|
-
'
|
|
2235
|
+
'没有检测到项目需求源(sino-skill-config.json 或 .requirement-sources.json)。要读取需求表,可配置项目需求源,或在下面手动填写表格链接。',
|
|
2147
2236
|
)
|
|
2148
2237
|
: null,
|
|
2149
2238
|
),
|
|
@@ -2151,6 +2240,7 @@ window.__ModuleLoader__.load({
|
|
|
2151
2240
|
'div',
|
|
2152
2241
|
{ className: 'rdw-card', style: { marginTop: 12 } },
|
|
2153
2242
|
h('h3', null, '2. 需求来源'),
|
|
2243
|
+
failure ? h('div', { className: 'rdw-error', role: 'alert' }, failure) : null,
|
|
2154
2244
|
detected.length
|
|
2155
2245
|
? h(
|
|
2156
2246
|
'div',
|
|
@@ -2170,14 +2260,32 @@ window.__ModuleLoader__.load({
|
|
|
2170
2260
|
),
|
|
2171
2261
|
),
|
|
2172
2262
|
)
|
|
2173
|
-
: h('div', { className: 'rdw-note' }, '
|
|
2263
|
+
: h('div', { className: 'rdw-note' }, '项目没有可选的需求源。'),
|
|
2174
2264
|
h(Field, {
|
|
2175
|
-
label: '多维表格链接或 base_token
|
|
2265
|
+
label: '多维表格链接或 base_token(手动填写,选项目配置时也可留空)',
|
|
2176
2266
|
value: link,
|
|
2177
2267
|
placeholder: 'https://xxx.feishu.cn/base/xxxx?table=tblxxxx',
|
|
2178
2268
|
onChange: setLink,
|
|
2179
2269
|
}),
|
|
2180
|
-
h(
|
|
2270
|
+
remoteSource ? h(
|
|
2271
|
+
'div',
|
|
2272
|
+
{ style: { marginBottom: 8 } },
|
|
2273
|
+
h('div', { className: 'rdw-note' }, remoteSource.baseUrl ? `项目已保存的链接:${remoteSource.baseUrl}` : '还没有为这个项目单独保存链接。填好后点「保存并拉取需求」会写入本项目的 sino-skill-config.json。'),
|
|
2274
|
+
remoteSource.baseUrl
|
|
2275
|
+
? h('button', {
|
|
2276
|
+
className: 'rdw-btn',
|
|
2277
|
+
onClick: async () => {
|
|
2278
|
+
try {
|
|
2279
|
+
await api('/project-source', { method: 'POST', body: JSON.stringify({ baseUrl: '', projectDir }) })
|
|
2280
|
+
await onSave({ projectDir: remoteSource.projectDir ?? projectDir })
|
|
2281
|
+
} catch (error) {
|
|
2282
|
+
setFailure(error.message)
|
|
2283
|
+
}
|
|
2284
|
+
},
|
|
2285
|
+
}, '清除本项目链接')
|
|
2286
|
+
: null,
|
|
2287
|
+
) : null,
|
|
2288
|
+
h(Field, { label: '表名或 table_id(链接里已含 table 时可留空)', value: tableId, placeholder: 'tblxxxx', onChange: setTableId }),
|
|
2181
2289
|
h('div', { className: 'rdw-note' }, `读取身份:${larkCli ? `lark-cli 就绪(${larkCli})` : 'lark-cli 未找到'} · 本工作台不保存飞书凭证。`),
|
|
2182
2290
|
),
|
|
2183
2291
|
h(
|
|
@@ -2245,8 +2353,247 @@ window.__ModuleLoader__.load({
|
|
|
2245
2353
|
})
|
|
2246
2354
|
}
|
|
2247
2355
|
|
|
2356
|
+
/**
|
|
2357
|
+
* 模块数据来源:每个模块自己一份飞书表链接。
|
|
2358
|
+
*
|
|
2359
|
+
* 以前只有一个「表格设置」,改一次链接所有模块都跟着变;现在链接挂在模块上(存 view.json),
|
|
2360
|
+
* 改这个模块只影响这个模块。留空即回到「跟着项目配置走」。
|
|
2361
|
+
*/
|
|
2362
|
+
function ModuleSourceDialog({ moduleKey, moduleTitle, data, onClose, onSaved }) {
|
|
2363
|
+
const [link, setLink] = useState('')
|
|
2364
|
+
const [failure, setFailure] = useState('')
|
|
2365
|
+
const [busy, setBusy] = useState(false)
|
|
2366
|
+
const [notice, setNotice] = useState('')
|
|
2367
|
+
const [test, setTest] = useState(null)
|
|
2368
|
+
const [testing, setTesting] = useState(false)
|
|
2369
|
+
const [moduleDir, setModuleDir] = useState('')
|
|
2370
|
+
const [titleField, setTitleField] = useState('')
|
|
2371
|
+
const [rawField, setRawField] = useState('')
|
|
2372
|
+
const [optionNames, setOptionNames] = useState([])
|
|
2373
|
+
const loaded = data !== null
|
|
2374
|
+
useEffect(() => {
|
|
2375
|
+
if (!loaded) return
|
|
2376
|
+
setLink(String(data?.baseUrl ?? ''))
|
|
2377
|
+
setModuleDir(String(data?.ownProjectDir ?? ''))
|
|
2378
|
+
setTitleField(String(data?.fields?.title ?? ''))
|
|
2379
|
+
setRawField(String(data?.fields?.rawRequirement ?? ''))
|
|
2380
|
+
setTest(null)
|
|
2381
|
+
setFailure('')
|
|
2382
|
+
}, [loaded, data?.baseUrl, data?.moduleKey])
|
|
2383
|
+
useEffect(() => {
|
|
2384
|
+
if (!moduleKey) return
|
|
2385
|
+
let live = true
|
|
2386
|
+
api(`/fields?t=${encodeURIComponent(moduleKey)}`)
|
|
2387
|
+
.then((result) => { if (live) setOptionNames(Array.isArray(result?.names) ? result.names : []) })
|
|
2388
|
+
.catch(() => { if (live) setOptionNames([]) })
|
|
2389
|
+
return () => { live = false }
|
|
2390
|
+
}, [moduleKey, loaded])
|
|
2391
|
+
const save = async (baseUrl) => {
|
|
2392
|
+
setBusy(true)
|
|
2393
|
+
setFailure('')
|
|
2394
|
+
try {
|
|
2395
|
+
const fields = {}
|
|
2396
|
+
if (titleField.trim()) fields.title = titleField.trim()
|
|
2397
|
+
if (rawField.trim()) fields.rawRequirement = rawField.trim()
|
|
2398
|
+
await api('/module-source', { method: 'POST', body: JSON.stringify({ moduleKey, baseUrl, projectDir: moduleDir.trim(), fields: Object.keys(fields).length ? fields : null, setProjectDir: true }) })
|
|
2399
|
+
setNotice(baseUrl ? '已保存到这个模块' : '已恢复为跟随项目配置')
|
|
2400
|
+
if (typeof onSaved === 'function') await onSaved()
|
|
2401
|
+
onClose()
|
|
2402
|
+
} catch (error) {
|
|
2403
|
+
setFailure(error.message)
|
|
2404
|
+
} finally {
|
|
2405
|
+
setBusy(false)
|
|
2406
|
+
}
|
|
2407
|
+
}
|
|
2408
|
+
const probe = async () => {
|
|
2409
|
+
setTesting(true)
|
|
2410
|
+
setTest(null)
|
|
2411
|
+
try {
|
|
2412
|
+
const result = await api(`/records?table=${encodeURIComponent(`module:${moduleKey}`)}&fresh=1`)
|
|
2413
|
+
setTest(
|
|
2414
|
+
result?.error
|
|
2415
|
+
? { ok: false, text: `${result.error}${result.detail ? `:${String(result.detail).slice(0, 200)}` : ''}` }
|
|
2416
|
+
: { ok: true, text: `读到 ${result?.count ?? result?.items?.length ?? 0} 条记录(${result?.table?.tableId ?? ''})` },
|
|
2417
|
+
)
|
|
2418
|
+
} catch (error) {
|
|
2419
|
+
setTest({ ok: false, text: error.message })
|
|
2420
|
+
} finally {
|
|
2421
|
+
setTesting(false)
|
|
2422
|
+
}
|
|
2423
|
+
}
|
|
2424
|
+
return h(
|
|
2425
|
+
'div',
|
|
2426
|
+
{ className: 'rdw-mask', role: 'presentation', onClick: onClose },
|
|
2427
|
+
h(
|
|
2428
|
+
'div',
|
|
2429
|
+
{
|
|
2430
|
+
className: 'rdw-modal',
|
|
2431
|
+
role: 'dialog',
|
|
2432
|
+
'aria-modal': 'true',
|
|
2433
|
+
'aria-label': `模块数据来源:${moduleTitle}`,
|
|
2434
|
+
style: { width: 'min(560px,94vw)' },
|
|
2435
|
+
onClick: (event) => event.stopPropagation(),
|
|
2436
|
+
},
|
|
2437
|
+
h(
|
|
2438
|
+
'div',
|
|
2439
|
+
{ className: 'rdw-modal-head' },
|
|
2440
|
+
h('strong', null, `数据来源 · ${moduleTitle}`),
|
|
2441
|
+
h('span', { className: 'rdw-grow' }),
|
|
2442
|
+
h('button', { className: 'rdw-btn', onClick: onClose }, '关闭'),
|
|
2443
|
+
),
|
|
2444
|
+
!loaded
|
|
2445
|
+
? h('div', { className: 'rdw-note' }, data?.error ? `读取失败:${data.error}` : '读取中…')
|
|
2446
|
+
: h(
|
|
2447
|
+
'div',
|
|
2448
|
+
null,
|
|
2449
|
+
h('div', { className: 'rdw-note', style: { marginBottom: 8 } },
|
|
2450
|
+
'这个链接只属于当前模块:别的模块、别的项目都不会跟着变。留空则跟随「项目配置」(sino-skill-config.json)。'),
|
|
2451
|
+
h(Field, {
|
|
2452
|
+
label: '这个模块的多维表格链接',
|
|
2453
|
+
value: link,
|
|
2454
|
+
placeholder: 'https://xxx.feishu.cn/base/xxxx?table=tblxxxx',
|
|
2455
|
+
onChange: (value) => {
|
|
2456
|
+
setLink(value)
|
|
2457
|
+
setTest(null)
|
|
2458
|
+
},
|
|
2459
|
+
}),
|
|
2460
|
+
h(Field, {
|
|
2461
|
+
label: '这个模块的项目目录(留空 = 跟随当前项目)',
|
|
2462
|
+
value: moduleDir,
|
|
2463
|
+
placeholder: data.projectDir || 'D:\\workspace\\your-project',
|
|
2464
|
+
onChange: setModuleDir,
|
|
2465
|
+
}),
|
|
2466
|
+
h('div', { className: 'rdw-note' },
|
|
2467
|
+
`读取身份:${data.identity || 'bot'}${data.readOnly ? ' · 只读' : ''} · 同一个工作台里每个模块各存各的链接与目录,互不牵动。`),
|
|
2468
|
+
loaded && data?.resolved
|
|
2469
|
+
? h('div', { className: 'rdw-note' }, `当前实际读取:${data.resolved.tableId}${data.resolved.label ? `(${data.resolved.label})` : ''}`)
|
|
2470
|
+
: h('div', { className: 'rdw-note' }, '当前跟随项目配置。'),
|
|
2471
|
+
h('div', { className: 'rdw-note', style: { marginTop: 10 } },
|
|
2472
|
+
'字段映射(可选):手填「标题」与「原始需求」的真实列名,模块就按这两列显示。'),
|
|
2473
|
+
h(Field, {
|
|
2474
|
+
label: '标题字段(默认按 页面/标题 自动认)',
|
|
2475
|
+
value: titleField,
|
|
2476
|
+
placeholder: '页面',
|
|
2477
|
+
onChange: setTitleField,
|
|
2478
|
+
}),
|
|
2479
|
+
h(Field, {
|
|
2480
|
+
label: '原始需求字段(详情里展示的那一列)',
|
|
2481
|
+
value: rawField,
|
|
2482
|
+
placeholder: '需求|方案|问题',
|
|
2483
|
+
onChange: setRawField,
|
|
2484
|
+
}),
|
|
2485
|
+
optionNames.length
|
|
2486
|
+
? h('div', { className: 'rdw-note' }, `这张表已有的列:${optionNames.slice(0, 24).join('、')}`)
|
|
2487
|
+
: null,
|
|
2488
|
+
failure ? h('div', { className: 'rdw-error', role: 'alert', style: { marginTop: 8 } }, failure) : null,
|
|
2489
|
+
notice ? h('div', { className: 'rdw-note', style: { marginTop: 8 } }, notice) : null,
|
|
2490
|
+
test ? h('div', { className: 'rdw-note', style: { marginTop: 8, color: test.ok ? undefined : 'var(--dsw-alias-label-danger,#ff6b6b)' } }, test.text) : null,
|
|
2491
|
+
h(
|
|
2492
|
+
'div',
|
|
2493
|
+
{ className: 'rdw-toolbar', style: { marginTop: 12 } },
|
|
2494
|
+
h('button', { className: 'rdw-btn primary', disabled: busy, onClick: () => save(link.trim()) }, busy ? '保存中…' : '保存到这个模块'),
|
|
2495
|
+
h('button', { className: 'rdw-btn', disabled: busy || !link.trim(), onClick: () => save('') }, '改为跟随项目'),
|
|
2496
|
+
h('span', { className: 'rdw-grow' }),
|
|
2497
|
+
h('button', { className: 'rdw-btn', disabled: testing || !link.trim(), onClick: probe }, testing ? '读取中…' : '先试着读一次'),
|
|
2498
|
+
),
|
|
2499
|
+
),
|
|
2500
|
+
),
|
|
2501
|
+
)
|
|
2502
|
+
}
|
|
2503
|
+
|
|
2504
|
+
/**
|
|
2505
|
+
* 模块工作区弹窗:每个模块自己的项目目录。
|
|
2506
|
+
* 以前「选工作区」写的是全局 settings.projectDir,所以一改全改;
|
|
2507
|
+
* 现在只写这个模块自己的目录,别的模块一点不动。
|
|
2508
|
+
*/
|
|
2509
|
+
function WorkspaceDialog({ moduleKey, moduleTitle, data, onSave, onClose, chooseDirectory }) {
|
|
2510
|
+
const [dir, setDir] = useState('')
|
|
2511
|
+
const [busy, setBusy] = useState(false)
|
|
2512
|
+
const [failure, setFailure] = useState('')
|
|
2513
|
+
const [done, setDone] = useState('')
|
|
2514
|
+
useEffect(() => {
|
|
2515
|
+
if (data === null) return
|
|
2516
|
+
setDir(String(data?.ownProjectDir ?? ''))
|
|
2517
|
+
setFailure('')
|
|
2518
|
+
setDone('')
|
|
2519
|
+
}, [data])
|
|
2520
|
+
const save = async (projectDir) => {
|
|
2521
|
+
setBusy(true)
|
|
2522
|
+
setFailure('')
|
|
2523
|
+
try {
|
|
2524
|
+
await onSave(projectDir)
|
|
2525
|
+
setDone(projectDir ? `已把「${moduleTitle}」的工作区设为 ${projectDir}` : '已恢复为跟随当前项目')
|
|
2526
|
+
} catch (error) {
|
|
2527
|
+
setFailure(error.message)
|
|
2528
|
+
} finally {
|
|
2529
|
+
setBusy(false)
|
|
2530
|
+
}
|
|
2531
|
+
}
|
|
2532
|
+
const pick = async () => {
|
|
2533
|
+
if (typeof chooseDirectory !== 'function') return
|
|
2534
|
+
const picked = await chooseDirectory(String(data?.ownProjectDir ?? data?.projectDir ?? ''))
|
|
2535
|
+
if (picked) {
|
|
2536
|
+
setDir(picked)
|
|
2537
|
+
await save(picked)
|
|
2538
|
+
}
|
|
2539
|
+
}
|
|
2540
|
+
return h(
|
|
2541
|
+
'div',
|
|
2542
|
+
{ className: 'rdw-mask', role: 'presentation', onClick: onClose },
|
|
2543
|
+
h(
|
|
2544
|
+
'div',
|
|
2545
|
+
{
|
|
2546
|
+
className: 'rdw-modal',
|
|
2547
|
+
role: 'dialog',
|
|
2548
|
+
'aria-modal': 'true',
|
|
2549
|
+
'aria-label': `模块工作区:${moduleTitle}`,
|
|
2550
|
+
style: { width: 'min(560px,94vw)' },
|
|
2551
|
+
onClick: (event) => event.stopPropagation(),
|
|
2552
|
+
},
|
|
2553
|
+
h(
|
|
2554
|
+
'div',
|
|
2555
|
+
{ className: 'rdw-modal-head' },
|
|
2556
|
+
h('strong', null, `工作区 · ${moduleTitle}`),
|
|
2557
|
+
h('span', { className: 'rdw-grow' }),
|
|
2558
|
+
h('button', { className: 'rdw-btn', onClick: onClose }, '关闭'),
|
|
2559
|
+
),
|
|
2560
|
+
data === null
|
|
2561
|
+
? h('div', { className: 'rdw-note' }, '读取中…')
|
|
2562
|
+
: h(
|
|
2563
|
+
'div',
|
|
2564
|
+
null,
|
|
2565
|
+
h('div', { className: 'rdw-note', style: { marginBottom: 8 } },
|
|
2566
|
+
'这个目录只属于当前模块:技能扫描、开发指令里的工作目录都按它来;别的模块保持各自的选择。'),
|
|
2567
|
+
h(Field, {
|
|
2568
|
+
label: '这个模块的项目目录(留空 = 跟随当前项目)',
|
|
2569
|
+
value: dir,
|
|
2570
|
+
placeholder: data?.projectDir || 'D:\\workspace\\your-project',
|
|
2571
|
+
onChange: setDir,
|
|
2572
|
+
}),
|
|
2573
|
+
h('div', { className: 'rdw-note' },
|
|
2574
|
+
`当前实际生效:${data?.projectDir || '(还没选)'}${data?.ownProjectDir ? '(本模块自己的)' : '(跟随当前项目)'}`
|
|
2575
|
+
+ ` · ${data?.hasSource ? `已认到 ${data?.tableCount ?? 0} 张表` : '这个目录里没认到需求表'}`),
|
|
2576
|
+
data?.moduleSource?.tableId
|
|
2577
|
+
? h('div', { className: 'rdw-note' }, `本模块自己的表格链接:${data.moduleSource.tableId}(目录换了也不影响它)`)
|
|
2578
|
+
: null,
|
|
2579
|
+
failure ? h('div', { className: 'rdw-error', role: 'alert', style: { marginTop: 8 } }, failure) : null,
|
|
2580
|
+
done ? h('div', { className: 'rdw-note', style: { marginTop: 8 } }, done) : null,
|
|
2581
|
+
h(
|
|
2582
|
+
'div',
|
|
2583
|
+
{ className: 'rdw-toolbar', style: { marginTop: 12 } },
|
|
2584
|
+
h('button', { className: 'rdw-btn primary', disabled: busy, onClick: () => save(dir.trim()) }, busy ? '保存中…' : '只改这个模块'),
|
|
2585
|
+
h('button', { className: 'rdw-btn', disabled: busy, onClick: () => save('') }, '改为跟随当前项目'),
|
|
2586
|
+
h('span', { className: 'rdw-grow' }),
|
|
2587
|
+
h('button', { className: 'rdw-btn', disabled: busy || typeof chooseDirectory !== 'function', onClick: pick }, '用系统目录选择器挑选'),
|
|
2588
|
+
),
|
|
2589
|
+
),
|
|
2590
|
+
),
|
|
2591
|
+
)
|
|
2592
|
+
}
|
|
2593
|
+
|
|
2248
2594
|
/**
|
|
2249
2595
|
* 更新日志弹窗:左栏底部「vX.Y.Z · 更新日志」点开。
|
|
2596
|
+
*
|
|
2250
2597
|
* 内容来自包内 CHANGELOG.md(走 /changelog 接口解析成 sections),
|
|
2251
2598
|
* 只读不写;当前版本那一段标「当前版本」并默认展开在顶部。
|
|
2252
2599
|
*/
|
|
@@ -2406,12 +2753,12 @@ window.__ModuleLoader__.load({
|
|
|
2406
2753
|
h(
|
|
2407
2754
|
'div',
|
|
2408
2755
|
{ style: { marginTop: 14 } },
|
|
2409
|
-
h('div', { className: 'rdw-note' }, '回写飞书状态(可选)'),
|
|
2410
|
-
h(
|
|
2756
|
+
h('div', { className: 'rdw-note' }, writeBack ? '回写飞书状态(可选)' : '飞书来源:只读'),
|
|
2757
|
+
writeBack ? h(
|
|
2411
2758
|
'div',
|
|
2412
2759
|
{ className: 'rdw-toolbar', style: { marginTop: 6 } },
|
|
2413
2760
|
...statuses.map((status) => h('button', { key: status, className: 'rdw-btn', onClick: () => writeBack(status) }, status)),
|
|
2414
|
-
),
|
|
2761
|
+
) : null,
|
|
2415
2762
|
),
|
|
2416
2763
|
h(
|
|
2417
2764
|
'div',
|
|
@@ -3617,7 +3964,16 @@ window.__ModuleLoader__.load({
|
|
|
3617
3964
|
groupField: '状态',
|
|
3618
3965
|
listFields: ['需求标题', '状态', '优先级', '负责人', '期望完成时间'],
|
|
3619
3966
|
cardFields: ['状态', '负责人', '优先级', '期望完成时间'],
|
|
3620
|
-
|
|
3967
|
+
// 同一列在很多表里叫法不同:别名按「先出现的先用」认,模板的标准列名排第一(表里真有就优先用它)。
|
|
3968
|
+
// 认不到就跳过这一列,宁可在设置里手动补,也不摊出一排空列。
|
|
3969
|
+
aliases: {
|
|
3970
|
+
需求标题: ['页面', '需求名称', '标题', '需求', '名称'],
|
|
3971
|
+
负责人: ['开发顾问', '实施顾问', '处理人', '指派', '开发人'],
|
|
3972
|
+
期望完成时间: ['开发|配置计划结束时间×', '开发|配置计划结束时间', '计划结束时间', '期望完成', '截止时间', '计划完成时间'],
|
|
3973
|
+
优先级: ['需求优先级'],
|
|
3974
|
+
状态: ['需求状态', '进度'],
|
|
3975
|
+
},
|
|
3976
|
+
note: '需求池:按状态分组看汇总清单,列取标题 / 状态 / 优先级 / 负责人 / 期望完成时间(表里列名不同就自动认,比如「页面 / 开发顾问 / 计划结束时间」)。',
|
|
3621
3977
|
},
|
|
3622
3978
|
{
|
|
3623
3979
|
id: 'task',
|
|
@@ -3627,6 +3983,12 @@ window.__ModuleLoader__.load({
|
|
|
3627
3983
|
groupField: '状态',
|
|
3628
3984
|
listFields: ['任务标题', '状态', '优先级', '负责人', '任务类型', '预估工时'],
|
|
3629
3985
|
cardFields: ['状态', '负责人', '优先级', '预估工时'],
|
|
3986
|
+
aliases: {
|
|
3987
|
+
任务标题: ['任务名称', '标题', '名称', '任务'],
|
|
3988
|
+
负责人: ['指派', '处理人', '开发人', '执行人'],
|
|
3989
|
+
预估工时: ['工时', '预计工时', '预估人天', '人天', '工作量'],
|
|
3990
|
+
任务类型: ['类型', '任务分类'],
|
|
3991
|
+
},
|
|
3630
3992
|
note: '任务表:按状态分组看卡片看板,卡片给负责人 / 优先级 / 预估工时。',
|
|
3631
3993
|
},
|
|
3632
3994
|
]
|
|
@@ -3650,15 +4012,39 @@ window.__ModuleLoader__.load({
|
|
|
3650
4012
|
return suffix ? `${template.name} · ${suffix}` : template.name
|
|
3651
4013
|
}
|
|
3652
4014
|
|
|
4015
|
+
/**
|
|
4016
|
+
* 模板里的一个标准列,在这张表里实际叫哪一列:
|
|
4017
|
+
* 1. 表里本来就叫这个名 -> 用它本人;
|
|
4018
|
+
* 2. 否则按模板的别名顺序找(先出现的先用),找到就用它;
|
|
4019
|
+
* 3. 别名后面被加了标记(表里常见的「上线批次×」「开发顾问×」)也算;
|
|
4020
|
+
* 4. 都没有 -> 返回空,调用方据此跳过这一列。
|
|
4021
|
+
*/
|
|
4022
|
+
function templateColumn(template, name, known) {
|
|
4023
|
+
const names = Array.isArray(known) ? known.filter(Boolean) : []
|
|
4024
|
+
if (names.includes(name)) return name
|
|
4025
|
+
const marked = (target) => {
|
|
4026
|
+
if (!target || !/[×✕**※]$/u.test(target)) return ''
|
|
4027
|
+
const head = target.slice(0, -1).replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
|
4028
|
+
return names.find((entry) => new RegExp(`^${head}[×✕**※]$`, 'u').test(entry)) ?? ''
|
|
4029
|
+
}
|
|
4030
|
+
for (const alias of template?.aliases?.[name] ?? []) {
|
|
4031
|
+
if (names.includes(alias)) return alias
|
|
4032
|
+
const variant = marked(alias)
|
|
4033
|
+
if (variant) return variant
|
|
4034
|
+
}
|
|
4035
|
+
return marked(name)
|
|
4036
|
+
}
|
|
4037
|
+
|
|
3653
4038
|
/**
|
|
3654
4039
|
* 模板落到某张表的配置切片。列只保留这张表真的有的字段 ——
|
|
3655
4040
|
* 字段读不到(没连 lark-cli / 没缓存)时给空数组,让列表回到「自动列」,宁可不预设也别摊一排空列。
|
|
4041
|
+
* 列名按别名认(见 templateColumn),认到的就是这张表里的真实列名,所以写进去就能直接显示。
|
|
3656
4042
|
*/
|
|
3657
4043
|
function templateSlice(template, fieldNames) {
|
|
3658
4044
|
const known = Array.isArray(fieldNames) ? fieldNames.filter(Boolean) : []
|
|
3659
|
-
const keep = (names) => (known.length ? names.
|
|
4045
|
+
const keep = (names) => (known.length ? [...new Set(names.map((name) => templateColumn(template, name, known)).filter(Boolean))] : [])
|
|
3660
4046
|
return {
|
|
3661
|
-
groupField: template.groupField,
|
|
4047
|
+
groupField: templateColumn(template, template.groupField, known) || template.groupField,
|
|
3662
4048
|
listFields: keep(template.listFields),
|
|
3663
4049
|
cardFields: keep(template.cardFields),
|
|
3664
4050
|
}
|
|
@@ -4787,6 +5173,55 @@ window.__ModuleLoader__.load({
|
|
|
4787
5173
|
setChangelog({ found: false, sections: [], error: error.message })
|
|
4788
5174
|
}
|
|
4789
5175
|
}, [changelog])
|
|
5176
|
+
// 「模块数据来源」对话框:每个模块各自一份,openSource 时读该模块当前绑定的表。
|
|
5177
|
+
const [sourceFor, setSourceFor] = useState('')
|
|
5178
|
+
const [sourceDialog, setSourceDialog] = useState(null)
|
|
5179
|
+
const reloadSources = useCallback(async (moduleKey) => {
|
|
5180
|
+
try {
|
|
5181
|
+
setSourceDialog(await api(`/module-source?module=${encodeURIComponent(moduleKey)}`))
|
|
5182
|
+
} catch (error) {
|
|
5183
|
+
setSourceDialog({ error: error.message, moduleKey })
|
|
5184
|
+
}
|
|
5185
|
+
}, [])
|
|
5186
|
+
useEffect(() => {
|
|
5187
|
+
if (!sourceFor) return
|
|
5188
|
+
setSourceDialog(null)
|
|
5189
|
+
void reloadSources(sourceFor)
|
|
5190
|
+
}, [sourceFor, reloadSources])
|
|
5191
|
+
// 「模块工作区」对话框:同样只认这个模块自己的目录。
|
|
5192
|
+
const [workspaceFor, setWorkspaceFor] = useState('')
|
|
5193
|
+
const [workspaceDialog, setWorkspaceDialog] = useState(null)
|
|
5194
|
+
const reloadWorkspace = useCallback(async (moduleKey) => {
|
|
5195
|
+
try {
|
|
5196
|
+
setWorkspaceDialog(await api(`/workspace?module=${encodeURIComponent(moduleKey)}`))
|
|
5197
|
+
} catch (error) {
|
|
5198
|
+
setWorkspaceDialog({ error: error.message })
|
|
5199
|
+
}
|
|
5200
|
+
}, [])
|
|
5201
|
+
useEffect(() => {
|
|
5202
|
+
if (!workspaceFor) return
|
|
5203
|
+
setWorkspaceDialog(null)
|
|
5204
|
+
void reloadWorkspace(workspaceFor)
|
|
5205
|
+
}, [workspaceFor, reloadWorkspace])
|
|
5206
|
+
const saveModuleWorkspace = useCallback(async (projectDir) => {
|
|
5207
|
+
const result = await api('/workspace', { method: 'POST', body: JSON.stringify({ moduleKey: workspaceFor, projectDir }) })
|
|
5208
|
+
setWorkspaceDialog(result?.workspace ?? null)
|
|
5209
|
+
await reloadView()
|
|
5210
|
+
await reloadTables()
|
|
5211
|
+
return result
|
|
5212
|
+
}, [workspaceFor, reloadView, reloadTables])
|
|
5213
|
+
/** 让用户自己挑一个目录(优先系统对话框,没有就用自带的浏览器)。 */
|
|
5214
|
+
const pickDirectoryStarting = useCallback(async (start) => {
|
|
5215
|
+
if (uiWorkspace?.pickDirectory) {
|
|
5216
|
+
const picked = await uiWorkspace.pickDirectory()
|
|
5217
|
+
return picked || ''
|
|
5218
|
+
}
|
|
5219
|
+
const picked = await new Promise((resolve) => {
|
|
5220
|
+
setWorkspacePick({ start: String(start ?? ''), resolve })
|
|
5221
|
+
})
|
|
5222
|
+
return picked || ''
|
|
5223
|
+
}, [uiWorkspace])
|
|
5224
|
+
const [workspacePick, setWorkspacePick] = useState(null)
|
|
4790
5225
|
const renameModule = useCallback(
|
|
4791
5226
|
async (key, title) => {
|
|
4792
5227
|
const trimmed = String(title ?? '').trim()
|
|
@@ -4800,7 +5235,7 @@ window.__ModuleLoader__.load({
|
|
|
4800
5235
|
)
|
|
4801
5236
|
|
|
4802
5237
|
const handOff = useCallback(
|
|
4803
|
-
async (item, note, tableKey) => {
|
|
5238
|
+
async (item, note, tableKey, projectDir) => {
|
|
4804
5239
|
if (!item) return
|
|
4805
5240
|
try {
|
|
4806
5241
|
const result = await api('/runs', {
|
|
@@ -4809,7 +5244,7 @@ window.__ModuleLoader__.load({
|
|
|
4809
5244
|
tableKey: tableKey ?? '',
|
|
4810
5245
|
recordId: item.id,
|
|
4811
5246
|
title: item.title,
|
|
4812
|
-
projectDir: state?.settings?.projectDir ?? '',
|
|
5247
|
+
projectDir: String(projectDir ?? state?.settings?.projectDir ?? ''),
|
|
4813
5248
|
status: 'handed-off',
|
|
4814
5249
|
note: note ?? '',
|
|
4815
5250
|
}),
|
|
@@ -4870,7 +5305,12 @@ window.__ModuleLoader__.load({
|
|
|
4870
5305
|
{ kind: 'experts', id: 'experts', glyph: '🎓', label: '专家与专家团' },
|
|
4871
5306
|
]
|
|
4872
5307
|
for (const module of view?.modules?.length ? view.modules : defaultModules(tables)) {
|
|
4873
|
-
|
|
5308
|
+
// 模块自带的表用模块 key 当表 key(服务端 /fields、/records 都按它精确取),
|
|
5309
|
+
// 否则原来配的那张项目表被换掉后,模块会去借别的表甚至找不到表。
|
|
5310
|
+
const ownSource = module.source ? module.sourceResolved ?? module.source : null
|
|
5311
|
+
const table = (ownSource
|
|
5312
|
+
? { key: module.key, moduleKey: module.key, label: ownSource.label || ownSource.tableName || module.title, kind: ownSource.readOnly ? 'task' : 'requirement', own: true }
|
|
5313
|
+
: null) ?? tables.find((entry) => entry.key === module.tableKey)
|
|
4874
5314
|
list.push({
|
|
4875
5315
|
kind: 'table',
|
|
4876
5316
|
id: module.key,
|
|
@@ -5085,6 +5525,38 @@ window.__ModuleLoader__.load({
|
|
|
5085
5525
|
'✎',
|
|
5086
5526
|
)
|
|
5087
5527
|
: null,
|
|
5528
|
+
entry.kind === 'table' && renamingId !== entry.id
|
|
5529
|
+
? h(
|
|
5530
|
+
'button',
|
|
5531
|
+
{
|
|
5532
|
+
className: 'rdw-mod-edit',
|
|
5533
|
+
title: `设置这个模块的飞书表格:${entry.label}`,
|
|
5534
|
+
'aria-label': `设置数据来源:${entry.label}`,
|
|
5535
|
+
onClick: (event) => {
|
|
5536
|
+
event.stopPropagation()
|
|
5537
|
+
setSourceFor(entry.id)
|
|
5538
|
+
setActive(entry.id)
|
|
5539
|
+
},
|
|
5540
|
+
},
|
|
5541
|
+
'🔗',
|
|
5542
|
+
)
|
|
5543
|
+
: null,
|
|
5544
|
+
entry.kind === 'table' && renamingId !== entry.id
|
|
5545
|
+
? h(
|
|
5546
|
+
'button',
|
|
5547
|
+
{
|
|
5548
|
+
className: 'rdw-mod-edit',
|
|
5549
|
+
title: `设置这个模块的工作区(只影响这个模块):${entry.label}`,
|
|
5550
|
+
'aria-label': `设置工作区:${entry.label}`,
|
|
5551
|
+
onClick: (event) => {
|
|
5552
|
+
event.stopPropagation()
|
|
5553
|
+
setWorkspaceFor(entry.id)
|
|
5554
|
+
setActive(entry.id)
|
|
5555
|
+
},
|
|
5556
|
+
},
|
|
5557
|
+
'📁',
|
|
5558
|
+
)
|
|
5559
|
+
: null,
|
|
5088
5560
|
),
|
|
5089
5561
|
),
|
|
5090
5562
|
h(
|
|
@@ -5159,9 +5631,18 @@ window.__ModuleLoader__.load({
|
|
|
5159
5631
|
: h(TableModule, {
|
|
5160
5632
|
// key 里带上「配置好了没」:从设置页回到内容区时重建一次,
|
|
5161
5633
|
// 宽度测量才挂得到新出现的容器上(否则窄内容区的详情让位不会生效)。
|
|
5162
|
-
key: `${activeEntry?.id}:${state?.configured ? 'ready' : 'setup'}`,
|
|
5634
|
+
key: `${activeEntry?.id}:${state?.configured ? 'ready' : 'setup'}:${state?.settings?.projectDir ?? ''}`,
|
|
5163
5635
|
state,
|
|
5164
5636
|
reloadState,
|
|
5637
|
+
settingsOnly: activeEntry?.kind === 'settings',
|
|
5638
|
+
onCloseSettings: activeEntry?.kind === 'settings' ? () => setActive('overview') : undefined,
|
|
5639
|
+
onSavedSettings: async (patch) => {
|
|
5640
|
+
await reloadTables()
|
|
5641
|
+
if (Object.hasOwn(patch, 'baseInput')) {
|
|
5642
|
+
if (activeEntry?.kind === 'settings') setActive('overview')
|
|
5643
|
+
await loadOverview(true)
|
|
5644
|
+
}
|
|
5645
|
+
},
|
|
5165
5646
|
uiWorkspace,
|
|
5166
5647
|
table: activeEntry?.table,
|
|
5167
5648
|
view: sliceForTable(view, activeEntry?.module?.tableKey ?? ''),
|
|
@@ -5189,6 +5670,52 @@ window.__ModuleLoader__.load({
|
|
|
5189
5670
|
showConversation ? (frameActive && conversation ? conversation : h('div', { className: 'rdw-note', style: { padding: 12 } }, '宿主没有提供对话区;可以改成用左侧原来的对话窗口。')) : null,
|
|
5190
5671
|
),
|
|
5191
5672
|
changelogOpen ? h(ChangelogDialog, { data: changelog, current: WORKBENCH_VERSION, onClose: () => setChangelogOpen(false) }) : null,
|
|
5673
|
+
sourceFor
|
|
5674
|
+
? h(ModuleSourceDialog, {
|
|
5675
|
+
key: sourceFor,
|
|
5676
|
+
moduleKey: sourceFor,
|
|
5677
|
+
moduleTitle: railModules.find((entry) => entry.id === sourceFor)?.label ?? sourceFor,
|
|
5678
|
+
data: sourceDialog,
|
|
5679
|
+
onClose: () => {
|
|
5680
|
+
setSourceFor('')
|
|
5681
|
+
setSourceDialog(null)
|
|
5682
|
+
},
|
|
5683
|
+
onSaved: async () => {
|
|
5684
|
+
await reloadTables()
|
|
5685
|
+
await reloadView()
|
|
5686
|
+
await loadOverview(true)
|
|
5687
|
+
},
|
|
5688
|
+
})
|
|
5689
|
+
: null,
|
|
5690
|
+
workspaceFor
|
|
5691
|
+
? h(WorkspaceDialog, {
|
|
5692
|
+
key: workspaceFor,
|
|
5693
|
+
moduleKey: workspaceFor,
|
|
5694
|
+
moduleTitle: railModules.find((entry) => entry.id === workspaceFor)?.label ?? workspaceFor,
|
|
5695
|
+
data: workspaceDialog,
|
|
5696
|
+
chooseDirectory: pickDirectoryStarting,
|
|
5697
|
+
onSave: saveModuleWorkspace,
|
|
5698
|
+
onClose: () => {
|
|
5699
|
+
setWorkspaceFor('')
|
|
5700
|
+
setWorkspaceDialog(null)
|
|
5701
|
+
},
|
|
5702
|
+
})
|
|
5703
|
+
: null,
|
|
5704
|
+
workspacePick
|
|
5705
|
+
? h(DirectoryPickerDialog, {
|
|
5706
|
+
initialPath: workspacePick.start,
|
|
5707
|
+
onPick: (dir) => {
|
|
5708
|
+
const resolve = workspacePick.resolve
|
|
5709
|
+
setWorkspacePick(null)
|
|
5710
|
+
resolve(dir || '')
|
|
5711
|
+
},
|
|
5712
|
+
onClose: () => {
|
|
5713
|
+
const resolve = workspacePick.resolve
|
|
5714
|
+
setWorkspacePick(null)
|
|
5715
|
+
resolve('')
|
|
5716
|
+
},
|
|
5717
|
+
})
|
|
5718
|
+
: null,
|
|
5192
5719
|
])
|
|
5193
5720
|
}
|
|
5194
5721
|
|
|
@@ -5205,6 +5732,8 @@ window.__ModuleLoader__.load({
|
|
|
5205
5732
|
* 这里的 ctx.slots 用嵌套 inject + try/catch 拿:宿主没提供 slots 时工作台本体照常可用。
|
|
5206
5733
|
*/
|
|
5207
5734
|
function ExpertComposerEntry(props) {
|
|
5735
|
+
// 输入框入口可独立挂载,不能依赖用户先打开 BusinessPanel 才加载样式。
|
|
5736
|
+
ensureStyles()
|
|
5208
5737
|
const [open, setOpen] = useState(false)
|
|
5209
5738
|
const [data, setData] = useState(null)
|
|
5210
5739
|
const [failure, setFailure] = useState('')
|
|
@@ -5617,7 +6146,7 @@ window.__ModuleLoader__.load({
|
|
|
5617
6146
|
// Desktop 上有它就优先用(apply 里按需检测),没有就走原生 main 面板。
|
|
5618
6147
|
inject: [],
|
|
5619
6148
|
// 自测钩子:给 test/smoke.mjs 直接跑组件函数体与纯函数用;宿主只读 apply/inject,多余的键会被忽略。
|
|
5620
|
-
__components: { BusinessPanel, TableModule, OverviewModule, ModuleDialog, DetailView, ChangelogDialog, ViewConfigPanel, SettingsView, SkillsModule, DevModule, ExpertsModule, ExpertComposerEntry, FlowModule, DocsModule, DirectoryPickerDialog },
|
|
6149
|
+
__components: { BusinessPanel, TableModule, OverviewModule, ModuleDialog, ModuleSourceDialog, WorkspaceDialog, DetailView, ChangelogDialog, ViewConfigPanel, SettingsView, SkillsModule, DevModule, ExpertsModule, ExpertComposerEntry, FlowModule, DocsModule, DirectoryPickerDialog },
|
|
5621
6150
|
__pure: {
|
|
5622
6151
|
summarizeBuckets,
|
|
5623
6152
|
runBadge,
|
|
@@ -5628,6 +6157,7 @@ window.__ModuleLoader__.load({
|
|
|
5628
6157
|
templateForTableKind,
|
|
5629
6158
|
templateTables,
|
|
5630
6159
|
templateTitle,
|
|
6160
|
+
templateColumn,
|
|
5631
6161
|
templateSlice,
|
|
5632
6162
|
formatTime,
|
|
5633
6163
|
formatCellValue,
|