add wallpaper

This commit is contained in:
tamaina 2022-04-17 06:31:35 +09:00
parent 532a2f049f
commit 3d4c09510b

View file

@ -54,6 +54,7 @@ type Registry = {
coldDeviceStorage: Partial<typeof ColdDeviceStorage.default>; coldDeviceStorage: Partial<typeof ColdDeviceStorage.default>;
fontSize: string | null; fontSize: string | null;
useSystemFont: 't' | null; useSystemFont: 't' | null;
wallpaper: string | null;
}; };
type Registries = { type Registries = {
@ -99,6 +100,7 @@ async function saveNew() {
coldDeviceStorage: ColdDeviceStorage.getAll(), coldDeviceStorage: ColdDeviceStorage.getAll(),
fontSize: localStorage.getItem('fontSize'), fontSize: localStorage.getItem('fontSize'),
useSystemFont: localStorage.getItem('useSystemFont') as 't' | null, useSystemFont: localStorage.getItem('useSystemFont') as 't' | null,
wallpaper: localStorage.getItem('wallpaper'),
}; };
await os.api('i/registry/set', { scope, key: id, value: registry }); await os.api('i/registry/set', { scope, key: id, value: registry });
registries[id] = registry; registries[id] = registry;
@ -142,6 +144,13 @@ async function applyRegistry(id: string) {
localStorage.removeItem('useSystemFont'); localStorage.removeItem('useSystemFont');
} }
// wallpaper
if (registry.wallpaper != null) {
localStorage.setItem('wallpaper', registry.wallpaper);
} else {
localStorage.removeItem('wallpaper');
}
const { canceled: cancel2 } = await os.confirm({ const { canceled: cancel2 } = await os.confirm({
type: 'info', type: 'info',
text: ts.reloadToApplySetting, text: ts.reloadToApplySetting,
@ -183,6 +192,9 @@ async function save(id: string) {
updatedAt: (new Date()).toISOString(), updatedAt: (new Date()).toISOString(),
defaultStore: getDefaultStoreValues(), defaultStore: getDefaultStoreValues(),
coldDeviceStorage: ColdDeviceStorage.getAll(), coldDeviceStorage: ColdDeviceStorage.getAll(),
fontSize: localStorage.getItem('fontSize'),
useSystemFont: localStorage.getItem('useSystemFont') as 't' | null,
wallpaper: localStorage.getItem('wallpaper'),
}; };
await os.api('i/registry/set', { scope, key: id, value: registry }); await os.api('i/registry/set', { scope, key: id, value: registry });
registries[id] = registry; registries[id] = registry;