enhance: embedページではstoreの保存先を完全に分離するように
This commit is contained in:
37
packages/frontend/src/scripts/embed-page.ts
Normal file
37
packages/frontend/src/scripts/embed-page.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
import { miLocalStorage } from "@/local-storage.js";
|
||||
import type { Keys } from "@/local-storage.js";
|
||||
|
||||
export function isEmbedPage() {
|
||||
return location.pathname.startsWith('/embed');
|
||||
}
|
||||
|
||||
/**
|
||||
* EmbedページではlocalStorageを使用できないようにしているが、
|
||||
* 動作に必要な値はsafeSessionStorage(miLocalStorage内のやつ)に移動する
|
||||
*/
|
||||
export function initEmbedPageLocalStorage() {
|
||||
if (!isEmbedPage()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const keysToDuplicate: Keys[] = [
|
||||
'v',
|
||||
'lastVersion',
|
||||
'instance',
|
||||
'instanceCachedAt',
|
||||
'lang',
|
||||
'locale',
|
||||
'localeVersion',
|
||||
];
|
||||
|
||||
keysToDuplicate.forEach(key => {
|
||||
const value = window.localStorage.getItem(key);
|
||||
if (value && !miLocalStorage.getItem(key)) {
|
||||
miLocalStorage.setItem(key, value);
|
||||
}
|
||||
});
|
||||
}
|
Reference in New Issue
Block a user