Skip to content

Commit

Permalink
fix(core): 修复 store 环境检测问题
Browse files Browse the repository at this point in the history
  • Loading branch information
enncy committed Jun 12, 2022
1 parent ba63921 commit cd14eb0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/core/src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import defaultsDeep from 'lodash/defaultsDeep';
import { reactive } from 'vue';
import { createReactive } from './core/reactive';
import { OCSLocalStorage, OCSStore } from './core/types';
import { isInBrowser } from './core/utils';
import { isInBrowser, useUnsafeWindow } from './core/utils';
import { defaultOCSSetting } from './scripts';

/**
Expand All @@ -11,7 +11,7 @@ import { defaultOCSSetting } from './scripts';
let store: OCSStore;

// 环境检测
if (isInBrowser()) {
if (isInBrowser() && useUnsafeWindow()) {
// 创建响应式存储对象
store = reactive(createStore());
// 初始化本地
Expand All @@ -34,7 +34,7 @@ export function getStore() {
export function createStore(): OCSStore {
/** 默认存储数据 */
// eslint-disable-next-line no-undef
const localStore: OCSLocalStorage = defaultsDeep(isInBrowser() ? GM_getValue('store', {}) : {}, {
const localStore: OCSLocalStorage = defaultsDeep(GM_getValue('store', {}), {
setting: defaultOCSSetting,
logs: [],
alerts: [],
Expand Down

0 comments on commit cd14eb0

Please sign in to comment.