feat(ui): new SettingsNotification using antd

This commit is contained in:
Fu Diwei
2024-12-20 13:56:29 +08:00
parent cae33cfc4f
commit 7c1a2d5f91
60 changed files with 1105 additions and 2450 deletions

View File

@@ -1,15 +1,23 @@
import { type SettingsModel } from "@/domain/settings";
import { ClientResponseError } from "pocketbase";
import { SETTINGS_NAMES, type SettingsModel } from "@/domain/settings";
import { getPocketBase } from "./pocketbase";
export const get = async <T>(name: string) => {
export const get = async <T>(name: (typeof SETTINGS_NAMES)[keyof typeof SETTINGS_NAMES]) => {
try {
const resp = await getPocketBase().collection("settings").getFirstListItem<SettingsModel<T>>(`name='${name}'`);
const resp = await getPocketBase().collection("settings").getFirstListItem<SettingsModel<T>>(`name='${name}'`, {
requestKey: null,
});
return resp;
} catch {
return {
name: name,
content: {} as T,
} as SettingsModel<T>;
} catch (err) {
if (err instanceof ClientResponseError && err.status === 404) {
return {
name: name,
content: {} as T,
} as SettingsModel<T>;
}
throw err;
}
};