Files
vtsuru.live/src/client/store/useSettings.ts
Megghy 0195e7b01a feat: Add Tauri support and enhance client functionality
- Introduced Tauri as a new EventFetcherType in api-models.
- Enhanced ClientFetcher.vue to support forced mode switching for Danmaku client.
- Updated ClientLayout.vue to restrict usage outside Tauri environment with appropriate alerts.
- Improved ClientSettings.vue to fetch and display the current version of the application.
- Modified initialization logic in initialize.ts to handle minimized startup for Tauri.
- Updated QueryBiliAPI function to conditionally use cookies based on a new parameter.
- Added bootAsMinimized setting to useSettings store for better user experience.
- Refactored logging in useWebFetcher to use console instead of logError/logInfo for clarity.
- Created a new LabelItem component for better label handling in forms.
- Enhanced EventFetcherStatusCard.vue to display version information based on EventFetcherType.
2025-04-07 19:14:39 +08:00

48 lines
1.5 KiB
TypeScript

import { useTauriStore } from './useTauriStore';
export type NotificationType = 'question-box' | 'danmaku';
export type NotificationSettings = {
enableTypes: NotificationType[];
};
export type VTsuruClientSettings = {
useDanmakuClientType: 'openlive' | 'direct';
fallbackToOpenLive: boolean;
bootAsMinimized: boolean;
danmakuHistorySize: number;
loginType: 'qrcode' | 'cookiecloud'
enableNotification: boolean;
notificationSettings: NotificationSettings;
};
export const useSettings = defineStore('settings', () => {
const store = useTauriStore().getTarget<VTsuruClientSettings>('settings');
const defaultSettings: VTsuruClientSettings = {
useDanmakuClientType: 'openlive',
fallbackToOpenLive: true,
bootAsMinimized: true,
danmakuHistorySize: 100,
loginType: 'qrcode',
enableNotification: true,
notificationSettings: {
enableTypes: ['question-box', 'danmaku'],
},
};
const settings = ref<VTsuruClientSettings>(Object.assign({}, defaultSettings));
async function init() {
settings.value = (await store.get()) || Object.assign({}, defaultSettings);
settings.value.notificationSettings ??= defaultSettings.notificationSettings;
settings.value.notificationSettings.enableTypes ??= [ 'question-box', 'danmaku' ];
}
async function save() {
await store.set(settings.value);
}
return { init, save, settings };
});
if (import.meta.hot) import.meta.hot.accept(acceptHMRUpdate(useSettings, import.meta.hot));