feat:v1.4前端更新

This commit is contained in:
超凡
2025-06-24 14:43:09 +08:00
parent bdb4503456
commit 59800954f2
1026 changed files with 118424 additions and 56490 deletions

View File

@@ -1,26 +1,26 @@
import store from '@/store'
import store from '@/store';
function authPermission(permission) {
const all_permission = "*:*:*";
const permissions = store.getters && store.getters.permissions
const all_permission = '*:*:*';
const permissions = store.getters && store.getters.permissions;
if (permission && permission.length > 0) {
return permissions.some(v => {
return all_permission === v || v === permission
})
return permissions.some((v) => {
return all_permission === v || v === permission;
});
} else {
return false
return false;
}
}
function authRole(role) {
const super_admin = "admin";
const roles = store.getters && store.getters.roles
const super_admin = 'admin';
const roles = store.getters && store.getters.roles;
if (role && role.length > 0) {
return roles.some(v => {
return super_admin === v || v === role
})
return roles.some((v) => {
return super_admin === v || v === role;
});
} else {
return false
return false;
}
}
@@ -31,14 +31,14 @@ export default {
},
// 验证用户是否含有指定权限,只需包含其中一个
hasPermiOr(permissions) {
return permissions.some(item => {
return authPermission(item)
})
return permissions.some((item) => {
return authPermission(item);
});
},
// 验证用户是否含有指定权限,必须全部拥有
hasPermiAnd(permissions) {
return permissions.every(item => {
return authPermission(item)
})
return permissions.every((item) => {
return authPermission(item);
});
},
}
};

View File

@@ -29,7 +29,7 @@ const sessionCache = {
},
remove(key) {
sessionStorage.removeItem(key);
}
},
};
const localCache = {
set(key, value) {
@@ -63,38 +63,37 @@ const localCache = {
remove(key) {
localStorage.removeItem(key);
},
// 检测缓存是否存在
has(key)
{
return localStorage.getItem(key) ? true:false;
},
setItem(params){
// 检测缓存是否存在
has(key) {
return localStorage.getItem(key) ? true : false;
},
setItem(params) {
let obj = {
name:'',
value:'',
expires:"",
startTime:new Date().getTime()
}
name: '',
value: '',
expires: '',
startTime: new Date().getTime(),
};
let options = {};
//将obj和传进来的params合并
Object.assign(options,obj,params);
if(options.expires){
//如果options.expires设置了的话
//以options.name为keyoptions为值放进去
localStorage.setItem(options.name,JSON.stringify(options));
}else{
//如果options.expires没有设置就判断一下value的类型
let type = Object.prototype.toString.call(options.value);
//如果value是对象或者数组对象的类型就先用JSON.stringify转一下再存进去
if(Object.prototype.toString.call(options.value) == '[object Object]'){
options.value = JSON.stringify(options.value);
}
if(Object.prototype.toString.call(options.value) == '[object Array]'){
options.value = JSON.stringify(options.value);
}
localStorage.setItem(options.name,options.value);
Object.assign(options, obj, params);
if (options.expires) {
//如果options.expires设置了的话
//以options.name为keyoptions为值放进去
localStorage.setItem(options.name, JSON.stringify(options));
} else {
//如果options.expires没有设置就判断一下value的类型
let type = Object.prototype.toString.call(options.value);
//如果value是对象或者数组对象的类型就先用JSON.stringify转一下再存进去
if (Object.prototype.toString.call(options.value) == '[object Object]') {
options.value = JSON.stringify(options.value);
}
if (Object.prototype.toString.call(options.value) == '[object Array]') {
options.value = JSON.stringify(options.value);
}
localStorage.setItem(options.name, options.value);
}
}
},
};
export default {
@@ -105,5 +104,5 @@ export default {
/**
* 本地缓存
*/
local: localCache
local: localCache,
};

View File

@@ -1,61 +1,61 @@
import { saveAs } from 'file-saver'
import axios from 'axios'
import { getToken } from '@/utils/auth'
import { Message } from 'element-ui'
import { saveAs } from 'file-saver';
import axios from 'axios';
import { getToken } from '@/utils/auth';
import { Message } from 'element-ui';
const baseURL = process.env.VUE_APP_BASE_API
const baseURL = process.env.VUE_APP_BASE_API;
export default {
name(name, isDelete = true) {
var url = baseURL + "/common/download?fileName=" + encodeURI(name) + "&delete=" + isDelete
var url = baseURL + '/common/download?fileName=' + encodeURI(name) + '&delete=' + isDelete;
axios({
method: 'get',
url: url,
responseType: 'blob',
headers: { 'Authorization': 'Bearer ' + getToken() }
headers: { Authorization: 'Bearer ' + getToken() },
}).then(async (res) => {
const isLogin = await this.blobValidate(res.data);
if (isLogin) {
const blob = new Blob([res.data])
this.saveAs(blob, decodeURI(res.headers['download-filename']))
const blob = new Blob([res.data]);
this.saveAs(blob, decodeURI(res.headers['download-filename']));
} else {
Message.error('无效的会话,或者会话已过期,请重新登录。');
}
})
});
},
resource(resource) {
var url = baseURL + "/common/download/resource?resource=" + encodeURI(resource);
var url = baseURL + '/common/download/resource?resource=' + encodeURI(resource);
axios({
method: 'get',
url: url,
responseType: 'blob',
headers: { 'Authorization': 'Bearer ' + getToken() }
headers: { Authorization: 'Bearer ' + getToken() },
}).then(async (res) => {
const isLogin = await this.blobValidate(res.data);
if (isLogin) {
const blob = new Blob([res.data])
this.saveAs(blob, decodeURI(res.headers['download-filename']))
const blob = new Blob([res.data]);
this.saveAs(blob, decodeURI(res.headers['download-filename']));
} else {
Message.error('无效的会话,或者会话已过期,请重新登录。');
}
})
});
},
zip(url, name) {
var url = baseURL + url
var url = baseURL + url;
axios({
method: 'get',
url: url,
responseType: 'blob',
headers: { 'Authorization': 'Bearer ' + getToken() }
headers: { Authorization: 'Bearer ' + getToken() },
}).then(async (res) => {
const isLogin = await this.blobValidate(res.data);
if (isLogin) {
const blob = new Blob([res.data], { type: 'application/zip' })
this.saveAs(blob, name)
const blob = new Blob([res.data], { type: 'application/zip' });
this.saveAs(blob, name);
} else {
Message.error('无效的会话,或者会话已过期,请重新登录。');
}
})
});
},
saveAs(text, name, opts) {
saveAs(text, name, opts);
@@ -69,5 +69,4 @@ export default {
return true;
}
},
}
};

View File

@@ -1,17 +1,17 @@
import auth from './auth'
import cache from './cache'
import modal from './modal'
import download from './download'
import auth from './auth';
import cache from './cache';
import modal from './modal';
import download from './download';
export default {
install(Vue) {
// 认证对象
Vue.prototype.$auth = auth
Vue.prototype.$auth = auth;
// 缓存对象
Vue.prototype.$cache = cache
Vue.prototype.$cache = cache;
// 模态框对象
Vue.prototype.$modal = modal
Vue.prototype.$modal = modal;
// 下载文件
Vue.prototype.$download = download
}
}
Vue.prototype.$download = download;
},
};

View File

@@ -1,43 +1,43 @@
import { Message, MessageBox, Notification, Loading } from 'element-ui'
import { Message, MessageBox, Notification, Loading } from 'element-ui';
let loadingInstance;
export default {
// 消息提示
msg(content) {
Message.info(content)
Message.info(content);
},
// 错误消息
msgError(content) {
Message.error(content)
Message.error(content);
},
// 成功消息
msgSuccess(content) {
Message.success(content)
Message.success(content);
},
// 警告消息
msgWarning(content) {
Message.warning(content)
Message.warning(content);
},
// 弹出提示
alert(content) {
MessageBox.alert(content, "系统提示")
MessageBox.alert(content, '系统提示');
},
// 错误提示
alertError(content) {
MessageBox.alert(content, "系统提示", { type: 'error' })
MessageBox.alert(content, '系统提示', { type: 'error' });
},
// 成功提示
alertSuccess(content) {
MessageBox.alert(content, "系统提示", { type: 'success' })
MessageBox.alert(content, '系统提示', { type: 'success' });
},
// 警告提示
alertWarning(content) {
MessageBox.alert(content, "系统提示", { type: 'warning' })
MessageBox.alert(content, '系统提示', { type: 'warning' });
},
// 通知提示
notify(content) {
Notification.info(content)
Notification.info(content);
},
// 错误通知
notifyError(content) {
@@ -45,31 +45,32 @@ export default {
},
// 成功通知
notifySuccess(content) {
Notification.success(content)
Notification.success(content);
},
// 警告通知
notifyWarning(content) {
Notification.warning(content)
Notification.warning(content);
},
// 确认窗体
confirm(content) {
return MessageBox.confirm(content, "系统提示", {
return MessageBox.confirm(content, '系统提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: "warning",
})
type: 'warning',
customClass: 'deleteConfirm',
});
},
// 打开遮罩层
loading(content) {
loadingInstance = Loading.service({
lock: true,
text: content,
spinner: "el-icon-loading",
background: "rgba(0, 0, 0, 0.7)",
})
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.7)',
});
},
// 关闭遮罩层
closeLoading() {
loadingInstance.close();
}
}
},
};