enhance: embedページではstoreの保存先を完全に分離するように

This commit is contained in:
kakkokari-gtyih
2024-06-01 21:03:39 +09:00
parent ecf7945fe8
commit e9b3b5ffcd
13 changed files with 168 additions and 23 deletions

View File

@@ -24,7 +24,17 @@ import { miLocalStorage } from '@/local-storage.js';
import { fetchCustomEmojis } from '@/custom-emojis.js';
import { setupRouter } from '@/router/definition.js';
export async function common(createVue: () => App<Element>) {
export type CommonBootOptions = {
forceColorMode?: 'dark' | 'light' | 'auto';
};
const defaultCommonBootOptions: CommonBootOptions = {
forceColorMode: 'auto',
};
export async function common(createVue: () => App<Element>, partialOptions?: Partial<CommonBootOptions>) {
const bootOptions = Object.assign(defaultCommonBootOptions, partialOptions);
console.info(`Misskey v${version}`);
if (_DEV_) {
@@ -166,15 +176,19 @@ export async function common(createVue: () => App<Element>) {
});
//#region Sync dark mode
if (ColdDeviceStorage.get('syncDeviceDarkMode')) {
if (ColdDeviceStorage.get('syncDeviceDarkMode') && bootOptions.forceColorMode === 'auto') {
defaultStore.set('darkMode', isDeviceDarkmode());
}
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', (mql) => {
if (ColdDeviceStorage.get('syncDeviceDarkMode')) {
if (ColdDeviceStorage.get('syncDeviceDarkMode') && bootOptions.forceColorMode === 'auto') {
defaultStore.set('darkMode', mql.matches);
}
});
if (bootOptions.forceColorMode !== 'auto') {
defaultStore.set('darkMode', bootOptions.forceColorMode === 'dark');
}
//#endregion
fetchInstanceMetaPromise.then(() => {

View File

@@ -5,9 +5,10 @@
import { createApp, defineAsyncComponent } from 'vue';
import { common } from './common.js';
import type { CommonBootOptions } from './common.js';
export async function subBoot() {
export async function subBoot(options?: CommonBootOptions) {
const { isClientUpdated } = await common(() => createApp(
defineAsyncComponent(() => import('@/ui/minimum.vue')),
));
), options);
}