提交 9e654937 编写于 作者: Y yurj26

fix(h5): get storage when cookie enabled (question/164775)

上级 5869d16b
......@@ -37,7 +37,7 @@ if (__PLATFORM__ === 'h5' || __PLATFORM__ === 'app-plus') {
let locale
if (__PLATFORM__ === 'h5') {
locale = (window.localStorage && localStorage[UNI_STORAGE_LOCALE]) || __uniConfig.locale || navigator.language
locale = (navigator.cookieEnabled && window.localStorage && localStorage[UNI_STORAGE_LOCALE]) || __uniConfig.locale || navigator.language
} else if (__PLATFORM__ === 'app-plus') {
if (typeof weex === 'object') {
locale = weex.requireModule('plus').getLanguage()
......
......@@ -6,7 +6,7 @@ import {
} from 'uni-helpers/i18n'
import {
UNI_STORAGE_LOCALE
} from 'uni-helpers/constants'
} from 'uni-helpers/constants'
export function getLocale () {
// 优先使用 $locale
......@@ -33,9 +33,9 @@ export function setLocale (locale) {
)
})
weex.requireModule('plus').setLanguage(locale)
}
if (__PLATFORM__ === 'h5') {
window.localStorage && (localStorage[UNI_STORAGE_LOCALE] = locale)
}
if (__PLATFORM__ === 'h5') {
navigator.cookieEnabled && window.localStorage && (localStorage[UNI_STORAGE_LOCALE] = locale)
}
callbacks.forEach(callbackId => {
invoke(callbackId, { locale })
......@@ -47,4 +47,4 @@ export function setLocale (locale) {
const callbacks = []
export function onLocaleChange (callbackId) {
callbacks.push(callbackId)
}
}
const UUID_KEY = '__DC_STAT_UUID'
const storage = window.localStorage || window.sessionStorage || {}
const storage = (navigator.cookieEnabled && (window.localStorage || window.sessionStorage)) || {}
let deviceId
export default function () {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册