feat(editor): follow app theme

This commit is contained in:
t8y2
2026-05-22 00:41:49 +08:00
parent 3dc4f40e7f
commit 355e09ccf4
9 changed files with 81 additions and 14 deletions
@@ -20,3 +20,12 @@ test("toolbar theme and language menus use shadcn tooltip without nesting trigge
assert.doesNotMatch(source, /group\/toolbar-tip/);
assert.doesNotMatch(source, /group-hover\/toolbar-tip/);
});
test("toolbar uses SunMoon for the system theme option", () => {
const source = readFileSync("apps/desktop/src/components/layout/AppToolbar.vue", "utf8");
assert.match(source, /SunMoon/);
assert.match(source, /<SunMoon v-if="themeMode === 'system'"/);
assert.match(source, /<SunMoon class="h-4 w-4" \/>/);
assert.doesNotMatch(source, /Monitor/);
});
@@ -0,0 +1,13 @@
import { strict as assert } from "node:assert";
import test from "node:test";
import { resolveEditorTheme } from "../../apps/desktop/src/lib/editorThemes.ts";
test("editor theme follows the resolved app appearance when configured to follow app theme", () => {
assert.equal(resolveEditorTheme("app", "light"), "vscode-light");
assert.equal(resolveEditorTheme("app", "dark"), "one-dark");
});
test("editor theme keeps explicit CodeMirror theme selections", () => {
assert.equal(resolveEditorTheme("nord", "light"), "nord");
assert.equal(resolveEditorTheme("xcode", "dark"), "xcode");
});
@@ -38,6 +38,12 @@ test("settings dialog has a shortcuts category", () => {
assert.match(shortcutSource, /settings\.shortcutToggleTranspose/);
});
test("settings editor theme preview can follow app appearance", () => {
assert.match(source, /useTheme/);
assert.match(source, /appAppearance: isDark\.value \? "dark" : "light"/);
assert.match(source, /loadEditorTheme\(ss\.theme, ss\.appAppearance\)/);
});
test("shortcut settings capture custom keydown input instead of fixed select options", () => {
assert.match(source, /onShortcutKeydown/);
assert.match(source, /@keydown="\(event: KeyboardEvent\) => onShortcutKeydown/);
+8
View File
@@ -23,6 +23,14 @@ test("normalizes saved query result page size", () => {
assert.equal(normalizeEditorSettings({ pageSize: 0 }).pageSize, 100);
});
test("normalizes editor theme settings", () => {
assert.equal(DEFAULT_EDITOR_SETTINGS.theme, "app");
assert.equal(normalizeEditorSettings({}).theme, "app");
assert.equal(normalizeEditorSettings({ theme: "app" }).theme, "app");
assert.equal(normalizeEditorSettings({ theme: "vscode-light" }).theme, "vscode-light");
assert.equal(normalizeEditorSettings({ theme: "invalid" as any }).theme, DEFAULT_EDITOR_SETTINGS.theme);
});
test("defaults shortcut settings", () => {
const settings = normalizeEditorSettings({});