const tl_rtc_app_module_setting_content = { props: { socket: { type: Object, default: null }, isMobile:{ type: Boolean, default: false }, user: { type: Object, default: null }, company: { type: Object, default: null }, leftModule: { type: String, default: '' }, rightModule: { type: String, default: '' } }, computed: { propsSocket(){ return this.socket; }, propsIsMobile(){ return this.isMobile; }, propsUser(){ return this.user }, propsCompany(){ return this.company }, propsLeftModule() { return this.leftModule; }, propsRightModule() { return this.rightModule; }, }, watch: { leftModule: function (val) { }, rightModule: function (val) { } }, data : function(){ return { settingType : 'normal', // 设置类型 } }, methods: { /** * 事件触发,向上传递 * @param {*} event */ leftModuleChange: function(event){ this.$emit('left-module-change', event) }, /** * 事件触发,向上传递 * @param {*} event */ rightModuleChange: function(event){ this.$emit('right-module-change', event) }, /** * 设置模块数据变更 * @param {*} data */ moduleDataChange: function({ settingType, callback }){ this.settingType = settingType callback && callback() }, /** * 回退 */ goBack: function(){ this.emitSubModuleEvent({ event: 'sub-module-core-change-module-show', data: { showRightModule: false, } }) }, /** * 更新用户通用设置 */ updateUserConfigNormal: async function(updateNormalSetting){ let params = { normal: updateNormalSetting } if(!window.tl_rtc_app_comm.checkRequestParams(params)){ this.popErrorMsg("请求参数非法") return } const { data: userConfigRes } = await this.tlRequest({ url: '/api/web/user-config/update-user-config-normal', method: 'post', useCache: false, data: params, }) if(!userConfigRes.success){ this.popErrorMsg(userConfigRes.msg) return } this.emitSubModuleEvent({ event: 'sub-module-core-user-setting-change', data: { normalSetting: updateNormalSetting } }) this.popSuccessMsg(userConfigRes.msg) }, /** * 更新用户帐号设置 */ updateUserConfigAccount: async function(updateAccountSetting){ let params = { account: updateAccountSetting } if(!window.tl_rtc_app_comm.checkRequestParams(params)){ this.popErrorMsg("请求参数非法") return } const { data: userConfigRes } = await this.tlRequest({ url: '/api/web/user-config/update-user-config-account', method: 'post', useCache: false, data: params, }) if(!userConfigRes.success){ this.popErrorMsg(userConfigRes.msg) return } this.emitSubModuleEvent({ event: 'sub-module-core-user-setting-change', data: { accountSetting: updateAccountSetting } }) this.popSuccessMsg(userConfigRes.msg) }, /** * 更新用户消息设置 */ updateUserConfigMessage: async function(updateMessageSetting){ let params = { message: updateMessageSetting } if(updateMessageSetting.webNotify){ if (window.Notification) { if(Notification.permission !== "granted"){ Notification.requestPermission(function (status) { if (Notification.permission !== status) { Notification.permission = status; } }); } }else{ that.popWarningMsg('浏览器不支持消息通知') updateMessageSetting.webNotify = false } } if(!window.tl_rtc_app_comm.checkRequestParams(params)){ this.popErrorMsg("请求参数非法") return } const { data: userConfigRes } = await this.tlRequest({ url: '/api/web/user-config/update-user-config-message', method: 'post', useCache: false, data: params, }) if(!userConfigRes.success){ this.popErrorMsg(userConfigRes.msg) return } this.emitSubModuleEvent({ event: 'sub-module-core-user-setting-change', data: { messageSetting: updateMessageSetting } }) this.popSuccessMsg(userConfigRes.msg) }, /** * 更新用户皮肤设置 */ updateUserConfigSkin: async function(udpateSkinSetting){ let params = { skin: udpateSkinSetting } if(!window.tl_rtc_app_comm.checkRequestParams(params)){ this.popErrorMsg("请求参数非法") return } const { data: userConfigRes } = await this.tlRequest({ url: '/api/web/user-config/update-user-config-skin', method: 'post', useCache: false, data: params, }) if(!userConfigRes.success){ this.popErrorMsg(userConfigRes.msg) return } this.emitSubModuleEvent({ event: 'sub-module-core-user-setting-change', data: { skinSetting: udpateSkinSetting } }) this.popSuccessMsg(userConfigRes.msg) }, /** * 更新用户其他设置 */ updateUserConfigOther: async function(updateOtherSetting){ let params = { other: updateOtherSetting } if(updateOtherSetting.customWss){ const isWssHost = window.tl_rtc_app_comm.isWssHost(updateOtherSetting.customWss) if(!isWssHost){ this.popWarningMsg('自定义socket服务器地址格式不正确') return } } if(!window.tl_rtc_app_comm.checkRequestParams(params)){ this.popErrorMsg("请求参数非法") return } const { data: userConfigRes } = await this.tlRequest({ url: '/api/web/user-config/update-user-config-other', method: 'post', useCache: false, data: params, }) if(!userConfigRes.success){ this.popErrorMsg(userConfigRes.msg) return } this.emitSubModuleEvent({ event: 'sub-module-core-user-setting-change', data: { otherSetting: updateOtherSetting } }) this.popSuccessMsg(userConfigRes.msg) }, /** * 清除当前用户缓存(服务端 + 浏览器请求缓存) */ clearSelfCache: async function(){ const { data: res } = await this.tlRequest({ url: '/api/web/user-clear/clear-self-cache', method: 'post', useCache: false, data: {}, }) if(!res || !res.success){ this.popErrorMsg((res && res.msg) || '清除缓存失败') return } const token = window.localStorage.getItem('token') || '' if(token){ await this.emitSubModuleEvent({ event: 'component-cache-del', data: { subKeys: [token + ':'] } }) } this.popSuccessMsg('清除缓存成功') } }, mounted: function() { }, created(){ // 监听子模块数据变更 window.subModule.$on('sub-module-setting-content-data-change', this.moduleDataChange) }, components : { 'tl_rtc_app_module_setting_content_normal': window.tl_rtc_app_module_setting_content_normal, 'tl_rtc_app_module_setting_content_account': window.tl_rtc_app_module_setting_content_account, 'tl_rtc_app_module_setting_content_message': window.tl_rtc_app_module_setting_content_message, 'tl_rtc_app_module_setting_content_skin': window.tl_rtc_app_module_setting_content_skin, 'tl_rtc_app_module_setting_content_other': window.tl_rtc_app_module_setting_content_other, }, template: `
`, } window.tl_rtc_app_module_setting_content = tl_rtc_app_module_setting_content