提交 5e93075c 编写于 作者: KK's avatar KK

格式化代码 & 修复未配置英文名称不显示文本 & 增加路由配置

上级 abe38884
...@@ -66,14 +66,7 @@ ...@@ -66,14 +66,7 @@
</ion-page> </ion-page>
</template> </template>
<script lang="ts"> <script lang="ts">
import { import { Vue, Component, Prop, Provide, Emit, Watch, } from "vue-property-decorator";
Vue,
Component,
Prop,
Provide,
Emit,
Watch,
} from "vue-property-decorator";
import { settingConfig } from "./config"; import { settingConfig } from "./config";
import i18n from '@/locale' import i18n from '@/locale'
@Component({ @Component({
...@@ -83,27 +76,24 @@ export default class AppSetting extends Vue { ...@@ -83,27 +76,24 @@ export default class AppSetting extends Vue {
/** /**
* 用户名称 * 用户名称
*
* @type {string}
* @memberof AppSetting
*/ */
public srfloginname = ""; public srfloginname = "";
/** /**
* 第三方服务 * 第三方服务
*
* @type {string}
* @memberof AppSetting
*/ */
public thirdPartyName = this.$viewTool.getThirdPartyName(); 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();
}
/** /**
* 视图数据 * 视图数据
*
* @memberof AppSetting
*/ */
public data: any = { public data: any = {
top: [], top: [],
...@@ -113,9 +103,10 @@ export default class AppSetting extends Vue { ...@@ -113,9 +103,10 @@ export default class AppSetting extends Vue {
/** /**
* 初始化数据 * 初始化数据
*
* @memberof AppSetting
*/ */
public initializeData() { public initializeData() {
// console.log(settingConfig);
let data = []; let data = [];
data.push(...settingConfig.default, ...settingConfig.userCustomize); data.push(...settingConfig.default, ...settingConfig.userCustomize);
// 分类合并 // 分类合并
...@@ -133,9 +124,11 @@ export default class AppSetting extends Vue { ...@@ -133,9 +124,11 @@ export default class AppSetting extends Vue {
if (item.entext) { if (item.entext) {
if (i18n.locale == "ZH-CN") { if (i18n.locale == "ZH-CN") {
item.showtext = item.text; item.showtext = item.text;
} else if (i18n.locale == "EN-US"){ } else if (i18n.locale == "EN-US") {
item.showtext = item.entext; item.showtext = item.entext;
} }
} else {
item.showtext = item.text;
} }
}); });
// 排序规则 // 排序规则
...@@ -155,12 +148,14 @@ export default class AppSetting extends Vue { ...@@ -155,12 +148,14 @@ export default class AppSetting extends Vue {
/** /**
* 标题状态 * 标题状态
* *
* @memberof AppSetting
*/ */
public titleStatus: boolean = true; public titleStatus: boolean = true;
/** /**
* 设置标题状态 * 设置标题状态
* *
* @memberof AppSetting
*/ */
public setViewTitleStatus() { public setViewTitleStatus() {
const thirdPartyName = this.$store.getters.getThirdPartyName(); const thirdPartyName = this.$store.getters.getThirdPartyName();
...@@ -171,6 +166,8 @@ export default class AppSetting extends Vue { ...@@ -171,6 +166,8 @@ export default class AppSetting extends Vue {
/** /**
* 退出登录 * 退出登录
*
* @memberof AppSetting
*/ */
public async logout() { public async logout() {
const title: any = this.$t("app.tabpage.sureclosetip.title"); const title: any = this.$t("app.tabpage.sureclosetip.title");
...@@ -196,6 +193,7 @@ export default class AppSetting extends Vue { ...@@ -196,6 +193,7 @@ export default class AppSetting extends Vue {
/** /**
* 去登录 * 去登录
* *
* @memberof AppSetting
*/ */
public doLogin(data?: any): void { public doLogin(data?: any): void {
// 清除user、token // 清除user、token
...@@ -210,6 +208,8 @@ export default class AppSetting extends Vue { ...@@ -210,6 +208,8 @@ export default class AppSetting extends Vue {
/** /**
* 清除缓存 * 清除缓存
*
* @memberof AppSetting
*/ */
public async clear() { public async clear() {
const result = await this.$notice.confirm("清除缓存", "清除缓存可能会导致当前登录信息失效!!!"); const result = await this.$notice.confirm("清除缓存", "清除缓存可能会导致当前登录信息失效!!!");
...@@ -220,6 +220,8 @@ export default class AppSetting extends Vue { ...@@ -220,6 +220,8 @@ export default class AppSetting extends Vue {
/** /**
* 主题切换 * 主题切换
*
* @memberof AppSetting
*/ */
public changeTheme() { public changeTheme() {
let changeTheme: any = this.$refs.changeTheme; let changeTheme: any = this.$refs.changeTheme;
...@@ -230,6 +232,8 @@ export default class AppSetting extends Vue { ...@@ -230,6 +232,8 @@ export default class AppSetting extends Vue {
/** /**
* 个人中心 * 个人中心
*
* @memberof AppSetting
*/ */
public userCenter() { public userCenter() {
const { context, param } = this.$store.getters.getAppData(); const { context, param } = this.$store.getters.getAppData();
...@@ -250,6 +254,7 @@ export default class AppSetting extends Vue { ...@@ -250,6 +254,7 @@ export default class AppSetting extends Vue {
/** /**
* 模态打开 * 模态打开
* *
* @memberof AppSetting
*/ */
private async openPopupModal(view: any, context: any, param: any): Promise<any> { private async openPopupModal(view: any, context: any, param: any): Promise<any> {
const result: any = await this.$appmodal.openModal(view, context, param); const result: any = await this.$appmodal.openModal(view, context, param);
...@@ -261,33 +266,35 @@ export default class AppSetting extends Vue { ...@@ -261,33 +266,35 @@ export default class AppSetting extends Vue {
/** /**
* 语言列表 * 语言列表
* *
* @memberof AppSetting
*/ */
public lanArray:any; public lanArray: any;
/** /**
* 切换语言 * 切换语言
* *
* @memberof AppSetting
*/ */
public changeLanguage(){ public changeLanguage() {
let lanarr:any = localStorage.getItem('lanArray'); let lanarr: any = localStorage.getItem('lanArray');
this.lanArray = JSON.parse(lanarr); 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")); 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]; i18n.locale = this.lanArray[0];
localStorage.setItem('local',this.lanArray[0]); localStorage.setItem('local', this.lanArray[0]);
localStorage.setItem('lanArray',JSON.stringify(this.lanArray)) ; localStorage.setItem('lanArray', JSON.stringify(this.lanArray));
// 提示框 // 提示框
if (this.lanArray[0] === "ZH-CN") { if (this.lanArray[0] === "ZH-CN") {
this.$notice.success('已切换为中文!'); this.$notice.success('已切换为中文!');
} else if (this.lanArray[0] === "EN-US"){ } else if (this.lanArray[0] === "EN-US") {
this.$notice.success('已切换为英文!'); this.$notice.success('已切换为英文!');
} }
Object.keys(this.data).forEach((items: any) => { Object.keys(this.data).forEach((items: any) => {
// 多语言处理 // 多语言处理
this.data[items].forEach((item:any)=>{ this.data[items].forEach((item: any) => {
if (item.entext) { if (item.entext) {
if (i18n.locale == "ZH-CN") { if (i18n.locale == "ZH-CN") {
item.showtext = item.text; item.showtext = item.text;
} else if (i18n.locale == "EN-US"){ } else if (i18n.locale == "EN-US") {
item.showtext = item.entext; item.showtext = item.entext;
} }
} }
...@@ -298,6 +305,8 @@ export default class AppSetting extends Vue { ...@@ -298,6 +305,8 @@ export default class AppSetting extends Vue {
/** /**
* item点击事件 * item点击事件
*
* @memberof AppSetting
*/ */
public onItemClick(item: any) { public onItemClick(item: any) {
// 内置功能 // 内置功能
...@@ -311,15 +320,30 @@ export default class AppSetting extends Vue { ...@@ -311,15 +320,30 @@ export default class AppSetting extends Vue {
this.logout(); this.logout();
} else if (item.name == "clear") { } else if (item.name == "clear") {
this.clear(); this.clear();
} else if (item.name == "language"){ } else if (item.name == "language") {
this.changeLanguage(); this.changeLanguage();
} else { } else {
// 自定义功能 // 自定义功能
if (item.viewName) { if (item.path) {
this.$router.push(`/viewshell/null/${item.path}`);
} else if (item.viewName) {
this.openPopupModal({ viewname: 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> </script>
<style lang="less"> <style lang="less">
......
...@@ -118,6 +118,8 @@ export const settingConfig = { ...@@ -118,6 +118,8 @@ export const settingConfig = {
// sort: "201", // sort: "201",
// 打开视图名称 // 打开视图名称
// viewName: "", // viewName: "",
// 路由路径
// path: "",
// }, // },
], ],
}; };
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册