feat: 客户端新窗口打开文件

This commit is contained in:
kuaifan 2021-12-25 14:48:38 +08:00
parent f7fc379e56
commit 343c5eb587
6 changed files with 109 additions and 12 deletions

View File

@ -79,6 +79,20 @@ class FileController extends AbstractController
return Base::retSuccess('success', $array); return Base::retSuccess('success', $array);
} }
/**
* 获取单条数据
* @return array
*/
public function one()
{
User::auth();
//
$id = intval(Request::input('id'));
//
$file = File::allowFind($id);
return Base::retSuccess('success', $file);
}
/** /**
* 搜索文件列表 * 搜索文件列表
* *

View File

@ -15,8 +15,6 @@
</template> </template>
<script> <script>
import state from "../store/state";
export default { export default {
name: 'DrawerOverlay', name: 'DrawerOverlay',
props: { props: {

View File

@ -82,16 +82,16 @@ export default {
name: "FileContent", name: "FileContent",
components: {TEditor, MDEditor, LuckySheet, Flow, OnlyOffice}, components: {TEditor, MDEditor, LuckySheet, Flow, OnlyOffice},
props: { props: {
value: {
type: Boolean,
default: false
},
file: { file: {
type: Object, type: Object,
default: () => { default: () => {
return {}; return {};
} }
}, },
parentShow: {
type: Boolean,
default: true
},
}, },
data() { data() {
@ -144,7 +144,7 @@ export default {
case 'file': case 'file':
if (data.action == 'content') { if (data.action == 'content') {
if (this.parentShow && data.id == this.fileId) { if (this.value && data.id == this.fileId) {
$A.modalConfirm({ $A.modalConfirm({
title: "更新提示", title: "更新提示",
content: '团队成员(' + info.nickname + ')更新了内容,<br/>更新时间:' + $A.formatDate("Y-m-d H:i:s", info.time) + '。<br/><br/>点击【确定】加载最新内容。', content: '团队成员(' + info.nickname + ')更新了内容,<br/>更新时间:' + $A.formatDate("Y-m-d H:i:s", info.time) + '。<br/><br/>点击【确定】加载最新内容。',
@ -160,7 +160,7 @@ export default {
deep: true, deep: true,
}, },
parentShow: { value: {
handler(val) { handler(val) {
if (!val) { if (!val) {
this.fileContent[this.fileId] = this.contentDetail; this.fileContent[this.fileId] = this.contentDetail;

View File

@ -199,7 +199,7 @@
v-model="editShow" v-model="editShow"
class="page-file-drawer" class="page-file-drawer"
:mask-closable="false"> :mask-closable="false">
<FileContent v-if="editNum > 0" :parent-show="editShow" :file="editInfo"/> <FileContent v-if="editNum > 0" v-model="editShow" :file="editInfo"/>
</DrawerOverlay> </DrawerOverlay>
</div> </div>
@ -289,8 +289,8 @@ export default {
shareInfo: {}, shareInfo: {},
shareLoad: 0, shareLoad: 0,
editNum: 0, //
editShow: false, editShow: false,
editNum: 0,
editInfo: {}, editInfo: {},
uploadDir: false, uploadDir: false,
@ -643,10 +643,22 @@ export default {
if (item.type == 'folder') { if (item.type == 'folder') {
this.searchKey = ''; this.searchKey = '';
this.pid = item.id; this.pid = item.id;
} else {
if (this.isElectron) {
this.openSingle(item);
} else { } else {
this.editInfo = item; this.editInfo = item;
this.editShow = true; this.editShow = true;
} }
}
},
openSingle(item) {
let url = $A.originUrl("index.html/#/single/file/" + item.id + "?title=" + encodeURIComponent(item.name)),
name = 'file-' + item.id,
width = Math.min(window.screen.availWidth, 1280),
height = Math.min(window.screen.availHeight, 800);
window.open(url, name, 'height=' + height + ',innerHeight=' + height + ',width=' + width + ',innerWidth=' + width);
}, },
clickRow(row) { clickRow(row) {

View File

@ -0,0 +1,68 @@
<template>
<div class="electron-file">
<PageTitle :title="editInfo.name"/>
<Loading v-if="loadIng > 0"/>
<FileContent v-else v-model="editShow" :file="editInfo"/>
</div>
</template>
<style lang="scss" scoped>
.electron-file {
display: flex;
align-items: center;
}
</style>
<script>
import FileContent from "../manage/components/FileContent";
export default {
components: {FileContent},
data() {
return {
loadIng: 0,
editShow: true,
editInfo: {},
}
},
mounted() {
//
},
watch: {
'$route': {
handler() {
this.getInfo();
},
immediate: true
},
},
methods: {
getInfo() {
let id = $A.runNum(this.$route.params.id);
if (id <= 0) {
return;
}
this.loadIng++;
this.$store.dispatch("call", {
url: 'file/one',
data: {
id,
},
}).then(({data}) => {
this.loadIng--;
this.editInfo = data;
}).catch(({msg}) => {
this.loadIng--;
$A.modalError({
content: msg,
onOk: () => {
if (this.isElectron) {
window.close();
}
}
});
});
}
}
}
</script>

View File

@ -70,6 +70,11 @@ export default [
}, },
] ]
}, },
{
name: 'single-file',
path: '/single/file/:id',
component: () => import('./pages/single/file.vue'),
},
{ {
name: 'login', name: 'login',
path: '/login', path: '/login',