Merge projectA into B with conflict resolution
This commit is contained in:
@ -2,7 +2,13 @@ import $cache from '@/plugins/cache';
|
||||
//获取班组列表
|
||||
import { listProjectTeam } from '@/api/project/projectTeam';
|
||||
import { ProjectTeamVO } from '@/api/project/projectTeam/types';
|
||||
import useUserStore from '@/store/modules/user';
|
||||
export const getProjectTeam = async () => {
|
||||
const isPermission = useUserStore().permissions.some((item) => item == 'project:team:list');
|
||||
console.log(useUserStore().permissions);
|
||||
|
||||
if (!isPermission && useUserStore().permissions[0] != '*:*:*') return;
|
||||
|
||||
const { id } = $cache.local.getJSON('selectedProject');
|
||||
const res = await listProjectTeam({
|
||||
pageNum: 1,
|
||||
|
@ -85,8 +85,6 @@ service.interceptors.request.use(
|
||||
// 生成一个 AES 密钥
|
||||
const aesKey = generateAesKey();
|
||||
config.headers[encryptHeader] = encrypt(encryptBase64(aesKey));
|
||||
console.log(encrypt(encryptBase64(aesKey)));
|
||||
|
||||
config.data = typeof config.data === 'object' ? encryptWithAes(JSON.stringify(config.data), aesKey) : encryptWithAes(config.data, aesKey);
|
||||
}
|
||||
}
|
||||
@ -178,22 +176,26 @@ service.interceptors.response.use(
|
||||
}
|
||||
);
|
||||
// 通用下载方法
|
||||
export function download(url: string, params: any, fileName: string) {
|
||||
export function download(url: string, params: any, fileName: string, isHeader?: boolean) {
|
||||
downloadLoadingInstance = ElLoading.service({ text: '正在下载数据,请稍候', background: 'rgba(0, 0, 0, 0.7)' });
|
||||
// prettier-ignore
|
||||
return service.post(url, params, {
|
||||
let data={
|
||||
transformRequest: [
|
||||
(params: any) => {
|
||||
|
||||
return tansParams(params);
|
||||
}
|
||||
],
|
||||
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
||||
headers: isHeader?{'Content-Type': 'application/json'}:{ 'Content-Type': 'application/x-www-form-urlencoded' },
|
||||
responseType: 'blob'
|
||||
}).then(async (resp: any) => {
|
||||
}
|
||||
if (isHeader) delete data.transformRequest;
|
||||
return service
|
||||
.post(url, params, data as any)
|
||||
.then(async (resp: any) => {
|
||||
const isLogin = blobValidate(resp);
|
||||
if (isLogin) {
|
||||
console.log("🚀 ~ download ~ resp:", resp)
|
||||
console.log('🚀 ~ download ~ resp:', resp);
|
||||
const blob = new Blob([resp]);
|
||||
FileSaver.saveAs(blob, fileName);
|
||||
} else {
|
||||
@ -203,7 +205,8 @@ export function download(url: string, params: any, fileName: string) {
|
||||
ElMessage.error(errMsg);
|
||||
}
|
||||
downloadLoadingInstance.close();
|
||||
}).catch((r: any) => {
|
||||
})
|
||||
.catch((r: any) => {
|
||||
console.error(r);
|
||||
ElMessage.error('下载文件出现错误,请联系管理员!');
|
||||
downloadLoadingInstance.close();
|
||||
|
@ -20,20 +20,38 @@ export const initSSE = (url: any) => {
|
||||
});
|
||||
|
||||
watch(error, () => {
|
||||
console.log('SSE connection error:', error.value);
|
||||
error.value = null;
|
||||
});
|
||||
|
||||
watch(data, () => {
|
||||
if (!data.value) return;
|
||||
let label = '';
|
||||
let route1 = '';
|
||||
let detailId = '';
|
||||
try {
|
||||
if (JSON.parse(data.value)) {
|
||||
const obj = JSON.parse(data.value);
|
||||
route1 = obj.type;
|
||||
if (obj.type == 'count') {
|
||||
return;
|
||||
}
|
||||
label = obj.content;
|
||||
// detailId = obj.detailId;
|
||||
data.value = null;
|
||||
}
|
||||
} catch (error) {
|
||||
label = data.value;
|
||||
}
|
||||
if (!label) return;
|
||||
useNoticeStore().addNotice({
|
||||
message: data.value,
|
||||
message: label,
|
||||
read: false,
|
||||
time: new Date().toLocaleString()
|
||||
time: new Date().toLocaleString(),
|
||||
route: route1,
|
||||
detailId: detailId
|
||||
});
|
||||
ElNotification({
|
||||
title: '消息',
|
||||
message: data.value,
|
||||
message: label,
|
||||
type: 'success',
|
||||
duration: 3000
|
||||
});
|
||||
|
63
src/utils/useFileDownload.js
Normal file
63
src/utils/useFileDownload.js
Normal file
@ -0,0 +1,63 @@
|
||||
import { ElMessage } from 'element-plus';
|
||||
|
||||
/**
|
||||
* 下载文件下载工具函数
|
||||
* @param {string} fileUrl - 文件地址
|
||||
* @param {string} [fileName] - 可选,指定文件名
|
||||
* @param {Object} [headers] - 可选,请求头(如携带token)
|
||||
*/
|
||||
export const downloadFile = async (fileUrl, fileName, headers = {}) => {
|
||||
try {
|
||||
// 发起请求获取文件数据
|
||||
const response = await fetch(fileUrl, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/octet-stream',
|
||||
...headers
|
||||
},
|
||||
credentials: 'include' // 允许携带cookie
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`下载失败: ${response.statusText}`);
|
||||
}
|
||||
|
||||
// 将响应转换为blob对象
|
||||
const blob = await response.blob();
|
||||
|
||||
// 创建临时URL
|
||||
const url = URL.createObjectURL(blob);
|
||||
|
||||
// 处理文件名
|
||||
let downloadName = fileName;
|
||||
if (!downloadName) {
|
||||
// 从响应头获取文件名
|
||||
const contentDisposition = response.headers.get('content-disposition');
|
||||
if (contentDisposition) {
|
||||
const match = contentDisposition.match(/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/);
|
||||
if (match && match[1]) {
|
||||
downloadName = decodeURIComponent(match[1].replace(/['"]/g, ''));
|
||||
}
|
||||
} else {
|
||||
// 从URL提取文件名
|
||||
downloadName = fileUrl.split('/').pop()?.split('?')[0] || 'download_file';
|
||||
}
|
||||
}
|
||||
|
||||
// 创建a标签并触发下载
|
||||
const link = document.createElement('a');
|
||||
link.href = url;
|
||||
link.download = downloadName;
|
||||
link.style.display = 'none'; // 隐藏a标签
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
|
||||
// 清理资源
|
||||
setTimeout(() => {
|
||||
document.body.removeChild(link);
|
||||
URL.revokeObjectURL(url); // 释放临时URL
|
||||
}, 100);
|
||||
} catch (error) {
|
||||
ElMessage.error(`文件下载失败: ${error.message}`);
|
||||
}
|
||||
};
|
@ -32,6 +32,8 @@ export const initWebSocket = (url: any) => {
|
||||
console.log('websocket已经断开');
|
||||
},
|
||||
onMessage: (_, e) => {
|
||||
console.log('websocket收到消息', e);
|
||||
|
||||
if (e.data.indexOf('ping') > 0) {
|
||||
return;
|
||||
}
|
||||
|
Reference in New Issue
Block a user