mirror of
https://gh-proxy.org/https://github.com/tiajinsha/JKVideo
synced 2026-07-07 23:18:38 +08:00
设置页面
This commit is contained in:
22
store/settingsStore.ts
Normal file
22
store/settingsStore.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { create } from 'zustand';
|
||||
import AsyncStorage from '@react-native-async-storage/async-storage';
|
||||
|
||||
interface SettingsState {
|
||||
coverQuality: 'hd' | 'normal';
|
||||
setCoverQuality: (q: 'hd' | 'normal') => Promise<void>;
|
||||
restore: () => Promise<void>;
|
||||
}
|
||||
|
||||
export const useSettingsStore = create<SettingsState>((set) => ({
|
||||
coverQuality: 'hd',
|
||||
|
||||
setCoverQuality: async (q) => {
|
||||
await AsyncStorage.setItem('COVER_QUALITY', q);
|
||||
set({ coverQuality: q });
|
||||
},
|
||||
|
||||
restore: async () => {
|
||||
const q = await AsyncStorage.getItem('COVER_QUALITY');
|
||||
if (q === 'hd' || q === 'normal') set({ coverQuality: q });
|
||||
},
|
||||
}));
|
||||
Reference in New Issue
Block a user