diff --git a/resources/assets/js/App.vue b/resources/assets/js/App.vue
index cd8d48d68..b9d73de5e 100755
--- a/resources/assets/js/App.vue
+++ b/resources/assets/js/App.vue
@@ -7,18 +7,18 @@
-
+
diff --git a/resources/assets/js/components/PreviewImage/state.vue b/resources/assets/js/components/PreviewImage/state.vue
new file mode 100644
index 000000000..92d39644c
--- /dev/null
+++ b/resources/assets/js/components/PreviewImage/state.vue
@@ -0,0 +1,37 @@
+
+
+
+
+
diff --git a/resources/assets/js/pages/manage.vue b/resources/assets/js/pages/manage.vue
index 4d640b6ff..6c4428ecf 100644
--- a/resources/assets/js/pages/manage.vue
+++ b/resources/assets/js/pages/manage.vue
@@ -615,7 +615,6 @@ export default {
watch: {
'$route' (route) {
this.curPath = route.path;
- this.chackPass();
},
userInfo() {
@@ -663,6 +662,14 @@ export default {
}
},
+ curPath: {
+ handler(path) {
+ this.$store.dispatch("websocketPath", path);
+ this.chackPass();
+ },
+ immediate: true
+ },
+
unreadTotal: {
handler(num) {
if (this.$Electron) {
@@ -720,6 +727,9 @@ export default {
toggleRoute(path) {
this.show768Menu = false;
+ if (path === 'file' && $A.getStorageInt("filePid") > 0) {
+ path += `/${$A.getStorageInt("filePid")}`
+ }
this.goForward({path: '/manage/' + path});
},
@@ -779,7 +789,7 @@ export default {
classNameRoute(path) {
return {
- "active": this.curPath == '/manage/' + path,
+ "active": $A.leftExists(this.curPath, '/manage/' + path),
};
},
@@ -787,7 +797,7 @@ export default {
let path = 'project/' + item.id;
let openMenu = this.openMenu[item.id];
return {
- "active": this.curPath == '/manage/' + path,
+ "active": $A.leftExists(this.curPath, '/manage/' + path),
"open-menu": openMenu === true,
"operate": item.id == this.topOperateItem.id && this.topOperateVisible
};
diff --git a/resources/assets/js/pages/manage/components/FileContent.vue b/resources/assets/js/pages/manage/components/FileContent.vue
index b76f80917..dd97d95a8 100644
--- a/resources/assets/js/pages/manage/components/FileContent.vue
+++ b/resources/assets/js/pages/manage/components/FileContent.vue
@@ -187,16 +187,10 @@ export default {
},
deep: true,
},
-
- wsOpenNum() {
- if (this.$isSubElectron) {
- this.$store.dispatch("websocketPath", "file/content/" + this.fileId);
- }
- },
},
computed: {
- ...mapState(['fileContent', 'wsMsg', 'userId', 'wsOpenNum']),
+ ...mapState(['fileContent', 'wsMsg', 'userId']),
equalContent() {
return this.contentBak == $A.jsonStringify(this.contentDetail);
diff --git a/resources/assets/js/pages/manage/file.vue b/resources/assets/js/pages/manage/file.vue
index 5036652d7..72f728724 100644
--- a/resources/assets/js/pages/manage/file.vue
+++ b/resources/assets/js/pages/manage/file.vue
@@ -23,9 +23,9 @@
- - {{$L('全部文件')}}
+ - {{$L('全部文件')}}
- {{$L('搜索')}} "{{searchKey}}"
- -
+
-
{{item.name}}
{{$L('只读')}}
@@ -76,7 +76,7 @@
highlight: selectIds.includes(item.id),
}"
@contextmenu.prevent.stop="handleRightClick($event, item)"
- @click="openFile(item)">
+ @click="dropFile(item, 'openCheckMenu')">
@@ -332,6 +332,12 @@
+
+
+
import('./components/FilePreview');
const FileContent = () => import('./components/FileContent');
export default {
- components: {FilePreview, DrawerOverlay, UserInput, FileContent},
+ components: {PreviewImage, FilePreview, DrawerOverlay, UserInput, FileContent},
data() {
return {
loadIng: 0,
searchKey: '',
searchTimeout: null,
- pid: $A.getStorageInt("fileOpenPid"),
-
types: [
{
"value": "folder",
@@ -441,6 +446,10 @@ export default {
fileShow: false,
fileInfo: {permission: -1},
+ imageShow: false,
+ imageIndex: 0,
+ imageList:[],
+
uploadDir: false,
uploadIng: 0,
uploadShow: false,
@@ -497,13 +506,28 @@ export default {
},
activated() {
- this.$store.dispatch("websocketPath", "file");
this.getFileList();
},
computed: {
...mapState(['userId', 'userToken', 'userIsAdmin', 'userInfo', 'files', 'wsOpenNum']),
+ pid() {
+ let {pid} = this.$route.params;
+ if (!/^\d+$/.test(pid)) {
+ pid = 0
+ }
+ return parseInt(pid);
+ },
+
+ fid() {
+ let {fid} = this.$route.params;
+ if (!/^\d+$/.test(fid)) {
+ fid = 0
+ }
+ return parseInt(fid);
+ },
+
actionUrl() {
return $A.apiUrl('file/content/upload?pid=' + this.pid)
},
@@ -582,20 +606,28 @@ export default {
watch: {
pid() {
+ this.searchKey = '';
this.selectIds = [];
this.getFileList();
},
+ fid() {
+ this.openFileJudge();
+ },
+
tableMode(val) {
$A.setStorage("fileTableMode", val)
},
fileShow(val) {
- if (val) {
- this.$store.dispatch("websocketPath", "file/content/" + this.fileInfo.id);
- } else {
- this.$store.dispatch("websocketPath", "file");
- this.getFileList();
+ if (!val) {
+ this.browseFile(0)
+ }
+ },
+
+ imageShow(val) {
+ if (!val) {
+ this.browseFile(0)
}
},
@@ -620,11 +652,7 @@ export default {
wsOpenNum(num) {
if (num <= 1) return
this.wsOpenTimeout && clearTimeout(this.wsOpenTimeout)
- this.wsOpenTimeout = setTimeout(() => {
- if (this.$route.name == 'manage-file') {
- this.getFileList();
- }
- }, 5000)
+ this.wsOpenTimeout = setTimeout(this.getFileList, 5000)
}
},
@@ -814,22 +842,21 @@ export default {
return name;
},
- backHomeDirectory() {
- this.pid = 0
- this.searchKey = ''
- },
-
getFileList() {
+ if (this.$route.name !== 'manage-file') {
+ return;
+ }
this.loadIng++;
this.$store.dispatch("getFiles", this.pid).then(() => {
this.loadIng--;
- $A.setStorage("fileOpenPid", this.pid)
+ this.openFileJudge()
+ $A.setStorage("filePid", this.pid)
}).catch(({msg}) => {
this.loadIng--;
$A.modalError({
content: msg,
onOk: () => {
- this.backHomeDirectory();
+ this.browseFolder(0);
}
});
});
@@ -876,41 +903,55 @@ export default {
})
},
- openFile(item, checkMenuVisible = true) {
- if (checkMenuVisible && this.contextMenuVisible) {
- return;
- }
- if (this.fileList.findIndex((file) => file._edit === true) > -1) {
- return;
- }
- if (item._load) {
- return;
- }
- if (item.type == 'folder') {
- this.searchKey = '';
- this.pid = item.id;
+ browseFolder(id) {
+ if (id > 0) {
+ this.goForward({params: {pid: id, fid: undefined}});
} else {
- // 图片直接浏览
- if (item.image_url) {
- const list = this.fileList.filter(({image_url}) => !!image_url)
- if (list.length > 0) {
- this.$store.state.previewImageIndex = list.findIndex(({id}) => item.id === id);
- this.$store.state.previewImageList = list.map(item => item.image_url);
- return;
- }
- }
- // 客户端打开独立窗口
- if (this.$Electron) {
- this.openSingle(item);
- return;
- }
- // 正常显示弹窗
- this.fileInfo = item;
- this.fileShow = true;
+ this.goForward({name: 'manage-file'});
}
},
- openSingle(item) {
+ browseFile(id) {
+ if (id > 0) {
+ this.goForward({params: {pid: this.pid, fid: id}});
+ } else {
+ this.browseFolder(this.pid);
+ }
+ },
+
+ openFileJudge() {
+ if (this.fid <= 0) {
+ this.fileShow = false;
+ this.imageShow = false;
+ return;
+ }
+ const item = this.fileList.find(({id}) => id === this.fid)
+ if (!item) {
+ this.fileShow = false;
+ this.imageShow = false;
+ return;
+ }
+ // 图片直接浏览
+ if (item.image_url) {
+ const list = this.fileList.filter(({image_url}) => !!image_url)
+ if (list.length > 0) {
+ this.imageIndex = list.findIndex(({id}) => item.id === id)
+ this.imageList = list.map(item => item.image_url)
+ this.imageShow = true
+ return;
+ }
+ }
+ // 客户端打开独立窗口
+ if (this.$Electron) {
+ this.openFileSingle(item);
+ return;
+ }
+ // 正常显示弹窗
+ this.fileInfo = item;
+ this.fileShow = true;
+ },
+
+ openFileSingle(item) {
this.$Electron.sendMessage('windowRouter', {
name: 'file-' + item.id,
path: "/single/file/" + item.id,
@@ -962,7 +1003,21 @@ export default {
dropFile(item, command) {
switch (command) {
case 'open':
- this.openFile(item, false);
+ case 'openCheckMenu':
+ if (command === 'openCheckMenu' && this.contextMenuVisible) {
+ return;
+ }
+ if (this.fileList.findIndex((file) => file._edit === true) > -1) {
+ return;
+ }
+ if (item._load) {
+ return;
+ }
+ if (item.type == 'folder') {
+ this.browseFolder(item.id)
+ } else {
+ this.browseFile(item.id)
+ }
break;
case 'select':
diff --git a/resources/assets/js/routes.js b/resources/assets/js/routes.js
index 531b4bf48..3f6ca5a8d 100755
--- a/resources/assets/js/routes.js
+++ b/resources/assets/js/routes.js
@@ -65,7 +65,7 @@ export default [
},
{
name: 'manage-file',
- path: 'file',
+ path: 'file/:pid?/:fid?',
component: () => import('./pages/manage/file.vue'),
},
]