dshgo-connect-madao 0.1.0 → 0.1.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/CHANGELOG.md +4 -0
- package/README.md +3 -0
- package/docs/market/index.json +2 -4
- package/lib/index.js +24 -13
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
package/docs/market/index.json
CHANGED
|
@@ -57,11 +57,9 @@
|
|
|
57
57
|
"versions": [
|
|
58
58
|
{
|
|
59
59
|
"version": "0.1.0",
|
|
60
|
-
"publishTimestamp":
|
|
60
|
+
"publishTimestamp": 1795716995,
|
|
61
61
|
"source": {
|
|
62
|
-
"type": "
|
|
63
|
-
"url": "https://github.com/wsdzwx2001/dshgo-connect-madao",
|
|
64
|
-
"commit": "730054f437103f4597d18a94413bd36e372fc2d3"
|
|
62
|
+
"type": "npm"
|
|
65
63
|
},
|
|
66
64
|
"engines": {
|
|
67
65
|
"dsh": ">=0.2.1-rc.2 <0.3.0-0"
|
package/lib/index.js
CHANGED
|
@@ -226,6 +226,7 @@ export function apply(ctx, config = {}) {
|
|
|
226
226
|
// dshGo 就绪后由它接管:主动重取两个面板的数据(凭证页平时不推送)
|
|
227
227
|
let refreshPanels = () => {}
|
|
228
228
|
const listeners = new Set()
|
|
229
|
+
const credsListeners = new Set()
|
|
229
230
|
const notify = () => {
|
|
230
231
|
for (const fn of listeners) {
|
|
231
232
|
try {
|
|
@@ -281,13 +282,15 @@ export function apply(ctx, config = {}) {
|
|
|
281
282
|
/** 保存凭证 → 重连 → 拉模型 → 注册 provider → 自检。 */
|
|
282
283
|
const saveCreds = async (ak, sk) => {
|
|
283
284
|
await saveCredentials(ak, sk)
|
|
284
|
-
void bridge
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
285
|
+
void bridge
|
|
286
|
+
.reload()
|
|
287
|
+
.then(async (ok) => {
|
|
288
|
+
if (!ok) return
|
|
289
|
+
await bridge.syncModels()
|
|
290
|
+
ensureProvider(bridge.state.models, bridge.status().port)
|
|
291
|
+
await bridge.test()
|
|
292
|
+
})
|
|
293
|
+
.finally(() => refreshPanels())
|
|
291
294
|
}
|
|
292
295
|
|
|
293
296
|
/** 从表单提交的 value 里尽量捞出 AK / SK(不同 App 版本可能包一层)。 */
|
|
@@ -315,11 +318,16 @@ export function apply(ctx, config = {}) {
|
|
|
315
318
|
|
|
316
319
|
ctx.inject(['dshGo'], (ctx) => {
|
|
317
320
|
refreshPanels = () => {
|
|
318
|
-
|
|
321
|
+
// 主面板本来就订阅了 listeners;凭证页只在保存/连接完成后推一次,
|
|
322
|
+
// 这样既能更新「当前 AK / 状态」,又不会在输入途中把内容刷掉。
|
|
323
|
+
for (const fn of credsListeners) {
|
|
319
324
|
try {
|
|
320
|
-
|
|
325
|
+
fn()
|
|
321
326
|
} catch {}
|
|
322
327
|
}
|
|
328
|
+
try {
|
|
329
|
+
ctx.dshGo.refresh?.('madao')
|
|
330
|
+
} catch {}
|
|
323
331
|
}
|
|
324
332
|
const snapshot = (locale) => {
|
|
325
333
|
const s = bridge.status()
|
|
@@ -510,9 +518,12 @@ export function apply(ctx, config = {}) {
|
|
|
510
518
|
],
|
|
511
519
|
},
|
|
512
520
|
data: (scope, emit, caps) => {
|
|
513
|
-
//
|
|
514
|
-
|
|
515
|
-
|
|
521
|
+
// 打开时推一次;之后只在保存凭证 / 连接完成时由 refreshPanels 再推。
|
|
522
|
+
// 这里没有定时刷新,避免输入到一半被刷掉。
|
|
523
|
+
const push = () => emit({ akInput: '', skInput: '', ...snapshot(caps?.locale) })
|
|
524
|
+
push()
|
|
525
|
+
credsListeners.add(push)
|
|
526
|
+
return () => credsListeners.delete(push)
|
|
516
527
|
},
|
|
517
528
|
actions: {
|
|
518
529
|
save: async (scope, event) => {
|
|
@@ -526,7 +537,7 @@ export function apply(ctx, config = {}) {
|
|
|
526
537
|
} catch (err) {
|
|
527
538
|
return { toast: `保存失败:${String(err?.message ?? err).slice(0, 24)}` }
|
|
528
539
|
}
|
|
529
|
-
return { toast: '已保存,正在验证…', patch: { akInput: '', skInput: '' }
|
|
540
|
+
return { toast: '已保存,正在验证…', patch: { akInput: '', skInput: '' } }
|
|
530
541
|
},
|
|
531
542
|
},
|
|
532
543
|
})
|