dsh-gufa-code 1.3.133 → 1.3.173

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/host/lint.js CHANGED
@@ -6,9 +6,12 @@
6
6
  * importScripts 自定义协议资源会失败,导致语法/语义诊断时有时无;Host 侧
7
7
  * 编译结果稳定,且可以随插件依赖(typescript)一起分发。
8
8
  */
9
+ import { existsSync, readFileSync, statSync } from 'node:fs'
9
10
  import { readFile } from 'node:fs/promises'
10
- import { dirname, isAbsolute, relative, resolve, sep } from 'node:path'
11
+ import { createRequire } from 'node:module'
12
+ import { dirname, isAbsolute, join, relative, resolve, sep } from 'node:path'
11
13
 
14
+ import { ESLint } from 'eslint'
12
15
  import ts from 'typescript'
13
16
 
14
17
  import { ApiError, badRequest } from './context.js'
@@ -60,7 +63,7 @@ function severityOf(category) {
60
63
  return 2
61
64
  }
62
65
 
63
- export async function diagnose(body, env) {
66
+ async function diagnoseWithTsc(body, env) {
64
67
  if (typeof body.root !== 'string' || body.root === '') throw badRequest('root is required')
65
68
  const project = env.projects.ensure(body.root)
66
69
  const root = project.root
@@ -196,6 +199,153 @@ export async function diagnose(body, env) {
196
199
  return { diagnostics }
197
200
  }
198
201
 
202
+ const FLAT_CONFIG_FILES = ['eslint.config.js', 'eslint.config.cjs', 'eslint.config.mjs']
203
+ const LEGACY_CONFIG_FILES = ['.eslintrc', '.eslintrc.js', '.eslintrc.cjs', '.eslintrc.json', '.eslintrc.yml', '.eslintrc.yaml']
204
+ const eslintCache = new Map()
205
+
206
+ function configSignature(root) {
207
+ const parts = []
208
+ for (const name of [...FLAT_CONFIG_FILES, ...LEGACY_CONFIG_FILES, 'package.json']) {
209
+ const file = join(root, name)
210
+ try {
211
+ parts.push(`${name}:${statSync(file).mtimeMs}`)
212
+ } catch {
213
+ /* ignore */
214
+ }
215
+ }
216
+ return parts.join('|')
217
+ }
218
+
219
+ function hasLegacyRegexConfig(root) {
220
+ for (const name of LEGACY_CONFIG_FILES) {
221
+ if (existsSync(join(root, name))) return true
222
+ }
223
+ try {
224
+ const pkg = JSON.parse(readFileSync(join(root, 'package.json'), 'utf8'))
225
+ return pkg !== null && typeof pkg === 'object' && pkg.eslintConfig !== undefined
226
+ } catch {
227
+ return false
228
+ }
229
+ }
230
+
231
+ function fallbackEslintConfig() {
232
+ return {
233
+ env: { browser: true, node: true, es2022: true },
234
+ parserOptions: { ecmaVersion: 'latest', sourceType: 'module', ecmaFeatures: { jsx: true } },
235
+ rules: {
236
+ 'no-undef': 'error',
237
+ 'no-unused-vars': 'off',
238
+ },
239
+ }
240
+ }
241
+
242
+ /** 优先用项目自己的 eslint(支持 eslint.config.js / 自定义规则),否则用插件内置 ESLint。 */
243
+ async function getEslint(root) {
244
+ const signature = configSignature(root)
245
+ const cached = eslintCache.get(root)
246
+ if (cached !== undefined && cached.signature === signature) return cached.instance
247
+ let instance = null
248
+ const flatConfig = FLAT_CONFIG_FILES.find((name) => existsSync(join(root, name)))
249
+ if (flatConfig !== undefined) {
250
+ try {
251
+ const projectRequire = createRequire(join(root, 'package.json'))
252
+ const projectModule = projectRequire('eslint')
253
+ const ProjectESLint = projectModule?.ESLint
254
+ if (typeof ProjectESLint === 'function') {
255
+ instance = new ProjectESLint({ cwd: root, errorOnUnmatchedPattern: false })
256
+ }
257
+ } catch {
258
+ instance = null
259
+ }
260
+ }
261
+ if (instance === null) {
262
+ try {
263
+ const legacy = hasLegacyRegexConfig(root) || flatConfig !== undefined
264
+ instance = new ESLint({
265
+ cwd: root,
266
+ useEslintrc: true,
267
+ errorOnUnmatchedPattern: false,
268
+ resolvePluginsRelativeTo: root,
269
+ ...(legacy ? {} : { overrideConfig: fallbackEslintConfig() }),
270
+ })
271
+ } catch {
272
+ instance = null
273
+ }
274
+ }
275
+ eslintCache.set(root, { signature, instance })
276
+ return instance
277
+ }
278
+
279
+ async function eslintDiagnostics(root, absolute, content) {
280
+ const eslint = await getEslint(root)
281
+ if (eslint === null || eslint === undefined) return null
282
+ let results = []
283
+ try {
284
+ results = await eslint.lintText(content, { filePath: absolute, warnIgnored: false })
285
+ } catch {
286
+ return null
287
+ }
288
+ const result = Array.isArray(results) ? results[0] : null
289
+ if (result === null || result === undefined) return []
290
+ const diagnostics = []
291
+ const seen = new Set()
292
+ for (const message of Array.isArray(result.messages) ? result.messages : []) {
293
+ if (message === null || typeof message !== 'object') continue
294
+ if (Number(message.severity) < 1) continue
295
+ const ruleId = typeof message.ruleId === 'string' && message.ruleId !== '' ? message.ruleId : (message.fatal === true ? 'parsing-error' : 'eslint')
296
+ const line = Math.max(1, Math.trunc(Number(message.line) || 1))
297
+ const column = Math.max(1, Math.trunc(Number(message.column) || 1))
298
+ const endLine = Math.max(line, Math.trunc(Number(message.endLine) || line))
299
+ const endColumn = Math.max(column + 1, Math.trunc(Number(message.endColumn) || (column + 1)))
300
+ const text = String(message.message ?? '')
301
+ const key = `${ruleId}:${line}:${column}:${text}`
302
+ if (seen.has(key)) continue
303
+ seen.add(key)
304
+ diagnostics.push({
305
+ severity: Number(message.severity) === 2 ? 1 : 0,
306
+ message: text,
307
+ code: ruleId,
308
+ line,
309
+ column,
310
+ endLine,
311
+ endColumn,
312
+ })
313
+ if (diagnostics.length >= 200) break
314
+ }
315
+ return diagnostics
316
+ }
317
+
318
+ export async function diagnose(body, env) {
319
+ if (typeof body.root !== 'string' || body.root === '') throw badRequest('root is required')
320
+ const project = env.projects.ensure(body.root)
321
+ const root = project.root
322
+ const rawPath = typeof body.path === 'string' ? body.path : ''
323
+ if (rawPath === '') throw badRequest('path is required')
324
+ const absolute = resolve(root, rawPath)
325
+ if (!inside(root, absolute)) throw new ApiError('path-outside', '路径超出项目范围', 403)
326
+ const extension = rawPath.split('.').pop()?.toLowerCase() ?? ''
327
+ if (!['js', 'jsx', 'mjs', 'cjs', 'ts', 'tsx', 'mts', 'cts'].includes(extension)) return { diagnostics: [] }
328
+ let content = typeof body.content === 'string' ? body.content : ''
329
+ if (content === '') {
330
+ try {
331
+ content = await readFile(absolute, 'utf8')
332
+ } catch {
333
+ throw new ApiError('not-found', `文件不存在:${rawPath}`, 404)
334
+ }
335
+ }
336
+ /* JS/JSX 用 ESLint(尊重项目 .eslintrc / eslint.config.js 的 globals、rules、插件);
337
+ TS/TSX 仍用 TypeScript 编译器(ESLint 默认 parser 不解析 TS 语法)。 */
338
+ if (['js', 'jsx', 'mjs', 'cjs'].includes(extension)) {
339
+ try {
340
+ const diagnostics = await eslintDiagnostics(root, absolute, content)
341
+ if (diagnostics !== null) return { diagnostics }
342
+ } catch {
343
+ /* 配置/插件加载失败时回落 tsc,避免完全没诊断 */
344
+ }
345
+ }
346
+ return diagnoseWithTsc(body, env)
347
+ }
348
+
199
349
  export function registerLint(router, env) {
200
350
  router.method('lint.javascript', (body) => diagnose(body, env))
201
351
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-gufa-code",
3
- "version": "1.3.133",
3
+ "version": "1.3.173",
4
4
  "description": "古法编程 · AI 辅助:一键把 DSH 主面板变成 VS Code 风格 IDE(Monaco 编辑器、文件树、Git、SSH、真实终端 + 右侧官方会话);主张亲手写、每个改动心中有数,AI 是助理、你是第一责任人",
5
5
  "icon": "icon.svg",
6
6
  "keywords": [
@@ -40,6 +40,7 @@
40
40
  "desktop"
41
41
  ],
42
42
  "dependencies": {
43
+ "eslint": "^8.57.1",
43
44
  "pyright": "^1.1.414",
44
45
  "typescript": "^5.9.3",
45
46
  "ws": "^8.22.0"
@@ -133,6 +133,11 @@ try {
133
133
  const missingMtimes = await call(router, 'fs.mtimes', { root, paths: [] })
134
134
  check('fs.mtimes handles empty list', missingMtimes.files !== null && typeof missingMtimes.files === 'object' && Object.keys(missingMtimes.files).length === 0)
135
135
 
136
+ const resolvedPath = await call(router, 'code.resolvePath', { root, path: 'main.ts' })
137
+ check('code.resolvePath resolves basename', resolvedPath.path === 'src/main.ts', JSON.stringify(resolvedPath))
138
+ const resolvedMissing = await call(router, 'code.resolvePath', { root, path: 'not-exist-file.ts' })
139
+ check('code.resolvePath returns null for missing', resolvedMissing.path === null, JSON.stringify(resolvedMissing))
140
+
136
141
  console.log('lint.javascript')
137
142
  await call(router, 'fs.create', { root, path: 'src/lint-sample.js', kind: 'file' })
138
143
  const lintResult = await call(router, 'lint.javascript', {
@@ -141,14 +146,14 @@ try {
141
146
  language: 'javascript',
142
147
  content: 'const lintValue = undefinedVariable\n',
143
148
  })
144
- check('lint reports undefined variable', lintResult.diagnostics.some((item) => item.code === 2304 && item.line === 1), JSON.stringify(lintResult.diagnostics))
149
+ check('lint reports undefined variable', lintResult.diagnostics.some((item) => item.code === 'no-undef' && item.line === 1 && String(item.message).includes('not defined')), JSON.stringify(lintResult.diagnostics))
145
150
  const lintSyntax = await call(router, 'lint.javascript', {
146
151
  root,
147
152
  path: 'src/lint-sample.js',
148
153
  language: 'javascript',
149
154
  content: 'const = 1\n',
150
155
  })
151
- check('lint reports syntax error', lintSyntax.diagnostics.some((item) => item.severity === 1 && item.code === 1134), JSON.stringify(lintSyntax.diagnostics))
156
+ check('lint reports syntax error', lintSyntax.diagnostics.some((item) => item.severity === 1 && item.code === 'parsing-error'), JSON.stringify(lintSyntax.diagnostics))
152
157
  const lintNoisy = await call(router, 'lint.javascript', {
153
158
  root,
154
159
  path: 'src/lint-sample.js',
@@ -156,6 +161,16 @@ try {
156
161
  content: 'const someObject = {}\nsomeObject.missingProperty\n',
157
162
  })
158
163
  check('lint suppresses dynamic property warnings', lintNoisy.diagnostics.length === 0, JSON.stringify(lintNoisy.diagnostics))
164
+ await call(router, 'fs.create', { root, path: '.eslintrc.json', kind: 'file' })
165
+ await call(router, 'fs.write', { root, path: '.eslintrc.json', content: JSON.stringify({ globals: { zzConfiguredGlobal: 'readonly' } }) })
166
+ const lintConfigured = await call(router, 'lint.javascript', {
167
+ root,
168
+ path: 'src/lint-sample.js',
169
+ language: 'javascript',
170
+ content: 'zzConfiguredGlobal\n',
171
+ })
172
+ check('lint respects project eslint globals', lintConfigured.diagnostics.length === 0, JSON.stringify(lintConfigured.diagnostics))
173
+ await call(router, 'fs.delete', { root, path: '.eslintrc.json' }).catch(() => {})
159
174
  await call(router, 'fs.delete', { root, path: 'src/lint-sample.js' }).catch(() => {})
160
175
 
161
176
  console.log('code.tsDefinition')
@@ -268,12 +268,12 @@ test('主题映射 dark→vs-dark / light→vs', () => {
268
268
  assert.equal(monacoTheme(undefined), 'vs')
269
269
  })
270
270
 
271
- test('编辑器选项:automaticLayout 开、minimap/overview ruler 关', () => {
271
+ test('编辑器选项:automaticLayout 开、minimap 关、ruler 开(查找标记)', () => {
272
272
  const options = G.EditorPane.internals.editorOptions('dark')
273
273
  assert.equal(options.automaticLayout, true)
274
274
  assert.equal(options.minimap.enabled, false)
275
- assert.equal(options.overviewRulerLanes, 0)
276
- assert.equal(options.renderOverviewRuler, false)
275
+ assert.equal(options.overviewRulerLanes, 1)
276
+ assert.equal(options.renderOverviewRuler, true)
277
277
  assert.equal(options.theme, 'vs-dark')
278
278
  assert.equal(G.EditorPane.internals.editorOptions('light').theme, 'vs')
279
279
  })
@@ -1153,6 +1153,7 @@ G.errorText = (error) => {
1153
1153
  G.CSS = `
1154
1154
  .gufa-overlay-root{position:fixed;inset:0;z-index:1;display:flex;box-sizing:border-box;background:var(--gufa-solid-bg, var(--dsw-alias-bg-base));pointer-events:auto;overflow:hidden}
1155
1155
  .gufa-backdrop{position:absolute;inset:0;z-index:0;overflow:hidden;pointer-events:none}
1156
+
1156
1157
  /* 桌面悬浮层(摸鱼)模式:整窗半透明,透明度由 --gufa-float-alpha 控制(标题栏滑块) */
1157
1158
  html[data-gufa-float]{--gufa-float-alpha:0.55}
1158
1159
  html[data-gufa-float] body{background:transparent!important;color-scheme:dark;
@@ -1293,7 +1294,17 @@ html[data-gufa-float] #root [data-gufa-dock],
1293
1294
  html[data-gufa-float] #root .gufa-overlay-root *,
1294
1295
  html[data-gufa-float] #root [data-gufa-dock] *{visibility:visible!important}
1295
1296
  /* 桌宠提到覆盖层之上:同时兼容 @linxin666/dsh-pet(data-dsh-pet-root)与官方 dsh-pet(.dsh-pet-root) */
1297
+ /* 古法覆盖层打开时,DSH 右侧栏被覆盖却仍参与 layout/paint;
1298
+ myrta 这类会话会给右侧栏渲染 7000+ 节点,导致编辑器滚动每帧 style/layout 50ms。 */
1299
+ html[data-gufa-ide] [class*="rightbarCol"],
1300
+ html[data-gufa-float] [class*="rightbarCol"]{display:none!important}
1301
+
1296
1302
  html[data-gufa-ide] .dsh-pet-root{z-index:2147483050!important}
1303
+ /* 聊天栏收起时,把覆盖层下面的官方会话(可能几千个 DOM 节点)真正隐藏,
1304
+ 避免编辑器滚动时整页 layout/paint 把它一起算进去。 */
1305
+ /* 古法/摸鱼模式下皮肤自身的粒子 canvas 不参与绘制(防止 WebGL/rAF 在覆盖层下面持续跑) */
1306
+ html[data-gufa-ide] .liang-ambient,
1307
+ html[data-gufa-float] .liang-ambient{display:none!important}
1297
1308
  /* 外部弹窗(DSH 设置等)打开时:停靠会话、古法 portal、桌宠全部降到官方弹窗之下 */
1298
1309
  html[data-gufa-external-modal] [data-gufa-dock]{z-index:2!important}
1299
1310
  html[data-gufa-external-modal] #gufa-portal-root{z-index:1!important}
@@ -130,6 +130,9 @@
130
130
  'editorLink.activeForeground': gufaHex(accent),
131
131
  'editorInfo.foreground': gufaHex(accent),
132
132
  'editorOverviewRuler.border': '#00000000',
133
+ 'editorOverviewRuler.findMatchForeground': dark ? '#d7ba7d' : '#b58900',
134
+ 'editorOverviewRuler.errorForeground': '#f14c4c',
135
+ 'editorOverviewRuler.warningForeground': '#cca700',
133
136
  'scrollbarSlider.background': gufaHexAlpha(fg, 0.16),
134
137
  'scrollbarSlider.hoverBackground': gufaHexAlpha(fg, 0.26),
135
138
  'scrollbarSlider.activeBackground': gufaHexAlpha(fg, 0.34),
@@ -541,7 +544,7 @@ function gufaRegisterDefinitionInfrastructure(monaco) {
541
544
  }
542
545
 
543
546
  /* 诊断波浪线已关闭(用户要求);Host lint 也不再在每次输入后跑 tsc,省 CPU */
544
- const GUFA_LINT_ENABLED = false
547
+ const GUFA_LINT_ENABLED = true
545
548
 
546
549
  /* ── model / URI ────────────────────────────────────────────────────── */
547
550
 
@@ -594,19 +597,82 @@ const GUFA_LINT_ENABLED = false
594
597
  return model
595
598
  }
596
599
 
600
+ /**
601
+ * 查找框可见时才打开 overview ruler(查找匹配标记),关闭时收起。
602
+ * 常开 ruler 会在每次滚动时额外渲染诊断/查找标记,体感卡。
603
+ */
604
+ function gufaInstallFindRuler(instance) {
605
+ try {
606
+ const dom = typeof instance.getDomNode === 'function' ? instance.getDomNode() : null
607
+ if (dom === null || dom === undefined) return null
608
+ let frame = 0
609
+ const apply = () => {
610
+ frame = 0
611
+ let visible = false
612
+ try {
613
+ const widget = dom.querySelector('.find-widget')
614
+ visible = widget !== null && widget !== undefined && widget.classList.contains('visible')
615
+ } catch {
616
+ visible = false
617
+ }
618
+ try {
619
+ instance.updateOptions({ renderOverviewRuler: visible, overviewRulerLanes: visible ? 1 : 0 })
620
+ } catch {
621
+ /* ignore */
622
+ }
623
+ }
624
+ const schedule = () => {
625
+ if (frame !== 0) return
626
+ frame = typeof requestAnimationFrame === 'function' ? requestAnimationFrame(apply) : window.setTimeout(apply, 16)
627
+ }
628
+ const observer = typeof MutationObserver === 'function' ? new MutationObserver((records) => {
629
+ for (const record of records) {
630
+ if (record.type === 'attributes' && record.target instanceof Element && record.target.classList.contains('find-widget')) {
631
+ schedule()
632
+ return
633
+ }
634
+ if (record.type === 'childList') {
635
+ for (const node of record.addedNodes) {
636
+ if (node instanceof Element && (node.classList.contains('find-widget') || node.querySelector('.find-widget') !== null)) {
637
+ schedule()
638
+ return
639
+ }
640
+ }
641
+ }
642
+ }
643
+ }) : null
644
+ observer?.observe(dom, { subtree: true, attributes: true, attributeFilter: ['class'], childList: true })
645
+ return () => {
646
+ try { observer?.disconnect() } catch { /* ignore */ }
647
+ if (frame !== 0) {
648
+ try {
649
+ if (typeof cancelAnimationFrame === 'function') cancelAnimationFrame(frame)
650
+ else window.clearTimeout(frame)
651
+ } catch { /* ignore */ }
652
+ frame = 0
653
+ }
654
+ }
655
+ } catch {
656
+ return null
657
+ }
658
+ }
659
+
597
660
  /** Monaco 编辑器选项:关闭 minimap / overview ruler,automaticLayout 跟随容器尺寸。 */
598
661
  function gufaEditorOptions(theme) {
599
662
  return {
600
663
  theme: gufaMonacoTheme(theme),
601
664
  automaticLayout: true,
602
665
  minimap: { enabled: false },
603
- renderOverviewRuler: false,
604
- overviewRulerLanes: 0,
666
+ /* 右侧 ruler 常开:查找匹配/诊断标记显示在滚动条旁 */
667
+ renderOverviewRuler: true,
668
+ overviewRulerLanes: 1,
605
669
  overviewRulerBorder: false,
606
670
  hideCursorInOverviewRuler: true,
607
671
  scrollBeyondLastLine: false,
608
672
  smoothScrolling: true,
609
673
  cursorBlinking: 'smooth',
674
+ /* 滚动相关的额外渲染关掉:sticky scroll / 常驻 overview ruler 已单独处理 */
675
+ stickyScroll: { enabled: false },
610
676
  fontSize: 13,
611
677
  lineHeight: 20,
612
678
  fontFamily: 'ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace',
@@ -882,27 +948,13 @@ const GUFA_LINT_ENABLED = false
882
948
  } catch {
883
949
  /* ignore */
884
950
  }
885
- /* 错误诊断恢复 Monaco 原生 TS worker:语法/语义/类型错误都正常画线。
886
- Monaco 的 javascriptDefaults 默认关掉了 JS 语义诊断(noSemanticValidation=true),
887
- 这里显式打开并开 checkJs,否则 .js 里只有语法错误、没有未定义变量等诊断。 */
951
+ /* 诊断统一由 Host 提供:JS 用项目 ESLint(尊重 .eslintrc/globals/rules),
952
+ TS 回落 Host tsc;关掉 Monaco worker 诊断,避免同一个错误画两条线/问题计数翻倍。 */
888
953
  try {
889
954
  const typescriptLanguages = monaco.languages.typescript
890
- if (typescriptLanguages !== null && typescriptLanguages !== undefined) {
891
- const diagnosticsOn = { noSemanticValidation: false, noSyntaxValidation: false }
892
- typescriptLanguages.typescriptDefaults?.setDiagnosticsOptions(diagnosticsOn)
893
- typescriptLanguages.javascriptDefaults?.setDiagnosticsOptions(diagnosticsOn)
894
- typescriptLanguages.javascriptDefaults?.setCompilerOptions({
895
- allowNonTsExtensions: true,
896
- allowJs: true,
897
- checkJs: true,
898
- target: 99,
899
- moduleResolution: 2,
900
- module: 99,
901
- jsx: 1,
902
- esModuleInterop: true,
903
- allowSyntheticDefaultImports: true,
904
- })
905
- }
955
+ const diagnosticsOff = { noSemanticValidation: true, noSyntaxValidation: true }
956
+ typescriptLanguages?.typescriptDefaults?.setDiagnosticsOptions(diagnosticsOff)
957
+ typescriptLanguages?.javascriptDefaults?.setDiagnosticsOptions(diagnosticsOff)
906
958
  } catch (error) {
907
959
  /* ignore */
908
960
  }
@@ -1828,7 +1880,10 @@ const GUFA_LINT_ENABLED = false
1828
1880
  minimap: { enabled: false },
1829
1881
  scrollBeyondLastLine: false,
1830
1882
  lineNumbers: 'on',
1831
- renderOverviewRuler: false,
1883
+ /* diff 编辑器也显示右侧 overview ruler:新增/删除改动在滚动条旁有红绿标记 */
1884
+ renderOverviewRuler: true,
1885
+ overviewRulerLanes: 1,
1886
+ overviewRulerBorder: false,
1832
1887
  fontFamily: 'ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace',
1833
1888
  fontSize: 12.5,
1834
1889
  lineHeight: 1.15,
@@ -504,6 +504,57 @@ G.BackdropParticles = function BackdropParticles(props) {
504
504
  return h('canvas', { ref: canvasRef, className: 'gufa-backdrop-particles', 'aria-hidden': 'true', style: { mixBlendMode: 'screen' } })
505
505
  }
506
506
 
507
+ /** 进入古法 IDE 时临时关掉皮肤自身的粒子/动效(它们会在覆盖层下面持续跑 WebGL/rAF);
508
+ * 退出时恢复用户原设置,不改变用户偏好。 */
509
+ let gufaSkinEffectsSaved = null
510
+ G.suspendSkinEffects = function suspendSkinEffects() {
511
+ try {
512
+ if (gufaSkinEffectsSaved !== null) return
513
+ const raw = localStorage.getItem(SKIN_SETTINGS_KEY)
514
+ if (raw === null || raw === '') return
515
+ const record = JSON.parse(raw)
516
+ if (record === null || typeof record !== 'object' || record.values === null || typeof record.values !== 'object') return
517
+ const values = record.values
518
+ if (values.particlesEnabled !== true && values.motionEnabled !== true) return
519
+ gufaSkinEffectsSaved = raw
520
+ const next = { ...record, values: { ...values, particlesEnabled: false, motionEnabled: false } }
521
+ const payload = JSON.stringify(next)
522
+ localStorage.setItem(SKIN_SETTINGS_KEY, payload)
523
+ try {
524
+ window.dispatchEvent(new StorageEvent('storage', {
525
+ key: SKIN_SETTINGS_KEY,
526
+ oldValue: raw,
527
+ newValue: payload,
528
+ storageArea: localStorage,
529
+ }))
530
+ } catch {
531
+ /* ignore */
532
+ }
533
+ } catch {
534
+ gufaSkinEffectsSaved = null
535
+ }
536
+ }
537
+ G.resumeSkinEffects = function resumeSkinEffects() {
538
+ try {
539
+ if (gufaSkinEffectsSaved === null) return
540
+ const raw = gufaSkinEffectsSaved
541
+ gufaSkinEffectsSaved = null
542
+ localStorage.setItem(SKIN_SETTINGS_KEY, raw)
543
+ try {
544
+ window.dispatchEvent(new StorageEvent('storage', {
545
+ key: SKIN_SETTINGS_KEY,
546
+ oldValue: null,
547
+ newValue: raw,
548
+ storageArea: localStorage,
549
+ }))
550
+ } catch {
551
+ /* ignore */
552
+ }
553
+ } catch {
554
+ /* ignore */
555
+ }
556
+ }
557
+
507
558
  /** 背景浓度滑杆(无级、连续;双击恢复「跟随皮肤」)。 */
508
559
  G.BackdropStrengthSlider = function BackdropStrengthSlider(props) {
509
560
  const t = G.useT()