save
This commit is contained in:
@@ -327,10 +327,10 @@
|
||||
|
||||
<script>
|
||||
// 旧域名地址
|
||||
const OLD_ORIGIN = 'https://2study.top';
|
||||
var OLD_ORIGIN = 'https://2study.top';
|
||||
|
||||
// 需要迁移的 IndexedDB key
|
||||
const IDB_KEYS = [
|
||||
var IDB_KEYS = [
|
||||
'type-words-app-version',
|
||||
'typing-word-dict',
|
||||
'typing-word-setting',
|
||||
@@ -338,7 +338,7 @@
|
||||
];
|
||||
|
||||
// 需要迁移的 localStorage key
|
||||
const LS_KEYS = [
|
||||
var LS_KEYS = [
|
||||
'PracticeSaveWord',
|
||||
'PracticeSaveArticle'
|
||||
];
|
||||
@@ -348,7 +348,7 @@
|
||||
return new Promise((resolve) => {
|
||||
if (window.idbKeyval) return resolve(window.idbKeyval);
|
||||
|
||||
const script = document.createElement('script');
|
||||
var script = document.createElement('script');
|
||||
script.src = 'https://cdn.jsdelivr.net/npm/idb-keyval@6.2.2/dist/umd.js';
|
||||
script.onload = () => resolve(window.idbKeyval);
|
||||
document.head.appendChild(script);
|
||||
@@ -367,8 +367,8 @@
|
||||
// 安全接收旧域名返回的数据
|
||||
function onMessage(event) {
|
||||
if (event.data?.type !== 'MIGRATION_RESULT') return;
|
||||
|
||||
const payload = event.data.payload;
|
||||
console.log('payload',payload)
|
||||
|
||||
// 写入 localStorage
|
||||
LS_KEYS.forEach(key => {
|
||||
@@ -396,7 +396,9 @@
|
||||
|
||||
// 等 iframe 加载完成再发请求
|
||||
iframe.onload = () => {
|
||||
iframe.contentWindow.postMessage({type: 'REQUEST_MIGRATION_DATA'}, OLD_ORIGIN);
|
||||
setTimeout(()=>{
|
||||
iframe.contentWindow.postMessage({type: 'REQUEST_MIGRATION_DATA'}, 'https://2study.top');
|
||||
},3000)
|
||||
};
|
||||
|
||||
document.body.appendChild(iframe);
|
||||
|
||||
Reference in New Issue
Block a user