xhj 2 лет назад
Родитель
Сommit
02f317231f
1 измененных файлов с 29 добавлено и 0 удалено
  1. 29 0
      chat/components/chat/inputbar/suit/main/main.vue

+ 29 - 0
chat/components/chat/inputbar/suit/main/main.vue

@@ -36,6 +36,8 @@
 				userMessage: "", // input 的实时值
 				isIPX: false,
 				userInfo:'',
+				about:{},
+				SENSITIVE:[],//敏感词屏蔽
 			};
 		},
 
@@ -53,6 +55,7 @@
 
 		// lifetimes
 		created() {
+			this.getConfig()
 			this.userInfo = req.getStorage('userInfo');
 			this.setData({
 				isIPX: getApp().globalData.isIPX,
@@ -68,6 +71,23 @@
 		mounted() {},
 
 		methods: {
+			getConfig() {
+				var _this = this;
+				return new Promise((res, rej) => {
+					req.g(
+						'/api/other/config',
+						data => {
+							req.setStorage('configRes', JSON.stringify(data));
+							this.about = data;
+							if(this.about.SENSITIVE){
+								this.SENSITIVE = this.about.SENSITIVE.split(',')
+							}
+							res(data);
+						},
+						true
+					);
+				});
+			},
 			focus() {
 				this.$emit("inputFocused", null, {
 					bubbles: true,
@@ -88,6 +108,15 @@
 			},
 
 			bindMessage(e) {
+				this.SENSITIVE.forEach(item=>{
+					const reg = new RegExp(item, 'g');
+					let il = item.length
+					let s = ''
+					for(let i=0;i<il;i++){
+						s = s+'*'
+					}
+					e.detail.value = e.detail.value.replace(reg, s);
+				})
 				this.setData({
 					userMessage: e.detail.value,
 				});