Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
iBiz-Vue-Mob-R7-Res
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
iBiz-R7前端标准模板
iBiz-Vue-Mob-R7-Res
提交
5e93075c
提交
5e93075c
编写于
10月 30, 2020
作者:
KK
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
格式化代码 & 修复未配置英文名称不显示文本 & 增加路由配置
上级
abe38884
变更
2
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
250 行增加
和
224 行删除
+250
-224
app-setting.vue
src/ibiz-core/components/app-setting/app-setting.vue
+248
-224
config.ts
src/ibiz-core/components/app-setting/config.ts
+2
-0
未找到文件。
src/ibiz-core/components/app-setting/app-setting.vue
浏览文件 @
5e93075c
...
...
@@ -66,260 +66,284 @@
</ion-page>
</template>
<
script
lang=
"ts"
>
import
{
Vue
,
Component
,
Prop
,
Provide
,
Emit
,
Watch
,
}
from
"vue-property-decorator"
;
import
{
Vue
,
Component
,
Prop
,
Provide
,
Emit
,
Watch
,
}
from
"vue-property-decorator"
;
import
{
settingConfig
}
from
"./config"
;
import
i18n
from
'@/locale'
@
Component
({
components
:
{},
components
:
{},
})
export
default
class
AppSetting
extends
Vue
{
/**
* 用户名称
*/
public
srfloginname
=
""
;
/**
* 用户名称
*
* @type {string}
* @memberof AppSetting
*/
public
srfloginname
=
""
;
/**
* 第三方服务
*/
public
thirdPartyName
=
this
.
$viewTool
.
getThirdPartyName
();
/**
* 第三方服务
*
* @type {string}
* @memberof AppSetting
*/
public
thirdPartyName
=
this
.
$viewTool
.
getThirdPartyName
();
/**
* 生命周期
*/
public
created
()
{
let
appdata
=
this
.
$store
.
state
.
appdata
;
this
.
srfloginname
=
appdata
&&
appdata
.
context
&&
appdata
.
context
.
srfloginname
?
appdata
.
context
.
srfloginname
:
""
;
this
.
$viewTool
.
setViewTitleOfThirdParty
(
"设置"
);
this
.
setViewTitleStatus
();
this
.
initializeData
();
}
/**
* 视图数据
*/
public
data
:
any
=
{
top
:
[],
center
:
[],
bottom
:
[],
};
/**
* 初始化数据
*/
public
initializeData
()
{
// console.log(settingConfig);
let
data
=
[];
data
.
push
(...
settingConfig
.
default
,
...
settingConfig
.
userCustomize
);
// 分类合并
data
.
forEach
((
item
:
any
)
=>
{
if
(
item
.
position
==
"top"
)
{
this
.
data
.
top
.
push
(
item
);
}
if
(
item
.
position
==
"center"
)
{
this
.
data
.
center
.
push
(
item
);
}
if
(
item
.
position
==
"bottom"
)
{
this
.
data
.
bottom
.
push
(
item
);
}
// 多语言处理
if
(
item
.
entext
)
{
if
(
i18n
.
locale
==
"ZH-CN"
)
{
item
.
showtext
=
item
.
text
;
}
else
if
(
i18n
.
locale
==
"EN-US"
){
item
.
showtext
=
item
.
entext
;
}
}
});
// 排序规则
let
compare
=
(
property
:
any
)
=>
{
return
(
a
:
any
,
b
:
any
)
=>
{
var
value1
=
a
[
property
];
var
value2
=
b
[
property
];
return
value1
-
value2
;
};
/**
* 视图数据
*
* @memberof AppSetting
*/
public
data
:
any
=
{
top
:
[],
center
:
[],
bottom
:
[],
};
// 排序
Object
.
keys
(
this
.
data
).
forEach
((
item
:
any
)
=>
{
this
.
data
[
item
].
sort
(
compare
(
"sort"
));
});
}
/**
* 标题状态
*
*/
public
titleStatus
:
boolean
=
true
;
/**
* 设置标题状态
*
*/
public
setViewTitleStatus
()
{
const
thirdPartyName
=
this
.
$store
.
getters
.
getThirdPartyName
();
if
(
thirdPartyName
)
{
this
.
titleStatus
=
false
;
}
}
/**
* 退出登录
*/
public
async
logout
()
{
const
title
:
any
=
this
.
$t
(
"app.tabpage.sureclosetip.title"
);
const
contant
:
any
=
this
.
$t
(
"app.tabpage.sureclosetip.content"
);
const
result
=
await
this
.
$notice
.
confirm
(
title
,
"确认退出当前账号?"
);
if
(
result
)
{
if
(
this
.
thirdPartyName
)
{
this
.
$viewTool
.
ThirdPartyClose
();
return
;
}
const
get
:
Promise
<
any
>
=
this
.
$http
.
get
(
"v7/logout"
);
get
.
then
((
response
:
any
)
=>
{
if
(
response
&&
response
.
status
===
200
)
{
this
.
doLogin
();
}
})
.
catch
((
error
:
any
)
=>
{
console
.
error
(
error
);
/**
* 初始化数据
*
* @memberof AppSetting
*/
public
initializeData
()
{
let
data
=
[];
data
.
push
(...
settingConfig
.
default
,
...
settingConfig
.
userCustomize
);
// 分类合并
data
.
forEach
((
item
:
any
)
=>
{
if
(
item
.
position
==
"top"
)
{
this
.
data
.
top
.
push
(
item
);
}
if
(
item
.
position
==
"center"
)
{
this
.
data
.
center
.
push
(
item
);
}
if
(
item
.
position
==
"bottom"
)
{
this
.
data
.
bottom
.
push
(
item
);
}
// 多语言处理
if
(
item
.
entext
)
{
if
(
i18n
.
locale
==
"ZH-CN"
)
{
item
.
showtext
=
item
.
text
;
}
else
if
(
i18n
.
locale
==
"EN-US"
)
{
item
.
showtext
=
item
.
entext
;
}
}
else
{
item
.
showtext
=
item
.
text
;
}
});
// 排序规则
let
compare
=
(
property
:
any
)
=>
{
return
(
a
:
any
,
b
:
any
)
=>
{
var
value1
=
a
[
property
];
var
value2
=
b
[
property
];
return
value1
-
value2
;
};
};
// 排序
Object
.
keys
(
this
.
data
).
forEach
((
item
:
any
)
=>
{
this
.
data
[
item
].
sort
(
compare
(
"sort"
));
});
}
}
/**
* 去登录
*
*/
public
doLogin
(
data
?:
any
):
void
{
// 清除user、token
if
(
localStorage
.
getItem
(
"user"
))
{
localStorage
.
removeItem
(
"user"
);
/**
* 标题状态
*
* @memberof AppSetting
*/
public
titleStatus
:
boolean
=
true
;
/**
* 设置标题状态
*
* @memberof AppSetting
*/
public
setViewTitleStatus
()
{
const
thirdPartyName
=
this
.
$store
.
getters
.
getThirdPartyName
();
if
(
thirdPartyName
)
{
this
.
titleStatus
=
false
;
}
}
if
(
localStorage
.
getItem
(
"token"
))
{
localStorage
.
removeItem
(
"token"
);
/**
* 退出登录
*
* @memberof AppSetting
*/
public
async
logout
()
{
const
title
:
any
=
this
.
$t
(
"app.tabpage.sureclosetip.title"
);
const
contant
:
any
=
this
.
$t
(
"app.tabpage.sureclosetip.content"
);
const
result
=
await
this
.
$notice
.
confirm
(
title
,
"确认退出当前账号?"
);
if
(
result
)
{
if
(
this
.
thirdPartyName
)
{
this
.
$viewTool
.
ThirdPartyClose
();
return
;
}
const
get
:
Promise
<
any
>
=
this
.
$http
.
get
(
"v7/logout"
);
get
.
then
((
response
:
any
)
=>
{
if
(
response
&&
response
.
status
===
200
)
{
this
.
doLogin
();
}
})
.
catch
((
error
:
any
)
=>
{
console
.
error
(
error
);
});
}
}
this
.
$router
.
push
({
name
:
"login"
});
}
/**
* 清除缓存
*/
public
async
clear
()
{
const
result
=
await
this
.
$notice
.
confirm
(
"清除缓存"
,
"清除缓存可能会导致当前登录信息失效!!!"
);
if
(
result
)
{
localStorage
.
clear
();
/**
* 去登录
*
* @memberof AppSetting
*/
public
doLogin
(
data
?:
any
):
void
{
// 清除user、token
if
(
localStorage
.
getItem
(
"user"
))
{
localStorage
.
removeItem
(
"user"
);
}
if
(
localStorage
.
getItem
(
"token"
))
{
localStorage
.
removeItem
(
"token"
);
}
this
.
$router
.
push
({
name
:
"login"
});
}
}
/**
* 主题切换
*/
public
changeTheme
()
{
let
changeTheme
:
any
=
this
.
$refs
.
changeTheme
;
if
(
changeTheme
&&
changeTheme
[
0
])
{
changeTheme
[
0
].
open
();
/**
* 清除缓存
*
* @memberof AppSetting
*/
public
async
clear
()
{
const
result
=
await
this
.
$notice
.
confirm
(
"清除缓存"
,
"清除缓存可能会导致当前登录信息失效!!!"
);
if
(
result
)
{
localStorage
.
clear
();
}
}
}
/**
* 个人中心
*/
public
userCenter
()
{
const
{
context
,
param
}
=
this
.
$store
.
getters
.
getAppData
();
let
user
:
any
=
{};
if
(
context
&&
context
.
srfuserid
)
{
user
[
settingConfig
.
userEntityName
]
=
context
.
srfuserid
;
/**
* 主题切换
*
* @memberof AppSetting
*/
public
changeTheme
()
{
let
changeTheme
:
any
=
this
.
$refs
.
changeTheme
;
if
(
changeTheme
&&
changeTheme
[
0
])
{
changeTheme
[
0
].
open
();
}
}
if
(
settingConfig
.
userCenterViewName
)
{
this
.
$appmodal
.
openModal
(
{
viewname
:
settingConfig
.
userCenterViewName
,
title
:
""
},
user
);
}
else
{
this
.
$notice
.
warning
(
"用户自定义视图未配置"
);
/**
* 个人中心
*
* @memberof AppSetting
*/
public
userCenter
()
{
const
{
context
,
param
}
=
this
.
$store
.
getters
.
getAppData
();
let
user
:
any
=
{};
if
(
context
&&
context
.
srfuserid
)
{
user
[
settingConfig
.
userEntityName
]
=
context
.
srfuserid
;
}
if
(
settingConfig
.
userCenterViewName
)
{
this
.
$appmodal
.
openModal
(
{
viewname
:
settingConfig
.
userCenterViewName
,
title
:
""
},
user
);
}
else
{
this
.
$notice
.
warning
(
"用户自定义视图未配置"
);
}
}
}
/**
* 模态打开
*
*/
private
async
openPopupModal
(
view
:
any
,
context
:
any
,
param
:
any
):
Promise
<
any
>
{
const
result
:
any
=
await
this
.
$appmodal
.
openModal
(
view
,
context
,
param
);
if
(
result
||
Object
.
is
(
result
.
ret
,
"OK"
))
{
this
.
$emit
(
"change"
,
result
.
datas
[
0
].
backEnd
);
/**
* 模态打开
*
* @memberof AppSetting
*/
private
async
openPopupModal
(
view
:
any
,
context
:
any
,
param
:
any
):
Promise
<
any
>
{
const
result
:
any
=
await
this
.
$appmodal
.
openModal
(
view
,
context
,
param
);
if
(
result
||
Object
.
is
(
result
.
ret
,
"OK"
))
{
this
.
$emit
(
"change"
,
result
.
datas
[
0
].
backEnd
);
}
}
}
/**
* 语言列表
*
*/
public
lanArray
:
any
;
/**
* 语言列表
*
* @memberof AppSetting
*/
public
lanArray
:
any
;
/**
* 切换语言
*
*/
public
changeLanguage
(){
let
lanarr
:
any
=
localStorage
.
getItem
(
'lanArray'
);
this
.
lanArray
=
JSON
.
parse
(
lanarr
);
this
.
lanArray
=
this
.
lanArray
.
map
(
(
language
:
any
)
=>
language
.
indexOf
(
"ZH-CN"
)
>
-
1
?
language
.
replace
(
"ZH-CN"
,
"EN-US"
)
:
language
.
replace
(
"EN-US"
,
"ZH-CN"
));
i18n
.
locale
=
this
.
lanArray
[
0
];
localStorage
.
setItem
(
'local'
,
this
.
lanArray
[
0
]);
localStorage
.
setItem
(
'lanArray'
,
JSON
.
stringify
(
this
.
lanArray
))
;
// 提示框
if
(
this
.
lanArray
[
0
]
===
"ZH-CN"
)
{
this
.
$notice
.
success
(
'已切换为中文!'
);
}
else
if
(
this
.
lanArray
[
0
]
===
"EN-US"
){
this
.
$notice
.
success
(
'已切换为英文!'
);
/**
* 切换语言
*
* @memberof AppSetting
*/
public
changeLanguage
()
{
let
lanarr
:
any
=
localStorage
.
getItem
(
'lanArray'
);
this
.
lanArray
=
JSON
.
parse
(
lanarr
);
this
.
lanArray
=
this
.
lanArray
.
map
((
language
:
any
)
=>
language
.
indexOf
(
"ZH-CN"
)
>
-
1
?
language
.
replace
(
"ZH-CN"
,
"EN-US"
)
:
language
.
replace
(
"EN-US"
,
"ZH-CN"
));
i18n
.
locale
=
this
.
lanArray
[
0
];
localStorage
.
setItem
(
'local'
,
this
.
lanArray
[
0
]);
localStorage
.
setItem
(
'lanArray'
,
JSON
.
stringify
(
this
.
lanArray
));
// 提示框
if
(
this
.
lanArray
[
0
]
===
"ZH-CN"
)
{
this
.
$notice
.
success
(
'已切换为中文!'
);
}
else
if
(
this
.
lanArray
[
0
]
===
"EN-US"
)
{
this
.
$notice
.
success
(
'已切换为英文!'
);
}
Object
.
keys
(
this
.
data
).
forEach
((
items
:
any
)
=>
{
// 多语言处理
this
.
data
[
items
].
forEach
((
item
:
any
)
=>
{
if
(
item
.
entext
)
{
if
(
i18n
.
locale
==
"ZH-CN"
)
{
item
.
showtext
=
item
.
text
;
}
else
if
(
i18n
.
locale
==
"EN-US"
)
{
item
.
showtext
=
item
.
entext
;
}
}
})
});
this
.
$forceUpdate
();
}
Object
.
keys
(
this
.
data
).
forEach
((
items
:
any
)
=>
{
// 多语言处理
this
.
data
[
items
].
forEach
((
item
:
any
)
=>
{
if
(
item
.
entext
)
{
if
(
i18n
.
locale
==
"ZH-CN"
)
{
item
.
showtext
=
item
.
text
;
}
else
if
(
i18n
.
locale
==
"EN-US"
){
item
.
showtext
=
item
.
entext
;
}
/**
* item点击事件
*
* @memberof AppSetting
*/
public
onItemClick
(
item
:
any
)
{
// 内置功能
if
(
item
.
name
==
"accountInformation"
)
{
this
.
userCenter
();
}
else
if
(
item
.
name
==
"theme"
)
{
this
.
changeTheme
();
}
else
if
(
item
.
name
==
"layoutStyle"
)
{
this
.
openPopupModal
({
viewname
:
item
.
viewName
},
{},
{});
}
else
if
(
item
.
name
==
"logout"
)
{
this
.
logout
();
}
else
if
(
item
.
name
==
"clear"
)
{
this
.
clear
();
}
else
if
(
item
.
name
==
"language"
)
{
this
.
changeLanguage
();
}
else
{
// 自定义功能
if
(
item
.
path
)
{
this
.
$router
.
push
(
`/viewshell/null/
${
item
.
path
}
`
);
}
else
if
(
item
.
viewName
)
{
this
.
openPopupModal
({
viewname
:
item
.
viewName
},
{},
{});
}
}
})
});
this
.
$forceUpdate
();
}
}
/**
* item点击事件
*/
public
onItemClick
(
item
:
any
)
{
// 内置功能
if
(
item
.
name
==
"accountInformation"
)
{
this
.
userCenter
();
}
else
if
(
item
.
name
==
"theme"
)
{
this
.
changeTheme
();
}
else
if
(
item
.
name
==
"layoutStyle"
)
{
this
.
openPopupModal
({
viewname
:
item
.
viewName
},
{},
{});
}
else
if
(
item
.
name
==
"logout"
)
{
this
.
logout
();
}
else
if
(
item
.
name
==
"clear"
)
{
this
.
clear
();
}
else
if
(
item
.
name
==
"language"
){
this
.
changeLanguage
();
}
else
{
// 自定义功能
if
(
item
.
viewName
)
{
this
.
openPopupModal
({
viewname
:
item
.
viewName
},
{},
{});
}
/**
* 生命周期
*
* @memberof AppSetting
*/
public
created
()
{
let
appdata
=
this
.
$store
.
state
.
appdata
;
this
.
srfloginname
=
appdata
&&
appdata
.
context
&&
appdata
.
context
.
srfloginname
?
appdata
.
context
.
srfloginname
:
""
;
this
.
$viewTool
.
setViewTitleOfThirdParty
(
"设置"
);
this
.
setViewTitleStatus
();
this
.
initializeData
();
}
}
}
</
script
>
<
style
lang=
"less"
>
...
...
src/ibiz-core/components/app-setting/config.ts
浏览文件 @
5e93075c
...
...
@@ -118,6 +118,8 @@ export const settingConfig = {
// sort: "201",
// 打开视图名称
// viewName: "",
// 路由路径
// path: "",
// },
],
};
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录