This commit is contained in:
lcw
2025-08-16 16:54:03 +08:00
parent 71487ac647
commit 42f5e37f65
69 changed files with 5913 additions and 978 deletions

View File

@ -40,19 +40,21 @@ service.interceptors.request.use(
service.interceptors.response.use(
// 请求成功的处理
(response) => {
const { success, code, msg, message, data } = response.data;
const { success, code, msg, message, data } = response.data;
// 需要判断当前请求是否成功
if (success && code === 10000) {
return data; // 成功后返回解析后的数据
return data ? data : response.data; // 成功后返回解析后的数据
} else if (code === 200 || code == "00000" || code == "10000" || msg == 'success') {
return data; // 成功后返回解析后的数据
return data ? data : response.data; // // 成功后返回解析后的数据
} else if (code === 401) {
store.dispatch('user/logout');
ElMessage.error(message); // 提示错误信息
ElMessage({ message: message || msg, grouping: true, type: 'error' })
} else {
// 失败(请求成功 ,业务失败) 弹出消息提示
ElMessage({ message: message || msg, grouping: true, type: 'error' })
ElMessage({ message: message || msg, grouping: true, type: 'error' })
return Promise.reject(new Error(message));
}
},

View File

@ -2,14 +2,14 @@
import ImageCompressor from "image-compressor.js";
// 随机颜色 - 把16进制的颜色换成rgba格式
export function choseRbgb(color,opcity) {
if(color){
return 'rgba('+ parseInt('0x'+color.slice(1,3)) + ','+ parseInt('0x'+color.slice(3,5))+','+parseInt('0x'+color.slice(5,7)) + ','+opcity+')'
}else{
let r = Math.floor(Math.random()*256)
let g = Math.floor(Math.random()*256)
let b = Math.floor(Math.random()*256)
let a = opcity ? opcity :1
export function choseRbgb(color, opcity) {
if (color) {
return 'rgba(' + parseInt('0x' + color.slice(1, 3)) + ',' + parseInt('0x' + color.slice(3, 5)) + ',' + parseInt('0x' + color.slice(5, 7)) + ',' + opcity + ')'
} else {
let r = Math.floor(Math.random() * 256)
let g = Math.floor(Math.random() * 256)
let b = Math.floor(Math.random() * 256)
let a = opcity ? opcity : 1
return `rgba(${r},${g},${b},${a})`
}
}
@ -25,7 +25,7 @@ export function randomHexColor() { // 随机生成十六进制颜色
/**
* 压缩图片
* @param {*} file
* @param {*} file
* @param {*} quality 压缩比
*/
export function compressImage(file, quality = 0.6) {
@ -96,11 +96,11 @@ export function timeValidate(date, type) {
export function timeSlotChange(val) {
let startTime, endTime;
let now = new Date(); //当前日期
let nowDayOfWeek = now.getDay(); //今天本周的第几天
let nowDay = now.getDate(); //当前日
let nowMonth = now.getMonth(); //当前月
let nowYear = now.getFullYear(); //当前年
let now = new Date(); //当前日期
let nowDayOfWeek = now.getDay(); //今天本周的第几天
let nowDay = now.getDate(); //当前日
let nowMonth = now.getMonth(); //当前月
let nowYear = now.getFullYear(); //当前年
let jd = Math.ceil((nowMonth + 1) / 3)
switch (val) {
case '天':
@ -318,3 +318,8 @@ function _setTime(date) {
}
//拼接地址
export function setAddress(val) {
const url = '/mosty-api/mosty-base/minio/image/download/'
return url + val
}