master
lion 4 months ago
parent c383c97ef6
commit 2b9eeeb28b

@ -17,3 +17,12 @@ export function userListNoAuth(params) {
isLoading: false isLoading: false
}) })
} }
export function downLoadFile(params) {
return request({
url: '/api/download-file',
method: 'get',
params:params,
noloading: true
})
}

@ -28,7 +28,8 @@
<script> <script>
import { PopupManager } from "element-ui/lib/utils/popup"; import { PopupManager } from "element-ui/lib/utils/popup";
import {defaultModalSize} from "@/settings"; import {defaultModalSize} from "@/settings";
import {downLoadFile} from "@/api/common.js"
import { getToken } from '@/utils/auth'
export default { export default {
data() { data() {
return { return {
@ -45,6 +46,13 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.iframe.contentWindow.location.replace(`${window.location.origin}/admin/#/preview?url=${url}`) this.$refs.iframe.contentWindow.location.replace(`${window.location.origin}/admin/#/preview?url=${url}`)
}) })
},
async download(id){
// const res = await downLoadFile({
// id:id
// })
let url = `${window.location.origin}/api/download-file?id=${id}&token=${window.encodeURIComponent(getToken())}`
window.open(url,'_blank')
} }
}, },
computed: {}, computed: {},
@ -59,9 +67,11 @@ export default {
}, },
created() { created() {
this.$bus.$on('online-file',(url) => this.open(url)) this.$bus.$on('online-file',(url) => this.open(url))
this.$bus.$on('online-download',(id) => this.download(id))
}, },
beforeDestroy() { beforeDestroy() {
this.$bus.$off('online-file') this.$bus.$off('online-file')
this.$bus.$off('online-download')
} }
} }
</script> </script>

@ -1024,10 +1024,11 @@ export default function formBuilder(
padding: "0 4px", padding: "0 4px",
color:'blue' color:'blue'
}, },
attrs:{ on: {
href:file.url, click: (_) => {
target:"_blank" this.$bus.$emit("online-download", file.id);
} },
},
}, },
'下载' '下载'
), ),
@ -1804,10 +1805,11 @@ export default function formBuilder(
padding: "0 4px", padding: "0 4px",
color:'blue' color:'blue'
}, },
attrs:{ on: {
href:file.url, click: (_) => {
target:"_blank" this.$bus.$emit("online-download", file.id);
} },
},
}, },
'下载' '下载'
), ),

Loading…
Cancel
Save