Skip to content

Commit

Permalink
fix: 修复上个版本store加载问题
Browse files Browse the repository at this point in the history
  • Loading branch information
enncy committed Apr 13, 2022
1 parent ccf92ed commit 48fdc1a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/core/src/script/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@ export let store: OCSStore = {} as OCSStore;

// 环境检测
if (typeof global === "undefined") {
if (typeof unsafeWindow !== "undefined") {
store = createStore();
}

onReady(() => {
if (typeof unsafeWindow !== "undefined") {
store = unsafeWindow.top?.OCS.store || createStore();
// 统一转向顶层对象
store = unsafeWindow.top?.OCS.store || store;
} else {
logger("warn", "为了确保功能正常使用, 请在油猴环境下运行 https://www.tampermonkey.net/");
}
Expand Down

0 comments on commit 48fdc1a

Please sign in to comment.