更新 Preferences 接口以使用排序的对象键,并调整默认偏好设置的结构。同时,在 preference.ts 文件中添加了关于 scope 字段的注释,说明其未来用途。此更改旨在提高代码的可读性和一致性。

This commit is contained in:
fullex 2025-08-02 00:22:22 +08:00
parent c0efb46c2b
commit ec491f5f24
2 changed files with 24 additions and 24 deletions

View File

@ -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: { default: {
test1: string 'app.test5': {
test2: number
test3: boolean
test4: string[]
test5: {
content1: string content1: string
content2: number content2: number
} }
} 'sys.a.test3': boolean
user: { 'sys.a.test4': string[]
test1: string 'ui.a.test1': string
test2: number 'ui.b.test2': number
test3: boolean
} }
} }
export const defaultPreferences: Preferences = { /* eslint sort-keys: ["error", "asc", {"caseSensitive": true, "natural": false}] */
export const defaultPreferences: PreferencesType = {
default: { default: {
test1: 'test1', 'app.test5': {
test2: 1,
test3: true,
test4: ['test4-1', 'test4-2'],
test5: {
content1: 'test5-1', content1: 'test5-1',
content2: 2 content2: 2
} },
}, 'sys.a.test3': true,
user: { 'sys.a.test4': ['test4-1', 'test4-2'],
test1: 'test1', 'ui.a.test1': 'test1',
test2: 1, 'ui.b.test2': 1
test3: false
} }
} }

View File

@ -5,7 +5,7 @@ import { crudTimestamps } from './columnHelpers'
export const preferenceTable = sqliteTable( export const preferenceTable = sqliteTable(
'preference', 'preference',
{ {
scope: text().notNull(), scope: text().notNull(), // scope is reserved for future use, now only 'default' is supported
key: text().notNull(), key: text().notNull(),
value: text({ mode: 'json' }), value: text({ mode: 'json' }),
...crudTimestamps ...crudTimestamps