提交 173ec5df 编写于 作者: fxy060608's avatar fxy060608

Merge branch 'dev' of https://github.com/dcloudio/uni-app into alpha

...@@ -10901,23 +10901,23 @@ var serviceContext = (function () { ...@@ -10901,23 +10901,23 @@ var serviceContext = (function () {
uploadFile: uploadFile$1 uploadFile: uploadFile$1
}); });
const STORAGE_DATA_TYPE = '__TYPE';
const STORAGE_KEYS = 'uni-storage-keys';
function setStorage$1 ({ function setStorage$1 ({
key, key,
data data
} = {}) { } = {}) {
const value = { const type = typeof data;
type: typeof data === 'object' ? 'object' : 'string', const value = type === 'string' ? data : JSON.stringify({
type,
data: data data: data
}; });
localStorage.setItem(key, JSON.stringify(value)); try {
const keyList = localStorage.getItem('uni-storage-keys'); localStorage.setItem(key, value);
if (!keyList) { } catch (error) {
localStorage.setItem('uni-storage-keys', JSON.stringify([key])); return {
} else { errMsg: `setStorage:fail ${error}`
const keys = JSON.parse(keyList);
if (keys.indexOf(key) < 0) {
keys.push(key);
localStorage.setItem('uni-storage-keys', JSON.stringify(keys));
} }
} }
return { return {
...@@ -10935,13 +10935,33 @@ var serviceContext = (function () { ...@@ -10935,13 +10935,33 @@ var serviceContext = (function () {
function getStorage$1 ({ function getStorage$1 ({
key key
} = {}) { } = {}) {
const data = localStorage.getItem(key); const value = localStorage && localStorage.getItem(key);
return data ? { if (typeof value !== 'string') {
data: JSON.parse(data).data, return {
data: '',
errMsg: 'getStorage:fail'
}
}
let data = value;
try {
const object = JSON.parse(value);
// 兼容App端历史格式
const type = localStorage.getItem(key + STORAGE_DATA_TYPE);
if (!type) {
const keys = Object.keys(object);
if (keys.length === 2 && 'type' in object && 'data' in object) {
data = object.data;
} else if (keys.length === 1 && 'type' in object) {
data = '';
}
} else if (type !== 'String') {
data = object;
data = typeof data === 'string' ? JSON.parse(data) : data;
}
} catch (error) { }
return {
data,
errMsg: 'getStorage:ok' errMsg: 'getStorage:ok'
} : {
data: '',
errMsg: 'getStorage:fail'
} }
} }
...@@ -10955,14 +10975,11 @@ var serviceContext = (function () { ...@@ -10955,14 +10975,11 @@ var serviceContext = (function () {
function removeStorage$1 ({ function removeStorage$1 ({
key key
} = {}) { } = {}) {
const keyList = localStorage.getItem('uni-storage-keys'); if (localStorage) {
if (keyList) { // 兼容App端历史格式
const keys = JSON.parse(keyList); localStorage.removeItem(key + STORAGE_DATA_TYPE);
const index = keys.indexOf(key); localStorage.removeItem(key);
keys.splice(index, 1); }
localStorage.setItem('uni-storage-keys', JSON.stringify(keys));
}
localStorage.removeItem(key);
return { return {
errMsg: 'removeStorage:ok' errMsg: 'removeStorage:ok'
} }
...@@ -10975,7 +10992,7 @@ var serviceContext = (function () { ...@@ -10975,7 +10992,7 @@ var serviceContext = (function () {
} }
function clearStorage () { function clearStorage () {
localStorage.clear(); localStorage && localStorage.clear();
return { return {
errMsg: 'clearStorage:ok' errMsg: 'clearStorage:ok'
} }
...@@ -10985,18 +11002,23 @@ var serviceContext = (function () { ...@@ -10985,18 +11002,23 @@ var serviceContext = (function () {
clearStorage(); clearStorage();
} }
function getStorageInfo () { // TODO 暂时先不做大小的转换 function getStorageInfo () {
const keyList = localStorage.getItem('uni-storage-keys'); const length = (localStorage && (localStorage.length || localStorage.getLength())) || 0;
return keyList ? { const keys = [];
keys: JSON.parse(keyList), let currentSize = 0;
currentSize: 0, for (let index = 0; index < length; index++) {
limitSize: 0, const key = localStorage.key(index);
if (key !== STORAGE_KEYS && key.indexOf(STORAGE_DATA_TYPE) + STORAGE_DATA_TYPE.length !== key.length) {
const value = localStorage.getItem(key);
currentSize += key.length + value.length;
keys.push(key);
}
}
return {
keys,
currentSize: Math.ceil(currentSize * 2 / 1024),
limitSize: Number.MAX_VALUE,
errMsg: 'getStorageInfo:ok' errMsg: 'getStorageInfo:ok'
} : {
keys: '',
currentSize: 0,
limitSize: 0,
errMsg: 'getStorageInfo:fail'
} }
} }
......
...@@ -8,7 +8,6 @@ const { ...@@ -8,7 +8,6 @@ const {
} = require('@dcloudio/uni-template-compiler/lib/util') } = require('@dcloudio/uni-template-compiler/lib/util')
const TAGS = [ const TAGS = [
'ad',
'text', 'text',
'image', 'image',
'input', 'input',
......
...@@ -86,6 +86,12 @@ module.exports = function (content) { ...@@ -86,6 +86,12 @@ module.exports = function (content) {
let appConfigContent = '' let appConfigContent = ''
jsonFiles.forEach(jsonFile => { jsonFiles.forEach(jsonFile => {
if (jsonFile) { if (jsonFile) {
if (!isAppView && jsonFile.name === 'manifest.json') {
const content = JSON.parse(jsonFile.content)
if (!content.launch_path && content.plus['uni-app'].nvueLaunchMode === 'fast') {
console.log('Nvue 首页启动模式: fast 详见: https://ask.dcloud.net.cn/article/36749')
}
}
if (jsonFile.name === 'define-pages.js') { if (jsonFile.name === 'define-pages.js') {
appConfigContent = jsonFile.content appConfigContent = jsonFile.content
} else { } else {
...@@ -122,4 +128,4 @@ module.exports = function (content) { ...@@ -122,4 +128,4 @@ module.exports = function (content) {
} }
return '' return ''
} }
...@@ -92,8 +92,12 @@ module.exports = function (appJson, manifestJson, { ...@@ -92,8 +92,12 @@ module.exports = function (appJson, manifestJson, {
manifestJson.plus.launch_path = '__uniappview.html' // 首页地址固定 manifestJson.plus.launch_path = '__uniappview.html' // 首页地址固定
} }
// nvue 首页启动模式
manifestJson.plus['uni-app'].nvueLaunchMode = manifestJson.plus.nvueLaunchMode === 'fast' ? 'fast' : 'normal'
delete manifestJson.plus.nvueLaunchMode
manifest.name = 'manifest.json' manifest.name = 'manifest.json'
manifest.content = JSON.stringify(manifest.content) manifest.content = JSON.stringify(manifest.content)
delete appJson.nvue delete appJson.nvue
return [manifest, definePages(appJson), appConfigService(appJson)] return [manifest, definePages(appJson), appConfigService(appJson)]
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册