| 13 | |
| 14 | // 迁移数据到chrome.storage |
| 15 | export function migrateToChromeStorage() { |
| 16 | // 默认使用的事务,这里加个延时,用db.open()打开数据库后,再执行 |
| 17 | setTimeout(async () => { |
| 18 | try { |
| 19 | // 迁移脚本 |
| 20 | const scripts = await db.table("scripts").toArray(); |
| 21 | const scriptDAO = new ScriptDAO(); |
| 22 | const scriptCodeDAO = new ScriptCodeDAO(); |
| 23 | console.log("开始迁移脚本数据", scripts.length); |
| 24 | await Promise.all( |
| 25 | // 不处理 Promise.reject ? |
| 26 | scripts.map(async (script: ScriptAndCode) => { |
| 27 | const { |
| 28 | uuid, |
| 29 | name, |
| 30 | namespace, |
| 31 | author, |
| 32 | originDomain, |
| 33 | subscribeUrl, |
| 34 | type, |
| 35 | sort, |
| 36 | status, |
| 37 | runStatus, |
| 38 | metadata, |
| 39 | createtime, |
| 40 | checktime, |
| 41 | code, |
| 42 | checkUpdateUrl, |
| 43 | downloadUrl, |
| 44 | selfMetadata, |
| 45 | config, |
| 46 | error, |
| 47 | updatetime, |
| 48 | lastruntime, |
| 49 | nextruntime, |
| 50 | } = script; |
| 51 | const s = await scriptDAO.save({ |
| 52 | uuid, |
| 53 | name, |
| 54 | namespace, |
| 55 | author, |
| 56 | originDomain, |
| 57 | origin, |
| 58 | checkUpdateUrl, |
| 59 | downloadUrl, |
| 60 | metadata, |
| 61 | selfMetadata, |
| 62 | subscribeUrl, |
| 63 | config, |
| 64 | type, |
| 65 | status, |
| 66 | sort, |
| 67 | runStatus, |
| 68 | error, |
| 69 | createtime, |
| 70 | updatetime, |
| 71 | checktime, |
| 72 | lastruntime, |