直接下载
This commit is contained in:
parent
6a59863c60
commit
3c0ca34c5c
|
@ -75,12 +75,33 @@ export default {
|
||||||
},
|
},
|
||||||
handleZip(url) {
|
handleZip(url) {
|
||||||
if (url) {
|
if (url) {
|
||||||
window.open(url)
|
// window.open(url)
|
||||||
|
fetch(url)
|
||||||
|
.then(response => response.blob())
|
||||||
|
.then(blob => {
|
||||||
|
const link = document.createElement('a');
|
||||||
|
const objectUrl = URL.createObjectURL(blob);
|
||||||
|
link.href = objectUrl;
|
||||||
|
link.download = url.split('/').pop(); // Extract filename from URL
|
||||||
|
document.body.appendChild(link);
|
||||||
|
link.click();
|
||||||
|
document.body.removeChild(link);
|
||||||
|
URL.revokeObjectURL(objectUrl);
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
this.$message({
|
||||||
|
showClose: true,
|
||||||
|
message: '下载失败',
|
||||||
|
type: 'error'
|
||||||
|
});
|
||||||
|
console.error('Download error:', error);
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
this.$message({
|
this.$message({
|
||||||
showClose: true,
|
showClose: true,
|
||||||
message: '暂无下载链接'
|
message: '暂无下载链接',
|
||||||
})
|
type: 'warning'
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
load() {
|
load() {
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1 +1 @@
|
||||||
@font-face{font-family:PingFang;src:url(../../static/fonts/PingFang\ SC.212ada59.ttf);font-weight:400;font-style:normal}body[data-v-82d6d658]{font-family:PingFang!important}.infinite-list[data-v-82d6d658]{list-style-type:none;height:calc(100vh - 154px);padding:0;margin:0}.desc_container+.desc_container[data-v-82d6d658]{margin-top:10px;padding-top:10px}.desc_container .desc_title[data-v-82d6d658]{font-size:18px;font-weight:500;color:#333;line-height:25px;margin-bottom:10px}.desc_container .desc_content[data-v-82d6d658]{font-size:14px;font-weight:300}.problem .problem_form[data-v-82d6d658]{margin-top:10px;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center}.problem .problem_container[data-v-82d6d658],.problem .problem_form[data-v-82d6d658]{display:-webkit-box;display:-ms-flexbox;display:flex}.problem .problem_container .problem_left[data-v-82d6d658]{font-family:PingFang,sans-serif;font-weight:300;width:18%;background:#fff;padding:0 20px;border-right:2px solid #46a6ff;height:calc(100vh - 154px)}.problem .problem_container .problem_left .btn[data-v-82d6d658]{color:#fff;padding:10px 20px;cursor:pointer;text-align:center;background:#46a6ff;border-radius:10px}.problem .problem_container .problem_left .btn+.btn[data-v-82d6d658]{margin-top:10px}.problem .problem_container .problem_right[data-v-82d6d658]{width:100%;background:#fff;padding:0 20px}.problem .problem_container .problem_right .problem_right_container+.problem_right_container[data-v-82d6d658]{margin-top:20px}.problem .problem_container .problem_right .problem_right_container .title[data-v-82d6d658]{font-size:20px;font-weight:600;margin-bottom:10px;color:#46a6ff}.problem .problem_container .problem_right .problem_right_container .title[data-v-82d6d658]>:first-child{margin-right:40px}.problem .problem_container .problem_right .problem_right_container .desc[data-v-82d6d658]{font-size:14px;color:#666;line-height:24px}.problem .problem_container .problem_right .problem_right_container .desc .copy-button[data-v-82d6d658]{margin-left:300px}
|
@font-face{font-family:PingFang;src:url(../../static/fonts/PingFang\ SC.212ada59.ttf);font-weight:400;font-style:normal}body[data-v-3ccfbf84]{font-family:PingFang!important}.infinite-list[data-v-3ccfbf84]{list-style-type:none;height:calc(100vh - 154px);padding:0;margin:0}.desc_container+.desc_container[data-v-3ccfbf84]{margin-top:10px;padding-top:10px}.desc_container .desc_title[data-v-3ccfbf84]{font-size:18px;font-weight:500;color:#333;line-height:25px;margin-bottom:10px}.desc_container .desc_content[data-v-3ccfbf84]{font-size:14px;font-weight:300}.problem .problem_form[data-v-3ccfbf84]{margin-top:10px;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center}.problem .problem_container[data-v-3ccfbf84],.problem .problem_form[data-v-3ccfbf84]{display:-webkit-box;display:-ms-flexbox;display:flex}.problem .problem_container .problem_left[data-v-3ccfbf84]{font-family:PingFang,sans-serif;font-weight:300;width:18%;background:#fff;padding:0 20px;border-right:2px solid #46a6ff;height:calc(100vh - 154px)}.problem .problem_container .problem_left .btn[data-v-3ccfbf84]{color:#fff;padding:10px 20px;cursor:pointer;text-align:center;background:#46a6ff;border-radius:10px}.problem .problem_container .problem_left .btn+.btn[data-v-3ccfbf84]{margin-top:10px}.problem .problem_container .problem_right[data-v-3ccfbf84]{width:100%;background:#fff;padding:0 20px}.problem .problem_container .problem_right .problem_right_container+.problem_right_container[data-v-3ccfbf84]{margin-top:20px}.problem .problem_container .problem_right .problem_right_container .title[data-v-3ccfbf84]{font-size:20px;font-weight:600;margin-bottom:10px;color:#46a6ff}.problem .problem_container .problem_right .problem_right_container .title[data-v-3ccfbf84]>:first-child{margin-right:40px}.problem .problem_container .problem_right .problem_right_container .desc[data-v-3ccfbf84]{font-size:14px;color:#666;line-height:24px}.problem .problem_container .problem_right .problem_right_container .desc .copy-button[data-v-3ccfbf84]{margin-left:300px}
|
File diff suppressed because one or more lines are too long
|
@ -1 +0,0 @@
|
||||||
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-374d4636"],{"53c3":function(t,e,n){},bf4b:function(t,e,n){"use strict";n("53c3")},e132:function(t,e,n){"use strict";n.r(e);var i=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"problem"},[n("el-row",[n("el-col",{attrs:{span:24}},[n("div",{staticClass:"problem_form"},[n("el-form",{ref:"form",attrs:{inline:!0,model:t.dataForm,"label-width":"60px"}},[n("el-form-item",{attrs:{label:"关键字:"}},[n("el-input",{staticClass:"filter-item",staticStyle:{width:"400px"},attrs:{placeholder:"请输入搜索关键字"},model:{value:t.dataForm.keyword,callback:function(e){t.$set(t.dataForm,"keyword",e)},expression:"dataForm.keyword"}})],1),n("el-form-item",[n("el-button",{attrs:{type:"success"},on:{click:t.onSubmit}},[t._v("查询")])],1)],1)],1)])],1),n("div",{staticClass:"problem_container"},[n("div",{directives:[{name:"infinite-scroll",rawName:"v-infinite-scroll",value:t.load,expression:"load"}],staticClass:"problem_left",staticStyle:{overflow:"auto",padding:"10px"},attrs:{"infinite-scroll-immediate":!1}},t._l(t.getQaCityList,(function(e){return n("div",{staticClass:"btn",on:{click:function(n){return t.handleQacityl(e.city_id)}}},[t._v(t._s(e.city_name))])})),0),n("div",{staticClass:"problem_right"},[n("ul",{directives:[{name:"infinite-scroll",rawName:"v-infinite-scroll",value:t.load,expression:"load"}],staticClass:"infinite-list",staticStyle:{overflow:"auto"},attrs:{"infinite-scroll-immediate":!1}},t._l(t.getQaLists,(function(e){return n("li",{staticClass:"problem_right_container"},[n("div",{staticClass:"title"},[n("span",{domProps:{innerHTML:t._s(t.handleprant(e.title))}}),n("el-button",{attrs:{type:"primary"},on:{click:function(n){return t.handleZip(e.img_zip)}}},[t._v("下载图片")]),n("el-button",{attrs:{type:"primary"},on:{click:function(n){return t.handleZip(e.trip_zip)}}},[t._v("下载行程")])],1),t._l(e.qaQuestions,(function(e){return n("div",{staticClass:"desc_container"},[n("span",{staticClass:"desc",staticStyle:{"font-weight":"700",color:"#46a6ff"},domProps:{innerHTML:t._s(t.handleprant(e.title))}}),n("el-button",{staticStyle:{"margin-left":"10px"},attrs:{type:"primary",size:"mini"},on:{click:function(n){return t.copyToClipboard(e.content)}}},[t._v("复制")]),n("div",{staticClass:"desc",domProps:{innerHTML:t._s(t.handleprantHtml(e.content))}})],1)}))],2)})),0)])])],1)},a=[],o=(n("4d63"),n("ac1f"),n("2c3e"),n("25f0"),n("5319"),n("85a8")),r={data:function(){return{getQaCityList:[],getQaLists:[],dataForm:{keyword:"",city_id:""}}},created:function(){var t=this;Object(o["a"])().then((function(e){t.getQaCityList=e.data}))},watch:{"dataForm.keyword":function(t){t&&this.onSubmit()}},methods:{handleQacityl:function(t){var e=this;Object(o["b"])({city_id:t}).then((function(t){e.getQaLists=t.data.data}))},handleZip:function(t){t?window.open(t):this.$message({showClose:!0,message:"暂无下载链接"})},load:function(){console.log("load")},handleprant:function(t){if(!t)return"";var e=new RegExp(this.dataForm.keyword,"ig"),n='<span style="color: #fff;background-color: #FC0421FF;">'.concat(this.dataForm.keyword,"</span>");return t.replace(e,n)},handleprantHtml:function(t){if(!t)return"";var e=this.dataForm.keyword,n=new RegExp(e,"g"),i=t.replace(/(?<=>)[^>]+(?=<[/]?\w+.*>)/g,(function(t){return t.replace(n,"<span style='color: #fff;background-color: #FC0421FF;'>".concat(e,"</span>"))}));return i===t?this.handleprant(t):i},onSubmit:function(){var t=this;Object(o["b"])(this.dataForm).then((function(e){t.getQaLists=e.data.data}))},copyToClipboard:function(t){var e=this.stripHtml(t),n=document.createElement("textarea");n.value=e,document.body.appendChild(n),n.select(),document.execCommand("copy"),document.body.removeChild(n),this.$message({showClose:!0,message:"内容已复制"})},stripHtml:function(t){var e=document.createElement("div");return e.innerHTML=t,e.textContent||e.innerText||""}}},s=r,l=(n("bf4b"),n("2877")),c=Object(l["a"])(s,i,a,!1,null,"82d6d658",null);e["default"]=c.exports}}]);
|
|
|
@ -0,0 +1 @@
|
||||||
|
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-60e1f9c9"],{"09e5":function(t,e,n){},"5b1e":function(t,e,n){"use strict";n("09e5")},e132:function(t,e,n){"use strict";n.r(e);var a=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"problem"},[n("el-row",[n("el-col",{attrs:{span:24}},[n("div",{staticClass:"problem_form"},[n("el-form",{ref:"form",attrs:{inline:!0,model:t.dataForm,"label-width":"60px"}},[n("el-form-item",{attrs:{label:"关键字:"}},[n("el-input",{staticClass:"filter-item",staticStyle:{width:"400px"},attrs:{placeholder:"请输入搜索关键字"},model:{value:t.dataForm.keyword,callback:function(e){t.$set(t.dataForm,"keyword",e)},expression:"dataForm.keyword"}})],1),n("el-form-item",[n("el-button",{attrs:{type:"success"},on:{click:t.onSubmit}},[t._v("查询")])],1)],1)],1)])],1),n("div",{staticClass:"problem_container"},[n("div",{directives:[{name:"infinite-scroll",rawName:"v-infinite-scroll",value:t.load,expression:"load"}],staticClass:"problem_left",staticStyle:{overflow:"auto",padding:"10px"},attrs:{"infinite-scroll-immediate":!1}},t._l(t.getQaCityList,(function(e){return n("div",{staticClass:"btn",on:{click:function(n){return t.handleQacityl(e.city_id)}}},[t._v(t._s(e.city_name))])})),0),n("div",{staticClass:"problem_right"},[n("ul",{directives:[{name:"infinite-scroll",rawName:"v-infinite-scroll",value:t.load,expression:"load"}],staticClass:"infinite-list",staticStyle:{overflow:"auto"},attrs:{"infinite-scroll-immediate":!1}},t._l(t.getQaLists,(function(e){return n("li",{staticClass:"problem_right_container"},[n("div",{staticClass:"title"},[n("span",{domProps:{innerHTML:t._s(t.handleprant(e.title))}}),n("el-button",{attrs:{type:"primary"},on:{click:function(n){return t.handleZip(e.img_zip)}}},[t._v("下载图片")]),n("el-button",{attrs:{type:"primary"},on:{click:function(n){return t.handleZip(e.trip_zip)}}},[t._v("下载行程")])],1),t._l(e.qaQuestions,(function(e){return n("div",{staticClass:"desc_container"},[n("span",{staticClass:"desc",staticStyle:{"font-weight":"700",color:"#46a6ff"},domProps:{innerHTML:t._s(t.handleprant(e.title))}}),n("el-button",{staticStyle:{"margin-left":"10px"},attrs:{type:"primary",size:"mini"},on:{click:function(n){return t.copyToClipboard(e.content)}}},[t._v("复制")]),n("div",{staticClass:"desc",domProps:{innerHTML:t._s(t.handleprantHtml(e.content))}})],1)}))],2)})),0)])])],1)},i=[],o=(n("d3b7"),n("4d63"),n("ac1f"),n("2c3e"),n("25f0"),n("3ca3"),n("5319"),n("ddb0"),n("2b3d"),n("bf19"),n("9861"),n("85a8")),r={data:function(){return{getQaCityList:[],getQaLists:[],dataForm:{keyword:"",city_id:""}}},created:function(){var t=this;Object(o["a"])().then((function(e){t.getQaCityList=e.data}))},watch:{"dataForm.keyword":function(t){t&&this.onSubmit()}},methods:{handleQacityl:function(t){var e=this;Object(o["b"])({city_id:t}).then((function(t){e.getQaLists=t.data.data}))},handleZip:function(t){var e=this;t?fetch(t).then((function(t){return t.blob()})).then((function(e){var n=document.createElement("a"),a=URL.createObjectURL(e);n.href=a,n.download=t.split("/").pop(),document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(a)})).catch((function(t){e.$message({showClose:!0,message:"下载失败",type:"error"}),console.error("Download error:",t)})):this.$message({showClose:!0,message:"暂无下载链接",type:"warning"})},load:function(){console.log("load")},handleprant:function(t){if(!t)return"";var e=new RegExp(this.dataForm.keyword,"ig"),n='<span style="color: #fff;background-color: #FC0421FF;">'.concat(this.dataForm.keyword,"</span>");return t.replace(e,n)},handleprantHtml:function(t){if(!t)return"";var e=this.dataForm.keyword,n=new RegExp(e,"g"),a=t.replace(/(?<=>)[^>]+(?=<[/]?\w+.*>)/g,(function(t){return t.replace(n,"<span style='color: #fff;background-color: #FC0421FF;'>".concat(e,"</span>"))}));return a===t?this.handleprant(t):a},onSubmit:function(){var t=this;Object(o["b"])(this.dataForm).then((function(e){t.getQaLists=e.data.data}))},copyToClipboard:function(t){var e=this.stripHtml(t),n=document.createElement("textarea");n.value=e,document.body.appendChild(n),n.select(),document.execCommand("copy"),document.body.removeChild(n),this.$message({showClose:!0,message:"内容已复制"})},stripHtml:function(t){var e=document.createElement("div");return e.innerHTML=t,e.textContent||e.innerText||""}}},s=r,c=(n("5b1e"),n("2877")),l=Object(c["a"])(s,a,i,!1,null,"3ccfbf84",null);e["default"]=l.exports}}]);
|
Loading…
Reference in New Issue