From ec491f5f24c972a96b89e09a896d382f6ea3a155 Mon Sep 17 00:00:00 2001 From: fullex <0xfullex@gmail.com> Date: Sat, 2 Aug 2025 00:22:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20Preferences=20=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E4=BB=A5=E4=BD=BF=E7=94=A8=E6=8E=92=E5=BA=8F=E7=9A=84?= =?UTF-8?q?=E5=AF=B9=E8=B1=A1=E9=94=AE=EF=BC=8C=E5=B9=B6=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E5=81=8F=E5=A5=BD=E8=AE=BE=E7=BD=AE=E7=9A=84?= =?UTF-8?q?=E7=BB=93=E6=9E=84=E3=80=82=E5=90=8C=E6=97=B6=EF=BC=8C=E5=9C=A8?= =?UTF-8?q?=20preference.ts=20=E6=96=87=E4=BB=B6=E4=B8=AD=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E4=BA=86=E5=85=B3=E4=BA=8E=20scope=20=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E7=9A=84=E6=B3=A8=E9=87=8A=EF=BC=8C=E8=AF=B4=E6=98=8E?= =?UTF-8?q?=E5=85=B6=E6=9C=AA=E6=9D=A5=E7=94=A8=E9=80=94=E3=80=82=E6=AD=A4?= =?UTF-8?q?=E6=9B=B4=E6=94=B9=E6=97=A8=E5=9C=A8=E6=8F=90=E9=AB=98=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E7=9A=84=E5=8F=AF=E8=AF=BB=E6=80=A7=E5=92=8C=E4=B8=80?= =?UTF-8?q?=E8=87=B4=E6=80=A7=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/shared/preferences.ts | 46 +++++++++++++++---------------- src/main/db/schemas/preference.ts | 2 +- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/packages/shared/preferences.ts b/packages/shared/preferences.ts index bd318d8fdd..3da0ea4b59 100644 --- a/packages/shared/preferences.ts +++ b/packages/shared/preferences.ts @@ -1,35 +1,35 @@ -export interface Preferences { +/** + * we should use sorted object keys + * use `eslint --fix` to auto sort keys + */ + +/* eslint @typescript-eslint/member-ordering: ["error", { + "interfaces": { "order": "alphabetically" }, + "typeLiterals": { "order": "alphabetically" } +}] */ +export interface PreferencesType { default: { - test1: string - test2: number - test3: boolean - test4: string[] - test5: { + 'app.test5': { content1: string content2: number } - } - user: { - test1: string - test2: number - test3: boolean + 'sys.a.test3': boolean + 'sys.a.test4': string[] + 'ui.a.test1': string + 'ui.b.test2': number } } -export const defaultPreferences: Preferences = { +/* eslint sort-keys: ["error", "asc", {"caseSensitive": true, "natural": false}] */ +export const defaultPreferences: PreferencesType = { default: { - test1: 'test1', - test2: 1, - test3: true, - test4: ['test4-1', 'test4-2'], - test5: { + 'app.test5': { content1: 'test5-1', content2: 2 - } - }, - user: { - test1: 'test1', - test2: 1, - test3: false + }, + 'sys.a.test3': true, + 'sys.a.test4': ['test4-1', 'test4-2'], + 'ui.a.test1': 'test1', + 'ui.b.test2': 1 } } diff --git a/src/main/db/schemas/preference.ts b/src/main/db/schemas/preference.ts index 1a02e8e99d..bb1b4e469c 100644 --- a/src/main/db/schemas/preference.ts +++ b/src/main/db/schemas/preference.ts @@ -5,7 +5,7 @@ import { crudTimestamps } from './columnHelpers' export const preferenceTable = sqliteTable( 'preference', { - scope: text().notNull(), + scope: text().notNull(), // scope is reserved for future use, now only 'default' is supported key: text().notNull(), value: text({ mode: 'json' }), ...crudTimestamps