dsh-go-plugin-sync 0.3.1 → 0.3.2

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 CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.2 — 2026-12-04
4
+
5
+ - 修复 README 里的网页地址:实际路径是 `/dsh-go-plugin-sync/`;旧的 `/local-plugin-sync/` 自动跳转
6
+ - 电脑端插件详情页新增**打开插件同步网页**按钮,直接在浏览器里打开当前 DSH 地址下的同步页
7
+ - 网页顶部显示当前地址;引擎启动日志会打印同步页的完整 URL
8
+ - 网页版不再需要用户自己拼地址和端口
9
+
3
10
  ## 0.3.1 — 2026-12-04
4
11
 
5
12
  - 包名改为 `dsh-go-plugin-sync`,发布到 npm
package/README.md CHANGED
@@ -45,12 +45,14 @@ dsh plugin --profile web add ./dshgochajiantongbucha
45
45
 
46
46
  ## 网页版(电脑)
47
47
 
48
- 电脑上的 DSH Web 可以直接打开内置同步页面,不需要 dsh-go 桥接:
48
+ 电脑上的 DSH Web 可以直接打开内置同步页面,不需要 dsh-go 桥接。装好插件并重启 DSH 后,打开**插件**页,进入「插件同步」详情,点标题旁的**打开插件同步网页**,会在浏览器新标签页打开:
49
49
 
50
50
  ```text
51
- http://<DSH 地址>:<端口>/local-plugin-sync/
51
+ http://<DSH 地址>:<端口>/dsh-go-plugin-sync/
52
52
  ```
53
53
 
54
+ 地址就是当前 DSH Web 的地址和端口(例如 `http://127.0.0.1:3080/dsh-go-plugin-sync/`)。旧地址 `/local-plugin-sync/` 会自动跳转过来。
55
+
54
56
  页面提供和手机端一样的发送/接收:
55
57
 
56
58
  1. 勾选要同步的插件,点**复制同步码**
@@ -58,6 +60,8 @@ http://<DSH 地址>:<端口>/local-plugin-sync/
58
60
  3. 默认选中同步码里的插件,可以取消;点**安装选中**
59
61
  4. 页面下方显示任务状态和逐项结果
60
62
 
63
+ 如果页面返回 401:用已经登录 DSH 的同一个浏览器打开;如果返回 404:确认插件已启用并重启过 DSH。
64
+
61
65
  注意:电脑上装完插件后同样要重启一次 DSH。
62
66
 
63
67
  ## 只增不删
package/lib/client.js ADDED
@@ -0,0 +1,56 @@
1
+ window.__ModuleLoader__.load({
2
+ id: 'dsh-go-plugin-sync',
3
+ factory(require) {
4
+ const React = require('react')
5
+ const h = React.createElement
6
+ const PKG = 'dsh-go-plugin-sync'
7
+ const BUTTON = {
8
+ padding: '5px 12px',
9
+ borderRadius: '6px',
10
+ border: '1px solid rgba(128,128,128,.35)',
11
+ background: 'transparent',
12
+ color: 'inherit',
13
+ font: 'inherit',
14
+ fontSize: '13px',
15
+ cursor: 'pointer',
16
+ }
17
+
18
+ const isOurs = (subject) => Boolean(
19
+ subject
20
+ && (subject.kind === 'bundle' || subject.kind === 'row')
21
+ && subject.pkg
22
+ && subject.pkg.name === PKG,
23
+ )
24
+
25
+ function syncUrl() {
26
+ const url = new URL('/dsh-go-plugin-sync/', window.location.href)
27
+ url.search = window.location.search || ''
28
+ url.hash = window.location.hash || ''
29
+ return url.href
30
+ }
31
+
32
+ function OpenSync(props) {
33
+ if (!isOurs(props && props.subject)) return null
34
+ const zh = (navigator.language || '').toLowerCase().indexOf('zh') === 0
35
+ return h('button', {
36
+ type: 'button',
37
+ title: syncUrl(),
38
+ style: BUTTON,
39
+ onClick() {
40
+ window.open(syncUrl(), '_blank', 'noopener')
41
+ },
42
+ }, zh ? '打开插件同步网页' : 'Open plugin sync page')
43
+ }
44
+
45
+ return {
46
+ inject: ['slots'],
47
+ apply(ctx) {
48
+ ctx.slots.inject('plugins.detail.actions', () => ctx.slots.register({
49
+ name: 'plugins.detail.actions',
50
+ id: 'dsh-go-plugin-sync-open',
51
+ order: 100,
52
+ }, OpenSync))
53
+ },
54
+ }
55
+ },
56
+ })
package/lib/index.js CHANGED
@@ -1274,6 +1274,7 @@ li.item .name{font-weight:600}li.item .meta{margin-left:auto;font-size:12px;opac
1274
1274
  </head>
1275
1275
  <body>
1276
1276
  <h1>插件同步</h1>
1277
+ <div id="addr" class="muted"></div>
1277
1278
  <div class="muted">复制同步码到另一台主机导入;只安装缺少的插件,不卸载、不覆盖。</div>
1278
1279
  <div id="config" class="muted"></div>
1279
1280
 
@@ -1299,6 +1300,7 @@ li.item .name{font-weight:600}li.item .meta{margin-left:auto;font-size:12px;opac
1299
1300
  (function(){
1300
1301
  var localSelected=new Set(), diffSelected=new Set(), current={};
1301
1302
  function el(t,c,x){var n=document.createElement(t);if(c)n.className=c;if(x!=null)n.textContent=x;return n}
1303
+ (function(){var a=document.getElementById('addr');if(a)a.textContent='地址:'+location.origin+'/dsh-go-plugin-sync/'})();
1302
1304
  function api(p,b){var o=b===undefined?{}:{method:'POST',headers:{'content-type':'application/json'},body:JSON.stringify(b)};return fetch('api/'+p,o).then(function(r){return r.json()})}
1303
1305
  function setStatus(t,c){var n=document.getElementById('status');n.textContent=t;n.className='status'+(c?' '+c:'')}
1304
1306
  function renderPlugins(list){var ul=document.getElementById('plugins');ul.textContent='';(list||[]).forEach(function(p){var li=el('li','item');var cb=el('input');cb.type='checkbox';cb.checked=localSelected.has(p.name);cb.onchange=function(){if(cb.checked)localSelected.add(p.name);else localSelected.delete(p.name)};li.appendChild(cb);li.appendChild(el('span','name',p.name));li.appendChild(el('span','meta','v'+p.version+(p.installed?' · 已安装':' · 未安装')));ul.appendChild(li)})}
@@ -1598,6 +1600,11 @@ export function apply(ctx) {
1598
1600
  if (rejection !== undefined) { res.writeHead(rejection); res.end(); return }
1599
1601
  const url = new URL(req.url || '/', 'http://dsh.local')
1600
1602
  const path = url.pathname.replace(/\/+$/, '') || '/'
1603
+ if (url.pathname === '/local-plugin-sync' || url.pathname.startsWith('/local-plugin-sync/')) {
1604
+ res.writeHead(302, { location: `/dsh-go-plugin-sync${url.pathname.slice('/local-plugin-sync'.length)}${url.search || ''}` })
1605
+ res.end()
1606
+ return
1607
+ }
1601
1608
  if (req.method === 'GET' && (path === '/dsh-go-plugin-sync' || url.pathname === '/dsh-go-plugin-sync/')) {
1602
1609
  res.writeHead(200, { 'content-type': 'text/html; charset=utf-8', 'cache-control': 'no-store' })
1603
1610
  res.end(webPageHtml())
@@ -1653,5 +1660,12 @@ export function apply(ctx) {
1653
1660
  }
1654
1661
  }
1655
1662
  ctx.effect(() => webCtx.webServer.register({ kind: 'prefix', path: '/dsh-go-plugin-sync', handler }), 'dsh-go-plugin-sync: web ui')
1663
+ try {
1664
+ const ws = webCtx.webServer
1665
+ const host = String(ws.host || '127.0.0.1')
1666
+ const shown = host === '0.0.0.0' || host === '::' ? '127.0.0.1' : host
1667
+ const bracketed = shown.includes(':') ? `[${shown}]` : shown
1668
+ console.log(`[dsh-go-plugin-sync] 插件同步网页:${ws.protocol || 'http:'}//${bracketed}:${ws.port}/dsh-go-plugin-sync/`)
1669
+ } catch {}
1656
1670
  })
1657
1671
  }
package/package.json CHANGED
@@ -1,11 +1,18 @@
1
1
  {
2
2
  "name": "dsh-go-plugin-sync",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "type": "module",
5
5
  "main": "lib/index.js",
6
6
  "dsh": {
7
7
  "bundle": {
8
8
  "patch": "./cordis.patch.yml"
9
+ },
10
+ "client": {
11
+ "platform": "web",
12
+ "immediately": true,
13
+ "inject": [
14
+ "@deepseek-ai/dsh-client-ui-plugin-manager"
15
+ ]
9
16
  }
10
17
  },
11
18
  "engines": {
@@ -86,5 +93,10 @@
86
93
  "cordis.patch.yml",
87
94
  "README.md",
88
95
  "CHANGELOG.md"
89
- ]
96
+ ],
97
+ "exports": {
98
+ ".": "./lib/index.js",
99
+ "./client": "./lib/client.js",
100
+ "./package.json": "./package.json"
101
+ }
90
102
  }