mirror of https://github.com/1Panel-dev/1Panel
style: 删除无用代码
parent
6c99e04aee
commit
0a483383b4
|
@ -32,10 +32,3 @@ export interface DescriptionUpdate {
|
|||
id: number;
|
||||
description: string;
|
||||
}
|
||||
|
||||
// * 文件上传模块
|
||||
export namespace Upload {
|
||||
export interface ResFileUrl {
|
||||
fileUrl: string;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
import { Upload } from '@/api/interface/index';
|
||||
import { PORT1 } from '@/api/config/service-port';
|
||||
|
||||
import http from '@/api';
|
||||
|
||||
/**
|
||||
* @name 文件上传模块
|
||||
*/
|
||||
// * 图片上传
|
||||
export const uploadImg = (params: FormData) => {
|
||||
return http.post<Upload.ResFileUrl>(PORT1 + `/file/upload/img`, params);
|
||||
};
|
||||
|
||||
// * 视频上传
|
||||
export const uploadVideo = (params: FormData) => {
|
||||
return http.post<Upload.ResFileUrl>(PORT1 + `/file/upload/video`, params);
|
||||
};
|
|
@ -1,49 +0,0 @@
|
|||
import { ElNotification } from 'element-plus';
|
||||
|
||||
/**
|
||||
* @description 接收数据流生成blob,创建链接,下载文件
|
||||
* @param {Function} api 导出表格的api方法(必传)
|
||||
* @param {String} tempName 导出的文件名(必传)
|
||||
* @param {Object} params 导出的参数(默认为空对象)
|
||||
* @param {Boolean} isNotify 是否有导出消息提示(默认为 true)
|
||||
* @param {String} fileType 导出的文件格式(默认为.xlsx)
|
||||
* @return void
|
||||
* */
|
||||
export const useDownload = async (
|
||||
api: (param: any) => Promise<any>,
|
||||
tempName: string,
|
||||
params: any = {},
|
||||
isNotify: boolean = true,
|
||||
fileType: string = '.xlsx',
|
||||
) => {
|
||||
if (isNotify) {
|
||||
ElNotification({
|
||||
title: '温馨提示',
|
||||
message: '如果数据庞大会导致下载缓慢哦,请您耐心等待!',
|
||||
type: 'info',
|
||||
duration: 3000,
|
||||
});
|
||||
}
|
||||
try {
|
||||
const res = await api(params);
|
||||
// 这个地方的type,经测试不传也没事,因为zip文件不知道type是什么
|
||||
// const blob = new Blob([res], {
|
||||
// type: "application/vnd.ms-excel;charset=UTF-8"
|
||||
// });
|
||||
const blob = new Blob([res]);
|
||||
// 兼容edge不支持createObjectURL方法
|
||||
if ('msSaveOrOpenBlob' in navigator) return window.navigator.msSaveOrOpenBlob(blob, tempName + fileType);
|
||||
const blobUrl = window.URL.createObjectURL(blob);
|
||||
const exportFile = document.createElement('a');
|
||||
exportFile.style.display = 'none';
|
||||
exportFile.download = `${tempName}${fileType}`;
|
||||
exportFile.href = blobUrl;
|
||||
document.body.appendChild(exportFile);
|
||||
exportFile.click();
|
||||
// 去除下载对url的影响
|
||||
document.body.removeChild(exportFile);
|
||||
window.URL.revokeObjectURL(blobUrl);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
};
|
|
@ -1,23 +0,0 @@
|
|||
import { onUnmounted } from 'vue';
|
||||
import * as echarts from 'echarts';
|
||||
|
||||
/**
|
||||
* @description 使用Echarts(只是为了添加图表响应式)
|
||||
* @param {Element} myChart Echarts实例(必传)
|
||||
* @param {Object} options 绘制Echarts的参数(必传)
|
||||
* @return void
|
||||
* */
|
||||
export const useEcharts = (myChart: echarts.ECharts, options: echarts.EChartsCoreOption) => {
|
||||
if (options && typeof options === 'object') {
|
||||
myChart.setOption(options);
|
||||
}
|
||||
const echartsResize = () => {
|
||||
myChart && myChart.resize();
|
||||
};
|
||||
|
||||
window.addEventListener('resize', echartsResize, false);
|
||||
|
||||
onUnmounted(() => {
|
||||
window.removeEventListener('resize', echartsResize);
|
||||
});
|
||||
};
|
|
@ -1,27 +0,0 @@
|
|||
import { ref, onMounted, onUnmounted } from 'vue';
|
||||
|
||||
/**
|
||||
* @description 网络是否可用
|
||||
* */
|
||||
export const useOnline = () => {
|
||||
const online = ref(true);
|
||||
const showStatus = (val: any) => {
|
||||
online.value = typeof val == 'boolean' ? val : val.target.online;
|
||||
};
|
||||
// 在页面加载后,设置正确的网络状态
|
||||
navigator.onLine ? showStatus(true) : showStatus(false);
|
||||
|
||||
onMounted(() => {
|
||||
// 开始监听网络状态的变化
|
||||
window.addEventListener('online', showStatus);
|
||||
window.addEventListener('offline', showStatus);
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
// 移除监听网络状态的变化
|
||||
window.removeEventListener('online', showStatus);
|
||||
window.removeEventListener('offline', showStatus);
|
||||
});
|
||||
|
||||
return { online };
|
||||
};
|
Loading…
Reference in New Issue