diff --git a/.env.development b/.env.development index b88f3b6..4c00480 100644 --- a/.env.development +++ b/.env.development @@ -1,11 +1,8 @@ # 开发环境配置 -# ENV = 'development' +ENV = 'development' -# 路由懒加载 -# VUE_CLI_BABEL_TRANSPILE_MODULES = true +# 开发环境 +VUE_APP_BASE_API = '/dev-api' -# pei你看雪博客/开发环境/websocket地址 +# 开发环境websocket地址 VUE_APP_SOCKET = 'ws://localhost:8068/websocket' - -# 若依管理系统/开发环境 -VUE_APP_BASE_API = 'https://pnkx.top/prod-api' diff --git a/.env.production b/.env.production index ead3e4b..ff72e93 100644 --- a/.env.production +++ b/.env.production @@ -1,8 +1,8 @@ # 生产环境配置 ENV = 'production' -# pei你看雪博客/开发环境/websocket地址 -VUE_APP_SOCKET = 'wss://pnkx.top/websocket/websocket' - -# 若依管理系统/开发环境 +# 生产环境 VUE_APP_BASE_API = '/prod-api' + +# 生产环境websocket地址 +VUE_APP_SOCKET = 'wss://pnkx.top/websocket/websocket' diff --git a/package.json b/package.json index 0f4f680..94ba6bc 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,6 @@ "core-js": "^3.6.5", "element-ui": "^2.13.2", "es6-promise": "^4.2.8", - "js-cookie": "^2.2.1", "node-sass": "^4.14.1", "sass-loader": "^8.0.0", "vue": "^2.6.11", @@ -35,8 +34,8 @@ "eslint-plugin-promise": "^4.2.1", "eslint-plugin-standard": "^4.0.0", "eslint-plugin-vue": "^6.2.2", - "less": "^3.0.4", - "less-loader": "^7.3.0", + "sass": "1.32.0", + "sass-loader": "10.1.0", "vue-template-compiler": "^2.6.11" } } diff --git a/src/App.vue b/src/App.vue index bf94ed5..d4d76af 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,10 +1,21 @@ - diff --git a/src/api/index.js b/src/api/index.js index b900c02..d86e7ef 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -1,22 +1,32 @@ -import request from '../utils/request' +import request from '@/utils/request' /** -* 发送信息 -*/ -export function sendMessage(params) { + * 登录聊天室 + */ +export function loginChat () { return request({ - url: '/customer/sendMessage', + url: '/admin/chat/loginChat', + method: 'post' + }) +} + +/** + * 发送信息 + */ +export function sendMessage (params) { + return request({ + url: '/admin/chat/sendMessage', method: 'post', data: params }) } /** - * 登录聊天室 + * 获取信息 */ -export function loginChat(params) { +export function getMessageRecord (params) { return request({ - url: '/customer/loginChat', + url: '/admin/chat/getMessageRecord', method: 'post', data: params }) @@ -25,11 +35,35 @@ export function loginChat(params) { /** * 退出聊天室 */ -export function signOut(params) { +export function signOut (params) { return request({ - url: '/customer/signOut', + url: '/admin/chat/signOut', method: 'post', data: params }) } +// 查询文件记录列表 +export function listFile (query) { + return request({ + url: '/system/file/list', + method: 'get', + params: query + }) +} + +// 根据字典类型查询字典数据信息 +export function getDicts (dictType) { + return request({ + url: '/client/dictType/' + dictType, + method: 'get' + }) +} + +// 获取用户详细信息 +export function getInfo () { + return request({ + url: '/getInfo', + method: 'get' + }) +} diff --git a/src/assets/images/emoji/emoji.png b/src/assets/images/emoji/emoji.png new file mode 100644 index 0000000..6065e4a Binary files /dev/null and b/src/assets/images/emoji/emoji.png differ diff --git a/src/assets/js/common.js b/src/assets/js/common.js new file mode 100644 index 0000000..f18db4b --- /dev/null +++ b/src/assets/js/common.js @@ -0,0 +1,30 @@ +/** + * 颜色数组 + */ +export const colorArray = [ + '#5A8DEE', + '#CD594B', + '#F8CE5E', + '#4B9E65' +] + +/** + * 博客url + * @type {string} + */ +export const BLOG_URL = 'https://pnkx.top/' + +/** + * 图片的文件类型 + */ +export const IMAGE_TYPE = ['image/jpeg', '.jpg', '.jpeg', '.gif', '.bmp', '.webp'] + +/** + * websocket消息类型 + * @type {{}} + */ +export const WEBSOCKET_MESSAGE_TYPE = { + LOGIN: 'login', + LOG_OUT: 'log_out', + CHAT_MESSAGE: 'chat_message' +} diff --git a/src/assets/logo.png b/src/assets/logo.png deleted file mode 100644 index f3d2503..0000000 Binary files a/src/assets/logo.png and /dev/null differ diff --git a/src/components/Chat/emoji.vue b/src/components/Chat/emoji.vue new file mode 100644 index 0000000..c245128 --- /dev/null +++ b/src/components/Chat/emoji.vue @@ -0,0 +1,339 @@ + + + + + + + diff --git a/src/components/Chat/file.vue b/src/components/Chat/file.vue new file mode 100644 index 0000000..7f5efb6 --- /dev/null +++ b/src/components/Chat/file.vue @@ -0,0 +1,295 @@ + + + + + + diff --git a/src/components/Chat/index.vue b/src/components/Chat/index.vue new file mode 100644 index 0000000..1f6d8b4 --- /dev/null +++ b/src/components/Chat/index.vue @@ -0,0 +1,919 @@ + + + + + + diff --git a/src/components/ModelImage/index.vue b/src/components/ModelImage/index.vue new file mode 100644 index 0000000..2875243 --- /dev/null +++ b/src/components/ModelImage/index.vue @@ -0,0 +1,229 @@ + + + + + diff --git a/src/components/Pagination/index.vue b/src/components/Pagination/index.vue new file mode 100644 index 0000000..750b092 --- /dev/null +++ b/src/components/Pagination/index.vue @@ -0,0 +1,101 @@ + + + + + diff --git a/src/main.js b/src/main.js index 4db1b5c..63907c7 100644 --- a/src/main.js +++ b/src/main.js @@ -1,16 +1,14 @@ -import Vue from 'vue'; -import App from './App.vue'; -import router from './router'; -import store from './store'; -import ElementUI from 'element-ui'; -import 'element-ui/lib/theme-chalk/index.css'; -import axios from 'axios'; -Vue.prototype.$axios = axios; -Vue.use(ElementUI); +import Vue from 'vue' +import App from './App.vue' +import store from './store' +import ElementUI from 'element-ui' +import 'element-ui/lib/theme-chalk/index.css' +import axios from 'axios' +Vue.prototype.$axios = axios +Vue.use(ElementUI) Vue.config.productionTip = false new Vue({ - router, store, render: h => h(App) }).$mount('#app') diff --git a/src/router/index.js b/src/router/index.js deleted file mode 100644 index da7d553..0000000 --- a/src/router/index.js +++ /dev/null @@ -1,34 +0,0 @@ -import Vue from 'vue' -import VueRouter from 'vue-router' - -Vue.use(VueRouter) - -const routes = [ - { - path: '/', - name: 'index', - component: () => import("../views/Index") - }, -] - -const router = new VueRouter({ - routes -}) - -// 导航守卫 -// 使用 router.beforeEach 注册一个全局前置守卫,判断用户是否登陆 -router.beforeEach((to, from, next) => { - if (to.path === '/login') { - next(); - } else { - let token = localStorage.getItem('Authorization'); - - if (token === 'null' || token === '') { - next('/login'); - } else { - next(); - } - } -}); - -export default router diff --git a/src/store/index.js b/src/store/index.js index 332b916..bdab777 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1,15 +1,32 @@ import Vue from 'vue' import Vuex from 'vuex' +import { getInfo } from '@/api' +import { getToken } from '@/utils/auth' Vue.use(Vuex) export default new Vuex.Store({ state: { + // 用户信息 + userInfo: {} }, mutations: { + SET_USER_INFO: (state, userInfo) => { + state.userInfo = userInfo + } }, actions: { + // 获取用户信息 + GetInfo ({ commit, state }) { + return new Promise((resolve, reject) => { + getInfo(getToken()).then(res => { + commit('SET_USER_INFO', res.user) + resolve(res) + }).catch(error => { + reject(error) + }) + }) + } }, - modules: { - } + modules: {} }) diff --git a/src/utils/auth.js b/src/utils/auth.js index 08a43d6..ca6eedd 100644 --- a/src/utils/auth.js +++ b/src/utils/auth.js @@ -1,15 +1,17 @@ -import Cookies from 'js-cookie' - +/** + * 保存到localStorage中 + * @type {string} + */ const TokenKey = 'Admin-Token' export function getToken() { - return Cookies.get(TokenKey) + return localStorage.getItem(TokenKey) } export function setToken(token) { - return Cookies.set(TokenKey, token) + return localStorage.setItem(TokenKey, token) } export function removeToken() { - return Cookies.remove(TokenKey) + return localStorage.removeItem(TokenKey) } diff --git a/src/utils/request.js b/src/utils/request.js index a04d2c4..ffa7ffa 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -1,7 +1,6 @@ import axios from 'axios' -import { Notification, MessageBox, Message } from 'element-ui' -import store from '@/store' -import { getToken } from '@/utils/auth' +import {Message, Notification} from 'element-ui' +import {getToken} from '@/utils/auth' import errorCode from '@/utils/errorCode' axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8' diff --git a/src/utils/scroll-to.js b/src/utils/scroll-to.js new file mode 100644 index 0000000..a0f2b00 --- /dev/null +++ b/src/utils/scroll-to.js @@ -0,0 +1,60 @@ +Math.easeInOutQuad = function (t, b, c, d) { + t /= d / 2 + if (t < 1) { + return c / 2 * t * t + b + } + t-- + return -c / 2 * (t * (t - 2) - 1) + b +} + +// requestAnimationFrame for Smart Animating http://goo.gl/sx5sts +var requestAnimFrame = (function () { + return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || function (callback) { + window.setTimeout(callback, 1000 / 60) + } +})() + +/** + * Because it's so fucking difficult to detect the scrolling element, just move them all + * @param {number} amount + */ +function move(amount) { + document.documentElement.scrollTop = amount + document.body.parentNode.scrollTop = amount + document.body.scrollTop = amount +} + +function position() { + return document.documentElement.scrollTop || document.body.parentNode.scrollTop || document.body.scrollTop +} + +/** + * @param {number} to + * @param {number} duration + * @param {Function} callback + */ +export function scrollTo(to, duration, callback) { + const start = position() + const change = to - start + const increment = 20 + let currentTime = 0 + duration = (typeof (duration) === 'undefined') ? 500 : duration + var animateScroll = function () { + // increment the time + currentTime += increment + // find the value with the quadratic in-out easing function + var val = Math.easeInOutQuad(currentTime, start, change, duration) + // move the document.body + move(val) + // do the animation unless its over + if (currentTime < duration) { + requestAnimFrame(animateScroll) + } else { + if (callback && typeof (callback) === 'function') { + // the animation is done so lets callback + callback() + } + } + } + animateScroll() +} diff --git a/src/views/Index.vue b/src/views/Index.vue deleted file mode 100644 index 049da86..0000000 --- a/src/views/Index.vue +++ /dev/null @@ -1,675 +0,0 @@ - - - - -