(configBundle)
| 951 | } |
| 952 | |
| 953 | async function importSettingsBundle(configBundle) { |
| 954 | const state = await ensureManualInteractionAllowed('\u5bfc\u5165\u914d\u7f6e'); |
| 955 | if (Object.values(state.stepStatuses || {}).some((status) => status === 'running')) { |
| 956 | throw new Error('\u5f53\u524d\u6709\u6b65\u9aa4\u6b63\u5728\u6267\u884c\uff0c\u65e0\u6cd5\u5bfc\u5165\u914d\u7f6e\u3002'); |
| 957 | } |
| 958 | if (!configBundle || typeof configBundle !== 'object' || Array.isArray(configBundle)) { |
| 959 | throw new Error('\u914d\u7f6e\u6587\u4ef6\u5185\u5bb9\u65e0\u6548\u3002'); |
| 960 | } |
| 961 | |
| 962 | const schemaVersion = Number(configBundle.schemaVersion); |
| 963 | if (schemaVersion !== SETTINGS_EXPORT_SCHEMA_VERSION) { |
| 964 | throw new Error(`\u4ec5\u652f\u6301\u5bfc\u5165 schemaVersion=${SETTINGS_EXPORT_SCHEMA_VERSION} \u7684\u914d\u7f6e\u6587\u4ef6\u3002`); |
| 965 | } |
| 966 | if (!configBundle.settings || typeof configBundle.settings !== 'object' || Array.isArray(configBundle.settings)) { |
| 967 | throw new Error('\u914d\u7f6e\u6587\u4ef6\u7f3a\u5c11 settings \u914d\u7f6e\u6bb5\u3002'); |
| 968 | } |
| 969 | |
| 970 | const importedSettings = buildPersistentSettingsPayload(configBundle.settings, { |
| 971 | fillDefaults: true, |
| 972 | requireKnownKeys: true, |
| 973 | }); |
| 974 | |
| 975 | await setPersistentSettings(importedSettings); |
| 976 | |
| 977 | const sessionUpdates = { |
| 978 | ...importedSettings, |
| 979 | currentHotmailAccountId: null, |
| 980 | email: null, |
| 981 | }; |
| 982 | |
| 983 | await setState(sessionUpdates); |
| 984 | broadcastDataUpdate({ |
| 985 | ...importedSettings, |
| 986 | currentHotmailAccountId: null, |
| 987 | ...(sessionUpdates.email !== undefined ? { email: sessionUpdates.email } : {}), |
| 988 | }); |
| 989 | |
| 990 | return getState(); |
| 991 | } |
| 992 | |
| 993 | function broadcastDataUpdate(payload) { |
| 994 | chrome.runtime.sendMessage({ |
no test coverage detected