@refeain/dsh-xdpool 0.0.0-stage → 3.0.6
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 +2334 -0
- package/LICENSE +21 -0
- package/README.en.md +308 -0
- package/README.md +336 -2
- package/assets/account-credits.png +0 -0
- package/assets/account-pool.png +0 -0
- package/assets/aggregate-channels.png +0 -0
- package/assets/automation-panel.png +0 -0
- package/assets/community-qr-qq.jpg +0 -0
- package/assets/community-qr-wechat.jpg +0 -0
- package/assets/dashboard.png +0 -0
- package/assets/login-channels.png +0 -0
- package/assets/model-picker.png +0 -0
- package/cordis.patch.yml +24 -0
- package/lib/bin.js +13315 -0
- package/lib/client.js +21484 -0
- package/lib/index.d.ts +4973 -0
- package/lib/index.js +39303 -0
- package/package.json +140 -4
- package/screenshots.json +9 -0
- package/scripts/extract-design-css.mjs +322 -0
- package/scripts/link-host-peers.mjs +359 -0
- package/scripts/make-rail-icons.mjs +46 -0
- package/scripts/probe-channels.mjs +142 -0
- package/vendor/channel-pack/LICENSE +21 -0
- package/vendor/channel-pack/NOTICE.md +53 -0
- package/vendor/channel-pack/pack.js +69917 -0
- package/vendor/channel-pack/qoder-auth-wasm.wasm +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,142 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@refeain/dsh-xdpool",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"displayName": "DSH XD Pool",
|
|
4
|
+
"description": "One DSH model pool for every free quota you have: merge all locally signed-in WorkBuddy accounts with auto-failover, sign in to 22 vendors by QR/web, aggregate 77 external vendors' keys, plus a usage dashboard, model routing, a local OpenAI-compatible gateway and a points-automation suite.",
|
|
5
|
+
"version": "3.0.6",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "XDTrees",
|
|
8
|
+
"homepage": "https://github.com/XDTrees/dsh-xdpool#readme",
|
|
9
|
+
"bugs": {
|
|
10
|
+
"url": "https://github.com/XDTrees/dsh-xdpool/issues"
|
|
11
|
+
},
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/Refeain/dsh-xdpool.git"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"dsh-plugin",
|
|
18
|
+
"deepseek-harness",
|
|
19
|
+
"workbuddy",
|
|
20
|
+
"codebuddy",
|
|
21
|
+
"model-provider",
|
|
22
|
+
"multi-account",
|
|
23
|
+
"failover"
|
|
24
|
+
],
|
|
25
|
+
"type": "module",
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": "^22.19.0 || >=24.0.0",
|
|
28
|
+
"dsh": ">=0.1.5-rc.1 <0.3.0"
|
|
29
|
+
},
|
|
30
|
+
"main": "lib/index.js",
|
|
31
|
+
"types": "lib/index.d.ts",
|
|
32
|
+
"bin": {
|
|
33
|
+
"dsh-xdpool": "lib/bin.js"
|
|
34
|
+
},
|
|
35
|
+
"exports": {
|
|
36
|
+
".": {
|
|
37
|
+
"types": "./lib/index.d.ts",
|
|
38
|
+
"default": "./lib/index.js"
|
|
39
|
+
},
|
|
40
|
+
"./client": "./lib/client.js",
|
|
41
|
+
"./vendor/channel-pack/pack.js": "./vendor/channel-pack/pack.js",
|
|
42
|
+
"./cordis.patch.yml": "./cordis.patch.yml",
|
|
43
|
+
"./package.json": "./package.json"
|
|
44
|
+
},
|
|
45
|
+
"files": [
|
|
46
|
+
"lib",
|
|
47
|
+
"vendor",
|
|
48
|
+
"cordis.patch.yml",
|
|
49
|
+
"screenshots.json",
|
|
50
|
+
"assets",
|
|
51
|
+
"README.md",
|
|
52
|
+
"README.en.md",
|
|
53
|
+
"CHANGELOG.md",
|
|
54
|
+
"LICENSE",
|
|
55
|
+
"scripts"
|
|
56
|
+
],
|
|
57
|
+
"scripts": {
|
|
58
|
+
"build": "tsdown",
|
|
59
|
+
"prepublishOnly": "tsdown",
|
|
60
|
+
"test": "vitest run",
|
|
61
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
62
|
+
"typecheck:client": "tsc -p tsconfig.client.json --noEmit",
|
|
63
|
+
"probe": "node scripts/probe-channels.mjs"
|
|
64
|
+
},
|
|
65
|
+
"dsh": {
|
|
66
|
+
"bundle": {
|
|
67
|
+
"patch": "./cordis.patch.yml"
|
|
68
|
+
},
|
|
69
|
+
"client": {
|
|
70
|
+
"inject": [
|
|
71
|
+
"@deepseek-ai/dsh-client-ui-settings",
|
|
72
|
+
"@deepseek-ai/dsh-client-ui-slots",
|
|
73
|
+
"@deepseek-ai/dsh-client-ui-settings-plugins",
|
|
74
|
+
"@deepseek-ai/dsh-client-ui-primitives",
|
|
75
|
+
"@deepseek-ai/dsh-client-locale"
|
|
76
|
+
],
|
|
77
|
+
"platform": "web"
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
"devDependencies": {
|
|
81
|
+
"@deepseek-ai/cordis": "4.0.2",
|
|
82
|
+
"@deepseek-ai/dsh-client-locale": "0.1.5-rc.2",
|
|
83
|
+
"@deepseek-ai/dsh-client-runtime": "0.1.1-rc.2",
|
|
84
|
+
"@deepseek-ai/dsh-client-ui-primitives": "0.1.5-rc.2",
|
|
85
|
+
"@deepseek-ai/dsh-client-ui-settings-plugins": "0.1.5-rc.2",
|
|
86
|
+
"@deepseek-ai/dsh-client-ui-slots": "0.1.5-rc.2",
|
|
87
|
+
"@deepseek-ai/dsh-credentials": "0.1.5-rc.2",
|
|
88
|
+
"@deepseek-ai/dsh-host-webserver": "0.1.5-rc.2",
|
|
89
|
+
"@deepseek-ai/dsh-launch-environment": "0.1.5-rc.2",
|
|
90
|
+
"@deepseek-ai/dsh-llm": "0.1.5-rc.2",
|
|
91
|
+
"@deepseek-ai/dsh-llm-pi-ai": "0.1.5-rc.2",
|
|
92
|
+
"@deepseek-ai/dsh-settings": "0.1.5-rc.2",
|
|
93
|
+
"@deepseek-ai/schemastery": "3.18.2",
|
|
94
|
+
"@earendil-works/pi-ai": "0.85.1",
|
|
95
|
+
"@types/node": "^26.4.1",
|
|
96
|
+
"@types/react": "~18.3.31",
|
|
97
|
+
"@types/react-dom": "~18.3.0",
|
|
98
|
+
"react": "^18.2.0",
|
|
99
|
+
"tsdown": "^0.23.0",
|
|
100
|
+
"typescript": "^7.0.2",
|
|
101
|
+
"vite": "8.3.0",
|
|
102
|
+
"vitest": "^5.0.0"
|
|
103
|
+
},
|
|
104
|
+
"peerDependencies": {
|
|
105
|
+
"@deepseek-ai/cordis": "^4.0.1-rc.1",
|
|
106
|
+
"@deepseek-ai/dsh-llm": ">=0.1.1-rc.1 <0.3.0",
|
|
107
|
+
"@deepseek-ai/dsh-llm-pi-ai": ">=0.1.1-rc.1 <0.3.0",
|
|
108
|
+
"@deepseek-ai/dsh-credentials": ">=0.1.1-rc.1 <0.3.0",
|
|
109
|
+
"@deepseek-ai/dsh-settings": ">=0.1.1-rc.1 <0.3.0",
|
|
110
|
+
"@deepseek-ai/schemastery": "^3.18.1",
|
|
111
|
+
"@earendil-works/pi-ai": ">=0.82.1"
|
|
112
|
+
},
|
|
113
|
+
"peerDependenciesMeta": {
|
|
114
|
+
"@deepseek-ai/dsh-llm": {
|
|
115
|
+
"optional": true
|
|
116
|
+
},
|
|
117
|
+
"@deepseek-ai/dsh-llm-pi-ai": {
|
|
118
|
+
"optional": true
|
|
119
|
+
},
|
|
120
|
+
"@deepseek-ai/schemastery": {
|
|
121
|
+
"optional": true
|
|
122
|
+
},
|
|
123
|
+
"@earendil-works/pi-ai": {
|
|
124
|
+
"optional": true
|
|
125
|
+
},
|
|
126
|
+
"@deepseek-ai/cordis": {
|
|
127
|
+
"optional": true
|
|
128
|
+
},
|
|
129
|
+
"@deepseek-ai/dsh-settings": {
|
|
130
|
+
"optional": true
|
|
131
|
+
},
|
|
132
|
+
"@deepseek-ai/dsh-credentials": {
|
|
133
|
+
"optional": true
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
"pnpm": {
|
|
137
|
+
"onlyBuiltDependencies": []
|
|
138
|
+
},
|
|
139
|
+
"publishConfig": {
|
|
140
|
+
"access": "public"
|
|
141
|
+
}
|
|
142
|
+
}
|
package/screenshots.json
ADDED
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 设计稿的骨架接管层。
|
|
3
|
+
*
|
|
4
|
+
* 用户的原话:「你就只加载我们设计的,不用之前的元素了」。
|
|
5
|
+
*
|
|
6
|
+
* 这一份把插件多出来的三层(.body / .shellpanel / .shell)压平,让插件的
|
|
7
|
+
* DOM 表现得和设计稿的 `.app > rail + list + main` 一样,然后用设计稿的
|
|
8
|
+
* CSS 原样接管外观。
|
|
9
|
+
*
|
|
10
|
+
* 为什么不直接改 DOM:那三层被 tests 和几处兼容代码依赖(见 shell.tsx 的
|
|
11
|
+
* 注释),删掉会连带断掉十几处。压平成同样的视觉与尺寸,效果一样而风险小。
|
|
12
|
+
*/
|
|
13
|
+
import { readFileSync, writeFileSync } from 'node:fs'
|
|
14
|
+
|
|
15
|
+
const DESIGN = 'D:/dsh-home/xdpool-design'
|
|
16
|
+
|
|
17
|
+
const tokens = readFileSync(`${DESIGN}/tokens.css`, 'utf8')
|
|
18
|
+
const app = readFileSync(`${DESIGN}/app.css`, 'utf8')
|
|
19
|
+
const colors = readFileSync(`${DESIGN}/channel-colors.css`, 'utf8')
|
|
20
|
+
/*
|
|
21
|
+
mobile.css:窄屏适配的那批规则(.dock / .list-credit / 表格在窄屏下的折叠)。
|
|
22
|
+
|
|
23
|
+
之前没读它,于是 760px 窗口里手机的布局规则一条都没生效 ——
|
|
24
|
+
页面靠 app.css 的媒体查询勉强撑着,但那些是「缩小」,不是「重排」。
|
|
25
|
+
文件不存在时跳过,不打断构建。
|
|
26
|
+
*/
|
|
27
|
+
/*
|
|
28
|
+
icons.css:20 家厂商的图标(base64),写成 --icon-* 变量。
|
|
29
|
+
这是插件「13 家没有图标」的答案 —— 设计稿早就画好了,
|
|
30
|
+
只是提取脚本从来没读过这个文件。
|
|
31
|
+
*/
|
|
32
|
+
let icons = ''
|
|
33
|
+
try { icons = readFileSync(`${DESIGN}/icons.css`, 'utf8') } catch { icons = '' }
|
|
34
|
+
|
|
35
|
+
let mobile = ''
|
|
36
|
+
try { mobile = readFileSync(`${DESIGN}/mobile.css`, 'utf8') } catch { mobile = '' }
|
|
37
|
+
|
|
38
|
+
/** build-a.mjs 里的页面级 CSS(.kpi / .acct / .policy / .seg …)。 */
|
|
39
|
+
function pageCss() {
|
|
40
|
+
/*
|
|
41
|
+
所有 build-*.mjs 的页面级 CSS,**加上每个 html 里 <style> 块的规则**。
|
|
42
|
+
|
|
43
|
+
两处都有:build-*.mjs 里是生成脚本用的 CSS 常量,而设计稿最终落地的
|
|
44
|
+
html 里还有一段 <style>(每个页面自己的),两者不完全重合。
|
|
45
|
+
只读 mjs 会漏掉 .summary 的主规则 —— 结果只剩下媒体查询里的降级版本,
|
|
46
|
+
六格的汇总条被压成三列。
|
|
47
|
+
*/
|
|
48
|
+
const FILES = ['build-a', 'build-login', 'build-aggregate', 'build-pick',
|
|
49
|
+
'build-ledger', 'build-b', 'build-c', 'build-d', 'build-marvis']
|
|
50
|
+
const out = []
|
|
51
|
+
for (const file of FILES) {
|
|
52
|
+
let src = ''
|
|
53
|
+
try {
|
|
54
|
+
src = readFileSync(`${DESIGN}/${file}.mjs`, 'utf8')
|
|
55
|
+
} catch {
|
|
56
|
+
continue
|
|
57
|
+
}
|
|
58
|
+
for (const m of src.matchAll(/const\s+\w+\s*=\s*`([\s\S]*?)`/gu)) {
|
|
59
|
+
const body = m[1]
|
|
60
|
+
if (body.includes('{') && body.includes('.') && !body.includes('import ')) out.push(body)
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/*
|
|
64
|
+
每个 html 的 <style> 块 —— 扫目录,不写死清单。
|
|
65
|
+
|
|
66
|
+
写死清单漏过 aggregate-models.html,于是 .mp-row / .mp-name / .mp-id
|
|
67
|
+
这些规则从来没被提取出来:插件用了类名,但没有任何样式命中它们。
|
|
68
|
+
以后设计稿再加页面也不用回来改这里。
|
|
69
|
+
*/
|
|
70
|
+
let htmls = []
|
|
71
|
+
try {
|
|
72
|
+
htmls = readdirSync(DESIGN).filter(f => f.endsWith('.html'))
|
|
73
|
+
} catch {
|
|
74
|
+
htmls = []
|
|
75
|
+
}
|
|
76
|
+
for (const file of htmls) {
|
|
77
|
+
let src = ''
|
|
78
|
+
try {
|
|
79
|
+
src = readFileSync(`${DESIGN}/${file}`, 'utf8')
|
|
80
|
+
} catch {
|
|
81
|
+
continue
|
|
82
|
+
}
|
|
83
|
+
for (const m of src.matchAll(/<style>([\s\S]*?)<\/style>/gu)) out.push(m[1])
|
|
84
|
+
}
|
|
85
|
+
return out.join('\n')
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** body/html 那些全局规则去掉 —— 插件在宿主的对话框里,不该改宿主。 */
|
|
89
|
+
const scoped = app
|
|
90
|
+
.replace(/html,\s*body\s*\{[^}]*\}/gu, '')
|
|
91
|
+
/* 全局 box-sizing 收进 .app 作用域,不改宿主 */
|
|
92
|
+
.replace(/^\s*\*\s*\{\s*box-sizing:\s*border-box;?\s*\}/gmu, '.app, .app * { box-sizing: border-box }')
|
|
93
|
+
/* :root 里的变量改成挂在 .app 上,不污染宿主 */
|
|
94
|
+
.replace(/^:root\s*\{/gmu, '.app {')
|
|
95
|
+
// 全局元素选择器删掉 —— 上面已经在 .app 里重新声明过了
|
|
96
|
+
.replace(/^button,\s*input,\s*select\s*\{[^}]*\}/gmu, '')
|
|
97
|
+
.replace(/^button\s*\{[^}]*\}/gmu, '')
|
|
98
|
+
.replace(/^button:disabled\s*\{[^}]*\}/gmu, '')
|
|
99
|
+
.replace(/::-webkit-scrollbar/gu, '.app ::-webkit-scrollbar')
|
|
100
|
+
|
|
101
|
+
const bridge = `
|
|
102
|
+
/* ============================================================
|
|
103
|
+
唯一的一条 bridge:把设计稿 body 上的排版落到 .app
|
|
104
|
+
------------------------------------------------------------
|
|
105
|
+
设计稿在 body 上定字号、字体、颜色;插件跑在宿主的对话框里,不能改 body。
|
|
106
|
+
所以把同样的声明放在 .app 上。
|
|
107
|
+
|
|
108
|
+
除此之外不再有第二条针对 dsm-xdpool-* 的规则 —— 前面几轮那些
|
|
109
|
+
「.dsm-xdpool-frame { grid-template-columns: ... }」和设计稿的 .app
|
|
110
|
+
抢同一个属性,谁赢取决于加载顺序,改一次生效一次不生效一次,
|
|
111
|
+
排查了很久才发现是规则在互相盖。一套类名配一份 CSS,不留 bridge。
|
|
112
|
+
============================================================ */
|
|
113
|
+
|
|
114
|
+
.app {
|
|
115
|
+
/* body 的背景色也要带过来 —— 插件靠宿主给底色的话,浅色主题下会串色 */
|
|
116
|
+
background: var(--bg);
|
|
117
|
+
font-family: var(--sans);
|
|
118
|
+
font-size: var(--fs-sm);
|
|
119
|
+
line-height: 1.65;
|
|
120
|
+
color: var(--text);
|
|
121
|
+
-webkit-font-smoothing: antialiased;
|
|
122
|
+
text-rendering: optimizeLegibility;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/* ============================================================
|
|
126
|
+
插件独有:没有图标的渠道用自己的首字母
|
|
127
|
+
------------------------------------------------------------
|
|
128
|
+
设计稿的 .ch-logo 用 background-image 放厂商图标。但二十二家里有五家
|
|
129
|
+
在任何构建里都没有图标(CodeArts / LobsterAI / Loom / 豆包 …),
|
|
130
|
+
设计稿没画这种情况 —— 那五格会是一片空白。
|
|
131
|
+
|
|
132
|
+
所以这一条是插件自己加的:有图标时用图标,没有就用首字母,
|
|
133
|
+
尺寸和圆角与图标版一致,看起来是同一个控件而不是缺图。
|
|
134
|
+
============================================================ */
|
|
135
|
+
|
|
136
|
+
/* 字母版:把首字母居中画在同一个方块里,底色用渠道自己的 accent */
|
|
137
|
+
.ch-logo-letters{
|
|
138
|
+
display:grid;place-items:center;
|
|
139
|
+
font-size:var(--fs-xs);font-weight:800;letter-spacing:-.02em;
|
|
140
|
+
line-height:1;color:#fff;text-transform:uppercase;
|
|
141
|
+
background-color:var(--ch-logo-accent, var(--surface-3));
|
|
142
|
+
/* 厂商色多为浅亮(橙、绿),纯白字在上面只有 2.3:1。
|
|
143
|
+
加一层暗影把字压出来,不改品牌色。 */
|
|
144
|
+
text-shadow:0 1px 2px rgba(0,0,0,.55);
|
|
145
|
+
}
|
|
146
|
+
.ch-logo-letters::after{content:none}
|
|
147
|
+
/* 设计稿的 .ch-logo 用伪元素叠图形;字母版要把它关掉。 */
|
|
148
|
+
.ch-logo::after{content:none}
|
|
149
|
+
/* 有图标的渠道:图标铺满,覆盖字母版留下的底色。 */
|
|
150
|
+
/*
|
|
151
|
+
有图标的渠道:插件把图放在 --ch-logo-icon 里(data URI),
|
|
152
|
+
设计稿靠 background-image 上色 —— 这一条把它接起来。
|
|
153
|
+
|
|
154
|
+
之前这里只写了 size/repeat/position,没有 background-image,
|
|
155
|
+
于是所有有图标的渠道都画成一块空底色。
|
|
156
|
+
*/
|
|
157
|
+
.ch-logo-art{background-image:var(--ch-logo-icon, none);background-color:var(--ch-logo-accent, var(--surface-3));background-size:contain;background-repeat:no-repeat;background-position:center}
|
|
158
|
+
|
|
159
|
+
/* ============================================================
|
|
160
|
+
插件独有:加载骨架与折叠箭头
|
|
161
|
+
------------------------------------------------------------
|
|
162
|
+
设计稿是静态稿,没有画「数据还在路上」的样子。插件要真加载,
|
|
163
|
+
所以这两条自己补:骨架用一条低对比的横线占位,箭头是个小三角。
|
|
164
|
+
============================================================ */
|
|
165
|
+
|
|
166
|
+
.skel-line{height:10px;border-radius:4px;background:var(--surface-3);opacity:.5;animation:xd-pulse 1.4s ease-in-out infinite}
|
|
167
|
+
.skel-line:nth-child(2n){width:72%}
|
|
168
|
+
@keyframes xd-pulse{0%,100%{opacity:.35}50%{opacity:.6}}
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
/* 插件用 span/b 写字实行,设计稿用 dt/dd —— 给前者补上同样的排布 */
|
|
172
|
+
.fact > .td-name{flex:0 0 auto;min-width:60px;color:var(--faint)}
|
|
173
|
+
.fact > .td-num{flex:1 1 auto;min-width:0;color:var(--text);font-weight:400;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
174
|
+
.fact > .td-num[data-tone="quiet"]{color:var(--faint)}
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
/* ============================================================
|
|
178
|
+
按下反馈
|
|
179
|
+
------------------------------------------------------------
|
|
180
|
+
设计稿是静态稿,没有 :active。但真实界面里,按下去没有任何变化
|
|
181
|
+
会让人不确定「点到了没有」——尤其是慢操作(重新获取模型要几秒)。
|
|
182
|
+
这里只加一点点下沉,不动配色。
|
|
183
|
+
============================================================ */
|
|
184
|
+
.btn:active:not(:disabled),
|
|
185
|
+
.tiny:active:not(:disabled),
|
|
186
|
+
.rail-item:active { transform: translateY(1px) }
|
|
187
|
+
.sw:active:not(:disabled) { filter: brightness(.94) }
|
|
188
|
+
button:disabled { cursor: not-allowed }
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
/* ============================================================
|
|
192
|
+
渠道详情:单列铺满
|
|
193
|
+
------------------------------------------------------------
|
|
194
|
+
.accts 是账号卡的网格(auto-fill 248px),用在设计稿的详情页正合适 ——
|
|
195
|
+
六个账号排成三列两行。
|
|
196
|
+
|
|
197
|
+
但渠道详情只有一个「卡」,放进那个网格会只占一列 248px,右边空一大片。
|
|
198
|
+
这一层是单列容器:它里面只有一张卡,卡就该铺满。
|
|
199
|
+
============================================================ */
|
|
200
|
+
/* 渠道详情里只有一个 .card(后面跟着它自己的动作行),让卡铺满整行 */
|
|
201
|
+
.accts > .card:first-child { grid-column: 1 / -1 }
|
|
202
|
+
.accts > .sec-actions { grid-column: 1 / -1 }
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
/* ============================================================
|
|
206
|
+
开关里的真实 checkbox 要藏起来
|
|
207
|
+
------------------------------------------------------------
|
|
208
|
+
设计稿的 .sw 是一个按钮(40×24,用 ::after 画滑块)。
|
|
209
|
+
插件有三处把它套在 <label> 上,里面放真的 <input type="checkbox">,
|
|
210
|
+
为的是让键盘和读屏能操作。
|
|
211
|
+
|
|
212
|
+
于是浏览器的原生复选框就画在滑块旁边 —— 聚合页那个勾选框跑出
|
|
213
|
+
开关右边,就是这么来的。藏掉 input,滑块照旧由 .sw 的伪元素画。
|
|
214
|
+
============================================================ */
|
|
215
|
+
label.sw > input[type="checkbox"] {
|
|
216
|
+
position: absolute;
|
|
217
|
+
width: 1px; height: 1px;
|
|
218
|
+
opacity: 0;
|
|
219
|
+
pointer-events: none;
|
|
220
|
+
}
|
|
221
|
+
label.sw { cursor: pointer }
|
|
222
|
+
label.sw:has(input:checked)::after { transform: translateX(16px) }
|
|
223
|
+
label.sw:has(input:disabled) { opacity: .5; cursor: not-allowed }
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
/* 搜索框那一行:输入框 + 命中数提示 */
|
|
227
|
+
.search-wrap {
|
|
228
|
+
display: flex;
|
|
229
|
+
align-items: center;
|
|
230
|
+
gap: var(--s2);
|
|
231
|
+
margin: var(--s2) 0;
|
|
232
|
+
}
|
|
233
|
+
.search-wrap > .search { flex: 1 1 auto; min-width: 0 }
|
|
234
|
+
.search-wrap > .hint { flex: 0 0 auto; margin: 0 }
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
/* 窄屏侧栏(60px)里,版本号竖排会换行成两行 —— 藏掉,鼠标悬停时用 title 看 */
|
|
238
|
+
@media (max-width: 1180px) {
|
|
239
|
+
.rail-ver { display: none }
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
/*
|
|
244
|
+
按钮的 line-height 是 UA 给的 normal,不继承父级。
|
|
245
|
+
只给侧栏项补上 —— .btn / .search 各自定了字号,强行 inherit 会覆盖它们。
|
|
246
|
+
*/
|
|
247
|
+
.rail-item {
|
|
248
|
+
line-height: 1.65;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
/* ============================================================
|
|
253
|
+
元素选择器收进 .app
|
|
254
|
+
------------------------------------------------------------
|
|
255
|
+
设计稿的 button { cursor: pointer } / input { font-family: inherit }
|
|
256
|
+
在独立页面里是对的。注入到宿主页面后就变成「改宿主所有按钮」——
|
|
257
|
+
DSH 自己的按钮、输入框都会受影响。
|
|
258
|
+
|
|
259
|
+
这里把它们重新声明在 .app 作用域内,并把原来那几条全局的删掉。
|
|
260
|
+
(删在下面的 CLEANUP 里做,因为它要处理拼接后的整份 CSS。)
|
|
261
|
+
============================================================ */
|
|
262
|
+
.app button,
|
|
263
|
+
.app input,
|
|
264
|
+
.app select,
|
|
265
|
+
.app textarea {
|
|
266
|
+
font-family: inherit;
|
|
267
|
+
}
|
|
268
|
+
.app button { cursor: pointer }
|
|
269
|
+
.app button:disabled { cursor: not-allowed }
|
|
270
|
+
|
|
271
|
+
.strip-caret{width:0;height:0;border-left:4px solid transparent;border-right:4px solid transparent;border-top:5px solid var(--faint);transition:transform var(--t-base) var(--ease)}
|
|
272
|
+
.strip-caret[data-open="true"]{transform:rotate(180deg)}
|
|
273
|
+
`
|
|
274
|
+
|
|
275
|
+
/*
|
|
276
|
+
设计稿里有几处 10px 的小字(.badge 一类)。10px 在 1080p 上已经要凑近看,
|
|
277
|
+
这里统一提到 12px —— 做法是把生成结果里的 font-size:10px 换掉,
|
|
278
|
+
而不是改设计稿源文件:源文件要保持原样,便于以后重新提取时对照。
|
|
279
|
+
*/
|
|
280
|
+
const MIN_FONT_FIX = (css) => css.replace(/font-size:1[01]px/gu, 'font-size:12px')
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* mobile.css —— 窄屏重排规则(自带 @media)。
|
|
284
|
+
*/
|
|
285
|
+
const scopedMobile = MIN_FONT_FIX(mobile)
|
|
286
|
+
|
|
287
|
+
let out = `/**
|
|
288
|
+
* 设计稿样式,原样接管。
|
|
289
|
+
*
|
|
290
|
+
* 来源:xdpool-design 的 tokens.css / app.css / channel-colors.css / build-a.mjs。
|
|
291
|
+
* 改样式请改设计稿源文件,再跑 scripts/extract-design-css.mjs。
|
|
292
|
+
*/
|
|
293
|
+
export const DESIGN_TOKENS_CSS = \`${tokens.replace(/^\*\s*\{\s*box-sizing:\s*border-box;?\s*\}/mu, '.app, .app * { box-sizing: border-box }').replace(/html,\s*body\s*\{[^}]*\}/gu, '').replace(/^:root\s*\{/gmu, '.app {')}\n${colors.replace(/^:root\s*\{/gmu, '.app {')}\n${icons.replace(/^:root\s*\{/gmu, '.app {')}\`
|
|
294
|
+
|
|
295
|
+
export const DESIGN_DETAIL_CSS = \`${MIN_FONT_FIX(scoped)}\n${MIN_FONT_FIX(pageCss())}\n${scopedMobile}\n${bridge}\`
|
|
296
|
+
`
|
|
297
|
+
|
|
298
|
+
/*
|
|
299
|
+
最后一道清理:全局元素选择器。
|
|
300
|
+
|
|
301
|
+
`button { cursor: pointer }` 这类规则在设计稿里没问题,但注入到宿主页面后
|
|
302
|
+
会改掉 DSH 自己的每一个按钮。上面已经在 .app 作用域里重新声明过了,
|
|
303
|
+
所以这里把全局的那几条删掉。
|
|
304
|
+
|
|
305
|
+
放在最后而不是各个 replace 里:三处 :root 分别来自 tokens / colors / icons,
|
|
306
|
+
每个都有自己的处理链,漏一条就漏一条。统一在这里扫一遍。
|
|
307
|
+
*/
|
|
308
|
+
const globals = [
|
|
309
|
+
/^button,\s*input,\s*select\s*\{[^}]*\}\n?/gmu,
|
|
310
|
+
/^button\s*\{[^}]*\}\n?/gmu,
|
|
311
|
+
/^button:disabled\s*\{[^}]*\}\n?/gmu,
|
|
312
|
+
/^input\s*\{[^}]*\}\n?/gmu,
|
|
313
|
+
/^select\s*\{[^}]*\}\n?/gmu,
|
|
314
|
+
/^html\s*\{[^}]*\}\n?/gmu,
|
|
315
|
+
/^body\s*\{[^}]*\}\n?/gmu,
|
|
316
|
+
]
|
|
317
|
+
let cleaned = out
|
|
318
|
+
for (const re of globals) cleaned = cleaned.replace(re, '')
|
|
319
|
+
out = cleaned
|
|
320
|
+
|
|
321
|
+
writeFileSync('D:/dsh-home/_xdpool-src/src/client/design-css.ts', out, 'utf8')
|
|
322
|
+
console.log('生成 design-css.ts:', Math.round(out.length / 1024), 'KB')
|