Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
anyefeiyu
uni-app
提交
0b166a4b
U
uni-app
项目概览
anyefeiyu
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0b166a4b
编写于
7月 20, 2019
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(app-plus-nvue): localStorage
上级
00a8f9f7
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
30 addition
and
41 deletion
+30
-41
build/rollup.config.app.js
build/rollup.config.app.js
+4
-2
packages/uni-app-plus-nvue/dist/index.js
packages/uni-app-plus-nvue/dist/index.js
+1
-1
packages/uni-app-plus-nvue/dist/uni.js
packages/uni-app-plus-nvue/dist/uni.js
+12
-17
src/core/service/api/storage.js
src/core/service/api/storage.js
+10
-19
src/platforms/app-plus/service/uni/polyfill.js
src/platforms/app-plus/service/uni/polyfill.js
+2
-1
src/platforms/app-plus/service/uni/popup.js
src/platforms/app-plus/service/uni/popup.js
+1
-1
未找到文件。
build/rollup.config.app.js
浏览文件 @
0b166a4b
...
...
@@ -18,8 +18,10 @@ if (process.env.UNI_SERVICE === 'legacy') {
}
else
if
(
process
.
env
.
UNI_SERVICE
===
'
uni
'
)
{
input
=
'
src/platforms/app-plus/service/uni/index.js
'
output
.
file
=
'
packages/uni-app-plus-nvue/dist/uni.js
'
output
.
banner
=
'
export function createUniInstance(weex, plus, __uniConfig, __uniRoutes, UniServiceJSBridge, getApp, getCurrentPages){
\n
'
output
.
banner
=
`export function createUniInstance(weex, plus, __uniConfig, __uniRoutes, UniServiceJSBridge, getApp, getCurrentPages){
var localStorage = plus.storage
`
output
.
footer
=
'
\n
return uni$1
\n
}
'
}
...
...
packages/uni-app-plus-nvue/dist/index.js
浏览文件 @
0b166a4b
...
...
@@ -677,7 +677,7 @@ let waiting;
let
waitingTimeout
;
let
toast
=
false
;
let
toastTimeout
;
// 此处设计不对
function
initPopup
(
on
,
{
plus
})
{
...
...
packages/uni-app-plus-nvue/dist/uni.js
浏览文件 @
0b166a4b
export
function
createUniInstance
(
weex
,
plus
,
__uniConfig
,
__uniRoutes
,
UniServiceJSBridge
,
getApp
,
getCurrentPages
){
var
localStorage
=
plus
.
storage
const
_toString
=
Object
.
prototype
.
toString
;
const
hasOwnProperty
=
Object
.
prototype
.
hasOwnProperty
;
...
...
@@ -1855,7 +1856,7 @@ function wrapper (name, invokeMethod, extras) {
}
}
// 尽早将 invokeCallbackHandler 挂在 UniServiceJSBridge 中
UniServiceJSBridge
.
publishHandler
=
UniServiceJSBridge
.
emit
;
UniServiceJSBridge
.
invokeCallbackHandler
=
invokeCallbackHandler
;
function
createCommonjsModule
(
fn
,
module
)
{
...
...
@@ -2252,28 +2253,23 @@ function switchTab$1 (args) {
return
onAppRoute
(
'
switchTab
'
,
args
)
}
function
getStorageHolder
()
{
return
plus
.
storage
}
function
setStorage$1
({
key
,
data
}
=
{})
{
const
storageHolder
=
getStorageHolder
();
const
value
=
{
type
:
typeof
data
===
'
object
'
?
'
object
'
:
'
string
'
,
data
:
data
};
storageHolder
.
setItem
(
key
,
JSON
.
stringify
(
value
));
const
keyList
=
storageHolder
.
getItem
(
'
uni-storage-keys
'
);
localStorage
.
setItem
(
key
,
JSON
.
stringify
(
value
));
const
keyList
=
localStorage
.
getItem
(
'
uni-storage-keys
'
);
if
(
!
keyList
)
{
storageHolder
.
setItem
(
'
uni-storage-keys
'
,
JSON
.
stringify
([
key
]));
localStorage
.
setItem
(
'
uni-storage-keys
'
,
JSON
.
stringify
([
key
]));
}
else
{
const
keys
=
JSON
.
parse
(
keyList
);
if
(
keys
.
indexOf
(
key
)
<
0
)
{
keys
.
push
(
key
);
storageHolder
.
setItem
(
'
uni-storage-keys
'
,
JSON
.
stringify
(
keys
));
localStorage
.
setItem
(
'
uni-storage-keys
'
,
JSON
.
stringify
(
keys
));
}
}
return
{
...
...
@@ -2291,7 +2287,7 @@ function setStorageSync$1 (key, data) {
function
getStorage
({
key
}
=
{})
{
const
data
=
getStorageHolder
()
.
getItem
(
key
);
const
data
=
localStorage
.
getItem
(
key
);
return
data
?
{
data
:
JSON
.
parse
(
data
).
data
,
errMsg
:
'
getStorage:ok
'
...
...
@@ -2311,15 +2307,14 @@ function getStorageSync (key) {
function
removeStorage
({
key
}
=
{})
{
const
storageHolder
=
getStorageHolder
();
const
keyList
=
storageHolder
.
getItem
(
'
uni-storage-keys
'
);
const
keyList
=
localStorage
.
getItem
(
'
uni-storage-keys
'
);
if
(
keyList
)
{
const
keys
=
JSON
.
parse
(
keyList
);
const
index
=
keys
.
indexOf
(
key
);
keys
.
splice
(
index
,
1
);
storageHolder
.
setItem
(
'
uni-storage-keys
'
,
JSON
.
stringify
(
keys
));
localStorage
.
setItem
(
'
uni-storage-keys
'
,
JSON
.
stringify
(
keys
));
}
storageHolder
.
removeItem
(
key
);
localStorage
.
removeItem
(
key
);
return
{
errMsg
:
'
removeStorage:ok
'
}
...
...
@@ -2332,7 +2327,7 @@ function removeStorageSync (key) {
}
function
clearStorage
()
{
getStorageHolder
()
.
clear
();
localStorage
.
clear
();
return
{
errMsg
:
'
clearStorage:ok
'
}
...
...
@@ -2343,7 +2338,7 @@ function clearStorageSync () {
}
function
getStorageInfo
()
{
// TODO 暂时先不做大小的转换
const
keyList
=
getStorageHolder
()
.
getItem
(
'
uni-storage-keys
'
);
const
keyList
=
localStorage
.
getItem
(
'
uni-storage-keys
'
);
return
keyList
?
{
keys
:
JSON
.
parse
(
keyList
),
currentSize
:
0
,
...
...
src/core/service/api/storage.js
浏览文件 @
0b166a4b
function
getStorageHolder
()
{
if
(
__PLATFORM__
===
'
h5
'
)
{
return
localStorage
}
return
plus
.
storage
}
export
function
setStorage
({
key
,
data
}
=
{})
{
const
storageHolder
=
getStorageHolder
()
const
value
=
{
type
:
typeof
data
===
'
object
'
?
'
object
'
:
'
string
'
,
data
:
data
}
storageHolder
.
setItem
(
key
,
JSON
.
stringify
(
value
))
const
keyList
=
storageHolder
.
getItem
(
'
uni-storage-keys
'
)
localStorage
.
setItem
(
key
,
JSON
.
stringify
(
value
))
const
keyList
=
localStorage
.
getItem
(
'
uni-storage-keys
'
)
if
(
!
keyList
)
{
storageHolder
.
setItem
(
'
uni-storage-keys
'
,
JSON
.
stringify
([
key
]))
localStorage
.
setItem
(
'
uni-storage-keys
'
,
JSON
.
stringify
([
key
]))
}
else
{
const
keys
=
JSON
.
parse
(
keyList
)
if
(
keys
.
indexOf
(
key
)
<
0
)
{
keys
.
push
(
key
)
storageHolder
.
setItem
(
'
uni-storage-keys
'
,
JSON
.
stringify
(
keys
))
localStorage
.
setItem
(
'
uni-storage-keys
'
,
JSON
.
stringify
(
keys
))
}
}
return
{
...
...
@@ -40,7 +32,7 @@ export function setStorageSync (key, data) {
export
function
getStorage
({
key
}
=
{})
{
const
data
=
getStorageHolder
()
.
getItem
(
key
)
const
data
=
localStorage
.
getItem
(
key
)
return
data
?
{
data
:
JSON
.
parse
(
data
).
data
,
errMsg
:
'
getStorage:ok
'
...
...
@@ -60,15 +52,14 @@ export function getStorageSync (key) {
export
function
removeStorage
({
key
}
=
{})
{
const
storageHolder
=
getStorageHolder
()
const
keyList
=
storageHolder
.
getItem
(
'
uni-storage-keys
'
)
const
keyList
=
localStorage
.
getItem
(
'
uni-storage-keys
'
)
if
(
keyList
)
{
const
keys
=
JSON
.
parse
(
keyList
)
const
index
=
keys
.
indexOf
(
key
)
keys
.
splice
(
index
,
1
)
storageHolder
.
setItem
(
'
uni-storage-keys
'
,
JSON
.
stringify
(
keys
))
localStorage
.
setItem
(
'
uni-storage-keys
'
,
JSON
.
stringify
(
keys
))
}
storageHolder
.
removeItem
(
key
)
localStorage
.
removeItem
(
key
)
return
{
errMsg
:
'
removeStorage:ok
'
}
...
...
@@ -81,7 +72,7 @@ export function removeStorageSync (key) {
}
export
function
clearStorage
()
{
getStorageHolder
()
.
clear
()
localStorage
.
clear
()
return
{
errMsg
:
'
clearStorage:ok
'
}
...
...
@@ -92,7 +83,7 @@ export function clearStorageSync () {
}
export
function
getStorageInfo
()
{
// TODO 暂时先不做大小的转换
const
keyList
=
getStorageHolder
()
.
getItem
(
'
uni-storage-keys
'
)
const
keyList
=
localStorage
.
getItem
(
'
uni-storage-keys
'
)
return
keyList
?
{
keys
:
JSON
.
parse
(
keyList
),
currentSize
:
0
,
...
...
src/platforms/app-plus/service/uni/polyfill.js
浏览文件 @
0b166a4b
import
{
invokeCallbackHandler
}
from
'
uni-helpers/api
'
// 尽早将 invokeCallbackHandler 挂在 UniServiceJSBridge 中
UniServiceJSBridge
.
publishHandler
=
UniServiceJSBridge
.
emit
UniServiceJSBridge
.
invokeCallbackHandler
=
invokeCallbackHandler
src/platforms/app-plus/service/uni/popup.js
浏览文件 @
0b166a4b
...
...
@@ -2,7 +2,7 @@ let waiting
let
waitingTimeout
let
toast
=
false
let
toastTimeout
// 此处设计不对
export
default
function
initPopup
(
on
,
{
plus
})
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录