feat(ui): new SettingsSSLProvider using antd

This commit is contained in:
Fu Diwei
2024-12-20 20:42:46 +08:00
parent 9e1e0dee1d
commit a917d6c2c5
16 changed files with 392 additions and 488 deletions

View File

@@ -1,9 +1,9 @@
import { ClientResponseError } from "pocketbase";
import { SETTINGS_NAMES, type SettingsModel } from "@/domain/settings";
import { type SettingsModel, type SettingsNames } from "@/domain/settings";
import { getPocketBase } from "./pocketbase";
export const get = async <T>(name: (typeof SETTINGS_NAMES)[keyof typeof SETTINGS_NAMES]) => {
export const get = async <T extends NonNullable<unknown>>(name: SettingsNames) => {
try {
const resp = await getPocketBase().collection("settings").getFirstListItem<SettingsModel<T>>(`name='${name}'`, {
requestKey: null,
@@ -21,7 +21,7 @@ export const get = async <T>(name: (typeof SETTINGS_NAMES)[keyof typeof SETTINGS
}
};
export const save = async <T>(record: MaybeModelRecordWithId<SettingsModel<T>>) => {
export const save = async <T extends NonNullable<unknown>>(record: MaybeModelRecordWithId<SettingsModel<T>>) => {
if (record.id) {
return await getPocketBase().collection("settings").update<SettingsModel<T>>(record.id, record);
}