From 2d80b2f2ac99219ff230b510c58139030f139d1b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=90=91=E6=96=87=E5=8F=AF?= <1041367524@qq.com>
Date: Tue, 7 Jun 2022 15:34:13 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20IM=E4=B8=AD=E5=8F=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/api/im/index.js | 105 ++++++++++++++
src/store/modules/im/chatStore.js | 78 +++++++++++
src/store/modules/im/chatSystem.js | 73 ++++++++++
src/store/modules/im/chatWaiter.js | 78 +++++++++++
src/store/modules/im/im.js | 83 +++++++++++
src/store/modules/system/notify.js | 2 +-
src/views/im/home/index.vue | 7 +
src/views/im/store/index.vue | 190 +++++++++++++++++++++++++
src/views/im/system/index.vue | 164 ++++++++++++++++++++++
src/views/im/waiter/index.vue | 216 +++++++++++++++++++++++++++++
vite.config.js | 4 +-
11 files changed, 997 insertions(+), 3 deletions(-)
create mode 100644 src/api/im/index.js
create mode 100644 src/store/modules/im/chatStore.js
create mode 100644 src/store/modules/im/chatSystem.js
create mode 100644 src/store/modules/im/chatWaiter.js
create mode 100644 src/store/modules/im/im.js
create mode 100644 src/views/im/home/index.vue
create mode 100644 src/views/im/store/index.vue
create mode 100644 src/views/im/system/index.vue
create mode 100644 src/views/im/waiter/index.vue
diff --git a/src/api/im/index.js b/src/api/im/index.js
new file mode 100644
index 0000000..aa51360
--- /dev/null
+++ b/src/api/im/index.js
@@ -0,0 +1,105 @@
+import request from '@/utils/request.js';
+export const online = () => {
+ return request({
+ url: '/im/admin/count/online',
+ method: 'get',
+ });
+};
+export const hours = (params) => {
+ return request({
+ url: '/im/admin/count/hoursMessage',
+ method: 'get',
+ params,
+ });
+};
+export const days = (params) => {
+ return request({
+ url: '/im/admin/count/daysMessage',
+ method: 'get',
+ params,
+ });
+};
+export const searchSystem = (params) => {
+ return request({
+ url: '/im/admin/thirdSystem',
+ method: 'get',
+ params,
+ });
+};
+export const createSystem = (data) => {
+ return request({
+ url: '/im/admin/thirdSystem',
+ method: 'post',
+ data,
+ });
+};
+export const updateSystem = (data) => {
+ return request({
+ url: '/im/admin/thirdSystem',
+ method: 'put',
+ data,
+ });
+};
+export const removeSystem = (data) => {
+ return request({
+ url: '/im/admin/thirdSystem',
+ method: 'delete',
+ data,
+ });
+};
+export const searchStore = (params) => {
+ return request({
+ url: '/im/admin/storeConfig',
+ method: 'get',
+ params,
+ });
+};
+export const createStore = (data) => {
+ return request({
+ url: '/im/admin/storeConfig',
+ method: 'post',
+ data,
+ });
+};
+export const updateStore = (data) => {
+ return request({
+ url: '/im/admin/storeConfig',
+ method: 'put',
+ data,
+ });
+};
+export const removeStore = (data) => {
+ return request({
+ url: '/im/admin/storeConfig',
+ method: 'delete',
+ data,
+ });
+};
+export const searchWaiter = (params) => {
+ return request({
+ url: '/im/admin/waiter',
+ method: 'get',
+ params,
+ });
+};
+export const createWaiter = (data) => {
+ return request({
+ url: '/im/admin/waiter',
+ method: 'post',
+ data,
+ });
+};
+export const updateWaiter = (data) => {
+ return request({
+ url: '/im/admin/waiter',
+ method: 'put',
+ data,
+ });
+};
+export const removeWaiter = (data) => {
+ return request({
+ url: '/im/admin/waiter',
+ method: 'delete',
+ data,
+ });
+};
diff --git a/src/store/modules/im/chatStore.js b/src/store/modules/im/chatStore.js
new file mode 100644
index 0000000..48528f4
--- /dev/null
+++ b/src/store/modules/im/chatStore.js
@@ -0,0 +1,78 @@
+import * as api from '@/api/im/index.js';
+import { ElMessage, ElMessageBox } from '@/plugins/element-plus';
+const state = () => ({
+ code: 'ChatStore',
+ condition: {},
+ list: [],
+ total: 0,
+ opts: {
+ init: false,
+ system: [],
+ },
+});
+const getters = {};
+const mutations = {
+ setCode: (state, data) => (state.code = data),
+ setCondition: (state, data) => (state.condition = data),
+ setList: (state, data) => (state.list = data),
+ setTotal: (state, data) => (state.total = data),
+ setOpts: (state, data) => (state.opts = data),
+};
+const actions = {
+ search: async ({ state, commit, rootGetters }) => {
+ let data = { ...state.condition };
+ let res = await api.searchStore({ ...rootGetters['local/page'](state.code), ...data });
+ if (res) {
+ commit('setList', res.records);
+ commit('setTotal', res.total);
+ } else {
+ ElMessage.error('查询失败');
+ commit('setList', []);
+ }
+ return res;
+ },
+ load: async ({ commit }) => {
+ commit('setOpts', {
+ init: true,
+ system: (await api.searchSystem({ pageIndex: 1, length: 9999 }))?.records || [],
+ });
+ },
+ save: async ({ dispatch }, data) => {
+ if (data.id) {
+ data.systemId = data.sysId;
+ }
+ let save = data.id ? api.updateStore : api.createStore;
+ let res = await save(data);
+ if (res) {
+ ElMessage.success('保存成功');
+ dispatch('search');
+ } else {
+ ElMessage.error('保存失败');
+ }
+ return res;
+ },
+ remove: async ({ dispatch }, ids) => {
+ if (!ids.length) {
+ ElMessage.warning('请选择要删除的数据');
+ } else {
+ try {
+ await ElMessageBox.confirm('数据删除后无法恢复,确定要删除吗?', '危险操作');
+ let res = await api.removeStore({ ids });
+ if (res) {
+ ElMessage.success('删除成功');
+ dispatch('search');
+ } else {
+ ElMessage.error('删除失败');
+ }
+ } catch (e) {
+ console.info('取消删除', e);
+ }
+ }
+ },
+};
+export default {
+ state,
+ getters,
+ mutations,
+ actions,
+};
diff --git a/src/store/modules/im/chatSystem.js b/src/store/modules/im/chatSystem.js
new file mode 100644
index 0000000..7bc9559
--- /dev/null
+++ b/src/store/modules/im/chatSystem.js
@@ -0,0 +1,73 @@
+import * as api from '@/api/im/index.js';
+import { ElMessage, ElMessageBox } from '@/plugins/element-plus';
+const state = () => ({
+ code: 'ChatSystem',
+ condition: {},
+ list: [],
+ total: 0,
+ opts: {
+ init: false,
+ },
+});
+const getters = {};
+const mutations = {
+ setCode: (state, data) => (state.code = data),
+ setCondition: (state, data) => (state.condition = data),
+ setList: (state, data) => (state.list = data),
+ setTotal: (state, data) => (state.total = data),
+ setOpts: (state, data) => (state.opts = data),
+};
+const actions = {
+ search: async ({ state, commit, rootGetters }) => {
+ let data = { ...state.condition };
+ let res = await api.searchSystem({ ...rootGetters['local/page'](state.code), ...data });
+ if (res) {
+ commit('setList', res.records);
+ commit('setTotal', res.total);
+ } else {
+ ElMessage.error('查询失败');
+ commit('setList', []);
+ }
+ return res;
+ },
+ load: async ({ commit }) => {
+ commit('setOpts', {
+ init: true,
+ });
+ },
+ save: async ({ dispatch }, data) => {
+ let save = data.id ? api.updateSystem : api.createSystem;
+ let res = await save(data);
+ if (res) {
+ ElMessage.success('保存成功');
+ dispatch('search');
+ } else {
+ ElMessage.error('保存失败');
+ }
+ return res;
+ },
+ remove: async ({ dispatch }, ids) => {
+ if (!ids.length) {
+ ElMessage.warning('请选择要删除的数据');
+ } else {
+ try {
+ await ElMessageBox.confirm('数据删除后无法恢复,确定要删除吗?', '危险操作');
+ let res = await api.removeSystem({ ids });
+ if (res) {
+ ElMessage.success('删除成功');
+ dispatch('search');
+ } else {
+ ElMessage.error('删除失败');
+ }
+ } catch (e) {
+ console.info('取消删除', e);
+ }
+ }
+ },
+};
+export default {
+ state,
+ getters,
+ mutations,
+ actions,
+};
diff --git a/src/store/modules/im/chatWaiter.js b/src/store/modules/im/chatWaiter.js
new file mode 100644
index 0000000..9ac965e
--- /dev/null
+++ b/src/store/modules/im/chatWaiter.js
@@ -0,0 +1,78 @@
+import * as api from '@/api/im/index.js';
+import { ElMessage, ElMessageBox } from '@/plugins/element-plus';
+const state = () => ({
+ code: 'ChatWaiter',
+ condition: {},
+ list: [],
+ total: 0,
+ opts: {
+ init: false,
+ system: [],
+ },
+});
+const getters = {};
+const mutations = {
+ setCode: (state, data) => (state.code = data),
+ setCondition: (state, data) => (state.condition = data),
+ setList: (state, data) => (state.list = data),
+ setTotal: (state, data) => (state.total = data),
+ setOpts: (state, data) => (state.opts = data),
+};
+const actions = {
+ search: async ({ state, commit, rootGetters }) => {
+ let data = { ...state.condition };
+ let res = await api.searchWaiter({ ...rootGetters['local/page'](state.code), ...data });
+ if (res) {
+ commit('setList', res.records);
+ commit('setTotal', res.total);
+ } else {
+ ElMessage.error('查询失败');
+ commit('setList', []);
+ }
+ return res;
+ },
+ load: async ({ commit }) => {
+ commit('setOpts', {
+ init: true,
+ system: (await api.searchSystem({ pageIndex: 1, length: 9999 }))?.records || [],
+ });
+ },
+ save: async ({ dispatch }, data) => {
+ if (data.id) {
+ data.systemId = data.sysId;
+ }
+ let save = data.id ? api.updateWaiter : api.createWaiter;
+ let res = await save(data);
+ if (res) {
+ ElMessage.success('保存成功');
+ dispatch('search');
+ } else {
+ ElMessage.error('保存失败');
+ }
+ return res;
+ },
+ remove: async ({ dispatch }, ids) => {
+ if (!ids.length) {
+ ElMessage.warning('请选择要删除的数据');
+ } else {
+ try {
+ await ElMessageBox.confirm('数据删除后无法恢复,确定要删除吗?', '危险操作');
+ let res = await api.removeWaiter({ ids });
+ if (res) {
+ ElMessage.success('删除成功');
+ dispatch('search');
+ } else {
+ ElMessage.error('删除失败');
+ }
+ } catch (e) {
+ console.info('取消删除', e);
+ }
+ }
+ },
+};
+export default {
+ state,
+ getters,
+ mutations,
+ actions,
+};
diff --git a/src/store/modules/im/im.js b/src/store/modules/im/im.js
new file mode 100644
index 0000000..535c033
--- /dev/null
+++ b/src/store/modules/im/im.js
@@ -0,0 +1,83 @@
+import * as api from '@/api/system/notify.js';
+import { ElMessage, ElMessageBox } from '@/plugins/element-plus';
+const state = () => ({
+ code: 'NotifyManagement',
+ condition: {},
+ list: [],
+ total: 0,
+ opts: {
+ init: false,
+ },
+});
+const getters = {};
+const mutations = {
+ setCode: (state, data) => (state.code = data),
+ setCondition: (state, data) => (state.condition = data),
+ setList: (state, data) => (state.list = data),
+ setTotal: (state, data) => (state.total = data),
+ setOpts: (state, data) => (state.opts = data),
+};
+const actions = {
+ search: async ({ state, commit, rootGetters }) => {
+ let data = { ...state.condition };
+ data.startReleaseTime = data.dateRange?.[0];
+ data.endReleaseTime = data.dateRange?.[1];
+ delete data.dateRange;
+ let res = await api.search({ ...rootGetters['local/page'](state.code), ...state.condition });
+ if (res) {
+ commit('setList', res.records);
+ commit('setTotal', res.total);
+ } else {
+ ElMessage.error('查询失败');
+ commit('setList', []);
+ }
+ return res;
+ },
+ load: async ({ commit }) => {
+ commit('setOpts', {
+ init: true,
+ });
+ },
+ detail: async (context, id) => {
+ let res = await api.detail(id);
+ if (!res) {
+ ElMessage.error('加载详情失败');
+ }
+ return res;
+ },
+ save: async ({ dispatch }, data) => {
+ let save = data.id ? api.update : api.create;
+ let res = await save(data);
+ if (res) {
+ ElMessage.success('保存成功');
+ dispatch('search');
+ } else {
+ ElMessage.error('保存失败');
+ }
+ return res;
+ },
+ remove: async ({ dispatch }, idList) => {
+ if (!idList.length) {
+ ElMessage.warning('请选择要删除的数据');
+ } else {
+ try {
+ await ElMessageBox.confirm('数据删除后无法恢复,确定要删除吗?', '危险操作');
+ let res = await api.remove(idList.join(','));
+ if (res) {
+ ElMessage.success('删除成功');
+ dispatch('search');
+ } else {
+ ElMessage.error('删除失败');
+ }
+ } catch (e) {
+ console.info('取消删除', e);
+ }
+ }
+ },
+};
+export default {
+ state,
+ getters,
+ mutations,
+ actions,
+};
diff --git a/src/store/modules/system/notify.js b/src/store/modules/system/notify.js
index 535c033..d4a1d55 100644
--- a/src/store/modules/system/notify.js
+++ b/src/store/modules/system/notify.js
@@ -23,7 +23,7 @@ const actions = {
data.startReleaseTime = data.dateRange?.[0];
data.endReleaseTime = data.dateRange?.[1];
delete data.dateRange;
- let res = await api.search({ ...rootGetters['local/page'](state.code), ...state.condition });
+ let res = await api.search({ ...rootGetters['local/page'](state.code), ...data });
if (res) {
commit('setList', res.records);
commit('setTotal', res.total);
diff --git a/src/views/im/home/index.vue b/src/views/im/home/index.vue
new file mode 100644
index 0000000..914fcd1
--- /dev/null
+++ b/src/views/im/home/index.vue
@@ -0,0 +1,7 @@
+
+ 在线人数
+
+
+
+
+
diff --git a/src/views/im/store/index.vue b/src/views/im/store/index.vue
new file mode 100644
index 0000000..9706e0b
--- /dev/null
+++ b/src/views/im/store/index.vue
@@ -0,0 +1,190 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 取消
+ 保存
+
+
+
+
+
+
+
+
diff --git a/src/views/im/system/index.vue b/src/views/im/system/index.vue
new file mode 100644
index 0000000..8f29ace
--- /dev/null
+++ b/src/views/im/system/index.vue
@@ -0,0 +1,164 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 取消
+
+ 保存
+
+
+
+
+
+
+
+
+
diff --git a/src/views/im/waiter/index.vue b/src/views/im/waiter/index.vue
new file mode 100644
index 0000000..80e253f
--- /dev/null
+++ b/src/views/im/waiter/index.vue
@@ -0,0 +1,216 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 取消
+ 保存
+
+
+
+
+
+
+
+
diff --git a/vite.config.js b/vite.config.js
index 611fffc..e61b7e3 100644
--- a/vite.config.js
+++ b/vite.config.js
@@ -23,9 +23,9 @@ export default (configEnv) => {
// target: 'http://192.168.10.109:8090/', // 显雨
// target: 'http://192.168.10.5:4500', // 高玉
// target: 'http://192.168.10.67:8090', // 罗战
- // target: 'http://192.168.10.93:8090', // 周渺
+ target: 'http://192.168.10.94:8090', // 周渺
// target: 'http://192.168.10.124:8090', // 舒梦娇
- target: 'https://k8s-horse-gateway.mashibing.cn/', // 测试地址
+ // target: 'https://k8s-horse-gateway.mashibing.cn/', // 测试地址
// target: 'https://you-gateway.mashibing.com', // 生产环境
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, ''),