-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b3553c5
commit 3be1ff4
Showing
1 changed file
with
7 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,22 @@ | ||
let store = {} | ||
const appGlobal = global || {} | ||
const globalRef = Object.getPrototypeOf(appGlobal) || appGlobal | ||
|
||
export function getStore () { | ||
if (process.env.TARO_ENV === 'alipay') { | ||
return my.taroMobxStore || {} | ||
} else if (process.env.TARO_ENV === 'quickapp') { | ||
return globalRef.taroMobxStore || {} | ||
} | ||
return store | ||
} | ||
|
||
export function setStore (arg) { | ||
if (process.env.TARO_ENV === 'alipay') { | ||
my.taroMobxStore = arg | ||
} else if (process.env.TARO_ENV === 'quickapp') { | ||
globalRef.taroMobxStore = arg | ||
} else { | ||
store = arg | ||
} | ||
} | ||
} |