@oipage/cli 0.3.0-alpha.5 → 1.0.0-alpha.0
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 +30 -1
- package/README.md +134 -62
- package/bin/WebSocket/index.js +1 -1
- package/bin/data/mineTypes.json +5 -1
- package/bin/help.js +8 -0
- package/bin/notebook/data.js +185 -0
- package/bin/notebook/index.js +163 -4
- package/bin/run +2 -2
- package/bin/serve.js +191 -54
- package/bin/tools/moduleForm.js +548 -0
- package/bin/tools/resolve404.js +2 -2
- package/bin/tools/resolveImport.js +248 -67
- package/bin/tools/resolvePackage.js +412 -0
- package/bin/website-plugins/intercept/index.js +0 -4
- package/docs/css/base.css +122 -0
- package/docs/css/components.css +180 -0
- package/docs/css/layout.css +295 -0
- package/docs/css/responsive.css +49 -0
- package/docs/images/file-list.webp +0 -0
- package/docs/images/logo-topbar.svg +5 -0
- package/docs/images/logo.png +0 -0
- package/docs/images/logo.svg +6 -0
- package/docs/images/manual.webp +0 -0
- package/docs/images/terminal-serve.webp +0 -0
- package/docs/index.html +1392 -0
- package/docs/js/copy.js +37 -0
- package/docs/js/nav.js +111 -0
- package/docs/js/search.js +241 -0
- package/docs/js/theme.js +17 -0
- package/package.json +1 -1
- package/src/index.js +0 -3
- package/bin/website-plugins/intercept/oipage-vislite-intercept.js +0 -56
- package/bin/website-plugins/intercept/oipage-zipaper-intercept.js +0 -37
- package/docs/config.md +0 -107
|
@@ -0,0 +1,412 @@
|
|
|
1
|
+
const { existsSync, readFileSync, statSync } = require("fs");
|
|
2
|
+
const { join, dirname, resolve, relative, sep, extname } = require("path");
|
|
3
|
+
const { getForm } = require("./moduleForm.js");
|
|
4
|
+
|
|
5
|
+
// 命令行工具自身根目录(本文件位于 bin/tools/ 下)
|
|
6
|
+
const cliRoot = resolve(__dirname, "../..");
|
|
7
|
+
|
|
8
|
+
// 补全候选
|
|
9
|
+
const EXTENSIONS = [".js", ".mjs", ".cjs", ".json"];
|
|
10
|
+
const INDEX_FILES = ["index.js", "index.mjs", "index.cjs", "index.json"];
|
|
11
|
+
|
|
12
|
+
// package.json 读取缓存:路径 -> { mtimeMs, size, value }
|
|
13
|
+
const packageCache = new Map();
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* 静态读取 package.json(不使用 require,避免长期缓存与 ESM 报错)
|
|
17
|
+
* @param {string} packageDir 包目录
|
|
18
|
+
* @returns {object|null} package.json 内容
|
|
19
|
+
*/
|
|
20
|
+
function readPackageJson(packageDir) {
|
|
21
|
+
const file = join(packageDir, "package.json");
|
|
22
|
+
const stat = statOf(file);
|
|
23
|
+
|
|
24
|
+
if (!stat || stat.isDirectory()) return null;
|
|
25
|
+
|
|
26
|
+
const cached = packageCache.get(file);
|
|
27
|
+
if (cached && cached.mtimeMs === stat.mtimeMs && cached.size === stat.size) return cached.value;
|
|
28
|
+
|
|
29
|
+
let value = null;
|
|
30
|
+
|
|
31
|
+
try {
|
|
32
|
+
value = JSON.parse(readFileSync(file, "utf8"));
|
|
33
|
+
} catch (e) {
|
|
34
|
+
// 解析失败的 package.json 不应该让整个服务器挂掉
|
|
35
|
+
console.log("\x1b[1m\x1b[33m[resolvePackage] invalid package.json: " + file + "\x1b[0m " + e.message);
|
|
36
|
+
value = null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
packageCache.set(file, { mtimeMs: stat.mtimeMs, size: stat.size, value });
|
|
40
|
+
return value;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* 向上查找离文件最近的 package.json
|
|
45
|
+
* @param {string} filePath 文件路径
|
|
46
|
+
* @returns {{dir: string, value: object}|null}
|
|
47
|
+
*/
|
|
48
|
+
function findPackageJson(filePath) {
|
|
49
|
+
let dir = dirname(filePath);
|
|
50
|
+
|
|
51
|
+
while (true) {
|
|
52
|
+
const file = join(dir, "package.json");
|
|
53
|
+
|
|
54
|
+
if (existsSync(file)) {
|
|
55
|
+
return { dir, value: readPackageJson(dir) };
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const parent = dirname(dir);
|
|
59
|
+
if (parent === dir) return null;
|
|
60
|
+
dir = parent;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function statOf(file) {
|
|
65
|
+
try {
|
|
66
|
+
return statSync(file);
|
|
67
|
+
} catch (e) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* 补全路径:扩展名、目录 index
|
|
74
|
+
* @param {string} candidate 候选路径
|
|
75
|
+
* @returns {string|null} 真实文件路径
|
|
76
|
+
*/
|
|
77
|
+
function completePath(candidate) {
|
|
78
|
+
const stat = statOf(candidate);
|
|
79
|
+
|
|
80
|
+
if (stat && stat.isFile()) return candidate;
|
|
81
|
+
|
|
82
|
+
if (stat && stat.isDirectory()) {
|
|
83
|
+
for (const name of INDEX_FILES) {
|
|
84
|
+
const file = join(candidate, name);
|
|
85
|
+
const subStat = statOf(file);
|
|
86
|
+
if (subStat && subStat.isFile()) return file;
|
|
87
|
+
}
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (!extname(candidate)) {
|
|
92
|
+
for (const ext of EXTENSIONS) {
|
|
93
|
+
const file = candidate + ext;
|
|
94
|
+
const subStat = statOf(file);
|
|
95
|
+
if (subStat && subStat.isFile()) return file;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* exports 字段是否属于“条件对象”(不含以 . 开头的子路径键)
|
|
104
|
+
*/
|
|
105
|
+
function isConditionalObject(value) {
|
|
106
|
+
const keys = Object.keys(value);
|
|
107
|
+
return keys.length > 0 && !keys.some(key => key.startsWith("."));
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* 把 exports 统一成 { 子路径: 目标 } 的形式
|
|
112
|
+
*/
|
|
113
|
+
function normalizeExportsMap(exportsField) {
|
|
114
|
+
if (typeof exportsField === "string" || Array.isArray(exportsField)) {
|
|
115
|
+
return { ".": exportsField };
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (exportsField && typeof exportsField === "object") {
|
|
119
|
+
const keys = Object.keys(exportsField);
|
|
120
|
+
if (keys.length === 0) return {};
|
|
121
|
+
if (!keys.some(key => key.startsWith("."))) return { ".": exportsField };
|
|
122
|
+
return exportsField;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return {};
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* 按条件优先级取出目标路径
|
|
130
|
+
* @param {*} target exports 里的某一项
|
|
131
|
+
* @param {Array<string>} conditions 条件优先级
|
|
132
|
+
* @param {string} packageDir 包目录
|
|
133
|
+
* @param {string|null} patternMatch 通配命中的片段
|
|
134
|
+
* @returns {string|null} 绝对路径
|
|
135
|
+
*/
|
|
136
|
+
function pickTarget(target, conditions, packageDir, patternMatch) {
|
|
137
|
+
if (typeof target === "string") {
|
|
138
|
+
let targetPath = target;
|
|
139
|
+
|
|
140
|
+
if (patternMatch !== null && patternMatch !== undefined) {
|
|
141
|
+
targetPath = targetPath.split("*").join(patternMatch);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// 只允许包内相对路径
|
|
145
|
+
if (!targetPath.startsWith("./")) return null;
|
|
146
|
+
|
|
147
|
+
return completePath(resolve(packageDir, targetPath));
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (Array.isArray(target)) {
|
|
151
|
+
for (const item of target) {
|
|
152
|
+
const result = pickTarget(item, conditions, packageDir, patternMatch);
|
|
153
|
+
if (result) return result;
|
|
154
|
+
}
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if (target && typeof target === "object") {
|
|
159
|
+
if (!isConditionalObject(target)) return null;
|
|
160
|
+
|
|
161
|
+
for (const key of Object.keys(target)) {
|
|
162
|
+
// types 永远不是运行时入口
|
|
163
|
+
if (key === "types" || key === "typings") continue;
|
|
164
|
+
|
|
165
|
+
if (key === "default" || conditions.includes(key)) {
|
|
166
|
+
const result = pickTarget(target[key], conditions, packageDir, patternMatch);
|
|
167
|
+
if (result) return result;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
return null;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* 解析 exports 里的子路径
|
|
179
|
+
* @param {object} exportsField exports 字段
|
|
180
|
+
* @param {string} subpath 子路径(不带前导 ./,空串代表入口)
|
|
181
|
+
* @param {Array<string>} conditions 条件优先级
|
|
182
|
+
* @param {string} packageDir 包目录
|
|
183
|
+
* @returns {string|null} 绝对路径
|
|
184
|
+
*/
|
|
185
|
+
function resolveExportsSubpath(exportsField, subpath, conditions, packageDir) {
|
|
186
|
+
const map = normalizeExportsMap(exportsField);
|
|
187
|
+
const key = subpath ? "./" + subpath : ".";
|
|
188
|
+
|
|
189
|
+
if (map[key] !== undefined) {
|
|
190
|
+
const result = pickTarget(map[key], conditions, packageDir, null);
|
|
191
|
+
if (result) return result;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// 通配匹配:取前缀最长的那个(对齐 Node 的规则)
|
|
195
|
+
let best = null;
|
|
196
|
+
|
|
197
|
+
for (const mapKey of Object.keys(map)) {
|
|
198
|
+
const starIndex = mapKey.indexOf("*");
|
|
199
|
+
if (starIndex < 0) continue;
|
|
200
|
+
|
|
201
|
+
const prefix = mapKey.slice(0, starIndex);
|
|
202
|
+
const suffix = mapKey.slice(starIndex + 1);
|
|
203
|
+
|
|
204
|
+
if (key.length < prefix.length + suffix.length) continue;
|
|
205
|
+
if (!key.startsWith(prefix) || !key.endsWith(suffix)) continue;
|
|
206
|
+
|
|
207
|
+
const match = key.slice(prefix.length, key.length - suffix.length);
|
|
208
|
+
|
|
209
|
+
if (!best || prefix.length > best.prefix.length) {
|
|
210
|
+
best = { prefix, suffix, match, value: map[mapKey] };
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
if (best) {
|
|
215
|
+
return pickTarget(best.value, conditions, packageDir, best.match);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
return null;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* 传统字段回退:browser -> module -> main -> index.js
|
|
223
|
+
*/
|
|
224
|
+
function resolveLegacy(pkg, packageDir, subpath) {
|
|
225
|
+
// 子路径的 browser 映射(browser 字段写成对象时)
|
|
226
|
+
if (subpath && pkg && pkg.browser && typeof pkg.browser === "object") {
|
|
227
|
+
const mapped = pkg.browser["./" + subpath] || pkg.browser[subpath];
|
|
228
|
+
if (typeof mapped === "string") {
|
|
229
|
+
const result = completePath(resolve(packageDir, mapped));
|
|
230
|
+
if (result) return result;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
const candidates = [];
|
|
235
|
+
|
|
236
|
+
if (typeof pkg.browser === "string") candidates.push(pkg.browser);
|
|
237
|
+
if (typeof pkg.module === "string") candidates.push(pkg.module);
|
|
238
|
+
if (typeof pkg.main === "string") candidates.push(pkg.main);
|
|
239
|
+
|
|
240
|
+
if (!subpath) candidates.push("index.js");
|
|
241
|
+
|
|
242
|
+
for (const candidate of candidates) {
|
|
243
|
+
const result = completePath(resolve(packageDir, candidate));
|
|
244
|
+
if (result) return result;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
// 子路径直接按物理路径找
|
|
248
|
+
if (subpath) {
|
|
249
|
+
const result = completePath(join(packageDir, subpath));
|
|
250
|
+
if (result) return result;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
return null;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* 拆分包名与子路径
|
|
258
|
+
* @param {string} specifier 包说明符
|
|
259
|
+
*/
|
|
260
|
+
function splitSpecifier(specifier) {
|
|
261
|
+
const segments = specifier.split("/");
|
|
262
|
+
|
|
263
|
+
if (specifier.startsWith("@")) {
|
|
264
|
+
if (segments.length < 2) return null;
|
|
265
|
+
return {
|
|
266
|
+
name: segments.slice(0, 2).join("/"),
|
|
267
|
+
subpath: segments.slice(2).join("/")
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
return {
|
|
272
|
+
name: segments[0],
|
|
273
|
+
subpath: segments.slice(1).join("/")
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* 构造搜索根目录:命令行工程 -> 当前目录 -> 命令行工具自身
|
|
279
|
+
* preferCli 为 true 时把命令行工具自身放到最前(内置网站固定用自带依赖)
|
|
280
|
+
* @param {string} basePath 服务器根目录
|
|
281
|
+
* @param {boolean} preferCli 是否优先使用命令行工具自带的依赖
|
|
282
|
+
*/
|
|
283
|
+
function makeRoots(basePath, preferCli) {
|
|
284
|
+
const roots = [];
|
|
285
|
+
const seen = new Set();
|
|
286
|
+
|
|
287
|
+
const push = (projectDir, urlMode) => {
|
|
288
|
+
const nodeModules = join(projectDir, "node_modules");
|
|
289
|
+
if (seen.has(nodeModules)) return;
|
|
290
|
+
seen.add(nodeModules);
|
|
291
|
+
roots.push({ dir: nodeModules, urlMode });
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
if (preferCli) push(cliRoot, "modules");
|
|
295
|
+
|
|
296
|
+
push(basePath, "base");
|
|
297
|
+
push(process.cwd(), "modules");
|
|
298
|
+
|
|
299
|
+
if (!preferCli) push(cliRoot, "modules");
|
|
300
|
+
|
|
301
|
+
return roots;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* 把文件路径映射回浏览器 URL
|
|
306
|
+
* @param {string} filePath 文件路径
|
|
307
|
+
* @param {string} basePath 服务器根目录
|
|
308
|
+
* @returns {string|null} URL
|
|
309
|
+
*/
|
|
310
|
+
function urlOf(filePath, basePath) {
|
|
311
|
+
const cliNodeModules = join(cliRoot, "node_modules");
|
|
312
|
+
const cwdNodeModules = join(process.cwd(), "node_modules");
|
|
313
|
+
|
|
314
|
+
const toUrl = (root, prefix) => prefix + relative(root, filePath).split(sep).join("/");
|
|
315
|
+
|
|
316
|
+
if (filePath.startsWith(cliNodeModules + sep)) return toUrl(cliNodeModules, "/@modules/");
|
|
317
|
+
if (filePath.startsWith(basePath + sep)) return toUrl(basePath, "/");
|
|
318
|
+
if (filePath.startsWith(cwdNodeModules + sep)) return toUrl(cwdNodeModules, "/@modules/");
|
|
319
|
+
|
|
320
|
+
return null;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* 解析一个裸包说明符
|
|
325
|
+
* @param {string} specifier 说明符,如 @auipage/core 或 vislite
|
|
326
|
+
* @param {object} options 选项
|
|
327
|
+
* @param {string} options.basePath 服务器根目录
|
|
328
|
+
* @param {Array<string>} options.conditions 条件优先级
|
|
329
|
+
* @param {boolean} options.preferCli 是否优先使用命令行工具自带的依赖
|
|
330
|
+
* @returns {{filePath: string, url: string, form: string, via: string, packageDir: string, fromCli: boolean}|null}
|
|
331
|
+
*/
|
|
332
|
+
function resolveSpecifier(specifier, options) {
|
|
333
|
+
const parsed = splitSpecifier(specifier);
|
|
334
|
+
if (!parsed) return null;
|
|
335
|
+
|
|
336
|
+
const { name, subpath } = parsed;
|
|
337
|
+
const basePath = options.basePath;
|
|
338
|
+
const conditions = options.conditions || ["browser", "import", "default"];
|
|
339
|
+
const cliNodeModules = join(cliRoot, "node_modules");
|
|
340
|
+
|
|
341
|
+
for (const root of makeRoots(basePath, options.preferCli)) {
|
|
342
|
+
const packageDir = join(root.dir, name);
|
|
343
|
+
const stat = statOf(packageDir);
|
|
344
|
+
|
|
345
|
+
if (!stat || !stat.isDirectory()) continue;
|
|
346
|
+
|
|
347
|
+
const pkg = readPackageJson(packageDir);
|
|
348
|
+
let filePath = null;
|
|
349
|
+
let via = "";
|
|
350
|
+
|
|
351
|
+
if (pkg && pkg.exports) {
|
|
352
|
+
const exportsResult = resolveExportsSubpath(pkg.exports, subpath, conditions, packageDir);
|
|
353
|
+
if (exportsResult) {
|
|
354
|
+
filePath = exportsResult;
|
|
355
|
+
via = "exports";
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
// exports 没命中时退回物理路径(保留历史行为,方便深链导入)
|
|
360
|
+
if (!filePath) {
|
|
361
|
+
const legacyResult = resolveLegacy(pkg || {}, packageDir, subpath);
|
|
362
|
+
if (legacyResult) {
|
|
363
|
+
filePath = legacyResult;
|
|
364
|
+
via = pkg && pkg.exports ? "path" : "legacy";
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
if (!filePath) continue;
|
|
369
|
+
|
|
370
|
+
const url = urlOf(filePath, basePath);
|
|
371
|
+
|
|
372
|
+
return {
|
|
373
|
+
filePath,
|
|
374
|
+
url,
|
|
375
|
+
form: getForm(filePath, pkg),
|
|
376
|
+
via,
|
|
377
|
+
packageDir,
|
|
378
|
+
// 是否取自命令行工具自带的依赖,决定 URL 上要不要带 oipage=cli 标记
|
|
379
|
+
fromCli: filePath.startsWith(cliNodeModules + sep)
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
return null;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* 生成可读的解析失败说明(写进 500 响应/终端日志)
|
|
388
|
+
*/
|
|
389
|
+
function explain(specifier, options) {
|
|
390
|
+
const parsed = splitSpecifier(specifier);
|
|
391
|
+
if (!parsed) return "invalid specifier: " + specifier;
|
|
392
|
+
|
|
393
|
+
const tried = [];
|
|
394
|
+
|
|
395
|
+
for (const root of makeRoots(options.basePath || process.cwd(), options.preferCli)) {
|
|
396
|
+
const packageDir = join(root.dir, parsed.name);
|
|
397
|
+
if (!existsSync(packageDir)) { tried.push(packageDir + " (missing)"); continue; }
|
|
398
|
+
|
|
399
|
+
const pkg = readPackageJson(packageDir);
|
|
400
|
+
tried.push(packageDir + " (exports:" + (pkg && pkg.exports ? "yes" : "no") + ", main:" + (pkg && pkg.main ? pkg.main : "-") + ")");
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
return "cannot resolve \"" + specifier + "\", tried: " + tried.join("; ");
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
module.exports = {
|
|
407
|
+
resolveSpecifier,
|
|
408
|
+
readPackageJson,
|
|
409
|
+
findPackageJson,
|
|
410
|
+
explain,
|
|
411
|
+
completePath
|
|
412
|
+
};
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
const OIPageZipaperIntercept = require("./oipage-zipaper-intercept.js");
|
|
2
|
-
const OIPageVISLiteIntercept = require("./oipage-vislite-intercept.js");
|
|
3
1
|
const ChartIntercept = require("./chart.js");
|
|
4
2
|
|
|
5
3
|
module.exports = [
|
|
6
|
-
OIPageZipaperIntercept,
|
|
7
|
-
OIPageVISLiteIntercept,
|
|
8
4
|
ChartIntercept
|
|
9
5
|
];
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/* ============================================================
|
|
2
|
+
@oipage/cli 参考手册 —— 文档站版式(对齐 webpack 文档站观感)
|
|
3
|
+
|
|
4
|
+
base 层:reset / 颜色与尺寸变量 / 双主题 / 字体与基础排版。
|
|
5
|
+
亮色为默认主题,深色作为可切换的备选;代码块配色跟随主题。
|
|
6
|
+
后续文件按 base → layout → components → responsive 依次引入。
|
|
7
|
+
============================================================ */
|
|
8
|
+
*, *::before, *::after { box-sizing: border-box; }
|
|
9
|
+
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
|
|
10
|
+
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
|
|
11
|
+
|
|
12
|
+
:root {
|
|
13
|
+
/* 亮色:默认 */
|
|
14
|
+
--bg: #ffffff;
|
|
15
|
+
--page: #f4f6f8;
|
|
16
|
+
--panel: #ffffff;
|
|
17
|
+
--line: #e4eaef;
|
|
18
|
+
--line-strong: #d3dce4;
|
|
19
|
+
--rule: #e9eef2;
|
|
20
|
+
--surface: #f7f9fb;
|
|
21
|
+
--surface-2: #f2f6f9;
|
|
22
|
+
--surface-3: #edf1f5;
|
|
23
|
+
--hover: #f6f9fb;
|
|
24
|
+
--text: #1d2b36;
|
|
25
|
+
--text-dim: #46596a;
|
|
26
|
+
--muted: #6d8292;
|
|
27
|
+
--faint: #8ea1af;
|
|
28
|
+
--ink: #10202b;
|
|
29
|
+
--accent: #1a6fd4;
|
|
30
|
+
--accent-soft: #eaf2fd;
|
|
31
|
+
--accent-wash: #eff6fd;
|
|
32
|
+
--accent-line: #b9d6f6;
|
|
33
|
+
--violet: #6a4ecb;
|
|
34
|
+
--warn: #a15c00;
|
|
35
|
+
--warn-wash: #fdf6e9;
|
|
36
|
+
|
|
37
|
+
/* 顶栏(深色石板,两种主题一致) */
|
|
38
|
+
--topbar: #2f3d45;
|
|
39
|
+
--topbar-2: #26333a;
|
|
40
|
+
--topbar-text: #eef3f6;
|
|
41
|
+
--topbar-dim: #b3c1c9;
|
|
42
|
+
--topbar-line: rgba(255, 255, 255, .16);
|
|
43
|
+
|
|
44
|
+
/* 代码块:亮色主题下是浅底深字 */
|
|
45
|
+
--code-bg: #f6f8fa;
|
|
46
|
+
--code-head: #eef2f6;
|
|
47
|
+
--code-border: #e1e7ee;
|
|
48
|
+
--code-text: #24292f;
|
|
49
|
+
--code-comment: #74808c;
|
|
50
|
+
--code-key: #0550ae;
|
|
51
|
+
--code-str: #0a3069;
|
|
52
|
+
--code-num: #953800;
|
|
53
|
+
|
|
54
|
+
--sidebar: 272px;
|
|
55
|
+
--topbar-h: 62px;
|
|
56
|
+
--tabs-h: 46px;
|
|
57
|
+
--measure: 46em;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
html[data-theme="dark"] {
|
|
61
|
+
--bg: #0f1418;
|
|
62
|
+
--page: #0b0f13;
|
|
63
|
+
--panel: #0f1418;
|
|
64
|
+
--line: rgba(255, 255, 255, .10);
|
|
65
|
+
--line-strong: rgba(255, 255, 255, .18);
|
|
66
|
+
--rule: rgba(255, 255, 255, .13);
|
|
67
|
+
--surface: rgba(255, 255, 255, .025);
|
|
68
|
+
--surface-2: rgba(255, 255, 255, .045);
|
|
69
|
+
--surface-3: rgba(255, 255, 255, .07);
|
|
70
|
+
--hover: rgba(255, 255, 255, .022);
|
|
71
|
+
--text: #dde3ec;
|
|
72
|
+
--text-dim: #a7b1c2;
|
|
73
|
+
--muted: #7d8899;
|
|
74
|
+
--faint: #5f6b7d;
|
|
75
|
+
--ink: #f2f6fb;
|
|
76
|
+
--accent: #5aa9ff;
|
|
77
|
+
--accent-soft: rgba(90, 169, 255, .12);
|
|
78
|
+
--accent-wash: rgba(90, 169, 255, .06);
|
|
79
|
+
--accent-line: rgba(90, 169, 255, .38);
|
|
80
|
+
--violet: #9b86ff;
|
|
81
|
+
--warn: #ffb64d;
|
|
82
|
+
--warn-wash: rgba(255, 182, 77, .06);
|
|
83
|
+
|
|
84
|
+
--code-bg: #0f1319;
|
|
85
|
+
--code-head: #131922;
|
|
86
|
+
--code-border: rgba(255, 255, 255, .10);
|
|
87
|
+
--code-text: #cdd6e3;
|
|
88
|
+
--code-comment: #7b8698;
|
|
89
|
+
--code-key: #6cb2ff;
|
|
90
|
+
--code-str: #a895ff;
|
|
91
|
+
--code-num: #ffb64d;
|
|
92
|
+
color-scheme: dark;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
html[data-theme="light"] { color-scheme: light; }
|
|
96
|
+
|
|
97
|
+
body {
|
|
98
|
+
margin: 0;
|
|
99
|
+
background: var(--bg);
|
|
100
|
+
color: var(--text);
|
|
101
|
+
font-family: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", -apple-system, "Segoe UI", sans-serif;
|
|
102
|
+
font-size: 17px;
|
|
103
|
+
line-height: 1.9;
|
|
104
|
+
-webkit-font-smoothing: antialiased;
|
|
105
|
+
text-rendering: optimizeLegibility;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
a { color: var(--accent); }
|
|
109
|
+
|
|
110
|
+
/* 老版背景层已不再需要,保留元素但不绘制,避免页面出现多余纹理 */
|
|
111
|
+
.backdrop { display: none; }
|
|
112
|
+
|
|
113
|
+
/* ---------- 通用等宽字体 ---------- */
|
|
114
|
+
.mono,
|
|
115
|
+
code,
|
|
116
|
+
.code pre,
|
|
117
|
+
.chip,
|
|
118
|
+
.facts .v,
|
|
119
|
+
.field .sig,
|
|
120
|
+
.search input {
|
|
121
|
+
font-family: "SFMono-Regular", Menlo, Consolas, "Courier New", monospace;
|
|
122
|
+
}
|