添加前端

This commit is contained in:
橙子
2022-04-26 01:34:47 +08:00
parent f3061ed643
commit 630cfb6769
99 changed files with 5239 additions and 0 deletions

View 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 };

View File

@@ -0,0 +1,54 @@
var start = true;
function getUrl(menuList, menuStr) {
if (start) {
for (var i = 0; i < menuList.length; i++) {
if (menuList[i].menu_name == menuStr) {
start = false;
console.log(handUrl(menuList[i]))
return handUrl(menuList[i])
} else {
if (menuList[i].children != undefined && start) {
getUrl(menuList[i].children, menuStr);
}
}
}
}
};
function handUrl(menu) {
var axiosUrls = {
get: "123",
update: "123",
del: "123",
add: "123",
};
const myMenu = menu.children;
myMenu.forEach(item => {
const myName = item.mould.mould_name;
const myUrl = item.mould.url;
switch (myName) {
case 'get':
axiosUrls.get = myUrl;
break;
case 'update':
axiosUrls.update = myUrl;
break;
case 'del':
axiosUrls.del = myUrl;
break;
case 'add':
axiosUrls.add = myUrl;
break;
}
});
return axiosUrls;
}
export {
getUrl,
handUrl
}

View 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,
}

View 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))
}

View File

@@ -0,0 +1,16 @@
const actionList = [
"用户管理",
"角色管理",
"权限管理",
"板块管理",
"等级管理",
"主题管理",
"设置管理",
"横幅管理",
"版本管理",
"道具管理",
"商城管理",
"日志管理",
"类型管理"
];
export default { actionList };

View File

@@ -0,0 +1,85 @@
import axios from 'axios'
import store from '../store/index'
import vm from '../main'
// 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(async function(response) {
const resp = response.data
if (resp.code == undefined && resp.msg == undefined) {
vm.$dialog.notify.error("错误代码:无,原因:与服务器失去连接", {
position: "top-right",
timeout: 5000,
});
} else if (resp.code == 401) {
const res = await vm.$dialog.error({
text: `错误代码:${resp.code},原因:${resp.msg}<br>是否重新进行登录?`,
title: '错误',
actions: {
'false': '取消',
'true': '跳转'
}
});
if (res) {
vm.$router.push({ path: "/login" });
}
} else if (resp.code !== 200) {
vm.$dialog.notify.error(`错误代码:${resp.code},原因:${resp.msg}`, {
position: "top-right",
timeout: 5000,
});
}
store.dispatch("closeLoad");
return resp;
}, async function(error) {
const resp = error.response.data
if (resp.code == undefined && resp.msg == undefined) {
vm.$dialog.notify.error("错误代码:无,原因:与服务器失去连接", {
position: "top-right",
timeout: 5000,
});
} else if (resp.code == 401) {
const res = await vm.$dialog.error({
text: `错误代码:${resp.code},原因:${resp.msg}<br>是否重新进行登录?`,
title: '错误',
actions: {
'false': '取消',
'true': '跳转'
}
});
if (res) {
vm.$store.dispatch("Logout").then((resp) => {
vm.$router.push({ path: "/login" });
});
}
} else if (resp.code !== 200) {
vm.$dialog.notify.error(`错误代码:${resp.code},原因:${resp.msg}`, {
position: "top-right",
timeout: 5000,
});
}
store.dispatch("closeLoad");
return Promise.reject(error);
});
export default myaxios

View 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 };

View File

@@ -0,0 +1,75 @@
// 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,
}
}

View 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
}
}

View 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)
}