@weibaohui/dsh-plugin-kit 0.1.0 → 0.2.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/README.md +2 -2
- package/client/source.js +7 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -14,8 +14,8 @@ dsh 插件共享工具箱。把系列插件中重复的「AI 动作按钮」能
|
|
|
14
14
|
## 消费方式
|
|
15
15
|
|
|
16
16
|
```jsonc
|
|
17
|
-
// 插件 package.json
|
|
18
|
-
"dependencies": { "@weibaohui/dsh-plugin-kit": "
|
|
17
|
+
// 插件 package.json(npm 源;dsh plugin add 时作为传递依赖一次性装上)
|
|
18
|
+
"dependencies": { "@weibaohui/dsh-plugin-kit": "^0.1.0" }
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
`dsh plugin add` 安装插件时作为传递依赖一次性装上。
|
package/client/source.js
CHANGED
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
* title / hint / rows: [[label, value], ...] / initialPrompt
|
|
10
10
|
* run: async (prompt) => { jobId } — 发起执行
|
|
11
11
|
* poll: async (jobId) => { status, output, code }
|
|
12
|
-
* labels: { copy, copied, run, running, done, failed, outputLabel, close }
|
|
12
|
+
* labels: { copy, copied, run, running, done, failed, outputLabel, openSession, close }
|
|
13
|
+
* onOpenSession: (sessionId) => void — 可选;job 出现 sessionId 时渲染「打开会话」
|
|
13
14
|
* onClose
|
|
14
15
|
*
|
|
15
16
|
* 全部样式内联(主题 token + 回退值),消费者无需自带 CSS。
|
|
@@ -29,7 +30,8 @@ var PluginKit = (function () {
|
|
|
29
30
|
var doFetch = options.fetch || (typeof fetch !== 'undefined' ? fetch : null)
|
|
30
31
|
var inputStyle = { width: '100%', minHeight: 190, resize: 'vertical', fontFamily: 'var(--dsw-font-family)', lineHeight: 1.6, fontSize: 12, background: 'var(--dsw-alias-bg-layer-2,transparent)', color: 'inherit', border: '1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.3))', borderRadius: '8px', padding: '10px', boxSizing: 'border-box' }
|
|
31
32
|
var btnStyle = { background: 'transparent', color: 'inherit', border: '1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.3))', borderRadius: '8px', padding: '5px 12px', fontSize: 13, cursor: 'pointer', font: 'inherit' }
|
|
32
|
-
|
|
33
|
+
// 主按钮亮暗跟随:与 skills-management .sk-btn-primary 同款 token 组合
|
|
34
|
+
var primaryStyle = Object.assign({}, btnStyle, { background: 'var(--dsw-alias-state-business-primary,var(--dsw-alias-brand-primary,#4a7dff))', borderColor: 'transparent', color: 'var(--dsw-alias-label-primary-inverted,#fff)' })
|
|
33
35
|
|
|
34
36
|
return function ActionShareDialog(props) {
|
|
35
37
|
var title = props.title
|
|
@@ -70,6 +72,8 @@ var PluginKit = (function () {
|
|
|
70
72
|
setJob({ jobId: r.jobId, status: 'running', output: '', code: null })
|
|
71
73
|
}).catch(function (e) { setError(String(e && e.message)) }).finally(function () { setBusy(false) })
|
|
72
74
|
}
|
|
75
|
+
var canOpenSession = typeof props.onOpenSession === 'function' && job !== null && job.sessionId
|
|
76
|
+
var openSession = function () { props.onOpenSession(job.sessionId) }
|
|
73
77
|
var copy = function () {
|
|
74
78
|
if (typeof navigator !== 'undefined' && navigator.clipboard && navigator.clipboard.writeText) {
|
|
75
79
|
navigator.clipboard.writeText(prompt).then(function () { setCopied(true); setTimeout(function () { setCopied(false) }, 1500) }).catch(function () {})
|
|
@@ -93,6 +97,7 @@ var PluginKit = (function () {
|
|
|
93
97
|
h('div', { style: { fontSize: 12, opacity: .7, margin: '4px 0' } }, (labels.outputLabel || 'Output') + ' · ' + statusText),
|
|
94
98
|
h('pre', { style: { maxHeight: 220, margin: 0, overflow: 'auto', whiteSpace: 'pre-wrap', fontSize: 12, background: 'var(--dsw-alias-bg-layer-2,transparent)', border: '1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.2))', borderRadius: '8px', padding: '8px' } }, job.output || '…')) : null,
|
|
95
99
|
h('div', { style: { display: 'flex', gap: 8 } },
|
|
100
|
+
canOpenSession ? h('button', { onClick: openSession, style: btnStyle }, labels.openSession || 'Open chat') : null,
|
|
96
101
|
h('button', { onClick: copy, style: btnStyle }, copied ? (labels.copied || 'Copied') : (labels.copy || 'Copy')),
|
|
97
102
|
h('button', { onClick: doRun, disabled: busy || (job !== null && job.status === 'running'), style: primaryStyle }, job !== null && job.status === 'running' ? (labels.running || 'Running…') : (labels.run || 'Run')))))
|
|
98
103
|
}
|