dsh-task-board-tapd 0.0.0-stage → 0.5.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/INSTALL.md +137 -0
- package/README.md +139 -2
- package/client.js +691 -0
- package/cordis.patch.yml +19 -0
- package/icon.svg +6 -0
- package/index.js +30 -0
- package/install.ps1 +19 -0
- package/install.sh +19 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +41 -3
- package/src/host/config.js +24 -0
- package/src/host/routes.js +53 -0
- package/src/host/service.js +352 -0
- package/src/host/tapd.js +176 -0
- package/src/host/tools.js +60 -0
- package/src/host/version.js +138 -0
package/client.js
ADDED
|
@@ -0,0 +1,691 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dsh-task-board-tapd client half.
|
|
3
|
+
*
|
|
4
|
+
* Renders a TAPD task board inside the DeepSeek Harness Web shell:
|
|
5
|
+
* - a sidebar panel row (`sidebar.panellist`)
|
|
6
|
+
* - the center-column page (`main`, keyed by the same panel id)
|
|
7
|
+
*
|
|
8
|
+
* Data flows through the Host's same-origin routes:
|
|
9
|
+
* GET /api/tapd-board/state -> snapshot
|
|
10
|
+
* POST /api/tapd-board/action -> { action, payload } -> snapshot
|
|
11
|
+
*
|
|
12
|
+
* Styles use only host theme tokens (--dsw-alias-*). No Harness Client
|
|
13
|
+
* package imports; React comes from the module table.
|
|
14
|
+
*/
|
|
15
|
+
window.__ModuleLoader__.load({
|
|
16
|
+
id: 'dsh-task-board-tapd',
|
|
17
|
+
factory(require) {
|
|
18
|
+
const React = require('react')
|
|
19
|
+
const { useEffect, useRef, useState, useCallback, useMemo } = React
|
|
20
|
+
const h = React.createElement
|
|
21
|
+
|
|
22
|
+
const NS = 'tapd-task-board'
|
|
23
|
+
const PANEL_ID = 'tapd-task-board'
|
|
24
|
+
const ORDER = 30
|
|
25
|
+
|
|
26
|
+
const dicts = {
|
|
27
|
+
zh: {
|
|
28
|
+
entry: 'TAPD 看板',
|
|
29
|
+
title: 'TAPD 任务看板',
|
|
30
|
+
story: '需求', task: '任务', bug: '缺陷',
|
|
31
|
+
refresh: '刷新', lastUpdated: '更新于', workspace: '工作区',
|
|
32
|
+
search: '搜索标题 / ID', newStory: '新建需求', mineOnly: '只看我的', showAll: '全部',
|
|
33
|
+
fields: { status: '状态', owner: '处理人', creator: '创建人', priority: '优先级', due: '截止', begin: '开始', created: '创建时间', modified: '修改时间', module: '模块', severity: '严重程度', reporter: '报告人', iterationId: '迭代', id: 'ID', url: '打开 TAPD' },
|
|
34
|
+
detail: '详情', close: '关闭', move: '改状态', save: '保存', commentPlaceholder: '输入评论…', comment: '评论', comments: '评论', empty: '暂无数据', noResult: '没有匹配的工作项',
|
|
35
|
+
create: { title: '新建需求', name: '标题', description: '描述', owner: '处理人', priority: '优先级', create: '创建', cancel: '取消' },
|
|
36
|
+
priorityLabel: { '1': '高', '2': '中', '3': '低' },
|
|
37
|
+
loading: '正在刷新 TAPD…', updated: '已更新于', settings: '设置', setupTitle: 'TAPD / AI 设置', saveSettings: '保存设置', tokenReady: 'Token 已配置', tokenMissing: '缺少 Token', setupDocs: '首次使用:请在系统环境变量中配置 TAPD_TOKEN、TAPD_WORKSPACE_ID(或 TAPD_WORKSPACE_IDS)、TAPD_API_ENDPOINT,保存后点击刷新。', scheduleHint: '定时执行:在工作项详情中直接选择执行时间;到点会自动创建独立会话并由 Agent 使用 TAPD 工具处理。', aiSection: 'AI 执行(DeepSeek)', chatHint: '复制下方的执行提示,粘贴到任意 DeepSeek 对话中即可让客户端直接处理这条任务(Agent 具备 tapd_board_* 工具,可读详情、改状态、评论、建需求)。', copyPrompt: '复制执行提示', copied: '已复制,可粘贴到对话中直接执行', scheduleSection: '定时执行', scheduleViaChat: '选择时间后,插件会创建独立会话;到点自动唤醒 Agent 执行 TAPD 任务。', scheduleAtLabel: '执行时间', scheduleCreate: '创建自动任务', scheduleCreated: '已创建自动执行任务', scheduleUnavailable: '当前 DSH 未启用定时服务', workspacePathsLabel: 'TAPD 工作区 → DSH 执行工作区', workspacePathPlaceholder: '选择本地目录(如项目根目录)', workspacePathPick: '选择目录', workspacePathNone: '未选择执行工作区,将在默认空间执行', workspaceRegisterHint: '执行空间是当前任务的独立设置;可选择已登记的 DSH 工作区,或登记新的代码工程工作区。', workspacePathHint: '为每个 TAPD 工作区(任务登记的空间)绑定一个 DSH 工作区(任务执行的空间,绑定代码工程目录)。绑定后,该工作区的定时任务到点会自动在该 DSH 工作区打开会话,Agent 可直接读写对应代码工程;未绑定的工作区使用默认空间。可点「登记新工作区」用系统目录选择器把本地项目目录登记为 DSH 工作区。', workspacePathOverride: '执行空间目录(可选)', runInSpace: '执行空间', workspaceBindDefault: '(默认空间)', workspaceRegisterNew: '登记新工作区', workspaceRegistered: '已登记并绑定', workspaceNoRegistry: '当前 DSH 无已登记的工作区', endpointLabel: 'API 端点', workspaceIdsLabel: '工作区 ID(逗号分隔)', refreshSecondsLabel: '自动刷新间隔(秒)', listLimitLabel: '每类型条数上限', modelLabel: '默认模型(provider/model)', announceLabel: '向 Agent 声明本插件工具(对话可操作 TAPD)', error: '出错了', retry: '重试', deleting: '', unknown: '其他', welcomeTitle: '欢迎使用 TAPD 看板', welcomeSubtitle: '第一次使用请先完成 TAPD 配置;已配置可跳过。', welcomeVersionLabel: '当前版本', welcomeConfigTitle: '1. TAPD 配置', welcomeConfigStep1: '在系统环境变量中配置 TAPD_TOKEN(个人 Token,必填)', welcomeConfigStep2: '配置 TAPD_WORKSPACE_ID(单个)或 TAPD_WORKSPACE_IDS(多个,逗号分隔)', welcomeConfigStep3: '可选配置 TAPD_API_ENDPOINT,默认 https://api.tapd.cn;完成后完全退出并重开 DSH', welcomeGuideTitle: '2. 快速上手', welcomeGuideDrag: '拖拽卡片到其他泳道即可修改任务状态', welcomeGuideDetail: '点击卡片查看详情、评论、改状态', welcomeGuideSchedule: '在详情中选择执行时间与工作区,可创建到点自动执行的会话', welcomeGuideAgent: '对话中可用 tapd_board_* 工具读取和操作 TAPD', welcomeUpdateTitle: '3. 版本更新', welcomeUpToDate: '已是最新版本', welcomeNewVersion: '发现新版本', welcomeCheckUpdate: '检查更新', welcomeChecking: '正在检查…', welcomeUpdateNow: '立即更新', welcomeUpdating: '正在更新…', welcomeUpdated: '已更新,重启 DSH 后生效', welcomeOpenSettings: '打开设置', welcomeGotIt: '知道了', help: '帮助', versionLabel: '版本', newVersionBadge: '有新版本', currentVersion: '当前版本', latestVersion: '最新版本', checkUpdate: '检查更新', updateNow: '立即更新', updateRestartHint: '更新后需完全退出并重启 DSH 才能生效', versionSection: '版本与更新', updateDone: '已安装新版本', updateFailed: '更新失败', updateError: '检查更新失败',
|
|
38
|
+
},
|
|
39
|
+
en: {
|
|
40
|
+
entry: 'TAPD Board',
|
|
41
|
+
title: 'TAPD Task Board',
|
|
42
|
+
story: 'Stories', task: 'Tasks', bug: 'Bugs',
|
|
43
|
+
refresh: 'Refresh', lastUpdated: 'Updated', workspace: 'Workspace',
|
|
44
|
+
search: 'Search title / ID', newStory: 'New Story', mineOnly: 'Mine', showAll: 'All',
|
|
45
|
+
fields: { status: 'Status', owner: 'Owner', creator: 'Creator', priority: 'Priority', due: 'Due', begin: 'Start', created: 'Created', modified: 'Modified', module: 'Module', severity: 'Severity', reporter: 'Reporter', iterationId: 'Iteration', id: 'ID', url: 'Open TAPD' },
|
|
46
|
+
detail: 'Detail', close: 'Close', move: 'Status', save: 'Save', commentPlaceholder: 'Write a comment…', comment: 'Comment', comments: 'Comments', empty: 'No data', noResult: 'No matching items',
|
|
47
|
+
create: { title: 'New Story', name: 'Title', description: 'Description', owner: 'Owner', priority: 'Priority', create: 'Create', cancel: 'Cancel' },
|
|
48
|
+
priorityLabel: { '1': 'High', '2': 'Medium', '3': 'Low' },
|
|
49
|
+
loading: 'Refreshing TAPD…', updated: 'Updated', settings: 'Settings', setupTitle: 'TAPD / AI Settings', saveSettings: 'Save', tokenReady: 'Token configured', tokenMissing: 'Token missing', setupDocs: 'First run: configure TAPD_TOKEN, TAPD_WORKSPACE_ID (or TAPD_WORKSPACE_IDS) and TAPD_API_ENDPOINT as env vars, then refresh.', scheduleHint: 'Schedule runs from a story/task/bug detail: pick an execution time, and the plugin creates a dedicated Session that the Agent wakes to process the TAPD item.', aiSection: 'AI execution (DeepSeek)', chatHint: 'Copy the execution prompt and paste it into any DeepSeek chat. The Agent has tapd_board_* tools to read, update, comment, and create TAPD items.', copyPrompt: 'Copy prompt', copied: 'Copied. Paste it into a chat to run', scheduleSection: 'Scheduled execution', scheduleViaChat: 'Pick a time. The plugin creates a dedicated Session and wakes an Agent to execute the TAPD task automatically.', scheduleAtLabel: 'Execution time', scheduleCreate: 'Create automatic task', scheduleCreated: 'Automatic task scheduled', scheduleUnavailable: 'DSH scheduling service is not enabled', workspacePathsLabel: 'TAPD workspace → DSH execution workspace', workspacePathPlaceholder: 'Pick a local directory (e.g. project root)', workspacePathPick: 'Pick directory', workspacePathNone: 'No execution workspace chosen; will run in the default space', workspaceRegisterHint: 'The execution workspace is a per-task setting: pick a registered DSH workspace or register a new code project workspace.', workspacePathHint: 'Bind each TAPD workspace (where tasks are registered) to a DSH workspace (where tasks execute; bound to a code project directory). Scheduled tasks from a bound TAPD workspace then open their Session in that DSH workspace so the Agent can read/write the project; unmapped workspaces run in the default space. Use "Register new space" to register a project directory as a DSH workspace via the native picker.', workspacePathOverride: 'Run directory (optional)', runInSpace: 'Runs in space', workspaceBindDefault: '(default space)', workspaceRegisterNew: 'Register new space', workspaceRegistered: 'Registered and bound', workspaceNoRegistry: 'No DSH workspace registered', endpointLabel: 'API endpoint', workspaceIdsLabel: 'Workspace IDs (comma separated)', refreshSecondsLabel: 'Auto-refresh seconds', listLimitLabel: 'Items per type', modelLabel: 'Default model (provider/model)', announceLabel: 'Announce TAPD tools to the Agent', error: 'Error', retry: 'Retry', deleting: '', unknown: 'Other', welcomeTitle: 'Welcome to TAPD Board', welcomeSubtitle: 'On first use, complete the TAPD configuration below. Skip it if already configured.', welcomeVersionLabel: 'Current version', welcomeConfigTitle: '1. TAPD configuration', welcomeConfigStep1: 'Set env var TAPD_TOKEN (personal token, required)', welcomeConfigStep2: 'Set TAPD_WORKSPACE_ID (single) or TAPD_WORKSPACE_IDS (comma separated)', welcomeConfigStep3: 'Optionally set TAPD_API_ENDPOINT (default https://api.tapd.cn); then fully quit and reopen DSH', welcomeGuideTitle: '2. Quick start', welcomeGuideDrag: 'Drag a card to another lane to change its status', welcomeGuideDetail: 'Click a card to view details, comment, or change status', welcomeGuideSchedule: 'Pick an execution time and workspace in the detail drawer to schedule an auto-run session', welcomeGuideAgent: 'Use tapd_board_* tools in chat to read and operate TAPD', welcomeUpdateTitle: '3. Updates', welcomeUpToDate: 'Up to date', welcomeNewVersion: 'New version available', welcomeCheckUpdate: 'Check for updates', welcomeChecking: 'Checking…', welcomeUpdateNow: 'Update now', welcomeUpdating: 'Updating…', welcomeUpdated: 'Updated. Restart DSH to apply', welcomeOpenSettings: 'Open settings', welcomeGotIt: 'Got it', help: 'Help', versionLabel: 'Version', newVersionBadge: 'Update available', currentVersion: 'Current version', latestVersion: 'Latest version', checkUpdate: 'Check for updates', updateNow: 'Update now', updateRestartHint: 'Restart DSH fully after updating to apply it', versionSection: 'Version & updates', updateDone: 'New version installed', updateFailed: 'Update failed', updateError: 'Failed to check for updates',
|
|
50
|
+
},
|
|
51
|
+
}
|
|
52
|
+
const fallback = dicts.zh
|
|
53
|
+
let translate = key => fallback[key]
|
|
54
|
+
let pickDirectory = null
|
|
55
|
+
const STATUS_ORDER = ['open', 'status_1', 'status_6', 'status_2', 'status_11', 'status_3', 'in_progress', 'done', 'status_4', 'status_12', 'status_5']
|
|
56
|
+
const TYPE_KEYS = ['story', 'task', 'bug']
|
|
57
|
+
const TYPE_GLYPHS = { story: '📋', task: '✅', bug: '🐛' }
|
|
58
|
+
const STATUS_GLYPHS = { open: '○', done: '●', in_progress: '◐', status_11: '◐', status_4: '●' }
|
|
59
|
+
function typeGlyph(type) { return TYPE_GLYPHS[type] || '•' }
|
|
60
|
+
function statusGlyph(status) { return STATUS_GLYPHS[status] || '·' }
|
|
61
|
+
|
|
62
|
+
async function postAction(action, payload) {
|
|
63
|
+
const response = await fetch('/api/tapd-board/action', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ action, payload: payload || {} }) })
|
|
64
|
+
return response.json()
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** Render TAPD description safely and route protected capture images through Host. */
|
|
68
|
+
function safeDescription(html) {
|
|
69
|
+
if (!html) return ''
|
|
70
|
+
const doc = new DOMParser().parseFromString(String(html), 'text/html')
|
|
71
|
+
doc.querySelectorAll('script,iframe,object,embed,link,meta,style').forEach(node => node.remove())
|
|
72
|
+
doc.querySelectorAll('*').forEach(el => {
|
|
73
|
+
for (const attr of Array.from(el.attributes)) {
|
|
74
|
+
const name = attr.name.toLowerCase()
|
|
75
|
+
if (name.startsWith('on')) { el.removeAttribute(attr.name); continue }
|
|
76
|
+
if ((name === 'href' || name === 'src') && /^\s*javascript:/i.test(attr.value)) { el.removeAttribute(attr.name); continue }
|
|
77
|
+
if (name === 'src') {
|
|
78
|
+
const value = attr.value.trim()
|
|
79
|
+
const path = value.startsWith('//') ? new URL('https:' + value).pathname : value.startsWith('http') ? new URL(value).pathname : value
|
|
80
|
+
if (/^\/tfl\//i.test(path)) attr.value = '/api/tapd-board/attachment?path=' + encodeURIComponent(path)
|
|
81
|
+
else if (value.startsWith('//')) attr.value = 'https:' + value
|
|
82
|
+
} else if (name === 'href' && attr.value.startsWith('//')) attr.value = 'https:' + attr.value
|
|
83
|
+
else if (name === 'href' && attr.value.startsWith('/')) attr.value = 'https://www.tapd.cn' + attr.value
|
|
84
|
+
}
|
|
85
|
+
if (el.tagName === 'IMG') { el.setAttribute('loading', 'lazy'); el.style.maxWidth = '100%'; el.style.height = 'auto'; el.style.borderRadius = '6px' }
|
|
86
|
+
})
|
|
87
|
+
return doc.body.innerHTML
|
|
88
|
+
}
|
|
89
|
+
function pluralize(items) { return Array.isArray(items) ? items.length : 0 }
|
|
90
|
+
function formatUpdated(value) {
|
|
91
|
+
if (!value) return '-'
|
|
92
|
+
const date = new Date(value)
|
|
93
|
+
return Number.isNaN(date.getTime()) ? '-' : date.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', second: '2-digit' })
|
|
94
|
+
}
|
|
95
|
+
function taskPrompt(item, model) {
|
|
96
|
+
return `请在 DeepSeek 客户端中处理这条 TAPD 工作项。\n\n类型:${item.type}\nID:${item.id}\n标题:${item.title}\n状态:${item.statusLabel || item.status}\n处理人:${item.owner || ''}\nTAPD:${item.url}\n模型:${model || '使用当前对话模型'}\n\n任务描述:\n${item.description || '请先使用 tapd_board_get 读取完整详情。'}\n\n执行要求:先分析并确认方案,再使用 tapd_board_* 工具推进任务;完成后将结果和风险评论回 TAPD。`
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** Sidebar glyph: three cards in a frame. */
|
|
100
|
+
function BoardIcon({ size, active }) {
|
|
101
|
+
return h('svg', { 'data-dsh-panel-entry': PANEL_ID, viewBox: '0 0 16 16', width: size, height: size, fill: 'none', stroke: 'currentColor', strokeWidth: active ? '1.55' : '1.25', strokeLinecap: 'round', strokeLinejoin: 'round', 'aria-hidden': true },
|
|
102
|
+
h('rect', { x: '2', y: '2', width: '12', height: '12', rx: '2' }),
|
|
103
|
+
h('path', { d: 'M5 5.5h6M5 8h6M5 10.5h3.5' }),
|
|
104
|
+
h('circle', { cx: '11.5', cy: '10.5', r: '1', fill: 'currentColor', stroke: 'none' }))
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** One board card. */
|
|
108
|
+
function Card({ item, labels, onOpen, onDragStart, onDragEnd, dragging }) {
|
|
109
|
+
const owner = (item.owner || '').trim()
|
|
110
|
+
const priority = labels.priorityLabel?.[item.priority] || item.priority
|
|
111
|
+
const priorityKey = String(item.priority || '').toLowerCase()
|
|
112
|
+
const priorityClass = priorityKey === 'urgent' || priorityKey === 'high' || priorityKey === '1' || priorityKey === '高' ? 'high' : priorityKey === 'low' || priorityKey === '3' || priorityKey === '低' ? 'low' : 'medium'
|
|
113
|
+
const meta = [item.shortId, owner].filter(Boolean).join(' · ')
|
|
114
|
+
return h('button', {
|
|
115
|
+
className: 'tbx-card' + (dragging ? ' dragging' : ''),
|
|
116
|
+
onClick: () => onOpen(item),
|
|
117
|
+
draggable: true,
|
|
118
|
+
onDragStart: event => onDragStart(event, item),
|
|
119
|
+
onDragEnd: event => onDragEnd(event, item),
|
|
120
|
+
type: 'button', title: item.title },
|
|
121
|
+
h('div', { className: 'tbx-card-top' },
|
|
122
|
+
h('span', { className: 'tbx-card-glyph', 'aria-hidden': true }, typeGlyph(item.type)),
|
|
123
|
+
h('span', { className: 'tbx-card-id' }, item.shortId || item.id),
|
|
124
|
+
priority ? h('span', { className: 'tbx-priority ' + priorityClass }, priority) : null),
|
|
125
|
+
h('div', { className: 'tbx-card-title' }, item.title),
|
|
126
|
+
meta ? h('div', { className: 'tbx-card-meta' }, meta) : null)
|
|
127
|
+
}
|
|
128
|
+
/** Column header + cards. */
|
|
129
|
+
function Column({ label, items, labels, onOpen, count, onCardDragStart, onCardDragEnd, draggingKey, dragOver, onDropOn, onDragEnterColumn }) {
|
|
130
|
+
return h('div', {
|
|
131
|
+
className: 'tbx-col' + (dragOver ? ' drop-target' : ''),
|
|
132
|
+
onDragEnter: event => onDragEnterColumn(event),
|
|
133
|
+
onDragOver: event => { event.preventDefault(); event.dataTransfer.dropEffect = 'move'; onDragEnterColumn(event) },
|
|
134
|
+
onDrop: event => onDropOn(event),
|
|
135
|
+
},
|
|
136
|
+
h('div', { className: 'tbx-col-head' }, h('span', { className: 'tbx-col-title' }, h('span', { className: 'tbx-status-dot', 'aria-hidden': true }, statusGlyph(items[0]?.status)), label), h('span', { className: 'tbx-col-count' }, count)),
|
|
137
|
+
h('div', { className: 'tbx-col-body' }, items.map(item => h(Card, {
|
|
138
|
+
key: item.id,
|
|
139
|
+
item,
|
|
140
|
+
labels,
|
|
141
|
+
onOpen,
|
|
142
|
+
onDragStart: onCardDragStart,
|
|
143
|
+
onDragEnd: onCardDragEnd,
|
|
144
|
+
dragging: draggingKey === item.id,
|
|
145
|
+
}))))
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** The center-column board page. */
|
|
149
|
+
function BoardPage() {
|
|
150
|
+
const [state, setState] = useState(null)
|
|
151
|
+
const [loading, setLoading] = useState(true)
|
|
152
|
+
const [error, setError] = useState('')
|
|
153
|
+
const [query, setQuery] = useState('')
|
|
154
|
+
const [activeType, setActiveType] = useState('story')
|
|
155
|
+
const [selected, setSelected] = useState(null)
|
|
156
|
+
const [createOpen, setCreateOpen] = useState(false)
|
|
157
|
+
const [settingsOpen, setSettingsOpen] = useState(false)
|
|
158
|
+
const [message, setMessage] = useState('')
|
|
159
|
+
const [aboutOpen, setAboutOpen] = useState(false)
|
|
160
|
+
const [checking, setChecking] = useState(false)
|
|
161
|
+
const [updating, setUpdating] = useState(false)
|
|
162
|
+
const timerRef = useRef(null)
|
|
163
|
+
|
|
164
|
+
const fetchFresh = useCallback(async () => {
|
|
165
|
+
setError(''); setMessage('')
|
|
166
|
+
try {
|
|
167
|
+
const result = await postAction('refresh', {})
|
|
168
|
+
if (result.ok && result.state) setState(result.state)
|
|
169
|
+
else setError(result.error || '')
|
|
170
|
+
} catch (cause) { setError(cause instanceof Error ? cause.message : String(cause)) }
|
|
171
|
+
}, [])
|
|
172
|
+
|
|
173
|
+
const manualRefresh = useCallback(async () => {
|
|
174
|
+
setLoading(true)
|
|
175
|
+
await fetchFresh()
|
|
176
|
+
setLoading(false)
|
|
177
|
+
}, [fetchFresh])
|
|
178
|
+
|
|
179
|
+
// 首次打开时自动展示使用说明(配置引导 + 版本信息 + 使用手册)
|
|
180
|
+
useEffect(() => {
|
|
181
|
+
try {
|
|
182
|
+
if (!localStorage.getItem('tapd-task-board:welcome-v1')) setAboutOpen(true)
|
|
183
|
+
} catch { /* 隐私模式等场景忽略 */ }
|
|
184
|
+
}, [])
|
|
185
|
+
|
|
186
|
+
useEffect(() => {
|
|
187
|
+
// 先展示上一次的缓存快照(如果宿主有),避免每次打开都先空白再加载;
|
|
188
|
+
// 随后再发起一次真实刷新,用最新数据替换。
|
|
189
|
+
let cancelled = false
|
|
190
|
+
;(async () => {
|
|
191
|
+
try {
|
|
192
|
+
const response = await fetch('/api/tapd-board/state')
|
|
193
|
+
const result = await response.json()
|
|
194
|
+
if (!cancelled && result.ok && result.state) {
|
|
195
|
+
setState(result.state)
|
|
196
|
+
setLoading(false)
|
|
197
|
+
}
|
|
198
|
+
} catch { /* 无缓存也无妨,走真实刷新 */ }
|
|
199
|
+
})()
|
|
200
|
+
fetchFresh().finally(() => { if (!cancelled) setLoading(false) })
|
|
201
|
+
// 顺带检查 npm 上的新版本(Host 缓存 10 分钟,失败不影响看板)
|
|
202
|
+
postAction('checkVersion', {}).then(result => {
|
|
203
|
+
if (!cancelled && result?.ok && result.state?.version) {
|
|
204
|
+
setState(previous => previous ? { ...previous, version: result.state.version } : result.state)
|
|
205
|
+
}
|
|
206
|
+
}).catch(() => {})
|
|
207
|
+
return () => { cancelled = true }
|
|
208
|
+
}, [fetchFresh])
|
|
209
|
+
useEffect(() => {
|
|
210
|
+
const seconds = Number(state?.config?.refreshSeconds || 300)
|
|
211
|
+
timerRef.current = setInterval(fetchFresh, Math.max(30, seconds) * 1000)
|
|
212
|
+
return () => { if (timerRef.current) clearInterval(timerRef.current) }
|
|
213
|
+
}, [state?.config?.refreshSeconds, fetchFresh])
|
|
214
|
+
|
|
215
|
+
const runAction = useCallback(async (action, payload) => {
|
|
216
|
+
setError(''); setMessage('')
|
|
217
|
+
try {
|
|
218
|
+
const result = await postAction(action, payload)
|
|
219
|
+
if (result.ok) { if (result.state) setState(result.state); setMessage(result.message || '') } else setError(result.error || '')
|
|
220
|
+
return result
|
|
221
|
+
} catch (cause) { setError(cause instanceof Error ? cause.message : String(cause)); return undefined }
|
|
222
|
+
}, [])
|
|
223
|
+
|
|
224
|
+
const switchWorkspace = useCallback(async (workspaceId) => {
|
|
225
|
+
setSelected(null)
|
|
226
|
+
await runAction('switchWorkspace', { workspaceId })
|
|
227
|
+
}, [runAction])
|
|
228
|
+
|
|
229
|
+
const handleCheckUpdate = useCallback(async (force = true) => {
|
|
230
|
+
setChecking(true)
|
|
231
|
+
try {
|
|
232
|
+
const result = await postAction('checkVersion', { force })
|
|
233
|
+
if (result?.ok && result.state) setState(previous => previous ? { ...previous, version: result.state.version } : result.state)
|
|
234
|
+
else if (!result?.ok) setError(result.error || translate('updateError'))
|
|
235
|
+
return result
|
|
236
|
+
} catch (cause) {
|
|
237
|
+
setError(cause instanceof Error ? cause.message : String(cause))
|
|
238
|
+
return undefined
|
|
239
|
+
} finally { setChecking(false) }
|
|
240
|
+
}, [])
|
|
241
|
+
|
|
242
|
+
const handleUpdate = useCallback(async () => {
|
|
243
|
+
setUpdating(true)
|
|
244
|
+
setError(''); setMessage('')
|
|
245
|
+
try {
|
|
246
|
+
const result = await postAction('updatePlugin', {})
|
|
247
|
+
if (result?.ok) {
|
|
248
|
+
if (result.state) setState(result.state)
|
|
249
|
+
setMessage(result.update?.message || translate('updateDone'))
|
|
250
|
+
} else setError(result.error || translate('updateFailed'))
|
|
251
|
+
return result
|
|
252
|
+
} catch (cause) {
|
|
253
|
+
setError(cause instanceof Error ? cause.message : String(cause))
|
|
254
|
+
return undefined
|
|
255
|
+
} finally { setUpdating(false) }
|
|
256
|
+
}, [])
|
|
257
|
+
|
|
258
|
+
const items = (state?.items?.[activeType] || [])
|
|
259
|
+
const needle = query.trim().toLowerCase()
|
|
260
|
+
const filtered = useMemo(() => needle ? items.filter(item => [item.id, item.shortId, item.title, item.owner].join(' ').toLowerCase().includes(needle)) : items, [items, needle])
|
|
261
|
+
const labels = state?.statuses?.[activeType] || {}
|
|
262
|
+
const columns = useMemo(() => {
|
|
263
|
+
const buckets = new Map()
|
|
264
|
+
for (const item of filtered) {
|
|
265
|
+
const key = item.status || 'unknown'
|
|
266
|
+
if (!buckets.has(key)) buckets.set(key, [])
|
|
267
|
+
buckets.get(key).push(item)
|
|
268
|
+
}
|
|
269
|
+
const all = new Set(STATUS_ORDER)
|
|
270
|
+
const keys = [...buckets.keys()].sort((a, b) => {
|
|
271
|
+
const ia = a === 'unknown' ? 999 : STATUS_ORDER.indexOf(a)
|
|
272
|
+
const ib = b === 'unknown' ? 999 : STATUS_ORDER.indexOf(b)
|
|
273
|
+
if (ia !== ib) return ia - ib
|
|
274
|
+
return (labels[a] || a).localeCompare(labels[b] || b, 'zh')
|
|
275
|
+
})
|
|
276
|
+
return keys.map(key => ({ key, label: key === 'unknown' ? translate('unknown') : (labels[key] || key), items: buckets.get(key) }))
|
|
277
|
+
}, [filtered, labels])
|
|
278
|
+
|
|
279
|
+
// —— 泳道拖拽改状态(HTML5 DnD)——
|
|
280
|
+
const [draggingItem, setDraggingItem] = useState(null)
|
|
281
|
+
const [dropTarget, setDropTarget] = useState('')
|
|
282
|
+
const dragItemRef = useRef(null)
|
|
283
|
+
const handleCardDragStart = useCallback((event, item) => {
|
|
284
|
+
dragItemRef.current = item
|
|
285
|
+
setDraggingItem(item)
|
|
286
|
+
setDropTarget('')
|
|
287
|
+
try {
|
|
288
|
+
event.dataTransfer.setData('text/plain', JSON.stringify({ type: item.type, id: item.id }))
|
|
289
|
+
event.dataTransfer.effectAllowed = 'move'
|
|
290
|
+
// 个别浏览器要求拖拽中必须有数据,否则 dragstart 被忽略
|
|
291
|
+
event.dataTransfer.setData('text/uri-list', item.url || '')
|
|
292
|
+
} catch { /* setData 失败不影响拖拽 */ }
|
|
293
|
+
}, [])
|
|
294
|
+
const handleCardDragEnd = useCallback(() => {
|
|
295
|
+
dragItemRef.current = null
|
|
296
|
+
setDraggingItem(null)
|
|
297
|
+
setDropTarget('')
|
|
298
|
+
}, [])
|
|
299
|
+
const handleColumnDrop = useCallback(async (event, targetStatus) => {
|
|
300
|
+
event.preventDefault()
|
|
301
|
+
const source = dragItemRef.current
|
|
302
|
+
setDropTarget('')
|
|
303
|
+
setDraggingItem(null)
|
|
304
|
+
if (!source) return
|
|
305
|
+
if (targetStatus === 'unknown') return
|
|
306
|
+
if (source.status === targetStatus) return
|
|
307
|
+
await runAction('move', { type: source.type, id: source.id, status: targetStatus })
|
|
308
|
+
}, [runAction])
|
|
309
|
+
|
|
310
|
+
const statusOptions = useMemo(() => Object.entries(labels).map(([value, label]) => ({ value, label })), [labels])
|
|
311
|
+
const fieldsOf = useCallback((item) => {
|
|
312
|
+
const f = translate('fields')
|
|
313
|
+
if (item.type === 'bug') return [ [f.status, item.statusLabel], [f.severity, item.severity], [f.module, item.module], [f.reporter, item.creator], [f.owner, item.owner], [f.created, item.created] ]
|
|
314
|
+
return [ [f.status, item.statusLabel], [f.owner, item.owner], [f.creator, item.creator], [f.priority, item.priority], [f.begin, item.begin], [f.due, item.due], [f.iterationId, item.iterationId], [f.created, item.created] ]
|
|
315
|
+
}, [])
|
|
316
|
+
|
|
317
|
+
return h('div', { className: 'tbx', 'data-dsh-plugin': 'tapd-task-board' },
|
|
318
|
+
h('style', {}, `/* dsh theme: quiet surfaces, data-led accent, compact workbench rhythm */
|
|
319
|
+
.tbx{position:relative;height:100%;display:flex;flex-direction:column;min-height:0;background:var(--dsw-alias-bg-base);color:var(--dsw-alias-label-primary);font-size:13px}
|
|
320
|
+
.tbx *{box-sizing:border-box}
|
|
321
|
+
.tbx-head{display:flex;align-items:center;gap:10px;padding:12px 16px;flex-wrap:wrap}
|
|
322
|
+
.tbx-title{font-size:16px;font-weight:600;letter-spacing:-.01em;white-space:nowrap;display:inline-flex;align-items:center;gap:7px}
|
|
323
|
+
.tbx-logo{width:22px;height:22px;display:inline-flex;align-items:center;justify-content:center;font-size:14px;line-height:1}
|
|
324
|
+
.tbx-sub{font-size:12px;color:var(--dsw-alias-label-secondary);white-space:nowrap}
|
|
325
|
+
.tbx-updated{display:inline-flex;align-items:center;gap:4px;font-variant-numeric:tabular-nums;background:var(--dsw-alias-bg-layer-1);border:1px solid var(--dsw-alias-border-l1);border-radius:6px;padding:4px 8px}
|
|
326
|
+
.tbx-note{font-size:12px;color:var(--dsw-alias-label-secondary);line-height:1.55}
|
|
327
|
+
.tbx-note.ok{color:var(--dsw-alias-state-success-primary)}
|
|
328
|
+
.tbx-ai{border:1px solid color-mix(in srgb,var(--dsw-alias-brand-primary) 30%,transparent);background:color-mix(in srgb,var(--dsw-alias-brand-primary) 6%,transparent);border-radius:8px;padding:10px}
|
|
329
|
+
.tbx-status{display:inline-flex;align-items:center;gap:6px;font-size:13px;padding:6px 10px;border-radius:6px;border:1px solid var(--dsw-alias-border-l1);align-self:flex-start}
|
|
330
|
+
.tbx-status.ok{color:var(--dsw-alias-state-success-primary);border-color:color-mix(in srgb,var(--dsw-alias-state-success-primary) 35%,transparent)}
|
|
331
|
+
.tbx-status.err{color:var(--dsw-alias-state-error-primary);border-color:color-mix(in srgb,var(--dsw-alias-state-error-primary) 35%,transparent)}
|
|
332
|
+
.tbx-dialog-wide{width:540px;max-width:100%}
|
|
333
|
+
.tbx-grow{flex:1;min-width:140px}
|
|
334
|
+
.tbx-check{display:flex;flex-direction:row;align-items:center;gap:8px;cursor:pointer;font-size:13px}
|
|
335
|
+
.tbx-chip{display:inline-flex;align-items:center;gap:5px;font-size:12px;color:var(--dsw-alias-label-secondary);background:var(--dsw-alias-bg-layer-1);border:1px solid var(--dsw-alias-border-l1);border-radius:6px;padding:4px 8px;white-space:nowrap}
|
|
336
|
+
.tbx-spacer{flex:1;min-width:12px}
|
|
337
|
+
.tbx-tabs{display:flex;gap:2px;align-items:flex-end;border-bottom:1px solid var(--dsw-alias-border-l1);padding:0 16px}
|
|
338
|
+
.tbx-tab{appearance:none;border:0;background:transparent;color:var(--dsw-alias-label-secondary);font-size:13px;padding:8px 13px;cursor:pointer;position:relative;display:inline-flex;align-items:center;gap:6px;border-radius:6px 6px 0 0}
|
|
339
|
+
.tbx-tab:hover{color:var(--dsw-alias-label-primary)}
|
|
340
|
+
.tbx-tab.on{color:var(--dsw-alias-label-primary);font-weight:600}
|
|
341
|
+
.tbx-tab.on::after{content:'';position:absolute;left:9px;right:9px;bottom:-1px;height:2px;background:var(--dsw-alias-brand-primary);border-radius:2px}
|
|
342
|
+
.tbx-tab-count{font-size:11px;color:var(--dsw-alias-label-secondary);background:var(--dsw-alias-bg-layer-1);border:1px solid var(--dsw-alias-border-l1);border-radius:10px;padding:0 6px;line-height:16px;font-weight:500}
|
|
343
|
+
.tbx-tab.on .tbx-tab-count{color:var(--dsw-alias-label-primary)}
|
|
344
|
+
.tbx-btn{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-base);color:var(--dsw-alias-label-primary);font:inherit;font-size:13px;padding:6px 11px;border-radius:6px;cursor:pointer;display:inline-flex;align-items:center;gap:5px;transition:border-color .12s ease,background .12s ease}
|
|
345
|
+
.tbx-btn:hover{border-color:var(--dsw-alias-brand-primary);background:var(--dsw-alias-bg-layer-1)}
|
|
346
|
+
.tbx-btn:focus-visible,.tbx-card:focus-visible,.tbx-tab:focus-visible,.tbx-icon-btn:focus-visible{outline:2px solid color-mix(in srgb,var(--dsw-alias-brand-primary) 45%,transparent);outline-offset:1px}
|
|
347
|
+
.tbx-btn:disabled{opacity:.55;cursor:not-allowed}
|
|
348
|
+
.tbx-btn.on{background:var(--dsw-alias-brand-primary);border-color:transparent;color:#fff;font-weight:600}
|
|
349
|
+
.tbx-btn.on:hover{filter:brightness(1.06)}
|
|
350
|
+
.tbx-btn.primary{background:var(--dsw-alias-brand-primary);border-color:transparent;color:#fff}
|
|
351
|
+
.tbx-btn.primary:hover{filter:brightness(1.06)}
|
|
352
|
+
.tbx-search{width:220px;min-width:150px;background:var(--dsw-alias-bg-layer-1);border:1px solid var(--dsw-alias-border-l1);color:var(--dsw-alias-label-primary);font:inherit;font-size:13px;padding:6px 10px;border-radius:6px;outline:none}
|
|
353
|
+
.tbx-select{background:var(--dsw-alias-bg-layer-1);border:1px solid var(--dsw-alias-border-l1);color:var(--dsw-alias-label-primary);font:inherit;font-size:12px;padding:5px 8px;border-radius:6px;outline:none;cursor:pointer;max-width:220px}
|
|
354
|
+
.tbx-select:focus{border-color:var(--dsw-alias-brand-primary);box-shadow:0 0 0 3px color-mix(in srgb,var(--dsw-alias-brand-primary) 22%,transparent)}
|
|
355
|
+
.tbx-search:focus,.tbx-input:focus{border-color:var(--dsw-alias-brand-primary);box-shadow:0 0 0 3px color-mix(in srgb,var(--dsw-alias-brand-primary) 22%,transparent)}
|
|
356
|
+
.tbx-spin{display:inline-flex;animation:tbxSpin .8s linear infinite}
|
|
357
|
+
@keyframes tbxSpin{to{transform:rotate(360deg)}}
|
|
358
|
+
.tbx-bar{padding:6px 16px;font-size:12px;min-height:28px;border-bottom:1px solid var(--dsw-alias-border-l1);color:var(--dsw-alias-label-secondary)}
|
|
359
|
+
.tbx-bar.err{color:var(--dsw-alias-state-error-primary)}
|
|
360
|
+
.tbx-bar.ok{color:var(--dsw-alias-state-success-primary)}
|
|
361
|
+
.tbx-board{flex:1;overflow:auto;padding:14px 16px;display:flex;gap:12px;align-items:flex-start;scrollbar-width:auto;scrollbar-color:var(--dsw-alias-border-l2) var(--dsw-alias-bg-layer-1)}
|
|
362
|
+
.tbx-board::-webkit-scrollbar{width:10px;height:10px}
|
|
363
|
+
.tbx-board::-webkit-scrollbar-track{background:var(--dsw-alias-bg-layer-1);border-radius:5px}
|
|
364
|
+
.tbx-board::-webkit-scrollbar-thumb{background:var(--dsw-alias-border-l2);border:2px solid var(--dsw-alias-bg-layer-1);border-radius:6px;min-height:28px}
|
|
365
|
+
.tbx-board::-webkit-scrollbar-thumb:hover{background:var(--dsw-alias-label-secondary)}
|
|
366
|
+
.tbx-empty{margin:auto;color:var(--dsw-alias-label-secondary);font-size:13px;padding:32px}
|
|
367
|
+
.tbx-col{flex:0 0 272px;background:var(--dsw-alias-bg-layer-1);border:1px solid var(--dsw-alias-border-l1);border-radius:10px;display:flex;flex-direction:column;max-height:100%;overflow:hidden}
|
|
368
|
+
.tbx-col-head{display:flex;align-items:center;gap:7px;padding:10px 12px;border-bottom:1px solid var(--dsw-alias-border-l1)}
|
|
369
|
+
.tbx-col-title{font-size:13px;font-weight:600;color:var(--dsw-alias-label-primary);display:flex;align-items:center;gap:6px}
|
|
370
|
+
.tbx-status-dot{color:var(--dsw-alias-brand-primary);font-size:11px;line-height:1}
|
|
371
|
+
.tbx-col-count{margin-left:auto;font-size:11px;color:var(--dsw-alias-label-secondary);background:var(--dsw-alias-bg-base);border:1px solid var(--dsw-alias-border-l1);border-radius:10px;padding:0 6px;line-height:16px}
|
|
372
|
+
.tbx-col-body{padding:8px;display:flex;flex-direction:column;gap:8px;overflow-y:auto}
|
|
373
|
+
.tbx-col.drop-target{border-color:color-mix(in srgb,var(--dsw-alias-brand-primary) 55%,transparent);background:color-mix(in srgb,var(--dsw-alias-brand-primary) 7%,transparent);box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--dsw-alias-brand-primary) 40%,transparent)}
|
|
374
|
+
.tbx-col.drop-target .tbx-col-head{border-bottom-color:color-mix(in srgb,var(--dsw-alias-brand-primary) 35%,transparent)}
|
|
375
|
+
.tbx-col.drop-target .tbx-col-body{min-height:56px}
|
|
376
|
+
.tbx-card.dragging{opacity:.45;border-style:dashed;border-color:var(--dsw-alias-brand-primary)}
|
|
377
|
+
.tbx-card{border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-base);border-radius:8px;padding:10px 11px;cursor:pointer;text-align:left;font:inherit;color:var(--dsw-alias-label-primary);display:block;width:100%;transition:border-color .12s ease,background .12s ease}
|
|
378
|
+
.tbx-card:hover{border-color:var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-2)}
|
|
379
|
+
.tbx-card-top{display:flex;align-items:center;gap:6px;margin-bottom:6px;color:var(--dsw-alias-label-secondary);font-size:11px}
|
|
380
|
+
.tbx-card-glyph{font-size:12px;line-height:1}
|
|
381
|
+
.tbx-card-id{font-variant-numeric:tabular-nums;letter-spacing:.01em}
|
|
382
|
+
.tbx-priority{margin-left:auto;font-size:11px;line-height:1;padding:3px 6px;border-radius:10px;border:1px solid var(--dsw-alias-border-l1);color:var(--dsw-alias-label-secondary)}
|
|
383
|
+
.tbx-priority.high{color:var(--dsw-alias-state-error-primary);border-color:color-mix(in srgb,var(--dsw-alias-state-error-primary) 35%,transparent)}
|
|
384
|
+
.tbx-priority.medium{color:var(--dsw-alias-state-warn-primary);border-color:color-mix(in srgb,var(--dsw-alias-state-warn-primary) 35%,transparent)}
|
|
385
|
+
.tbx-priority.low{color:var(--dsw-alias-state-idle-primary)}
|
|
386
|
+
.tbx-card-title{font-size:13px;font-weight:500;line-height:1.5;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
|
|
387
|
+
.tbx-card-meta{margin-top:8px;font-size:12px;color:var(--dsw-alias-label-secondary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
388
|
+
.tbx-drawer{position:absolute;top:0;right:0;bottom:0;width:400px;max-width:92%;background:var(--dsw-alias-bg-base);border-left:1px solid var(--dsw-alias-border-l2);box-shadow:var(--dsw-shadow-lv3,-12px 0 32px rgba(0,0,0,.14));display:flex;flex-direction:column;z-index:20}
|
|
389
|
+
.tbx-drawer-head{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;padding:14px 16px;border-bottom:1px solid var(--dsw-alias-border-l1)}
|
|
390
|
+
.tbx-drawer-title{flex:1;min-width:0;font-size:15px;font-weight:700;line-height:1.45;color:var(--dsw-alias-label-primary);text-decoration:none;overflow-wrap:anywhere}
|
|
391
|
+
.tbx-drawer-title:hover{color:var(--dsw-alias-brand-primary);text-decoration:underline}
|
|
392
|
+
.tbx-icon-btn{flex:none;display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;border:1px solid transparent;background:transparent;color:var(--dsw-alias-label-secondary);border-radius:6px;cursor:pointer;font:inherit;transition:background .12s ease,color .12s ease}
|
|
393
|
+
.tbx-icon-btn:hover{background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary)}
|
|
394
|
+
.tbx-drawer-body{padding:14px 16px;overflow-y:auto;display:flex;flex-direction:column;gap:12px}
|
|
395
|
+
.tbx-field{display:flex;flex-direction:column;gap:4px}
|
|
396
|
+
.tbx-field-k{font-size:12px;color:var(--dsw-alias-label-secondary)}
|
|
397
|
+
.tbx-field-v{font-size:13px;color:var(--dsw-alias-label-primary);word-break:break-word}
|
|
398
|
+
.tbx-desc{font-size:13px;line-height:1.6;color:var(--dsw-alias-label-primary);background:var(--dsw-alias-bg-layer-1);border:1px solid var(--dsw-alias-border-l1);border-radius:8px;padding:10px 11px;max-height:48vh;min-height:8em;flex-shrink:0;overflow-y:auto;word-break:break-word}
|
|
399
|
+
.tbx-desc img{max-width:100%;height:auto}
|
|
400
|
+
.tbx-img-fallback{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin:6px 0;padding:10px 12px;border:1px dashed var(--dsw-alias-border-l2);border-radius:8px;font-size:12px;color:var(--dsw-alias-label-secondary);background:var(--dsw-alias-bg-layer-1)}
|
|
401
|
+
.tbx-desc a{color:var(--dsw-alias-brand-primary);text-decoration:none}
|
|
402
|
+
.tbx-desc a:hover{text-decoration:underline}
|
|
403
|
+
.tbx-desc p{margin:0 0 8px}
|
|
404
|
+
.tbx-desc p:last-child{margin-bottom:0}
|
|
405
|
+
.tbx-desc ul,.tbx-desc ol{margin:4px 0 8px;padding-left:18px}
|
|
406
|
+
.tbx-desc li{margin:2px 0}
|
|
407
|
+
.tbx-desc h1,.tbx-desc h2,.tbx-desc h3,.tbx-desc h4,.tbx-desc h5,.tbx-desc h6{font-size:1.05em;font-weight:600;line-height:1.4;margin:10px 0 6px}
|
|
408
|
+
.tbx-desc strong,.tbx-desc b{font-weight:600}
|
|
409
|
+
.tbx-desc em,.tbx-desc i{font-style:italic}
|
|
410
|
+
.tbx-desc code{background:rgba(127,127,127,.14);border-radius:4px;padding:1px 5px;font-size:12px;font-family:var(--dsw-alias-font-mono,ui-monospace,SFMono-Regular,Menlo,Consolas,monospace)}
|
|
411
|
+
.tbx-desc pre{background:var(--dsw-alias-bg-layer-1);border:1px solid var(--dsw-alias-border-l1);border-radius:8px;padding:10px 12px;overflow-x:auto;font-size:12px;line-height:1.5;margin:8px 0;white-space:pre-wrap;word-break:break-word}
|
|
412
|
+
.tbx-desc blockquote{border-left:3px solid var(--dsw-alias-border-l2);margin:8px 0;padding:2px 12px;color:var(--dsw-alias-label-secondary)}
|
|
413
|
+
.tbx-desc table{border-collapse:collapse;max-width:100%;width:100%}
|
|
414
|
+
.tbx-desc td,.tbx-desc th{border:1px solid var(--dsw-alias-border-l1);padding:4px 8px}
|
|
415
|
+
.tbx-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}
|
|
416
|
+
.tbx-input{background:var(--dsw-alias-bg-layer-1);border:1px solid var(--dsw-alias-border-l1);color:var(--dsw-alias-label-primary);font:inherit;font-size:13px;padding:6px 9px;border-radius:6px;outline:none;flex:1;min-width:0}
|
|
417
|
+
.tbx-date{flex:0 1 220px;min-width:190px}
|
|
418
|
+
.tbx-textarea{min-height:90px;resize:vertical}
|
|
419
|
+
.tbx-a{color:var(--dsw-alias-brand-primary);text-decoration:none;font-size:13px}
|
|
420
|
+
.tbx-a:hover{text-decoration:underline}
|
|
421
|
+
.tbx-dialog{position:absolute;inset:0;background:var(--dsw-alias-bg-mask-1,rgba(0,0,0,.45));display:flex;align-items:center;justify-content:center;z-index:30;padding:24px}
|
|
422
|
+
.tbx-dialog-box{width:440px;max-width:100%;background:var(--dsw-alias-bg-base);border:1px solid var(--dsw-alias-border-l2);border-radius:14px;box-shadow:var(--dsw-shadow-lv3,0 12px 40px rgba(0,0,0,.16));padding:18px;display:flex;flex-direction:column;gap:12px;max-height:calc(100vh - 48px);overflow-y:auto}
|
|
423
|
+
.tbx-dialog-wide{width:520px}
|
|
424
|
+
.tbx-version-btn{position:relative}
|
|
425
|
+
.tbx-version-btn.has-update{border-color:var(--dsw-alias-brand-primary)}
|
|
426
|
+
.tbx-dot{position:absolute;top:-2px;right:-2px;width:8px;height:8px;border-radius:50%;background:#ff4d4f;box-shadow:0 0 0 1.5px var(--dsw-alias-bg-base)}
|
|
427
|
+
.tbx-chip-new{color:#ff4d4f;border-color:#ff4d4f}
|
|
428
|
+
.tbx-welcome-title{font-weight:600;font-size:13px;margin-top:2px}
|
|
429
|
+
.tbx-welcome-step{display:flex;gap:8px;align-items:flex-start;font-size:13px;line-height:1.55}
|
|
430
|
+
.tbx-welcome-num{flex:0 0 18px;height:18px;border-radius:50%;background:color-mix(in srgb,var(--dsw-alias-brand-primary) 14%,transparent);color:var(--dsw-alias-brand-primary);display:flex;align-items:center;justify-content:center;font-size:11px;font-weight:600;margin-top:1px}
|
|
431
|
+
@media (max-width:720px){.tbx-head{padding:10px 12px}.tbx-tabs{padding:0 12px}.tbx-board{padding:12px}.tbx-search{flex:1;width:auto}.tbx-col{flex-basis:calc(100vw - 32px)}.tbx-drawer{width:100%;max-width:100%}.tbx-select{max-width:160px}}
|
|
432
|
+
@media (prefers-reduced-motion:reduce){.tbx *{transition:none!important}}`),
|
|
433
|
+
h('div', { className: 'tbx-head' },
|
|
434
|
+
h('span', { className: 'tbx-title' }, h('span', { className: 'tbx-logo', 'aria-hidden': true }, '📋'), translate('title')),
|
|
435
|
+
state?.config?.allowShowAll
|
|
436
|
+
? h('button', { className: 'tbx-btn' + (state?.config?.mineOnly ? ' on' : ''), onClick: () => runAction('scope', { mineOnly: !state?.config?.mineOnly }), type: 'button', title: translate('mineOnly') }, '👤 ', state?.config?.mineOnly ? translate('mineOnly') : translate('showAll'))
|
|
437
|
+
: null,
|
|
438
|
+
(state?.config?.workspaceIds || []).length > 1
|
|
439
|
+
? h('select', { className: 'tbx-select', value: state?.config?.workspaceId || state.workspaceId || '', onChange: event => switchWorkspace(event.target.value), title: translate('workspace') }, (state?.config?.workspaceIds || []).map(id => h('option', { key: id, value: id }, `${translate('workspace')} ${id}`)))
|
|
440
|
+
: h('span', { className: 'tbx-chip' }, `${translate('workspace')} ${state?.workspaceId || '-'}`),
|
|
441
|
+
h('span', { className: 'tbx-sub tbx-updated', title: state?.fetchedAt ? new Date(state.fetchedAt).toLocaleString() : '' }, '🕐 ', translate('lastUpdated'), ' ', formatUpdated(state?.fetchedAt)),
|
|
442
|
+
h('span', { className: 'tbx-spacer' }),
|
|
443
|
+
h('input', { className: 'tbx-search', placeholder: translate('search'), value: query, onChange: event => setQuery(event.target.value) }),
|
|
444
|
+
h('button', { className: 'tbx-btn', onClick: manualRefresh, type: 'button', disabled: loading }, h('span', { className: loading ? 'tbx-spin' : '', 'aria-hidden': true }, '🔄'), translate('refresh')),
|
|
445
|
+
h('button', { className: 'tbx-btn', onClick: () => setCreateOpen(true), type: 'button' }, '➕ ', translate('newStory')),
|
|
446
|
+
h('button', { className: 'tbx-btn tbx-version-btn' + (state?.version?.updateAvailable ? ' has-update' : ''), onClick: () => setSettingsOpen(true), type: 'button', title: (state?.version?.updateAvailable ? `🔴 ${translate('newVersionBadge')} v${state.version.latest} ` : '') + translate('settings') }, '⚙ ', translate('settings'), state?.version?.updateAvailable ? h('span', { className: 'tbx-dot', 'aria-hidden': true }) : null)),
|
|
447
|
+
h('div', { className: 'tbx-tabs' }, TYPE_KEYS.map(key => h('button', { key, className: 'tbx-tab' + (activeType === key ? ' on' : ''), onClick: () => setActiveType(key), type: 'button' }, h('span', { 'aria-hidden': true }, typeGlyph(key)), translate(key), h('span', { className: 'tbx-tab-count' }, state?.items?.[key]?.length || 0)))),
|
|
448
|
+
h('div', { className: 'tbx-bar' + (error ? ' err' : message ? ' ok' : ''), role: 'status' }, error ? `${translate('error')}:${error}` : message ? message : loading ? translate('loading') : ''),
|
|
449
|
+
h('div', { className: 'tbx-board', onDragLeave: event => { if (!event.currentTarget.contains(event.relatedTarget)) setDropTarget('') } },
|
|
450
|
+
columns.length ? columns.map(column => h(Column, {
|
|
451
|
+
key: column.key,
|
|
452
|
+
label: column.label,
|
|
453
|
+
items: column.items,
|
|
454
|
+
count: column.items.length,
|
|
455
|
+
labels,
|
|
456
|
+
onOpen: item => setSelected(item),
|
|
457
|
+
onCardDragStart: handleCardDragStart,
|
|
458
|
+
onCardDragEnd: handleCardDragEnd,
|
|
459
|
+
draggingKey: draggingItem?.id,
|
|
460
|
+
dragOver: dropTarget === column.key && draggingItem?.status !== column.key && column.key !== 'unknown',
|
|
461
|
+
onDragEnterColumn: () => { if (column.key !== 'unknown') setDropTarget(column.key) },
|
|
462
|
+
onDropOn: event => handleColumnDrop(event, column.key),
|
|
463
|
+
}))
|
|
464
|
+
: h('div', { className: 'tbx-empty' }, query ? translate('noResult') : translate('empty'))),
|
|
465
|
+
selected ? h(DetailDrawer, { item: selected, config: state?.config, statusOptions, fieldsOf: fieldsOf(selected), labels, pickDirectory, onClose: () => setSelected(null), onMove: async (status) => { const result = await runAction('move', { type: selected.type, id: selected.id, status }); if (result?.ok) setSelected(null) }, onComment: (content) => runAction('comment', { type: selected.type, id: selected.id, content }), onSchedule: payload => runAction('scheduleTask', payload), onRegisterWorkspace: (path) => runAction('registerWorkspace', { path }) }) : null,
|
|
466
|
+
createOpen ? h(CreateDialog, { labels, ownerDefault: state?.user?.name || '', onCancel: () => setCreateOpen(false), onCreate: (input) => runAction('createStory', input).then(() => setCreateOpen(false)) }) : null,
|
|
467
|
+
settingsOpen ? h(SettingsDialog, { config: state?.config, settings: state?.settings, version: state?.version, onClose: () => setSettingsOpen(false), onSave: payload => runAction('saveSettings', payload).then(() => setSettingsOpen(false)), onCheckUpdate: () => handleCheckUpdate(true), checking, onUpdate: handleUpdate, updating }) : null,
|
|
468
|
+
aboutOpen ? h(WelcomeDialog, { version: state?.version, settings: state?.settings, onClose: () => { setAboutOpen(false); try { localStorage.setItem('tapd-task-board:welcome-v1', '1') } catch { /* 忽略 */ } }, onOpenSettings: () => { setAboutOpen(false); setSettingsOpen(true) }, onCheckUpdate: () => handleCheckUpdate(true), checking, onUpdate: handleUpdate, updating }) : null)
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
/** Right-side detail drawer. */
|
|
472
|
+
function DetailDrawer({ item, config, statusOptions, fieldsOf, labels, pickDirectory, onClose, onMove, onComment, onSchedule, onRegisterWorkspace }) {
|
|
473
|
+
const f = translate('fields')
|
|
474
|
+
const [status, setStatus] = useState(item.status)
|
|
475
|
+
const [comment, setComment] = useState('')
|
|
476
|
+
const [aiTip, setAiTip] = useState('')
|
|
477
|
+
const [scheduleTip, setScheduleTip] = useState('')
|
|
478
|
+
const [scheduleAt, setScheduleAt] = useState('')
|
|
479
|
+
const dshWorkspaces = config?.dshWorkspaces || []
|
|
480
|
+
const [scheduleWs, setScheduleWs] = useState('')
|
|
481
|
+
const [registerTip, setRegisterTip] = useState('')
|
|
482
|
+
const descRef = useRef(null)
|
|
483
|
+
useEffect(() => {
|
|
484
|
+
const node = descRef.current
|
|
485
|
+
if (!node) return
|
|
486
|
+
const images = node.querySelectorAll('img')
|
|
487
|
+
const handler = (event) => {
|
|
488
|
+
const img = event.currentTarget
|
|
489
|
+
const wrap = document.createElement('div')
|
|
490
|
+
wrap.className = 'tbx-img-fallback'
|
|
491
|
+
wrap.textContent = '🔒 图片需要登录 TAPD 后查看'
|
|
492
|
+
const link = document.createElement('a')
|
|
493
|
+
link.href = item.url; link.target = '_blank'; link.rel = 'noreferrer'
|
|
494
|
+
link.textContent = f.url
|
|
495
|
+
wrap.appendChild(link)
|
|
496
|
+
img.replaceWith(wrap)
|
|
497
|
+
}
|
|
498
|
+
images.forEach(img => img.addEventListener('error', handler, { once: true }))
|
|
499
|
+
return () => images.forEach(img => img.removeEventListener('error', handler))
|
|
500
|
+
}, [item])
|
|
501
|
+
const allowAi = config?.allowAiHandoff !== false
|
|
502
|
+
const model = config?.model || ''
|
|
503
|
+
const execWs = (scheduleWs || '').trim()
|
|
504
|
+
const execLabel = dshWorkspaces.find(ws => ws.id === execWs)
|
|
505
|
+
async function registerNewSpace() {
|
|
506
|
+
if (!pickDirectory) return
|
|
507
|
+
const dir = await pickDirectory()
|
|
508
|
+
if (dir) {
|
|
509
|
+
setRegisterTip('…')
|
|
510
|
+
try {
|
|
511
|
+
const result = await onRegisterWorkspace(dir)
|
|
512
|
+
if (result?.registeredWorkspace) {
|
|
513
|
+
setScheduleWs(result.registeredWorkspace.id)
|
|
514
|
+
setRegisterTip(translate('workspaceRegistered'))
|
|
515
|
+
} else setRegisterTip(translate('error'))
|
|
516
|
+
} catch { setRegisterTip(translate('error')) }
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
async function copyText(text) {
|
|
520
|
+
let ok = false
|
|
521
|
+
try { await navigator.clipboard.writeText(text); ok = true } catch { ok = false }
|
|
522
|
+
if (!ok) {
|
|
523
|
+
try {
|
|
524
|
+
const ta = document.createElement('textarea')
|
|
525
|
+
ta.value = text; ta.style.position = 'fixed'; ta.style.opacity = '0'
|
|
526
|
+
document.body.appendChild(ta); ta.select()
|
|
527
|
+
ok = document.execCommand('copy'); ta.remove()
|
|
528
|
+
} catch { ok = false }
|
|
529
|
+
}
|
|
530
|
+
return ok
|
|
531
|
+
}
|
|
532
|
+
async function copyPrompt() {
|
|
533
|
+
setAiTip(await copyText(taskPrompt(item, model)) ? translate('copied') : translate('copyPrompt'))
|
|
534
|
+
}
|
|
535
|
+
return h('div', { className: 'tbx-drawer' },
|
|
536
|
+
h('div', { className: 'tbx-drawer-head' },
|
|
537
|
+
h('a', { className: 'tbx-drawer-title', href: item.url, target: '_blank', rel: 'noreferrer', title: f.url }, item.title),
|
|
538
|
+
h('button', { className: 'tbx-icon-btn', onClick: onClose, type: 'button', 'aria-label': translate('close'), title: translate('close') },
|
|
539
|
+
h('svg', { viewBox: '0 0 16 16', width: 15, height: 15, fill: 'none', stroke: 'currentColor', strokeWidth: 1.5, strokeLinecap: 'round', 'aria-hidden': true }, h('path', { d: 'M4 4l8 8M12 4l-8 8' })))),
|
|
540
|
+
h('div', { className: 'tbx-drawer-body' },
|
|
541
|
+
fieldsOf.map(([k, v]) => v ? h('div', { className: 'tbx-field', key: k }, h('span', { className: 'tbx-field-k' }, k), h('span', { className: 'tbx-field-v' }, v)) : null),
|
|
542
|
+
h('div', { className: 'tbx-field' }, h('span', { className: 'tbx-field-k' }, f.id), h('span', { className: 'tbx-field-v' }, item.id)),
|
|
543
|
+
item.description ? h('div', { className: 'tbx-desc', ref: descRef, dangerouslySetInnerHTML: { __html: safeDescription(item.description) } }) : null,
|
|
544
|
+
allowAi ? h('div', { className: 'tbx-field tbx-ai' },
|
|
545
|
+
h('span', { className: 'tbx-field-k' }, translate('aiSection')),
|
|
546
|
+
h('div', { className: 'tbx-row' },
|
|
547
|
+
h('button', { className: 'tbx-btn primary', onClick: copyPrompt, type: 'button', title: model ? `${translate('modelLabel')} ${model}` : '' }, '🧠 ', translate('copyPrompt'))),
|
|
548
|
+
h('span', { className: 'tbx-note' + (aiTip ? ' ok' : '') }, aiTip || translate('chatHint'))) : null,
|
|
549
|
+
h('div', { className: 'tbx-field' },
|
|
550
|
+
h('span', { className: 'tbx-field-k' }, translate('scheduleSection')),
|
|
551
|
+
h('div', { className: 'tbx-row' },
|
|
552
|
+
h('input', { className: 'tbx-input tbx-date', type: 'datetime-local', value: scheduleAt, onChange: event => setScheduleAt(event.target.value) }),
|
|
553
|
+
h('button', { className: 'tbx-btn', onClick: () => { if (scheduleAt) { onSchedule({ type: item.type, id: item.id, workspaceId: item.workspaceId, dshWorkspaceId: (scheduleWs || '').trim(), title: item.title, url: item.url, at: new Date(scheduleAt).toISOString() }); setScheduleTip(translate('scheduleCreated')) } }, type: 'button', disabled: !scheduleAt || config?.scheduleAvailable === false }, '⏰ ', translate('scheduleCreate'))),
|
|
554
|
+
h('div', { className: 'tbx-row' },
|
|
555
|
+
h('select', { className: 'tbx-input tbx-bind', value: scheduleWs, onChange: event => setScheduleWs(event.target.value), title: translate('workspacePathOverride') },
|
|
556
|
+
h('option', { value: '' }, translate('workspaceBindDefault')),
|
|
557
|
+
dshWorkspaces.map(ws => h('option', { key: ws.id, value: ws.id }, `${ws.title}(${ws.path || ws.id})`))),
|
|
558
|
+
pickDirectory ? h('button', { className: 'tbx-btn', onClick: registerNewSpace, type: 'button', title: translate('workspaceRegisterNew') }, '📁 ', translate('workspaceRegisterNew')) : null),
|
|
559
|
+
registerTip ? h('span', { className: 'tbx-note' + (registerTip === translate('workspaceRegistered') ? ' ok' : '') }, registerTip) : null,
|
|
560
|
+
scheduleTip ? h('span', { className: 'tbx-note ok' }, scheduleTip) : (config?.scheduleAvailable === false ? h('span', { className: 'tbx-note' }, translate('scheduleUnavailable')) : null)),
|
|
561
|
+
h('div', { className: 'tbx-field' }, h('span', { className: 'tbx-field-k' }, translate('move')), h('div', { className: 'tbx-row' },
|
|
562
|
+
h('select', { className: 'tbx-input', value: status, onChange: event => setStatus(event.target.value) }, statusOptions.map(option => h('option', { key: option.value, value: option.value }, option.label))),
|
|
563
|
+
h('button', { className: 'tbx-btn', onClick: () => onMove(status), type: 'button', disabled: status === item.status }, translate('save')))),
|
|
564
|
+
h('div', { className: 'tbx-field' }, h('span', { className: 'tbx-field-k' }, translate('comment')), h('div', { className: 'tbx-row' },
|
|
565
|
+
h('input', { className: 'tbx-input', placeholder: translate('commentPlaceholder'), value: comment, onChange: event => setComment(event.target.value), onKeyDown: event => { if (event.key === 'Enter' && comment.trim()) { onComment(comment); setComment('') } } }),
|
|
566
|
+
h('button', { className: 'tbx-btn', onClick: () => { if (comment.trim()) { onComment(comment); setComment('') } }, type: 'button', disabled: !comment.trim() }, translate('comment'))))))
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
/** New-story dialog. */
|
|
570
|
+
function CreateDialog({ labels, ownerDefault, onCancel, onCreate }) {
|
|
571
|
+
const c = translate('create')
|
|
572
|
+
const [name, setName] = useState('')
|
|
573
|
+
const [description, setDescription] = useState('')
|
|
574
|
+
const [owner, setOwner] = useState(ownerDefault)
|
|
575
|
+
const [priority, setPriority] = useState('2')
|
|
576
|
+
return h('div', { className: 'tbx-dialog', onClick: event => { if (event.target === event.currentTarget) onCancel() } },
|
|
577
|
+
h('div', { className: 'tbx-dialog-box' },
|
|
578
|
+
h('div', { style: { fontWeight: 600, fontSize: 14 } }, c.title),
|
|
579
|
+
h('input', { className: 'tbx-input', placeholder: c.name, value: name, onChange: event => setName(event.target.value) }),
|
|
580
|
+
h('textarea', { className: 'tbx-textarea', placeholder: c.description, value: description, onChange: event => setDescription(event.target.value) }),
|
|
581
|
+
h('div', { className: 'tbx-row' }, h('input', { className: 'tbx-input', placeholder: c.owner, value: owner, onChange: event => setOwner(event.target.value) })),
|
|
582
|
+
h('div', { className: 'tbx-row' }, h('select', { className: 'tbx-input', value: priority, onChange: event => setPriority(event.target.value) }, ['1', '2', '3'].map(p => h('option', { key: p, value: p }, `${c.priority} ${p}`)))),
|
|
583
|
+
h('div', { className: 'tbx-row', style: { justifyContent: 'flex-end' } },
|
|
584
|
+
h('button', { className: 'tbx-btn', onClick: onCancel, type: 'button' }, c.cancel),
|
|
585
|
+
h('button', { className: 'tbx-btn primary', onClick: () => { if (name.trim()) onCreate({ name: name.trim(), description, owner: owner.trim(), priority }) }, type: 'button', disabled: !name.trim() }, c.create))))
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
/** 首次打开/点击版本徽标时的使用说明弹窗:配置引导 + 版本信息 + 使用手册 + 更新入口。 */
|
|
589
|
+
function WelcomeDialog({ version, settings, onClose, onOpenSettings, onCheckUpdate, checking, onUpdate, updating }) {
|
|
590
|
+
const ready = settings?.tokenConfigured
|
|
591
|
+
const tokenText = ready === undefined ? '' : ready ? '✅ ' + translate('tokenReady') : '⚠️ ' + translate('tokenMissing')
|
|
592
|
+
const updateAvailable = Boolean(version?.updateAvailable)
|
|
593
|
+
const step = (num, text) => h('div', { className: 'tbx-welcome-step' }, h('span', { className: 'tbx-welcome-num', 'aria-hidden': true }, num), h('span', {}, text))
|
|
594
|
+
return h('div', { className: 'tbx-dialog', onClick: event => { if (event.target === event.currentTarget) onClose() } },
|
|
595
|
+
h('div', { className: 'tbx-dialog-box tbx-dialog-wide' },
|
|
596
|
+
h('div', { style: { display: 'flex', alignItems: 'center', gap: 8, fontWeight: 600, fontSize: 15 } },
|
|
597
|
+
h('span', { 'aria-hidden': true }, '📋'), translate('welcomeTitle'),
|
|
598
|
+
h('span', { className: 'tbx-chip' }, `${translate('versionLabel')} v${version?.current || '-'}`),
|
|
599
|
+
updateAvailable ? h('span', { className: 'tbx-chip tbx-chip-new' }, `🔴 ${translate('newVersionBadge')}`) : null),
|
|
600
|
+
h('span', { className: 'tbx-note' }, translate('welcomeSubtitle')),
|
|
601
|
+
h('div', { className: 'tbx-welcome-title' }, translate('welcomeConfigTitle')),
|
|
602
|
+
step('1', translate('welcomeConfigStep1')),
|
|
603
|
+
step('2', translate('welcomeConfigStep2')),
|
|
604
|
+
step('3', translate('welcomeConfigStep3')),
|
|
605
|
+
tokenText ? h('div', { className: 'tbx-status' + (ready ? ' ok' : ' err') }, tokenText) : null,
|
|
606
|
+
h('div', { className: 'tbx-welcome-title' }, translate('welcomeGuideTitle')),
|
|
607
|
+
step('·', translate('welcomeGuideDrag')),
|
|
608
|
+
step('·', translate('welcomeGuideDetail')),
|
|
609
|
+
step('·', translate('welcomeGuideSchedule')),
|
|
610
|
+
step('·', translate('welcomeGuideAgent')),
|
|
611
|
+
h('div', { className: 'tbx-welcome-title' }, translate('welcomeUpdateTitle')),
|
|
612
|
+
h('div', { className: 'tbx-row' },
|
|
613
|
+
h('span', { className: 'tbx-note tbx-grow' }, `${translate('currentVersion')} v${version?.current || '-'}${version?.latest ? ` · ${translate('latestVersion')} v${version.latest}` : ''}`),
|
|
614
|
+
h('button', { className: 'tbx-btn' + (updateAvailable ? ' has-update' : ''), onClick: onCheckUpdate, type: 'button', disabled: checking }, checking ? translate('welcomeChecking') : translate('welcomeCheckUpdate')),
|
|
615
|
+
updateAvailable ? h('button', { className: 'tbx-btn primary', onClick: onUpdate, type: 'button', disabled: updating }, updating ? translate('welcomeUpdating') : translate('welcomeUpdateNow')) : null),
|
|
616
|
+
updateAvailable
|
|
617
|
+
? h('span', { className: 'tbx-note ok' }, `🔴 ${translate('welcomeNewVersion')} v${version.latest} — ${translate('updateRestartHint')}`)
|
|
618
|
+
: (version?.latest ? h('span', { className: 'tbx-note ok' }, '✅ ' + translate('welcomeUpToDate')) : null),
|
|
619
|
+
version?.error ? h('span', { className: 'tbx-status err' }, '⚠️ ' + version.error) : null,
|
|
620
|
+
h('div', { className: 'tbx-row', style: { justifyContent: 'flex-end' } },
|
|
621
|
+
h('button', { className: 'tbx-btn', onClick: onOpenSettings, type: 'button' }, '⚙ ', translate('welcomeOpenSettings')),
|
|
622
|
+
h('button', { className: 'tbx-btn primary', onClick: onClose, type: 'button' }, translate('welcomeGotIt')))))
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
/** TAPD / AI settings dialog: connection status, editable overlay config, model + schedule hints. */
|
|
626
|
+
function SettingsDialog({ config, settings, version, onClose, onSave, onCheckUpdate, checking, onUpdate, updating }) {
|
|
627
|
+
const [endpoint, setEndpoint] = useState(config?.endpoint || '')
|
|
628
|
+
const [workspaceIds, setWorkspaceIds] = useState((config?.workspaceIds || []).join(','))
|
|
629
|
+
const [refreshSeconds, setRefreshSeconds] = useState(String(config?.refreshSeconds ?? 300))
|
|
630
|
+
const [listLimit, setListLimit] = useState(String(config?.listLimit ?? 200))
|
|
631
|
+
const [model, setModel] = useState(config?.model || '')
|
|
632
|
+
const [announce, setAnnounce] = useState(Boolean(config?.announceToAgent))
|
|
633
|
+
const ready = settings?.tokenConfigured
|
|
634
|
+
const statusText = ready === undefined ? translate('loading') : ready ? '✅ ' + translate('tokenReady') : '⚠️ ' + translate('tokenMissing')
|
|
635
|
+
const statusClass = ready === undefined ? '' : ready ? ' ok' : ' err'
|
|
636
|
+
return h('div', { className: 'tbx-dialog', onClick: event => { if (event.target === event.currentTarget) onClose() } },
|
|
637
|
+
h('div', { className: 'tbx-dialog-box tbx-dialog-wide' },
|
|
638
|
+
h('div', { style: { fontWeight: 600, fontSize: 14 } }, '⚙ ', translate('setupTitle')),
|
|
639
|
+
h('div', { className: 'tbx-status' + statusClass }, statusText),
|
|
640
|
+
h('span', { className: 'tbx-note' }, translate('setupDocs')),
|
|
641
|
+
h('label', { className: 'tbx-field' }, h('span', { className: 'tbx-field-k' }, translate('endpointLabel')), h('input', { className: 'tbx-input', value: endpoint, onChange: event => setEndpoint(event.target.value), placeholder: 'https://api.tapd.cn' })),
|
|
642
|
+
h('label', { className: 'tbx-field' }, h('span', { className: 'tbx-field-k' }, translate('workspaceIdsLabel')), h('input', { className: 'tbx-input', value: workspaceIds, onChange: event => setWorkspaceIds(event.target.value), placeholder: '54844448' })),
|
|
643
|
+
h('div', { className: 'tbx-row' },
|
|
644
|
+
h('label', { className: 'tbx-field tbx-grow' }, h('span', { className: 'tbx-field-k' }, translate('refreshSecondsLabel')), h('input', { className: 'tbx-input', type: 'number', min: 30, value: refreshSeconds, onChange: event => setRefreshSeconds(event.target.value) })),
|
|
645
|
+
h('label', { className: 'tbx-field tbx-grow' }, h('span', { className: 'tbx-field-k' }, translate('listLimitLabel')), h('input', { className: 'tbx-input', type: 'number', min: 20, max: 200, value: listLimit, onChange: event => setListLimit(event.target.value) }))),
|
|
646
|
+
h('label', { className: 'tbx-field' }, h('span', { className: 'tbx-field-k' }, translate('modelLabel')), h('input', { className: 'tbx-input', value: model, onChange: event => setModel(event.target.value), placeholder: 'deepseek/deepseek-chat' })),
|
|
647
|
+
h('label', { className: 'tbx-field tbx-check' }, h('input', { type: 'checkbox', checked: announce, onChange: event => setAnnounce(event.target.checked) }), h('span', {}, translate('announceLabel'))),
|
|
648
|
+
h('span', { className: 'tbx-note' }, translate('scheduleHint')),
|
|
649
|
+
h('div', { style: { borderTop: '1px solid var(--dsw-alias-border-l1)', paddingTop: 12, display: 'flex', flexDirection: 'column', gap: 8 } },
|
|
650
|
+
h('div', { style: { display: 'flex', alignItems: 'center', gap: 8, flexWrap: 'wrap' } },
|
|
651
|
+
h('span', { className: 'tbx-field-k' }, translate('versionSection')),
|
|
652
|
+
h('span', { className: 'tbx-chip' }, `v${version?.current || '-'}`),
|
|
653
|
+
version?.updateAvailable ? h('span', { className: 'tbx-chip tbx-chip-new' }, `🔴 ${translate('newVersionBadge')} v${version.latest}`) : null,
|
|
654
|
+
h('span', { className: 'tbx-spacer' }),
|
|
655
|
+
h('button', { className: 'tbx-btn', onClick: onCheckUpdate, type: 'button', disabled: checking }, checking ? translate('welcomeChecking') : translate('checkUpdate')),
|
|
656
|
+
version?.updateAvailable ? h('button', { className: 'tbx-btn primary', onClick: onUpdate, type: 'button', disabled: updating }, updating ? translate('welcomeUpdating') : translate('updateNow')) : null),
|
|
657
|
+
version?.updateAvailable ? h('span', { className: 'tbx-note ok' }, translate('updateRestartHint')) : null,
|
|
658
|
+
version?.error ? h('span', { className: 'tbx-status err' }, '⚠️ ' + version.error) : null),
|
|
659
|
+
h('div', { className: 'tbx-row', style: { justifyContent: 'flex-end' } },
|
|
660
|
+
h('button', { className: 'tbx-btn', onClick: onClose, type: 'button' }, translate('close')),
|
|
661
|
+
h('button', { className: 'tbx-btn primary', onClick: () => onSave({ endpoint: endpoint.trim(), workspaceIds, refreshSeconds: Number(refreshSeconds) || 300, listLimit: Number(listLimit) || 200, model: model.trim(), announceToAgent: announce }), type: 'button' }, translate('saveSettings')))))
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
return {
|
|
665
|
+
inject: ['slots'],
|
|
666
|
+
apply(ctx) {
|
|
667
|
+
try {
|
|
668
|
+
if (ctx.locale?.register) {
|
|
669
|
+
const locale = ctx.locale
|
|
670
|
+
try {
|
|
671
|
+
translate = key => (locale.getSnapshot && locale.getSnapshot().locale === 'en' ? dicts.en : dicts.zh)[key] ?? fallback[key]
|
|
672
|
+
locale.register(NS, { zh: dicts.zh, en: dicts.en })
|
|
673
|
+
} catch { /* keep fallback */ }
|
|
674
|
+
} else if (typeof document !== 'undefined') {
|
|
675
|
+
translate = key => (document.documentElement.lang === 'en' ? dicts.en : dicts.zh)[key] ?? fallback[key]
|
|
676
|
+
}
|
|
677
|
+
} catch { /* keep fallback */ }
|
|
678
|
+
const slots = ctx.slots
|
|
679
|
+
const disposers = []
|
|
680
|
+
try { pickDirectory = (ctx.uiWorkspace?.pickDirectory || (typeof ctx.get === 'function' ? ctx.get('uiWorkspace')?.pickDirectory : undefined)) || null } catch { pickDirectory = null }
|
|
681
|
+
try {
|
|
682
|
+
disposers.push(slots.inject('sidebar.panellist', () => slots.register({ name: 'sidebar.panellist', id: PANEL_ID, order: ORDER, label: () => translate('entry') }, BoardIcon)))
|
|
683
|
+
} catch (error) { console.warn('[tapd-task-board] sidebar entry failed', error) }
|
|
684
|
+
try {
|
|
685
|
+
disposers.push(slots.inject('main', () => slots.register({ name: 'main', key: PANEL_ID }, BoardPage)))
|
|
686
|
+
} catch (error) { console.warn('[tapd-task-board] main seat failed', error) }
|
|
687
|
+
return () => disposers.splice(0).forEach(dispose => { try { dispose?.() } catch {} })
|
|
688
|
+
},
|
|
689
|
+
}
|
|
690
|
+
},
|
|
691
|
+
})
|