feat(console): 更新横幅加「复制升级指令」按钮 + 更新方法说明行(复制指令→AI会话执行→重启DSH;或手动终端命令)
This commit is contained in:
@@ -196,6 +196,9 @@ export const zh = {
|
||||
'annot.skipVer': '忽略此版本',
|
||||
'annot.latest': '已是最新版本',
|
||||
'annot.checkFail': '检查失败,请稍后再试',
|
||||
'annot.copyUpgrade': '复制升级指令',
|
||||
'annot.copied': '已复制 ✓',
|
||||
'annot.howUpdate': '更新方法:点「复制升级指令」→ 粘贴给当前 AI 会话由它执行,完成后重启 DSH;或手动在终端运行升级命令。',
|
||||
'pane.expand': '展开窗格',
|
||||
'pane.jobsTitle': '后台任务',
|
||||
'pane.subagents': '子代理',
|
||||
@@ -416,6 +419,9 @@ export const en = {
|
||||
'annot.skipVer': 'Ignore this version',
|
||||
'annot.latest': 'Up to date',
|
||||
'annot.checkFail': 'Check failed — try again later',
|
||||
'annot.copyUpgrade': 'Copy upgrade command',
|
||||
'annot.copied': 'Copied ✓',
|
||||
'annot.howUpdate': 'How to update: click “Copy upgrade command” and paste it to your AI session to run, then restart DSH; or run the upgrade command in a terminal manually.',
|
||||
'pane.expand': 'Expand pane',
|
||||
'pane.jobsTitle': 'Background jobs',
|
||||
'pane.subagents': 'Subagents',
|
||||
|
||||
@@ -481,6 +481,23 @@ function boxPayload(x0: number, y0: number, x1: number, y1: number): { primary:
|
||||
return { primary, line, candidates, limited, src }
|
||||
}
|
||||
|
||||
/** 更新方法:复制给 AI 的升级指令(插件不自更新;升级由用户或其 Agent 执行 + 重启) */
|
||||
const UPGRADE_CMD = 'dsh plugin --profile web add "https://github.com/Aisland-SJL/dsh-worktable/releases/latest/download/dsh-worktable.tgz"'
|
||||
const UPGRADE_AI = '帮我升级 dsh-worktable:执行 ' + UPGRADE_CMD + ',完成后提醒我重启 dsh web 并刷新页面'
|
||||
|
||||
async function copyTextSafe(text: string): Promise<boolean> {
|
||||
try { if (navigator.clipboard?.writeText) { await navigator.clipboard.writeText(text); return true } } catch {}
|
||||
try {
|
||||
const ta = document.createElement('textarea')
|
||||
ta.value = text
|
||||
document.body.appendChild(ta)
|
||||
ta.select()
|
||||
const ok = document.execCommand('copy')
|
||||
document.body.removeChild(ta)
|
||||
return ok
|
||||
} catch { return false }
|
||||
}
|
||||
|
||||
/** 注入宿主对话框输入框(不发送);失败返回 false */
|
||||
function fillHostInput(text: string): boolean {
|
||||
try {
|
||||
@@ -1653,6 +1670,11 @@ function ConsolePane() {
|
||||
updBusyRef.current = false
|
||||
}
|
||||
}
|
||||
const [updCopied, setUpdCopied] = useState(false)
|
||||
const onCopyUpgrade = async () => {
|
||||
const ok = await copyTextSafe(UPGRADE_AI)
|
||||
if (ok) { setUpdCopied(true); window.setTimeout(() => setUpdCopied(false), 2200) }
|
||||
}
|
||||
const onSkipVersion = () => {
|
||||
if (updInfo) { setSkipVersion(updInfo.latest); setUpdInfo(null); setUpdStatus('uptodate') }
|
||||
}
|
||||
@@ -1921,7 +1943,9 @@ function ConsolePane() {
|
||||
<div className="dsh-wt_announceUpdate">
|
||||
<span className="dsh-wt_announceNewVer">{T('annot.newVer')} v{updInfo.latest}</span>
|
||||
<button type="button" className="dsh-wt_gridToggle dsh-wt_gridToggleOn" onClick={() => { try { window.open(updInfo.url, '_blank') } catch {} }}>{T('annot.gotoRelease')}</button>
|
||||
<button type="button" className="dsh-wt_announceUpg" onClick={onCopyUpgrade}>{updCopied ? T('annot.copied') : T('annot.copyUpgrade')}</button>
|
||||
<button type="button" className="dsh-wt_announceSkip" onClick={onSkipVersion}>{T('annot.skipVer')}</button>
|
||||
<div className="dsh-wt_announceHow">{T('annot.howUpdate')}</div>
|
||||
</div>
|
||||
)}
|
||||
{updStatus === 'failed' && <div className="dsh-wt_announceStatus">{T('annot.checkFail')}</div>}
|
||||
|
||||
@@ -440,6 +440,9 @@ export const css = xtermCss + '\n' + [
|
||||
'.dsh-wt_announceAuto{flex:none;font-size:12px;line-height:17px;color:var(--wt-text2);margin-left:auto}',
|
||||
'.dsh-wt_announceUpdate{display:flex;align-items:center;gap:10px;flex-wrap:wrap;padding:8px 10px;border-radius:8px;background:rgba(79,142,247,.12)}',
|
||||
'.dsh-wt_announceNewVer{font-size:12px;line-height:17px;color:#7eb3ff;font-weight:600}',
|
||||
'.dsh-wt_announceUpg{flex:none;padding:3px 10px;border:none;border-radius:6px;background:rgba(79,142,247,.16);color:#7eb3ff;font:inherit;font-size:11px;line-height:16px;cursor:pointer}',
|
||||
'.dsh-wt_announceUpg:hover{background:rgba(79,142,247,.3);color:#bcd6ff}',
|
||||
'.dsh-wt_announceHow{flex:none;width:100%;font-size:11px;line-height:16px;color:var(--wt-text3);padding-top:2px}',
|
||||
'.dsh-wt_announceSkip{flex:none;padding:3px 10px;border:none;border-radius:6px;background:transparent;color:var(--wt-text3);font:inherit;font-size:11px;line-height:16px;cursor:pointer}',
|
||||
'.dsh-wt_announceSkip:hover{background:rgba(244,63,94,.14);color:#f87171}',
|
||||
'.dsh-wt_announceStatus{font-size:11px;line-height:16px;color:var(--wt-text3)}',
|
||||
|
||||
Reference in New Issue
Block a user