Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
touchx
uni-app
提交
0f4b1e3d
U
uni-app
项目概览
touchx
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0f4b1e3d
编写于
4月 15, 2021
作者:
雪洛
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: uni-id mixin
上级
a8cb6790
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
59 addition
and
1 deletion
+59
-1
src/core/service/plugins/index.js
src/core/service/plugins/index.js
+6
-0
src/platforms/app-plus/service/framework/plugins/index.js
src/platforms/app-plus/service/framework/plugins/index.js
+7
-1
src/platforms/mp-weixin/runtime/wrapper/app-base-parser.js
src/platforms/mp-weixin/runtime/wrapper/app-base-parser.js
+5
-0
src/shared/uni-id-mixin.js
src/shared/uni-id-mixin.js
+39
-0
src/shared/util.js
src/shared/util.js
+2
-0
未找到文件。
src/core/service/plugins/index.js
浏览文件 @
0f4b1e3d
...
...
@@ -24,6 +24,10 @@ import {
getTabBarScrollPosition
}
from
'
./app/router-guard
'
import
{
uniIdMixin
}
from
'
uni-shared
'
function
getMinId
(
routes
)
{
let
minId
=
0
routes
.
forEach
(
route
=>
{
...
...
@@ -74,6 +78,8 @@ export default {
lifecycleMixin
(
Vue
)
uniIdMixin
(
Vue
)
/* eslint-disable no-undef */
if
(
typeof
__UNI_ROUTER_BASE__
!==
'
undefined
'
)
{
__uniConfig
.
router
.
base
=
__UNI_ROUTER_BASE__
...
...
src/platforms/app-plus/service/framework/plugins/index.js
浏览文件 @
0f4b1e3d
...
...
@@ -22,6 +22,10 @@ import {
vdSyncCallbacks
}
from
'
../subscribe-handlers/on-vd-sync-callback
'
import
{
uniIdMixin
}
from
'
uni-shared
'
export
default
{
install
(
Vue
,
options
)
{
initVue
(
Vue
)
...
...
@@ -31,6 +35,8 @@ export default {
initPolyfill
(
Vue
)
uniIdMixin
(
Vue
)
Vue
.
prototype
.
getOpenerEventChannel
=
function
()
{
if
(
!
this
.
$root
.
$scope
.
eventChannel
)
{
this
.
$root
.
$scope
.
eventChannel
=
new
EventChannel
()
...
...
@@ -94,4 +100,4 @@ export default {
return
callback
?
undefined
:
result
}
}
}
}
src/platforms/mp-weixin/runtime/wrapper/app-base-parser.js
浏览文件 @
0f4b1e3d
...
...
@@ -11,6 +11,10 @@ import {
getEventChannel
}
from
'
uni-helpers/navigate-to
'
import
{
uniIdMixin
}
from
'
uni-shared
'
const
hooks
=
[
'
onShow
'
,
'
onHide
'
,
...
...
@@ -101,6 +105,7 @@ export default function parseBaseApp (vm, {
if
(
vm
.
$options
.
store
)
{
Vue
.
prototype
.
$store
=
vm
.
$options
.
store
}
uniIdMixin
(
Vue
)
Vue
.
prototype
.
mpHost
=
__PLATFORM__
...
...
src/shared/uni-id-mixin.js
0 → 100644
浏览文件 @
0f4b1e3d
function
b64DecodeUnicode
(
str
)
{
return
decodeURIComponent
(
atob
(
str
).
split
(
''
).
map
(
function
(
c
)
{
return
'
%
'
+
(
'
00
'
+
c
.
charCodeAt
(
0
).
toString
(
16
)).
slice
(
-
2
)
}).
join
(
''
))
}
function
getCurrentUserInfo
()
{
const
token
=
(
__PLATFORM__
===
'
h5
'
||
__PLATFORM__
===
'
app-plus
'
?
uni
:
__GLOBAL__
).
getStorageSync
(
'
uni_id_token
'
)
||
''
const
tokenArr
=
token
.
split
(
'
.
'
)
if
(
!
token
||
tokenArr
.
length
!==
3
)
{
return
{
uid
:
null
,
role
:
[],
permission
:
[]
}
}
let
userInfo
try
{
userInfo
=
JSON
.
parse
(
b64DecodeUnicode
(
tokenArr
[
1
]))
}
catch
(
error
)
{
throw
new
Error
(
'
获取当前用户信息出错,详细错误信息为:
'
+
error
.
message
)
}
return
userInfo
}
export
function
uniIdMixin
(
Vue
)
{
Vue
.
prototype
.
uniIDHasRole
=
function
(
roleId
)
{
const
{
role
}
=
getCurrentUserInfo
()
return
role
.
indexOf
(
roleId
)
>
-
1
}
Vue
.
prototype
.
uniIDHasPermission
=
function
(
permissionId
)
{
const
{
permission
}
=
getCurrentUserInfo
()
return
this
.
uniIDHasRole
(
'
admin
'
)
||
permission
.
indexOf
(
permissionId
)
>
-
1
}
}
src/shared/util.js
浏览文件 @
0f4b1e3d
...
...
@@ -193,3 +193,5 @@ export function deepClone (vnodes, createElement) {
return
vnodes
.
map
(
cloneVNode
)
}
export
*
from
'
./uni-id-mixin
'
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录