头像上传功能、性别选择
This commit is contained in:
81
Yi.Vue2.x.Vuetify/src/util/btnHandle.js
Normal file
81
Yi.Vue2.x.Vuetify/src/util/btnHandle.js
Normal file
@@ -0,0 +1,81 @@
|
||||
import store from '../store/index'
|
||||
//匹配按钮,判断是否有按钮存在
|
||||
|
||||
function getBtn(par) {
|
||||
var axiosEnable = {
|
||||
get: false,
|
||||
update: false,
|
||||
del: false,
|
||||
add: false,
|
||||
};
|
||||
const per = store.state.user.per;
|
||||
switch (par) {
|
||||
case "user":
|
||||
per.forEach(p => {
|
||||
if(p=="user:get")
|
||||
{
|
||||
axiosEnable.get=true;
|
||||
}
|
||||
else if(p=="user:update")
|
||||
{
|
||||
axiosEnable.update=true;
|
||||
}
|
||||
else if(p=="user:del")
|
||||
{
|
||||
axiosEnable.del=true;
|
||||
}
|
||||
else if(p=="user:add")
|
||||
{
|
||||
axiosEnable.add=true;
|
||||
}
|
||||
});
|
||||
break;
|
||||
case "role":
|
||||
per.forEach(p => {
|
||||
if(p=="role:get")
|
||||
{
|
||||
axiosEnable.get=true;
|
||||
}
|
||||
else if(p=="role:update")
|
||||
{
|
||||
axiosEnable.update=true;
|
||||
}
|
||||
else if(p=="role:del")
|
||||
{
|
||||
axiosEnable.del=true;
|
||||
}
|
||||
else if(p=="role:add")
|
||||
{
|
||||
axiosEnable.add=true;
|
||||
}
|
||||
})
|
||||
break;
|
||||
case "menu":
|
||||
per.forEach(p => {
|
||||
if(p=="menu:get")
|
||||
{
|
||||
axiosEnable.get=true;
|
||||
}
|
||||
else if(p=="menu:update")
|
||||
{
|
||||
axiosEnable.update=true;
|
||||
}
|
||||
else if(p=="menu:del")
|
||||
{
|
||||
axiosEnable.del=true;
|
||||
}
|
||||
else if(p=="menu:add")
|
||||
{
|
||||
axiosEnable.add=true;
|
||||
}
|
||||
})
|
||||
break;
|
||||
|
||||
|
||||
default: console.log("未发现合法路由")
|
||||
}
|
||||
return axiosEnable;
|
||||
}
|
||||
|
||||
|
||||
export {getBtn};
|
||||
13
Yi.Vue2.x.Vuetify/src/util/dialog.js
Normal file
13
Yi.Vue2.x.Vuetify/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 };
|
||||
54
Yi.Vue2.x.Vuetify/src/util/getMould.js
Normal file
54
Yi.Vue2.x.Vuetify/src/util/getMould.js
Normal 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
|
||||
}
|
||||
11
Yi.Vue2.x.Vuetify/src/util/globals.js
Normal file
11
Yi.Vue2.x.Vuetify/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.Vue2.x.Vuetify/src/util/helpers.js
Normal file
11
Yi.Vue2.x.Vuetify/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))
|
||||
}
|
||||
26
Yi.Vue2.x.Vuetify/src/util/menuHandle.js
Normal file
26
Yi.Vue2.x.Vuetify/src/util/menuHandle.js
Normal file
@@ -0,0 +1,26 @@
|
||||
export function toTree(data) {
|
||||
// 删除 所有 children,以防止多次调用
|
||||
data.forEach(function (item) {
|
||||
delete item.children;
|
||||
});
|
||||
|
||||
// 将数据存储为 以 id 为 KEY 的 map 索引数据列
|
||||
var map = {};
|
||||
data.forEach(function (item) {
|
||||
map[item.id] = item;
|
||||
});
|
||||
// console.log(map);
|
||||
var val = [];
|
||||
data.forEach(function (item) {
|
||||
// 以当前遍历项,的pid,去map对象中找到索引的id
|
||||
var parent = map[item.parentId];
|
||||
// 好绕啊,如果找到索引,那么说明此项不在顶级当中,那么需要把此项添加到,他对应的父级中
|
||||
if (parent) {
|
||||
(parent.children || ( parent.children = [] )).push(item);
|
||||
} else {
|
||||
//如果没有在map中找到对应的索引ID,那么直接把 当前的item添加到 val结果集中,作为顶级
|
||||
val.push(item);
|
||||
}
|
||||
});
|
||||
return val;
|
||||
}
|
||||
16
Yi.Vue2.x.Vuetify/src/util/myaction.js
Normal file
16
Yi.Vue2.x.Vuetify/src/util/myaction.js
Normal file
@@ -0,0 +1,16 @@
|
||||
const actionList = [
|
||||
"用户管理",
|
||||
"角色管理",
|
||||
"权限管理",
|
||||
"板块管理",
|
||||
"等级管理",
|
||||
"主题管理",
|
||||
"设置管理",
|
||||
"横幅管理",
|
||||
"版本管理",
|
||||
"道具管理",
|
||||
"商城管理",
|
||||
"日志管理",
|
||||
"类型管理"
|
||||
];
|
||||
export default { actionList };
|
||||
93
Yi.Vue2.x.Vuetify/src/util/myaxios.js
Normal file
93
Yi.Vue2.x.Vuetify/src/util/myaxios.js
Normal file
@@ -0,0 +1,93 @@
|
||||
import axios from 'axios'
|
||||
import store from '../store/index'
|
||||
import vm from '../main'
|
||||
import JsonBig from 'json-bigint'
|
||||
// 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 ' + ""
|
||||
},
|
||||
//雪花id精度问题
|
||||
transformResponse: [ data => {
|
||||
const json = JsonBig({
|
||||
storeAsString: true
|
||||
})
|
||||
return json.parse(data)
|
||||
}],
|
||||
})
|
||||
// 请求拦截器
|
||||
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.message == 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.message}<br>是否重新进行登录?`,
|
||||
title: '错误',
|
||||
actions: {
|
||||
'false': '取消',
|
||||
'true': '跳转'
|
||||
}
|
||||
});
|
||||
if (res) {
|
||||
vm.$router.push({ path: "/login" });
|
||||
}
|
||||
|
||||
} else if (resp.code !== 200) {
|
||||
vm.$dialog.notify.error(`错误代码:${resp.code},原因:${resp.message}`, {
|
||||
position: "top-right",
|
||||
timeout: 5000,
|
||||
});
|
||||
}
|
||||
|
||||
store.dispatch("closeLoad");
|
||||
return resp;
|
||||
}, async function(error) {
|
||||
const resp = error.response.data
|
||||
if (resp.code == undefined && resp.message == 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.message}<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.message}`, {
|
||||
position: "top-right",
|
||||
timeout: 5000,
|
||||
});
|
||||
}
|
||||
|
||||
store.dispatch("closeLoad");
|
||||
return Promise.reject(error);
|
||||
});
|
||||
export default myaxios
|
||||
9
Yi.Vue2.x.Vuetify/src/util/myqq.js
Normal file
9
Yi.Vue2.x.Vuetify/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 };
|
||||
72
Yi.Vue2.x.Vuetify/src/util/objctHandle.js
Normal file
72
Yi.Vue2.x.Vuetify/src/util/objctHandle.js
Normal file
@@ -0,0 +1,72 @@
|
||||
//深拷贝
|
||||
export function deepCopy(obj) {
|
||||
var a = JSON.stringify(obj);
|
||||
var newobj = JSON.parse(a);
|
||||
return newobj;
|
||||
}
|
||||
|
||||
|
||||
//转换数据,0是相等,1是模糊查询
|
||||
export function objctToDic(object, isByPage) {
|
||||
if (object == undefined) {
|
||||
|
||||
object = {};
|
||||
}
|
||||
|
||||
if (isByPage) {
|
||||
var paramPage = {
|
||||
"index": object.pageIndex,
|
||||
"size": object.pageSize,
|
||||
"parameters": [],
|
||||
"orderBys": []
|
||||
}
|
||||
|
||||
var newData = deepCopy(object);
|
||||
delete newData.pageIndex;
|
||||
delete newData.pageSize;
|
||||
|
||||
var newList = [Object.keys(newData).map(val => {
|
||||
return {
|
||||
key: val,
|
||||
value: object[val],
|
||||
type: 1
|
||||
}
|
||||
})]
|
||||
|
||||
//过滤封装
|
||||
newList[0].forEach((item, index) => {
|
||||
if (item.value.length > 0) {
|
||||
if (item.key == 'isDeleted') {
|
||||
item.type = 0;
|
||||
}
|
||||
paramPage.parameters.push(item);
|
||||
}
|
||||
});
|
||||
|
||||
return paramPage;
|
||||
}
|
||||
else {
|
||||
var params = {
|
||||
"parameters": [],
|
||||
"orderBys": []
|
||||
}
|
||||
var thisList = [Object.keys(object).map(val => {
|
||||
return {
|
||||
key: val,
|
||||
value: object[val],
|
||||
type: 1
|
||||
}
|
||||
})]
|
||||
thisList[0].forEach((item, index) => {
|
||||
if (item.value.length > 0) {
|
||||
if (item.key == 'isDeleted') {
|
||||
item.type = 0;
|
||||
}
|
||||
params.parameters.push(item);
|
||||
}
|
||||
});
|
||||
|
||||
return params;
|
||||
}
|
||||
|
||||
}
|
||||
75
Yi.Vue2.x.Vuetify/src/util/routes.js
Normal file
75
Yi.Vue2.x.Vuetify/src/util/routes.js
Normal 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,
|
||||
}
|
||||
}
|
||||
34
Yi.Vue2.x.Vuetify/src/util/signalR.js
Normal file
34
Yi.Vue2.x.Vuetify/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
|
||||
}
|
||||
}
|
||||
30
Yi.Vue2.x.Vuetify/src/util/usertoken.js
Normal file
30
Yi.Vue2.x.Vuetify/src/util/usertoken.js
Normal file
@@ -0,0 +1,30 @@
|
||||
const TOKEN_KEY = "token_key"
|
||||
const USER_KEY = "user_key"
|
||||
const PER_KEY="per_key"
|
||||
export function getToken() {
|
||||
return localStorage.getItem(TOKEN_KEY)
|
||||
}
|
||||
export function getUser() {
|
||||
return JSON.parse(localStorage.getItem(USER_KEY))
|
||||
}
|
||||
export function getPer() {
|
||||
return JSON.parse(localStorage.getItem(PER_KEY))
|
||||
}
|
||||
|
||||
|
||||
|
||||
export function setToken(token) {
|
||||
return localStorage.setItem(TOKEN_KEY, token)
|
||||
}
|
||||
|
||||
export function setUser(user) {
|
||||
return localStorage.setItem(USER_KEY, JSON.stringify(user))
|
||||
}
|
||||
export function setPer(per) {
|
||||
return localStorage.setItem(PER_KEY, JSON.stringify(per))
|
||||
}
|
||||
export function removeToken() {
|
||||
localStorage.removeItem(TOKEN_KEY)
|
||||
localStorage.removeItem(USER_KEY)
|
||||
localStorage.removeItem(PER_KEY)
|
||||
}
|
||||
Reference in New Issue
Block a user