You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
856 B
JavaScript
32 lines
856 B
JavaScript
import axios from 'axios'
|
|
import { Message } from 'element-ui'
|
|
import { saveAs } from 'file-saver'
|
|
import { getToken } from '@/utils/auth'
|
|
import { blobValidate } from "@/utils/ruoyi";
|
|
|
|
const baseURL = process.env.VUE_APP_BASE_API
|
|
|
|
export default {
|
|
zip(url, name) {
|
|
var url = baseURL + url
|
|
axios({
|
|
method: 'get',
|
|
url: url,
|
|
responseType: 'blob',
|
|
headers: { 'Authorization': 'Bearer ' + getToken() }
|
|
}).then(async (res) => {
|
|
const isLogin = await blobValidate(res.data);
|
|
if (isLogin) {
|
|
const blob = new Blob([res.data], { type: 'application/zip' })
|
|
this.saveAs(blob, name)
|
|
} else {
|
|
Message.error('无效的会话,或者会话已过期,请重新登录。');
|
|
}
|
|
})
|
|
},
|
|
saveAs(text, name, opts) {
|
|
saveAs(text, name, opts);
|
|
}
|
|
}
|
|
|