zhaobao 1 年之前
父节点
当前提交
7109d28913

+ 3 - 3
package.json

@@ -38,7 +38,6 @@
     "screenfull": "4.2.0",
     "script-loader": "0.7.2",
     "sortablejs": "1.8.4",
-    "tui-editor": "1.3.3",
     "vue": "2.6.10",
     "vue-count-to": "1.0.13",
     "vue-router": "3.0.2",
@@ -67,14 +66,15 @@
     "husky": "1.3.1",
     "lint-staged": "8.1.5",
     "mockjs": "1.0.1-beta3",
-    "node-sass": "^4.14.1",
     "plop": "2.3.0",
+    "province-city-china": "^8.0.0",
     "runjs": "4.3.2",
+    "sass": "1.26.8",
     "sass-loader": "8.0.2",
     "script-ext-html-webpack-plugin": "2.1.3",
     "serve-static": "1.13.2",
     "svg-sprite-loader": "4.1.3",
-    "svgo": "1.2.0",
+    "svgo": "1.2.2",
     "vue-template-compiler": "2.6.10"
   },
   "browserslist": [

+ 0 - 31
src/components/MarkdownEditor/default-options.js

@@ -1,31 +0,0 @@
-// doc: https://nhnent.github.io/tui.editor/api/latest/ToastUIEditor.html#ToastUIEditor
-export default {
-  minHeight: '200px',
-  previewStyle: 'vertical',
-  useCommandShortcut: true,
-  useDefaultHTMLSanitizer: true,
-  usageStatistics: false,
-  hideModeSwitch: false,
-  toolbarItems: [
-    'heading',
-    'bold',
-    'italic',
-    'strike',
-    'divider',
-    'hr',
-    'quote',
-    'divider',
-    'ul',
-    'ol',
-    'task',
-    'indent',
-    'outdent',
-    'divider',
-    'table',
-    'image',
-    'link',
-    'divider',
-    'code',
-    'codeblock'
-  ]
-}

+ 0 - 118
src/components/MarkdownEditor/index.vue

@@ -1,118 +0,0 @@
-<template>
-  <div :id="id" />
-</template>
-
-<script>
-// deps for editor
-import 'codemirror/lib/codemirror.css' // codemirror
-import 'tui-editor/dist/tui-editor.css' // editor ui
-import 'tui-editor/dist/tui-editor-contents.css' // editor content
-
-import Editor from 'tui-editor'
-import defaultOptions from './default-options'
-
-export default {
-  name: 'MarkdownEditor',
-  props: {
-    value: {
-      type: String,
-      default: ''
-    },
-    id: {
-      type: String,
-      required: false,
-      default() {
-        return 'markdown-editor-' + +new Date() + ((Math.random() * 1000).toFixed(0) + '')
-      }
-    },
-    options: {
-      type: Object,
-      default() {
-        return defaultOptions
-      }
-    },
-    mode: {
-      type: String,
-      default: 'markdown'
-    },
-    height: {
-      type: String,
-      required: false,
-      default: '300px'
-    },
-    language: {
-      type: String,
-      required: false,
-      default: 'en_US' // https://github.com/nhnent/tui.editor/tree/master/src/js/langs
-    }
-  },
-  data() {
-    return {
-      editor: null
-    }
-  },
-  computed: {
-    editorOptions() {
-      const options = Object.assign({}, defaultOptions, this.options)
-      options.initialEditType = this.mode
-      options.height = this.height
-      options.language = this.language
-      return options
-    }
-  },
-  watch: {
-    value(newValue, preValue) {
-      if (newValue !== preValue && newValue !== this.editor.getValue()) {
-        this.editor.setValue(newValue)
-      }
-    },
-    language(val) {
-      this.destroyEditor()
-      this.initEditor()
-    },
-    height(newValue) {
-      this.editor.height(newValue)
-    },
-    mode(newValue) {
-      this.editor.changeMode(newValue)
-    }
-  },
-  mounted() {
-    this.initEditor()
-  },
-  destroyed() {
-    this.destroyEditor()
-  },
-  methods: {
-    initEditor() {
-      this.editor = new Editor({
-        el: document.getElementById(this.id),
-        ...this.editorOptions
-      })
-      if (this.value) {
-        this.editor.setValue(this.value)
-      }
-      this.editor.on('change', () => {
-        this.$emit('input', this.editor.getValue())
-      })
-    },
-    destroyEditor() {
-      if (!this.editor) return
-      this.editor.off('change')
-      this.editor.remove()
-    },
-    setValue(value) {
-      this.editor.setValue(value)
-    },
-    getValue() {
-      return this.editor.getValue()
-    },
-    setHtml(value) {
-      this.editor.setHtml(value)
-    },
-    getHtml() {
-      return this.editor.getHtml()
-    }
-  }
-}
-</script>

+ 110 - 110
src/components/MyChat/IChat/src/store/index.js

@@ -1,151 +1,151 @@
+/* eslint-disable no-unused-vars */
 import Watcher from './watcher'
 
 /**
  *  channel 的数据过滤列表
  */
-const channel_group_model = ["id", 'name', 'type', 'userList', 'notices', 'avatar'];
-const channel_friend_model = ["id", 'name', 'type', 'online', 'avatar'];
+const channel_group_model = ['id', 'name', 'type', 'userList', 'notices', 'avatar']
+const channel_friend_model = ['id', 'name', 'type', 'online', 'avatar']
 
+// eslint-disable-next-line no-unused-vars
 import { setCache, removeCache } from './cache'
 
 /**
  * cache key
  */
 const key_channels = 'key_channels'
+// eslint-disable-next-line no-unused-vars
 const key_sys_msg = 'key_sys_msg'
 
-
 Watcher.prototype.mutations = {
 
-    setFriends(states, friends) {
-        states.friends = friends;
-    },
-    // 针对单人删除
-    setFriend(states, item) {
-
-    },
+  setFriends(states, friends) {
+    states.friends = friends
+  },
+  // 针对单人删除
+  setFriend(states, item) {
 
-    setGroups(states, groups) {
-        states.groups = groups;
-    },
-    //对话排序变更
-    changeChannel() {
+  },
 
+  setGroups(states, groups) {
+    states.groups = groups
+  },
+  // 对话排序变更
+  changeChannel() {
 
-    },
-    // 插入对话
-    insertChannel(states, channel) {
-        states.channel.unshift(filterChannelParams(channel));
-        setCache(key_channels, states.channel);
-    },
-    // 替换
-    replaceChannel(states, channel) {
-        const { id, type } = channel;
-        let len = states.channel.length;
-        if (len < 1) {
-            return
-        }
-        for (let i = 0; i < len; i++) {
-            let model = states.channel[i]
-            if (model.id === id && model.type === type) {
-                replaceChannelParams(channel, model);
-                break;
-            }
-        }
-        setCache(key_channels, states.channel);
-    },
-    // 删除对话
-    removeChannel(states, index) {
-        // delete 会留下  空项
-        // delete states.channel[index]
-        states.channel.splice(index, 1)
-        setCache(key_channels, states.channel);
-    },
-    //设置系统消息
-    setSystemMessage(states, data) {
-        states.systemMessage.messages = data;
-    },
-    // 插入新的消息
-    updateSystemMessage(states, message) {
-        let len = states.systemMessage.messages.length;
-        let mark = -1;
-        for (let i = 0; i < len; i++) {
-            let item = states.systemMessage.messages[i];
-            if (item.id === message.id) {
-                mark = i;
-                break;
-            }
-        }
-        if (mark < 0) {
-            states.systemMessage.messages.push(message);
-        } else {
-            states.systemMessage.messages[mark] = message;
-        }
+  },
+  // 插入对话
+  insertChannel(states, channel) {
+    states.channel.unshift(filterChannelParams(channel))
+    setCache(key_channels, states.channel)
+  },
+  // 替换
+  replaceChannel(states, channel) {
+    const { id, type } = channel
+    const len = states.channel.length
+    if (len < 1) {
+      return
     }
+    for (let i = 0; i < len; i++) {
+      const model = states.channel[i]
+      if (model.id === id && model.type === type) {
+        replaceChannelParams(channel, model)
+        break
+      }
+    }
+    setCache(key_channels, states.channel)
+  },
+  // 删除对话
+  removeChannel(states, index) {
+    // delete 会留下  空项
+    // delete states.channel[index]
+    states.channel.splice(index, 1)
+    setCache(key_channels, states.channel)
+  },
+  // 设置系统消息
+  setSystemMessage(states, data) {
+    states.systemMessage.messages = data
+  },
+  // 插入新的消息
+  updateSystemMessage(states, message) {
+    const len = states.systemMessage.messages.length
+    let mark = -1
+    for (let i = 0; i < len; i++) {
+      const item = states.systemMessage.messages[i]
+      if (item.id === message.id) {
+        mark = i
+        break
+      }
+    }
+    if (mark < 0) {
+      states.systemMessage.messages.push(message)
+    } else {
+      states.systemMessage.messages[mark] = message
+    }
+  }
 }
 
 function indexSystemMessage(list = []) {
-    let channels = list;
-    let len = channels.length;
-    for (let i = 0; i < len; i++) {
-        let model = channels[i]
-        if (model.id === -1 && model.type === "sys_msg") {
-            return i;
-        }
+  const channels = list
+  const len = channels.length
+  for (let i = 0; i < len; i++) {
+    const model = channels[i]
+    if (model.id === -1 && model.type === 'sys_msg') {
+      return i
     }
+  }
 }
 /**
- * 
+ *
  *  过滤一些非必要属性
- * @param {*} channel 
+ * @param {*} channel
  */
 function filterChannelParams(channel) {
-    let data = {}, filters = [];
-    if (channel.type === 'group') {
-        filters = channel_group_model;
-    } else if (channel.type === 'friend') {
-        filters = channel_friend_model;
-    } else if (channel.type === 'sys_msg') {
-        return channel;
-    }
+  const data = {}; let filters = []
+  if (channel.type === 'group') {
+    filters = channel_group_model
+  } else if (channel.type === 'friend') {
+    filters = channel_friend_model
+  } else if (channel.type === 'sys_msg') {
+    return channel
+  }
 
-    for (let key of filters) {
-        data[key] = channel[key];
-    }
-    return data;
+  for (const key of filters) {
+    data[key] = channel[key]
+  }
+  return data
 }
 
 /**
- * 
+ *
  * 上面注释掉的方法是为了警示自己。
  * 上方 的方法和这个方法的本质差别在于一个是过滤出新的对象,一个是改变对象的引用
  * 对应组件中改变的是chat这个属性,里面内容改变vue是无法监听到的。
- * 
- * @param {*} data 
- * @param {*} channel 
+ *
+ * @param {*} data
+ * @param {*} channel
  */
 function replaceChannelParams(data, channel) {
-    let filters = [];
-    if (data.type === 'group') {
-        filters = channel_group_model;
-    } else if (data.type === 'friend') {
-        filters = channel_friend_model;
-    } else if (data.type === 'sys_msg') {
-        channel = data;
-    }
-    for (let key of filters) {
-        channel[key] = data[key];
-    }
+  let filters = []
+  if (data.type === 'group') {
+    filters = channel_group_model
+  } else if (data.type === 'friend') {
+    filters = channel_friend_model
+  } else if (data.type === 'sys_msg') {
+    channel = data
+  }
+  for (const key of filters) {
+    channel[key] = data[key]
+  }
 }
 
-
 // 提交属性
-Watcher.prototype.commit = function (name, ...args) {
-    const mutations = this.mutations;
-    if (mutations[name]) {
-        mutations[name].apply(this, [this.states].concat(args));
-    } else {
-        throw new Error(`Action not found: ${name}`);
-    }
-};
-export default Watcher;
+Watcher.prototype.commit = function(name, ...args) {
+  const mutations = this.mutations
+  if (mutations[name]) {
+    mutations[name].apply(this, [this.states].concat(args))
+  } else {
+    throw new Error(`Action not found: ${name}`)
+  }
+}
+export default Watcher

+ 2 - 2
src/config/index.js

@@ -1,7 +1,7 @@
 export default {
   baseUrl: {
-    // dev: 'http://192.168.3.164:1000', // qu
-    dev: 'http://8.142.77.51:1000', // test
+    dev: 'http://192.168.3.164:1000', // qu
+    // dev: 'http://8.142.77.51:1000', // test
     pro: 'http://8.142.77.51:1000',
     devSocketUrl: 'ws://192.168.3.164:1000/websocket', // qu
     // devSocketUrl: 'ws://8.142.77.51:1000/websocket', // test

+ 59 - 60
src/libs/rongcloud.js

@@ -1,102 +1,101 @@
 import Vue from 'vue'
 import * as RongIMLib from '@rongcloud/imlib-v4'
-const im = RongIMLib.init({ appkey:"mgb7ka1nm7yeg"}); 
+const im = RongIMLib.init({ appkey: 'mgb7ka1nm7yeg' })
 
-export function rongcloudInit(params){
-    Vue.prototype.rongcloudIM=im;
-    im.watch({
-        // 监听会话列表变更事件
-        conversation (event) {
-          if(params.conversation){
-            params.conversation(event)
-          }
-        },
-        // 监听消息通知
-        message (event) {
-          const message = event.message;
-          if(params.receiveMsg){
-            params.receiveMsg(message)
-          }
-        },
-        // 监听 IM 连接状态变化
-        status (event) {
-          console.log('监听 IM 连接状态变化connection status:', event.status);  
-            if(params.status){
-                params.status(event)
-            }
-        },
-        // 监听聊天室 KV 数据变更
-        chatroom (event) {
-          /**
+export function rongcloudInit(params) {
+  Vue.prototype.rongcloudIM = im
+  im.watch({
+    // 监听会话列表变更事件
+    conversation(event) {
+      if (params.conversation) {
+        params.conversation(event)
+      }
+    },
+    // 监听消息通知
+    message(event) {
+      const message = event.message
+      if (params.receiveMsg) {
+        params.receiveMsg(message)
+      }
+    },
+    // 监听 IM 连接状态变化
+    status(event) {
+      console.log('监听 IM 连接状态变化connection status:', event.status)
+      if (params.status) {
+        params.status(event)
+      }
+    },
+    // 监听聊天室 KV 数据变更
+    chatroom(event) {
+      /**
            * 聊天室 KV 存储数据更新
            * @example
            * [
            *  {
            *    'key': 'name',
            *    'value': '我是小融融',
-           *    'timestamp': 1597591258338, 
-           *    'chatroomId': 'z002', 
+           *    'timestamp': 1597591258338,
+           *    'chatroomId': 'z002',
            *    'type': 1 // 1: 更新( 含:修改和新增 )、2: 删除
            *  },
            * ]
            */
-          const updatedEntries = event.updatedEntries
-            if(params.updatedEntries){
-                params.updatedEntries(updatedEntries)
-            }
-        },
-        expansion (event) {
-          /**
+      const updatedEntries = event.updatedEntries
+      if (params.updatedEntries) {
+        params.updatedEntries(updatedEntries)
+      }
+    },
+    expansion(event) {
+      /**
            * 更新的消息拓展数据
            * @example {
            *    expansion: { key: 'value' },      // 设置或更新的扩展值
            *    messageUId: 'URIT-URIT-ODMF-DURR' // 设置或更新扩展的消息 uid
            * }
            */
-          //const updatedExpansion = event.updatedExpansion;
-          /**
+      // const updatedExpansion = event.updatedExpansion;
+      /**
            * 删除的消息拓展数据
            * @example {
            *    deletedKeys: ['key1', 'key2'],    // 设置或更新的扩展值
            *    messageUId: 'URIT-URIT-ODMF-DURR' // 设置或更新扩展的消息 uid
            * }
            */
-          const deletedExpansion = event.deletedExpansion;
-            if(params.deletedExpansion){
-                params.deletedExpansion(deletedExpansion)
-            }          
-        }
-      });     
+      const deletedExpansion = event.deletedExpansion
+      if (params.deletedExpansion) {
+        params.deletedExpansion(deletedExpansion)
+      }
+    }
+  })
 }
-export function connect({token}) {
-      im.connect({ token}).then(user => {
-        console.log('链接成功, 链接用户 id 为: ', user.id);
-      }).catch(error => {
-        console.log('链接失败: ', error.code, error.msg);
-      });
+export function connect({ token }) {
+  im.connect({ token }).then(user => {
+    console.log('链接成功, 链接用户 id 为: ', user.id)
+  }).catch(error => {
+    console.log('链接失败: ', error.code, error.msg)
+  })
 }
-    // 向会话内发消息
-export function sendMsg({sendmessage,targetId}) {
-  return new Promise(function(resolve,reject){
+// 向会话内发消息
+export function sendMsg({ sendmessage, targetId }) {
+  return new Promise(function(resolve, reject) {
     const conversation = im.Conversation.get({
       // targetId
       targetId,
       // 会话类型:RongIMLib.CONVERSATION_TYPE.PRIVATE | RongIMLib.CONVERSATION_TYPE.GROUP
       type: RongIMLib.CONVERSATION_TYPE.PRIVATE
-    });				
+    })
     conversation.send({
       // 消息类型,其中 RongIMLib.MESSAGE_TYPE 为 IMLib 内部的内置消息类型常量定义
       messageType: RongIMLib.MESSAGE_TYPE.TEXT, // 'RC:TxtMsg'
       // 消息内容
       content: {
-        content:sendmessage // 文本内容
+        content: sendmessage // 文本内容
       }
-    }).then(function(message){
+    }).then(function(message) {
       resolve(message)
     }).catch(error => {
       reject(error)
-      console.log('发送文字消息失败', error.code, error.msg);
-    });
+      console.log('发送文字消息失败', error.code, error.msg)
+    })
   })
-
-}				
+}