修改前端
This commit is contained in:
13
Yi.Vue/src/util/dialog.js
Normal file
13
Yi.Vue/src/util/dialog.js
Normal file
@@ -0,0 +1,13 @@
|
||||
function notify(resp) {
|
||||
if (resp.status) {
|
||||
this.$dialog.notify.success(resp.msg, {
|
||||
position: "top-right",
|
||||
});
|
||||
} else {
|
||||
this.$dialog.notify.error(resp.msg, {
|
||||
position: "top-right",
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export default { notify };
|
||||
11
Yi.Vue/src/util/globals.js
Normal file
11
Yi.Vue/src/util/globals.js
Normal file
@@ -0,0 +1,11 @@
|
||||
const EN_LOCALE_ONLY = process.env.EN_LOCALE_ONLY === 'true'
|
||||
const IN_BROWSER = typeof window !== 'undefined'
|
||||
const IS_DEBUG = process.env.DEBUG === 'true'
|
||||
const IS_PROD = process.env.NODE_ENV === 'production'
|
||||
|
||||
module.exports = {
|
||||
EN_LOCALE_ONLY,
|
||||
IN_BROWSER,
|
||||
IS_DEBUG,
|
||||
IS_PROD,
|
||||
}
|
||||
11
Yi.Vue/src/util/helpers.js
Normal file
11
Yi.Vue/src/util/helpers.js
Normal file
@@ -0,0 +1,11 @@
|
||||
export function leadingSlash (str) {
|
||||
return str.startsWith('/') ? str : '/' + str
|
||||
}
|
||||
|
||||
export function trailingSlash (str) {
|
||||
return str.endsWith('/') ? str : str + '/'
|
||||
}
|
||||
|
||||
export const wait = timeout => {
|
||||
return new Promise(resolve => setTimeout(resolve, timeout))
|
||||
}
|
||||
16
Yi.Vue/src/util/myaction.js
Normal file
16
Yi.Vue/src/util/myaction.js
Normal file
@@ -0,0 +1,16 @@
|
||||
const actionList = [
|
||||
"用户管理",
|
||||
"角色管理",
|
||||
"权限管理",
|
||||
"板块管理",
|
||||
"等级管理",
|
||||
"主题管理",
|
||||
"设置管理",
|
||||
"横幅管理",
|
||||
"版本管理",
|
||||
"道具管理",
|
||||
"商城管理",
|
||||
"日志管理",
|
||||
"类型管理"
|
||||
];
|
||||
export default { actionList };
|
||||
36
Yi.Vue/src/util/myaxios.js
Normal file
36
Yi.Vue/src/util/myaxios.js
Normal file
@@ -0,0 +1,36 @@
|
||||
import axios from 'axios'
|
||||
// import store from '../store/index'
|
||||
// import VuetifyDialogPlugin from 'vuetify-dialog/nuxt/index';
|
||||
const myaxios = axios.create({
|
||||
// baseURL:'/'//
|
||||
baseURL: process.env.VUE_APP_BASE_API, // /dev-apis
|
||||
timeout: 50000,
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + ""
|
||||
},
|
||||
})
|
||||
// 请求拦截器
|
||||
myaxios.interceptors.request.use(function(config) {
|
||||
// config.headers.Authorization = 'Bearer ' + store.state.user.token;
|
||||
// store.dispatch("openLoad");
|
||||
return config;
|
||||
}, function(error) {
|
||||
return Promise.reject(error);
|
||||
});
|
||||
|
||||
// 响应拦截器
|
||||
myaxios.interceptors.response.use(function(response) {
|
||||
const resp = response.data
|
||||
// store.dispatch("closeLoad");
|
||||
return resp;
|
||||
}, function(error) {
|
||||
const resp = error.response.data
|
||||
// if (resp.code == undefined && resp.msg == undefined) {
|
||||
// alert(`错误代码:无,原因:与服务器失去连接`)
|
||||
// } else if (resp.code != 200) {
|
||||
// alert(`错误代码:${resp.code},原因:${resp.msg}`)
|
||||
// }
|
||||
// store.dispatch("closeLoad");
|
||||
return Promise.reject(error);
|
||||
});
|
||||
export default myaxios
|
||||
9
Yi.Vue/src/util/myqq.js
Normal file
9
Yi.Vue/src/util/myqq.js
Normal file
@@ -0,0 +1,9 @@
|
||||
const myqqLogin = {
|
||||
appId: "101951505",
|
||||
redirectURI: "https://jiftcc.com/qq?state=0",
|
||||
};
|
||||
const myqqUpdate = {
|
||||
appId: "101951505",
|
||||
redirectURI: "https://jiftcc.com/qq?state=1",
|
||||
};
|
||||
export default { myqqLogin, myqqUpdate };
|
||||
76
Yi.Vue/src/util/routes.js
Normal file
76
Yi.Vue/src/util/routes.js
Normal file
@@ -0,0 +1,76 @@
|
||||
// Imports
|
||||
import { kebabCase } from 'lodash'
|
||||
import { leadingSlash, trailingSlash } from '@/util/helpers'
|
||||
|
||||
export function abort(code = 404) {
|
||||
return {
|
||||
name: 'FourOhFour',
|
||||
path: '*',
|
||||
component: () => error(code),
|
||||
}
|
||||
}
|
||||
|
||||
export function error(code = 404) {
|
||||
return import (
|
||||
/* webpackChunkName: "error-[request]" */
|
||||
`@/views/${code}.vue`
|
||||
)
|
||||
}
|
||||
|
||||
export function layout(layout = 'Default', children, path = '') {
|
||||
const dir = kebabCase(layout)
|
||||
|
||||
return {
|
||||
children,
|
||||
component: () =>
|
||||
import (
|
||||
/* webpackChunkName: "layout-[request]" */
|
||||
`@/layouts/${dir}/Index`
|
||||
),
|
||||
path,
|
||||
}
|
||||
}
|
||||
|
||||
export function redirect(
|
||||
path = '*',
|
||||
rhandler,
|
||||
) {
|
||||
if (typeof path === 'function') {
|
||||
rhandler = path
|
||||
path = '*'
|
||||
}
|
||||
|
||||
return {
|
||||
path,
|
||||
redirect: to => {
|
||||
const rpath = rhandler(to)
|
||||
const url = rpath !== '' ?
|
||||
leadingSlash(trailingSlash(rpath)) :
|
||||
rpath
|
||||
|
||||
return `/${url}`
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
export function route(name, component, path = '') {
|
||||
component = Object(component) === component ?
|
||||
component :
|
||||
{ default: name.replace(' ', '') }
|
||||
|
||||
const components = {}
|
||||
|
||||
for (const [key, value] of Object.entries(component)) {
|
||||
components[key] = () =>
|
||||
import (
|
||||
/* webpackChunkName: "views-[request]" */
|
||||
`@/views/${value}`
|
||||
)
|
||||
}
|
||||
|
||||
return {
|
||||
name,
|
||||
components,
|
||||
path,
|
||||
}
|
||||
}
|
||||
34
Yi.Vue/src/util/signalR.js
Normal file
34
Yi.Vue/src/util/signalR.js
Normal file
@@ -0,0 +1,34 @@
|
||||
//引入安装的signalr包
|
||||
import * as signalR from '@microsoft/signalr'
|
||||
|
||||
const signal = new signalR.HubConnectionBuilder() //服务器地址
|
||||
.withUrl([process.env.VUE_APP_BASE_API] + '/chat', {})
|
||||
.build()
|
||||
|
||||
/* const signalr = function () {
|
||||
var hub
|
||||
if (hub === undefined) {
|
||||
hub = signal
|
||||
}
|
||||
return hub
|
||||
} */
|
||||
// 自动重连
|
||||
// async function start() {
|
||||
// try {
|
||||
// await signal.start()
|
||||
// console.log('connected')
|
||||
// } catch (err) {
|
||||
// console.log(err)
|
||||
// setTimeout(() => start(), 5000)
|
||||
// }
|
||||
// }
|
||||
|
||||
// signal.onclose(async() => {
|
||||
// await start()
|
||||
// })
|
||||
// //将创建的signal赋值给Vue实例
|
||||
export default {
|
||||
install: function(Vue) {
|
||||
Vue.prototype.signalr = signal
|
||||
}
|
||||
}
|
||||
18
Yi.Vue/src/util/usertoken.js
Normal file
18
Yi.Vue/src/util/usertoken.js
Normal file
@@ -0,0 +1,18 @@
|
||||
const TOKEN_KEY = "token_key"
|
||||
const USER_KEY = "user_key"
|
||||
export function getToken() {
|
||||
return localStorage.getItem(TOKEN_KEY)
|
||||
}
|
||||
export function setToken(token) {
|
||||
return localStorage.setItem(TOKEN_KEY, token)
|
||||
}
|
||||
export function getUser() {
|
||||
return JSON.parse(localStorage.getItem(USER_KEY))
|
||||
}
|
||||
export function setUser(user) {
|
||||
return localStorage.setItem(USER_KEY, JSON.stringify(user))
|
||||
}
|
||||
export function removeToken() {
|
||||
localStorage.removeItem(TOKEN_KEY)
|
||||
localStorage.removeItem(USER_KEY)
|
||||
}
|
||||
Reference in New Issue
Block a user