解决搜索结果无法预览的文件不能直接下载的问题 #30

This commit is contained in:
Aicirou 2020-05-29 00:11:00 +08:00
parent 4c9e33ce36
commit edf690d5bd
3 changed files with 30 additions and 31 deletions

View File

@ -12,7 +12,7 @@
:data="buildFiles"
v-if="mode === 'list'"
:icons="getIcon"
:go="go"
:action="action"
:copy="copy"
/>
<grid-view
@ -20,7 +20,7 @@
:data="buildFiles"
v-if="mode !== 'list'"
:getIcon="getIcon"
:go="go"
:action="action"
:thum="thum"
/>
<div
@ -43,7 +43,10 @@
$t('list.total') + ' ' + files.length + ' ' + $t('list.item')
"
></div>
<readmemd :option="readmemd" v-if="renderReadMeMD && readmemd.display"></readmemd>
<readmemd
:option="readmemd"
v-if="renderReadMeMD && readmemd.display"
></readmemd>
<viewer
v-if="viewer && images && images.length > 0"
@ -72,7 +75,6 @@ import {
checkoutPath,
checkView,
checkExtends,
encodePath
} from "@utils/AcrouUtil";
import axios from "@/utils/axios";
import { mapState } from "vuex";
@ -234,6 +236,7 @@ export default {
},
copy(path) {
let origin = window.location.origin;
console.log(path)
path = origin + encodeURI(path);
this.$copyText(path)
.then(() => {
@ -256,7 +259,7 @@ export default {
inited(viewer) {
this.$viewer = viewer;
},
go(file, target) {
action(file, target) {
if (file.mimeType.indexOf("image") != -1) {
this.viewer = true;
this.$nextTick(() => {
@ -265,19 +268,25 @@ export default {
});
return;
}
let path = file.path;
let cmd = this.$route.params.cmd;
if (cmd && cmd === "search") {
this.goSearchResult(file, target);
return;
}
this.target(file, target);
},
target(file, target) {
let path = file.path;
if (target === "_blank") {
window.open(path);
return;
}
if (target === "copy") {
this.copy(path)
return;
}
if (target === "down" || (!checkExtends(path) && !file.isFolder)) {
let temp_path = this.$route.params.path ? this.$route.params.path : "";
location.href = `/${this.$route.params.id}:down/${temp_path}/${encodePath(file.name)}`;
location.href = path.replace(/^\/(\d+:)\//,"/$1down/");
return;
}
if (target === "view") {
@ -319,22 +328,15 @@ export default {
},
goSearchResult(file, target) {
this.loading = true;
let cur = window.current_drive_order;
let id = this.$route.params.id;
axios
.post(`/${cur}:id2path`, { id: file.id })
.post(`/${id}:id2path`, { id: file.id })
.then((res) => {
this.loading = false;
let data = res.data;
if (data) {
var href = checkoutPath(data, file);
href = `/${cur}:${data}`;
if (target === "_blank") {
window.open(href);
} else {
this.$router.push({
path: checkView(href),
});
}
file.path = `/${id}:${data}`;
this.target(file, target)
}
})
.catch((e) => {

View File

@ -5,7 +5,7 @@
class="column is-one-quarter"
v-for="(file, index) in folders"
:key="'folder_' + index"
@click="go(file)"
@click="action(file)"
>
<div class="card g2-grid-view-card g2-grid-view-folder">
<div class="media">
@ -24,7 +24,7 @@
class="column is-one-quarter"
v-for="(file, index) in files"
:key="'file_' + index"
@click="go(file, 'view')"
@click="action(file, 'view')"
>
<div class="card g2-grid-view-card">
<div
@ -65,7 +65,7 @@ export default {
getIcon: {
type: Function,
},
go: {
action: {
type: Function,
},
thum: {

View File

@ -20,7 +20,7 @@
<tr v-for="(file, index) in data" v-bind:key="index">
<td
@click.self="
go(
action(
file,
file.mimeType !== 'application/vnd.google-apps.folder'
? 'view'
@ -43,14 +43,14 @@
</td>
<td class="is-hidden-mobile is-hidden-touch">{{ file.size }}</td>
<td class="is-hidden-mobile is-hidden-touch">
<span class="icon" @click.stop="copy(file.path)">
<span class="icon" @click.stop="action(file,'copy')">
<i
class="fa fa-copy faa-shake animated-hover"
:title="$t('list.opt.copy')"
aria-hidden="true"
></i>
</span>
<span class="icon" @click.stop="go(file, '_blank')">
<span class="icon" @click.stop="action(file, '_blank')">
<i
class="fa fa-external-link faa-shake animated-hover"
:title="$t('list.opt.newTab')"
@ -59,7 +59,7 @@
</span>
<span
class="icon"
@click.stop="go(file, 'down')"
@click.stop="action(file, 'down')"
v-if="file.mimeType !== 'application/vnd.google-apps.folder'"
>
<i
@ -83,12 +83,9 @@ export default {
icons: {
type: Function,
},
go: {
action: {
type: Function,
},
copy: {
type: Function,
},
}
},
computed: {
columns() {