Merge pull request #51 from jamebal/dev

新增挂载文件夹的功能
This commit is contained in:
Morgana Clark 2023-08-13 20:05:43 +08:00 committed by GitHub
commit 59322a5803
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 3079 additions and 2022 deletions

View File

@ -53,7 +53,7 @@
"vditor": "3.9.3",
"vue-aplayer": "^1.6.1",
"vue-runtime-helpers": "^1.1.2",
"vue-simple-uploader": "^0.7.4",
"vue-simple-uploader": "0.7.6",
"vuedraggable": "^2.23.2",
"vuex": "^3.1.0",
"websocket": "^1.0.34"

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -153,6 +153,17 @@ export default {
}
})
},
/**
* 创建副本
* @param params
*/
duplicateFile(params) {
return request({
url: 'duplicate',
method: 'get',
params
})
},
// 生成分享链接
generate: function(data) {
return request({
@ -180,6 +191,14 @@ export default {
params
})
},
// 挂载文件夹
mountFolder: function(data) {
return request({
url: '/share/mount-folder',
method: 'put',
data: data
})
},
// 验证提取码
validShareCode: function(data) {
return request({
@ -302,5 +321,5 @@ export default {
method: 'get',
params
})
},
}
}

View File

@ -54,6 +54,14 @@ export function getInfo(params) {
})
}
export function getUsername(params) {
return request({
url: 'user/username',
method: 'get',
params
})
}
export function userList(params) {
return request({
url: 'user/userList',

View File

@ -3,7 +3,7 @@
<el-tree
ref="fileTree"
:data="directoryTreeData"
:node-key="localFileMode?'path':'id'"
:node-key="localFileMode ? 'path' : 'id'"
:props="directoryTreeProps"
:load="localFileMode ? loadOfLocalFileMode : directoryTreeLoadNode"
:highlight-current="true"
@ -19,182 +19,262 @@
</template>
<script>
import api from '@/api/file-api'
import IconFile from "@/components/Icon/IconFile"
import SimTextPreview from "@/components/preview/SimTextPreview"
import { iconClass,suffix } from '@/utils/file-type'
export default {
name: "FileTree",
components: {IconFile,SimTextPreview},
props: {
directoryTreeData: {
type: Array,
default: () => []
},
localFileMode: { //本地文件模式, true:通过文件路径加载, false: 通用文件Id加载
type: Boolean,
default: true
},
tempDir: {
type: Boolean,
default: false
}
import api from "@/api/file-api";
import IconFile from "@/components/Icon/IconFile";
import SimTextPreview from "@/components/preview/SimTextPreview";
import { iconClass } from "@/utils/file-type";
export default {
name: "FileTree",
components: { IconFile, SimTextPreview },
props: {
directoryTreeData: {
type: Array,
default: () => []
},
data() {
return {
directoryTreeProps: {
label: 'name',
children: 'children',
isLeaf: 'isLeaf'
}
}
localFileMode: {
//本地文件模式, true:通过文件路径加载, false: 通用文件Id加载
type: Boolean,
default: true
},
computed: {
// 默认展开项
defaultExpandedKeys() {
if(!this.localFileMode){
return ['0']
}else{
let keys = []
this.directoryTreeData.forEach(file => {
if(!file.isLeaf){
if(keys.length < 1){
keys.push(file.path)
}
tempDir: {
type: Boolean,
default: false
},
showFooter: {
type: Boolean,
default: false
},
hideMountFile: {
type: Boolean,
default: true
}
},
data() {
return {
directoryTreeProps: {
label: "name",
children: "children",
isLeaf: "isLeaf"
}
};
},
created() {
},
computed: {
// 默认展开项
defaultExpandedKeys() {
if (!this.localFileMode) {
return ["0"];
} else {
let keys = [];
this.directoryTreeData.forEach(file => {
if (!file.isLeaf) {
if (keys.length < 1) {
keys.push(file.path);
}
})
return keys
}
});
return keys;
}
}
},
methods: {
// 文件树里新建文件夹
fileTreeAndNewFolder(selectTreeNode) {
let newNodeId = "newFolderNodeKey";
let node = this.$refs.fileTree.getNode(newNodeId);
if (node !== null) {
this.$refs.fileTree.remove(node);
}
let childNodes = this.$refs.fileTree.store.currentNode.childNodes;
let newFolderName = this.getNewFileName(childNodes, "新建文件夹");
let newNode = {
id: newNodeId,
newFolder: true,
name: newFolderName,
showName: newFolderName,
isLeaf: true
};
this.$refs.fileTree.append(newNode, selectTreeNode);
setTimeout(function() {
let treeInput = document.getElementById("treeInput");
if (treeInput) {
treeInput.value = newFolderName;
treeInput.focus();
treeInput.select();
}
},
}, 100);
},
methods: {
// 加载下一级文件树 localFileMode = true
loadOfLocalFileMode(node, resolve) {
if (node.level === 0) {
return resolve(this.directoryTreeData)
getNewFileName(fileList, newFileName) {
let append = 0;
let filenameList = [];
fileList.forEach(file => {
let fileName = file.name || file.label;
filenameList.push(fileName);
});
const newName = newFileName;
while (filenameList.includes(newFileName)) {
append += 1;
if (newName.indexOf(".") > 0) {
const name = newName.substring(0, newName.lastIndexOf("."));
const suffix = newName.substring(newName.lastIndexOf("."));
newFileName = `${name}${append}${suffix}`;
} else {
newFileName = `${newName}${append}`;
}
if (node.level > 0){
api.listfiles({
}
return newFileName;
},
// 加载下一级文件树 localFileMode = true
loadOfLocalFileMode(node, resolve) {
if (node.level === 0) {
return resolve(this.directoryTreeData);
}
if (node.level > 0) {
api
.listfiles({
username: this.$store.state.user.name,
path: encodeURI(node.data.path),
tempDir: this.tempDir
}).then(res => {
const nextNodes = res.data.map(data => {
data.isLeaf = !data.isFolder
return data
})
return resolve(nextNodes)
})
}
},
// 加载下一级文件树 localFileMode = false
directoryTreeLoadNode(node, resolve) {
let fileId = null
if (node.level === 0) {
let data = [{'id':"0",'name':'全部文件'}]
const that = this
setTimeout(function () {
that.$refs.fileTree.setCurrentKey('0')
that.$emit('treeNodeClick',data[0])
},0)
return resolve(data)
}
if (node.level > 1){
fileId = node.data.id
}
api.queryFileTree({
.then(res => {
const nextNodes = res.data.map(data => {
data.isLeaf = !data.isFolder;
return data;
});
return resolve(nextNodes);
});
}
},
// 加载下一级文件树 localFileMode = false
directoryTreeLoadNode(node, resolve) {
let fileId = null;
if (node.level === 0) {
let data = [{ id: "0", name: "全部文件" }];
const that = this;
setTimeout(function() {
that.$refs.fileTree.setCurrentKey("0");
that.$emit("treeNodeClick", data[0]);
}, 0);
return resolve(data);
}
if (node.level > 1) {
fileId = node.data.id;
}
api.queryFileTree({
userId: this.$store.state.user.userId,
username: this.$store.state.user.name,
fileId: fileId,
hideMountFile: this.hideMountFile,
fileId: fileId
}).then(res => {
const nextNodes = res.data
return resolve(nextNodes)
})
},
// 点击文件树
treeNodeClick(row) {
this.$emit('treeNodeClick',row)
},
// 节点被展开时触发
treeNodeExpand(row,node,event) {
},
renderContent(h, { node, data, store }) {
if(data.newFolder){
return (
<span class="custom-tree-node">
<span><svg-icon icon-class="folder" /></span>
const nextNodes = res.data;
return resolve(nextNodes);
});
},
// 点击文件树
treeNodeClick(row) {
this.$emit("treeNodeClick", row);
},
// 节点被展开时触发
treeNodeExpand(row, node, event) {},
renderContent(h, { node, data, store }) {
if (data.newFolder) {
return (
<span class="custom-tree-node">
<span>
<div class="el-input el-input--mini el-input-tree">
<input type="text" autocomplete="on" value="新建文件夹" id="treeInput" class="el-input__inner"></input>
</div>
<button type="button" on-click={() => {
let path = '/'
let parentData = node.parent.data
if(parentData.path){
path = parentData.path + parentData.name + path
}
api.newFolder({
isFolder: true,
filename: encodeURI(data.name),
currentDirectory: encodeURI(path),
username: this.$store.state.user.name,
userId: this.$store.state.user.userId
}).then((res) => {
data.newFolder = false
data.id = res.data
}).catch(() => {
window.event.preventDefault()
window.event.stopPropagation()
})
}}
class="el-button el-icon-check el-button--mini el-input-tree-button" element-loading-spinner="el-icon-loading" element-loading-background="#f6f7fa88"></button>
<button type="button" on-click={() => {
this.$refs.fileTree.remove(node)
window.event.preventDefault()
window.event.stopPropagation()
}}
class="el-button el-icon-close el-button--mini el-input-tree-button" element-loading-spinner="el-icon-loading" element-loading-background="#f6f7fa88"></button>
<svg-icon icon-class="folder" />
</span>
</span>);
}
if(node.expanded){
return (
<span class="custom-tree-node">
<span>
<div class="el-input el-input--mini el-input-tree">
<input
type="text"
autocomplete="on"
value="新建文件夹"
id="treeInput"
class="el-input__inner"
/>
</div>
<button type="button" on-click={() => {
let path = '/'
let parentData = node.parent.data
if (parentData.path) {
path = parentData.path + parentData.name + path
}
let newFolderName = document.getElementById("treeInput").value
api.newFolder({
isFolder: true,
filename: encodeURI(newFolderName),
currentDirectory: encodeURI(path),
username: this.$store.state.user.name,
userId: this.$store.state.user.userId
}).then((res) => {
data.newFolder = false
data.isFolder = true
data.name = newFolderName
data.id = res.data
}).catch(() => {
window.event.preventDefault()
window.event.stopPropagation()
})
}}
class="el-button el-icon-check el-button--mini el-input-tree-button"
element-loading-spinner="el-icon-loading"
element-loading-background="#f6f7fa88"
/>
<button
type="button"
on-click={() => {
this.$refs.fileTree.remove(node);
window.event.preventDefault();
window.event.stopPropagation();
}}
class="el-button el-icon-close el-button--mini el-input-tree-button"
element-loading-spinner="el-icon-loading"
element-loading-background="#f6f7fa88"
/>
</span>
</span>
);
}
if (node.expanded) {
return (
<span class="custom-tree-node">
<svg-icon icon-class="open-folder" />
<span style="margin-left: 5px;">{node.label}</span>
<span>
</span>
</span>);
}else{
let iconClass = this.findIconClass(node.data)
if(!this.localFileMode && node.data.id === '0'){
iconClass = 'folder'
}
return (
<span class="custom-tree-node">
<svg-icon icon-class={iconClass}/>
<span />
</span>
);
} else {
let iconClass = this.findIconClass(node.data);
if (!this.localFileMode && node.data.id === "0") {
iconClass = "folder";
}
return (
<span class="custom-tree-node">
<svg-icon icon-class={iconClass} />
<span style="margin-left: 5px;">{node.label}</span>
<span>
</span>
</span>);
}
},
findIconClass(file){
if(file.isFolder){
return 'folder'
}
let suffix = file.suffix;
if(!suffix && file.name){
suffix = file.name.substring(file.name.lastIndexOf('.') + 1);
}
if(iconClass.has(suffix)){
return iconClass.get(suffix)
}
return 'file'
<span />
</span>
);
}
},
findIconClass(file) {
if (file.isFolder) {
return "folder";
}
let suffix = file.suffix;
if (!suffix && file.name) {
suffix = file.name.substring(file.name.lastIndexOf(".") + 1);
}
if (iconClass.has(suffix)) {
return iconClass.get(suffix);
}
return "file";
}
}
};
</script>
<style lang="scss" scoped>
</style>
<style lang="scss" scoped></style>

View File

@ -5,7 +5,7 @@
import { Icon } from 'ant-design-vue'
const IconFont = Icon.createFromIconfontCN({
scriptUrl: document.location.protocol + '/resource/font_2024484_qwtkvngfp5b.js'
scriptUrl: document.location.protocol + '/resource/font_2024484_qwtkvngfp5d.js'
})
// 把此段代码贴到iconfont项目页面的控制台中, 以获取图标列表

View File

@ -10,6 +10,16 @@
<svg-icon v-if="grid" class="mobile grid icon-favorite" icon-class="Favoritestarrate"/>
</div>
</div>
<div v-if="item.mountFileId">
<div v-if="pc">
<svg-icon v-if="!grid" class="pc list icon-share" icon-class="guazai"/>
<svg-icon v-if="grid" class="pc grid icon-share" icon-class="guazai"/>
</div>
<div v-else>
<svg-icon v-if="!grid" class="mobile list icon-share" icon-class="guazai"/>
<svg-icon v-if="grid" class="mobile grid icon-share" icon-class="guazai"/>
</div>
</div>
<div v-if="item.isShare && item.shareBase && !public">
<div v-if="pc">
<svg-icon v-if="!grid" class="pc list icon-share" icon-class="share"/>

View File

@ -178,7 +178,7 @@ export default {
return
}
let request = 'previewText'
if (this.hasReadOnly) {
if (!this.$store.state.user.token) {
request = 'sharePreviewText'
}
this.content = null
@ -411,6 +411,7 @@ export default {
relativePath: encodeURI(this.file.path + this.file.name),
userId: this.$store.state.user.userId,
username: this.$store.state.user.name,
mountFileId: this.$store.state.user.userId !== this.file.userId ? this.file.id : '',
contentText: value
}).then(() => {
this.saveBtnUpdating = false

View File

@ -10,14 +10,15 @@
:audio-cover-url="audioCoverUrl"></icon-file>
</div>
<div class="share-filename">
<span>{{ file.name }}</span>
<a v-if="this.file.shareId" :href="'/?path=' + filenamePath + '&highlight=' + file.name">{{ filename }}</a>
<span v-else>{{ filename }}</span>
</div>
<div>
<el-form ref="form" class="share-option" :model="shareOption" label-width="82px" size="mini">
<el-form ref="form" class="share-option" :model="shareOption" label-width="86px" size="mini">
<el-form-item :label="shareOptionConfig.linkLabel">
<el-col :span="9" class="share-expires-data" v-if="!shareOptionConfig.shared">
<el-col :span="shareOptionConfig.shared ? 9 : 20" class="share-expires-data" v-if="!shareOptionConfig.shared">
<el-form-item prop="expiresDateOption">
<el-select size="small" v-model="shareOption.expiresDateOption" @change="expiresDateOptionChange">
<el-select size="small" v-model="shareOption.expiresDateOption" @change="expiresDateOptionChange" style="width: 100%">
<el-option label="30天有效" :value="0"></el-option>
<el-option label="永久有效" :value="1"></el-option>
<el-option label="自定义" :value="2"></el-option>
@ -45,8 +46,8 @@
</el-col>
</el-form-item>
<el-form-item v-if="!shareOptionConfig.shared" class="share-option-form" label="分享形式" width="100">
<el-col :span="9">
<el-select size="small" v-model="shareOption.isPrivacy">
<el-col :span="20">
<el-select size="small" v-model="shareOption.isPrivacy" style="width: 100%">
<el-option label="公开链接" :value="false"></el-option>
<el-option label="私密链接" :value="true"></el-option>
</el-select>
@ -71,6 +72,17 @@
readonly="readonly" v-model="extractionCode">
<template slot="prepend">提取码</template>
</el-input>
<el-collapse accordion v-if="shareOptionConfig.shared && shareOption.isPrivacy">
<el-collapse-item title="操作权限">
<el-checkbox-group v-model="shareOption.operationPermissionList" @change="permissionActionChange">
<el-checkbox label="UPLOAD">上传</el-checkbox>
<el-checkbox label="PUT">修改</el-checkbox>
<el-checkbox label="DELETE">删除</el-checkbox>
</el-checkbox-group>
</el-collapse-item>
</el-collapse>
</el-col>
</el-form>
</div>
@ -180,6 +192,7 @@ export default {
expiresDateOption: 1,
isPrivacy: false,
expiresDate: '',
operationPermissionList: undefined
},
shareLink: "",
qrCodeshareLink: "",
@ -187,18 +200,32 @@ export default {
shareOptionConfig: {
shared: false,
linkLabel: "选择有效期",
}
},
filename: '',// 文件名
}
},
computed: {
filenamePath() {
return this.filename.slice(0, this.filename.lastIndexOf('/'))
}
},
watch: {
status(visible) {
if (visible) {
this.filename = this.file.name
this.shareDialogVisible = true
if (this.file.shareId) {
api.getFileInfoById({
id: this.file.fileId
}).then(res => {
this.filename = res.data.path + this.file.name
})
this.shareOptionConfig.shared = true
this.shareOptionConfig.linkLabel = '分享链接'
this.setShareLink(this.getShareLink(this.file.shareId))
this.shareOption.isPrivacy = this.file.isPrivacy
this.shareOption.operationPermissionList = this.file.operationPermissionList || []
if (this.file.expireDate) {
this.shareOption.expiresDate = moment(this.file.expireDate).format('x')
}
@ -215,9 +242,12 @@ export default {
}
},
methods: {
setShareLink(sahreLink) {
this.shareLink = sahreLink
QRCode.toDataURL(sahreLink)
permissionActionChange() {
this.createShare()
},
setShareLink(shareLink) {
this.shareLink = shareLink
QRCode.toDataURL(shareLink)
.then(url => {
this.qrCodeshareLink = url
})
@ -247,6 +277,7 @@ export default {
submitShare() {
this.$refs.form.validate((valid) => {
if (valid) {
this.shareOption.operationPermissionList = undefined
this.createShare()
} else {
console.log('error submit!!');
@ -279,16 +310,18 @@ export default {
fileId: this.file.fileId,
isFolder: this.file.isFolder,
expireDate: expireDate,
isPrivacy: this.shareOption.isPrivacy
isPrivacy: this.shareOption.isPrivacy,
operationPermissionList: this.shareOption.operationPermissionList
}).then(res => {
if (res.data) {
let {shareId, extractionCode} = res.data
let {shareId, extractionCode, operationPermissionList} = res.data
this.setShareLink(this.getShareLink(shareId))
this.generateShareLinkLoading = false
this.shareOptionConfig.shared = true
this.shareOption.expiresDateOption = 2
this.shareOptionConfig.linkLabel = "分享链接"
this.extractionCode = extractionCode
this.shareOption.operationPermissionList = operationPermissionList || []
this.$emit('onSuccess', shareId)
if (update) {
if (!expireDate) {
@ -385,13 +418,14 @@ export default {
}
> > > .el-form-item__label {
text-align: left;
line-height: 32px;
}
.shared-expires-text {
text-align: right;
line-height: 32px;
padding-right: 5px;
padding-right: 10px;
}
}
@ -428,5 +462,9 @@ export default {
text-align: center;
padding: 0 10px;
}
>>> .el-collapse {
border-top: 0;
}
}
</style>

File diff suppressed because it is too large Load Diff

View File

@ -261,7 +261,8 @@ export default {
this.params = {
currentDirectory: this.$route.query.path || '/',
username: this.$store.state.user.name,
userId: this.$store.state.user.userId
userId: this.$store.state.user.userId,
folder: this.$route.query.folder
}
},
onFilesAdded(files) {
@ -280,6 +281,7 @@ export default {
isFolder: true,
folderPath: encodeURI(folder.parent.path),
filename: encodeURI(folder.name),
folder: this.$route.query.folder,
currentDirectory: encodeURI(this.params.currentDirectory),
username: this.params.username,
userId: this.params.userId
@ -359,6 +361,7 @@ export default {
filename: encodeURI(file.name),
relativePath: encodeURI(file.relativePath),
identifier: file.uniqueIdentifier,
folder: this.$route.query.folder,
currentDirectory: encodeURI(this.params.currentDirectory),
username: this.params.username,
userId: this.params.userId,
@ -367,7 +370,7 @@ export default {
}).then(() => {
// console.log('文件合并成功', res)
// 文件合并成功
Bus.$emit('fileSuccess')
Bus.$emit('fileSuccess', file.name)
this.statusRemove(file.id)
this.statusSet(file.id, 'success')
// file.removeFile(file)
@ -376,7 +379,7 @@ export default {
})
// 不需要合并
} else {
Bus.$emit('fileSuccess')
Bus.$emit('fileSuccess', file.name)
// 完成后从文件列表移除
// file.removeFile(file)
// console.log('上传成功')

View File

@ -101,7 +101,7 @@ export default {
}
this.xml = ''
let request = 'previewText'
if(this.readOnly){
if (!this.$store.state.user.token) {
request = 'sharePreviewText'
}
api[request]({
@ -221,6 +221,7 @@ export default {
relativePath: encodeURI(this.file.path + this.file.name),
userId: this.$store.state.user.userId,
username: this.$store.state.user.name,
mountFileId: this.$store.state.user.userId !== this.file.userId ? this.file.id : '',
contentText: value
}).then(() => {
this.saveBtnUpdating = false

View File

@ -57,7 +57,6 @@ export default {
this.show = true
}
this.$nextTick(() => {
console.log('this.$refs', this.$refs)
let url = fileConfig.previewUrl(this.$store.state.user.name, newFile, this.$store.getters.token)
if (this.$store.getters.token === undefined) {
url = fileConfig.publicPreviewUrl(newFile, window.shareId, this.$store.getters.shareToken);
@ -77,7 +76,6 @@ export default {
this.list.push(this.currentMusic)
}
this.$refs.audioPlayer.thenPlay()
console.log(this.$refs.audioPlayer.repeat, this.$refs.audioPlayer.shuffle);
})
})
},

View File

@ -117,7 +117,7 @@ export default {
getImageUrl(element) {
let url = fileConfig.previewUrl(this.$store.state.user.name, element, this.$store.getters.token)
if (this.shareId) {
url = fileConfig.publicPreviewUrl(element, window.shareId, this.$store.getters.shareToken);
url = fileConfig.publicPreviewUrl(element, window.shareId, this.$store.getters.shareToken)
}
return url
},

View File

@ -93,7 +93,7 @@ export default {
this.$nextTick(() => {
this.previewDocument = document.querySelector('.preview-block')
})
this.checkReadOnly(this.file.userId)
this.checkReadOnly(this.file)
// 12秒后还没加载出来视为加载失败
let that = this
this.delayClosing = setTimeout(function () {
@ -208,10 +208,13 @@ export default {
},
/**
* 检查要预览调文件是否为只读
* @param fileUserId userId
* @param file userId
*/
checkReadOnly(fileUserId){
if(this.$store.state.user.token && this.$store.state.user.userId === fileUserId){
checkReadOnly(file){
if(this.$store.state.user.token && this.$store.state.user.userId === file.userId){
this.readOnly = false
}
if (this.$store.state.user.token && file.operationPermissionList && file.operationPermissionList.indexOf('PUT') > -1) {
this.readOnly = false
}
if (!this.$pc && this.fileType === 'office') {

View File

@ -55,16 +55,16 @@
<el-button v-if="isShowUpdateBtn" @click="saveAll(false)" :class="lightTheme?'':'dark-button'" size="small" :loading="updating">保存所有</el-button>
<!-- <el-button-->
<!-- v-if="editableTabsValue.endsWith('.md')"-->
<!-- :class="lightTheme?'':'dark-button'"-->
<!-- size="small"-->
<!-- circle-->
<!-- @click="changePreviewMode"-->
<!-- :title="previewMode?'编辑':'预览'"-->
<!-- >-->
<!-- <icon :type="previewMode?lightTheme?'icon-quxiaoyulan1':'icon-quxiaoyulan1-copy':lightTheme?'icon-yulan':'icon-yulan-copy'"></icon>-->
<!-- </el-button>-->
<el-button
v-if="editableTabsValue.endsWith('.md') && editableTabs.length > 0"
:class="lightTheme?'':'dark-button'"
size="small"
circle
@click="changePreviewMode"
:title="previewMode?'编辑':'预览'"
>
<icon :type="previewMode?lightTheme?'icon-quxiaoyulan1':'icon-quxiaoyulan1-copy':lightTheme?'icon-yulan':'icon-yulan-copy'"></icon>
</el-button>
<el-button
:class="lightTheme?'':'dark-button'"
size="small"
@ -82,7 +82,7 @@
</div>
</div>
<div class="content" :style="{height: editorHieght+26+'px'}">
<div class="file-contents" :style="{width: contentsWidth+'px',height: editorHieght+32+'px',transition: transition,left: panelReadOnly || moblie ?`-${contentsWidth}px`:`0px`}">
<div class="file-contents" :style="{width: contentsWidth+'px',height: editorHieght+32+'px',transition: transition,left: panelReadOnly || moblie || contentsHide ?`-${contentsWidth}px`:`0px`}">
<div class="content-tree">
<fancy-tree
ref="fancTree"
@ -101,12 +101,12 @@
</fancy-tree>
</div>
</div>
<div class="editor-resize" :style="{marginLeft: panelReadOnly || moblie ?`0px`:`${contentsWidth}px`,transition: transition}">
<div class="editor-resize" :style="{marginLeft: panelReadOnly || moblie || contentsHide ?`0px`:`${contentsWidth}px`,transition: transition}">
<div class="darg-resize-conter"></div>
<i v-show="!panelReadOnly && !moblie " class="editor-resize-conter" icon="el-icon-arrow-right" title="隐藏文件目录" @click="hideContents"/>
<i v-show="!panelReadOnly" class="editor-resize-conter" icon="el-icon-arrow-right" :title="contentsHide ? '展开目录' : '隐藏目录'" @click="hideContents"/>
</div>
<div :style="{width: editorWidth-2+'px'}">
<el-tabs v-model="editableTabsValue" type="card" closable @tab-remove="removeTab" @tab-click="clickTab">
<el-tabs v-model="editableTabsValue" type="card" closable @tab-remove="removeTab" @tab-click="clickTab()">
<el-tab-pane
v-for="(item,index) in editableTabs"
:key="item.name"
@ -199,11 +199,12 @@
data(){
return{
lightTheme: true,
contentsHide: false,
contentsHide: true,
defalutLanguage: 'redis',
lineWrapping: false,
moblie: false,
panelReadOnly: true,
mountFileId: undefined,
options: {
fontSize: 14,
contextmenu: true,
@ -292,7 +293,7 @@
}
this.editableTabs = []
this.checkMobile()
this.checkReadOnly(file.userId)
this.checkReadOnly(file)
this.loadEditorSize()
this.loading = this.$message({
iconClass: 'el-icon-loading',
@ -402,6 +403,7 @@
},
// loading
viewHistoryFile({historyInfo, diff, recovery}) {
this.previewMode = false
const pathname = this.editableTabsValue
let currentIndex = this.editableTabs.findIndex(editable => editable.name === pathname)
const tab = this.editableTabs[currentIndex]
@ -471,7 +473,7 @@
},
async requestStream(request, params, index) {
try {
const readOnly = this.panelReadOnly
const readOnly = this.options.readOnly
this.options.readOnly = true
this.abortControllerAbort(index)
const queryString = this.buildQueryString(params)
@ -590,7 +592,7 @@
that.dialogWidth = dialogWidth + moveX
that.editorWidth = editorWidth + moveX
that.editorHieght = editorHieght + (endY - startY)
that.loadConterSize()
that.loadContentSize()
}
}
// 鼠标松开事件
@ -714,7 +716,7 @@
fileName: row.name,
username: this.$store.state.user.name
}
api.previewTextByPath(params).then((res)=>{
api.previewTextByPath(params).then(()=>{
this.loading.close()
// 添加一个tab
let tab = {
@ -797,20 +799,24 @@
this.loadEditorSize()
},
checkMobile() {
if (!this.$pc) {
this.moblie = true
} else {
this.moblie = false
}
this.moblie = !this.$pc;
},
checkReadOnly(fileUserId){
if(this.$store.state.user.token && this.$store.state.user.userId === fileUserId){
checkReadOnly(file){
if(this.$store.state.user.token && this.$store.state.user.userId === file.userId){
this.options.readOnly = false
this.panelReadOnly = false
return
} else {
this.mountFileId = file.id
}
if (this.$store.state.user.token && file.operationPermissionList && file.operationPermissionList.indexOf('PUT') > -1) {
this.options.readOnly = false
this.panelReadOnly = true
return
}
if (!this.$pc) {
this.options.readOnly = true
this.panelReadOnly = false
this.options.readOnly = false
this.panelReadOnly = true
}
if(this.panelReadOnly || this.moblie){
this.$nextTick(()=> {
@ -827,12 +833,12 @@
this.editorWidth = this.dialogWidth - this.contentsWidth
}
this.editorHieght = document.body.clientHeight * this.dialogWidthPercent - 76
this.loadConterSize()
this.loadContentSize()
},
loadConterSize(){
let conter = document.querySelector('.editor-resize .editor-resize-conter');
if(conter){
conter.style.marginTop = ((this.editorHieght+26)/2 - conter.clientHeight/2) + 'px'
loadContentSize(){
let content = document.querySelector('.editor-resize .editor-resize-conter');
if(content){
content.style.marginTop = ((this.editorHieght+26)/2 - content.clientHeight/2) + 'px'
}
},
handleClose(done) {
@ -866,6 +872,7 @@
}
},
closeDialog() {
this.previewMode = false
this.textPreviewVisible = false
this.$emit('update:status', this.textPreviewVisible)
this.isSaveDialogVisible = false
@ -925,6 +932,7 @@
relativePath: encodeURI(path),
userId: this.$store.state.user.userId,
username: this.$store.state.user.name,
mountFileId: this.mountFileId,
contentText: value
}).then(() => {
this.updating = false
@ -1037,8 +1045,10 @@
this.clickTab()
},
clickTab() {
// this.editorWidth += 0.001
// this.editorHieght += 0.001
this.editorWidth += 0.001
this.editorHieght += 0.001
// 加载历史版本
this.$refs.historyPopover.loadHistoryPathList(this.editableTabsValue)
},
removeTab(targetName) {
let tabs = this.editableTabs;
@ -1534,13 +1544,20 @@
.nwse-resize {
z-index: 99999;
position: fixed;
width: 15px;
background: #00000000;
width: 12px;
margin-left: 3px;
background: #f0f0f0;
height: 15px;
margin-top: -15px;
float: right;
cursor: nwse-resize;
}
.nwse-resize::before {
content: "⠿";
display: inline-block;
padding-right: 5px;
vertical-align: middle;
}
.el-button--small.is-circle {
padding: 9px 9px;
}

View File

@ -70,6 +70,9 @@ export default {
if(this.$route.path.startsWith('/setting')){
this.isShow = true
}
if (this.$route.path.startsWith('/s/')) {
this.isShow = false
}
}else{
this.isShow = false
}

View File

@ -1,4 +1,5 @@
import fileApi from '@/api/file-api'
import store from '@/store'
export default {
baseUrl: '/api',
@ -20,7 +21,13 @@ export default {
},
// 预览文件的url
previewUrl: function(username, file, token, shareToken) {
let fileUrl = `${this.baseUrl}/file/${username}${encodeURI(file.path)}${encodeURI(file.name)}`
let owner
if (username !== store.getters.name) {
owner = localStorage.getItem('mountFileOwner')
} else {
owner = username
}
let fileUrl = `${this.baseUrl}/file/${owner}${encodeURI(file.path)}${encodeURI(file.name)}`
fileUrl = fileUrl.replace(/%5C/g, '/')
if (token) {
return `${fileUrl}?jmal-token=${token}&name=${username}`

View File

@ -2,7 +2,7 @@
<div>
<show-file
:isCollectView="true"
:defaultGrid="false"
:defaultGrid="true"
:sortable="sortable"
:orderCustom="true"
:defaultSort="sortable"

View File

@ -3,7 +3,7 @@
<show-file
queryFileType="video"
:orderCustom="true"
:defaultGrid="false"
:defaultGrid="true"
:sortable="sortable"
:queryCondition="queryCondition"
emptyStatus="还没有视频呢~"

View File

@ -428,7 +428,9 @@ export default {
}
})
}
if (this.$route.query.folder && this.path) {
localStorage.setItem(this.path, this.$route.query.folder)
}
if (window.history && window.history.pushState) {
history.pushState(null, null, document.URL)
window.addEventListener('popstate', this.goBack, false)
@ -586,6 +588,7 @@ export default {
api.rename({
newFileName: encodeURI(newFileName),
username: this.$store.state.user.name,
folder: this.$route.query.folder,
id: row.id
}).then(() => {
this.renameLoading = false
@ -809,7 +812,7 @@ export default {
if (!this.path) {
this.path = ''
}
this.$router.push(`?vmode=${this.vmode}&path=${this.path}`)
this.$router.push(`?vmode=${this.vmode}&path=${this.path}${this.$route.query.folder ? '&folder='+this.$route.query.folder : ''}`)
},
showSortSheet() {
this.actionSortSheetShow = true
@ -850,11 +853,12 @@ export default {
this.path += '/' + this.pathList[number].folder
}
})
let queryFolder = localStorage.getItem(this.path)
if (!unPushLink) {
if (!this.$route.query.path) {
this.$router.push(`/_m?vmode=${this.vmode}&path=${encodeURI(this.path)}`)
this.$router.push(`/_m?vmode=${this.vmode}&path=${encodeURI(this.path)}${queryFolder ? '&folder='+queryFolder : ''}`)
} else {
this.$router.push(`/_m?vmode=${this.vmode}&path=${encodeURI(this.path)}`)
this.$router.push(`/_m?vmode=${this.vmode}&path=${encodeURI(this.path)}${queryFolder ? '&folder='+queryFolder : ''}`)
}
}
if (!unRefresh) {
@ -881,12 +885,12 @@ export default {
this.getFileList();
},
getFileList(onLoad) {
console.log("getFileList", onLoad)
this.beforeLoadData(onLoad)
api.fileList({
username: this.$store.state.user.name,
userId: this.$store.state.user.userId,
currentDirectory: encodeURI(this.$route.query.path),
folder: this.$route.query.folder,
queryFileType: this.queryFileType,
sortableProp: this.sortableProp,
order: this.order,
@ -1069,7 +1073,14 @@ export default {
item['folder'] = row.name
item['index'] = this.pathList.length - 1
this.pathList.push(item)
this.$router.push(`/_m?vmode=${this.vmode}&path=${encodeURI(this.path)}`)
const path = encodeURI(this.path);
if (this.$store.getters.userId !== row.userId) {
row.mountFileId = row.id
}
if (row.mountFileId) {
localStorage.setItem(this.path, row.mountFileId)
}
this.$router.push(`/_m?vmode=${this.vmode}&path=${path}${row.mountFileId ? '&folder='+row.mountFileId : ''}`)
this.getFileList()
} else {
if (row.contentType.startsWith('image')) {
@ -1195,6 +1206,7 @@ export default {
// 打开文件选择框
Bus.$emit('openUploader', {
// 传入的参数
folder: this.$route.query.folder,
currentDirectory: encodeURI(this.path),
username: this.$store.state.user.name,
userId: this.$store.state.user.userId
@ -1205,6 +1217,7 @@ export default {
// 打开文件夹选择框
Bus.$emit('uploadFolder', {
// 传入的参数
folder: this.$route.query.folder,
currentDirectory: encodeURI(this.path),
username: this.$store.state.user.name,
userId: this.$store.state.user.userId
@ -1218,6 +1231,7 @@ export default {
api.uploadFolder({
isFolder: true,
filename: encodeURI(this.newFolderName),
folder: this.$route.query.folder,
currentDirectory: encodeURI(this.path),
username: this.$store.state.user.name,
userId: this.$store.state.user.userId

View File

@ -5,100 +5,93 @@
<div id='stars2'></div>
<div id='stars3'></div>
<el-card class="box-card">
<el-form ref="loginForm" :model="loginForm" :rules="loginRules" class="login-form" auto-complete="on" label-position="left">
<div class="login-content">
<el-card class="box-card">
<el-form ref="loginForm" :model="loginForm" :rules="loginRules" class="login-form" auto-complete="on" label-position="left">
<div class="title-container">
<h3 v-if="!initialize">
<div class="title">
<Logo v-model="webstieRecord.netdiskLogo" width="65"></Logo>
<div class="jmal-cloud-name">
<div>{{ webstieRecord.netdiskName ? webstieRecord.netdiskName : 'JmalCloud' }}</div>
<div class="title-container">
<h3 v-if="!initialize">
<div class="title">
<Logo v-model="webstieRecord.netdiskLogo" width="65"></Logo>
<div class="jmal-cloud-name">
<div>{{ webstieRecord.netdiskName ? webstieRecord.netdiskName : 'JmalCloud' }}</div>
</div>
</div>
</div>
</h3>
<h3 v-if="initialize" class="title">创建管理员</h3>
</div>
</h3>
<h3 v-if="initialize" class="title">创建管理员</h3>
</div>
<el-form-item prop="username">
<span class="svg-container">
<svg-icon icon-class="user" />
</span>
<el-input
ref="username"
v-model="loginForm.username"
placeholder="用户名"
name="username"
type="text"
tabindex="1"
auto-complete="on"
/>
</el-form-item>
<el-form-item prop="username">
<span class="svg-container">
<svg-icon icon-class="user" />
</span>
<el-input
ref="username"
v-model="loginForm.username"
placeholder="用户名"
name="username"
type="text"
tabindex="1"
auto-complete="on"
/>
</el-form-item>
<el-form-item prop="password">
<span class="svg-container">
<svg-icon icon-class="password" />
</span>
<el-input
:key="passwordType"
ref="password"
v-model="loginForm.password"
:type="passwordType"
placeholder="密码"
name="password"
tabindex="2"
auto-complete="on"
@keyup.enter.native="handleLogin"
/>
<span class="show-pwd" @click="showPwd">
<svg-icon :icon-class="passwordType === 'password' ? 'eye' : 'eye-open'" />
</span>
</el-form-item>
<el-form-item prop="password">
<span class="svg-container">
<svg-icon icon-class="password" />
</span>
<el-input
:key="passwordType"
ref="password"
v-model="loginForm.password"
:type="passwordType"
placeholder="密码"
name="password"
tabindex="2"
auto-complete="on"
@keyup.enter.native="handleLogin"
/>
<span class="show-pwd" @click="showPwd">
<svg-icon :icon-class="passwordType === 'password' ? 'eye' : 'eye-open'" />
</span>
</el-form-item>
<el-form-item v-if="!initialize" class="remember">
<!--<el-switch v-model="loginForm.rememberMe"></el-switch>-->
<el-checkbox label="记住我" v-model="loginForm.rememberMe"></el-checkbox>
</el-form-item>
<el-form-item v-if="!initialize" class="remember">
<!--<el-switch v-model="loginForm.rememberMe"></el-switch>-->
<el-checkbox label="记住我" v-model="loginForm.rememberMe"></el-checkbox>
</el-form-item>
<el-form-item v-if="initialize" prop="confirmPassword">
<span class="svg-container">
<svg-icon icon-class="password" />
</span>
<el-input
:key="passwordType"
ref="password"
v-model="loginForm.confirmPassword"
:type="passwordType"
placeholder="确认密码"
name="password"
tabindex="2"
auto-complete="on"
@keyup.enter.native="handleLogin"
/>
<span class="show-pwd" @click="showPwd">
<svg-icon :icon-class="passwordType === 'password' ? 'eye' : 'eye-open'" />
</span>
</el-form-item>
<el-button :loading="loading" type="primary" style="width:100%;margin: 30px 0;" @click.native.prevent="handleLogin">{{initialize?'创建':'登录'}}</el-button>
<!--<div class="tips">-->
<!--<span style="margin-right:20px;">username: admin</span>-->
<!--<span> password: any</span>-->
<!--</div>-->
</el-form>
</el-card>
<footer id="footer" class="clearfix">
<br><br><br>
<el-form-item v-if="initialize" prop="confirmPassword">
<span class="svg-container">
<svg-icon icon-class="password" />
</span>
<el-input
:key="passwordType"
ref="password"
v-model="loginForm.confirmPassword"
:type="passwordType"
placeholder="确认密码"
name="password"
tabindex="2"
auto-complete="on"
@keyup.enter.native="handleLogin"
/>
<span class="show-pwd" @click="showPwd">
<svg-icon :icon-class="passwordType === 'password' ? 'eye' : 'eye-open'" />
</span>
</el-form-item>
<el-button :loading="loading" type="primary" style="width:100%;margin: 30px 0;" @click.native.prevent="handleLogin">{{initialize?'创建':'登录'}}</el-button>
</el-form>
</el-card>
</div>
<footer id="footer" class="clearfix" style="font-size: 0.725rem;">
<div class="copyright">
<p><span>{{ webstieRecord.copyright }}</span></p>
<p>
<div>{{ webstieRecord.copyright }}</div>
<span>
<a target="_blank" href="https://beian.miit.gov.cn" >{{ webstieRecord.recordPermissionNum }}</a>
<a target="_blank" :href="'http://www.beian.gov.cn/portal/registerSystemInfo?recordcode='+webstieRecord.networkRecordNumber" ><img v-if="webstieRecord.networkRecordNumberStr" src="~@/assets/img/beian.png"/>{{ webstieRecord.networkRecordNumberStr }}</a>
</p>
</span>
</div>
<br>
</footer>
</div>
</template>
@ -285,6 +278,7 @@ $cursor: #409eff;
}
.login-container {
.el-input {
display: inline-block;
height: 47px;
@ -332,12 +326,15 @@ $light_gray:#eee;
overflow: hidden;
background: linear-gradient(#002766,30%, #0040f4);
.login-content {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.box-card {
text-align: center;
max-width: 316px;
margin-top: 128px;
margin-left: auto;
margin-right: auto;
}
.login-form {

View File

@ -9,8 +9,9 @@
<Logo v-model="netdiskLogo" width="35"></Logo>
<span>{{ netdiskName }}</span>
</div>
<div class="share-header-content sharer" v-if="sharer">
<span><span class="user">{{ sharer.showName }}</span>的分享</span>
<div class="share-header-content sharer" v-if="sharer && !showShareCode">
<el-button v-if="loginTitle.length > 0" type="primary" size="small" @click="loginOrMount"> {{ loginTitle }} </el-button>
<span class="user">{{ sharer.showName }}的分享</span>
<el-avatar :src="sharerAvatarUrl"></el-avatar>
</div>
</div>
@ -35,6 +36,15 @@
</div>
</el-breadcrumb>
</div>
<el-dialog :title="'挂载到:' + selectTreeNode.showName" :visible.sync="mountToVisible">
<file-tree v-if="mountToVisible" :localFileMode="false" ref="fileTreeMount" @treeNodeClick="onTreeNodeClick"></file-tree>
<div slot="footer" class="dialog-footer">
<el-button size="small" @click="fileTreeAndNewFolder" :disabled="fileTreeAndNewFolderDisabled"><i class="el-icon-folder-add"></i>&nbsp;&nbsp;新建文件夹</el-button>
<el-button size="small" type="primary" @click="mountFolder">挂载</el-button>
</div>
</el-dialog>
<!--右键菜单-->
<e-vue-contextmenu ref="contextShow" class="newFileMenu" :class="menuTriangle" @ctx-show="show" @ctx-hide="hide">
<div class="popper-arrow"></div>
@ -284,9 +294,11 @@ import Clipboard from "clipboard";
import OfficePreview from "@/components/preview/OfficePreview";
import Logo from "@/components/Logo";
import store from "@/store";
import FileTree from "@/components/FileTree";
export default {
components: {
FileTree,
Logo,
OfficePreview, IconFile, BreadcrumbFilePath, AlLoading,
AudioPreview, VideoPreview, ImageViewer, SimTextPreview
@ -368,6 +380,7 @@ export default {
dialogMoveOrCopyVisible: false,
directoryTreeData: [],
selectTreeNode: {},
fileTreeAndNewFolderDisabled: false,
directoryTreeProps: {
label: 'name',
children: 'children',
@ -404,13 +417,16 @@ export default {
audioPreviewVisible: false,
showUpdateDateItem: this.$pc,// 列表模式下是否显示修改时间
showSizeItem: this.$pc,// 列表模式下是否显示文件大小
sharer: undefined,//分享者信息
sharer: undefined,//分享者信息,
loginTitle: '',
sharerAvatarUrl: '',
netdiskName: 'JmalCloud',
netdiskLogo: '',
showShareCode: false,
shareData: {},
extractionCode: ''
extractionCode: '',
mountToVisible: false,
mountFileData: [],
}
},
computed: {
@ -674,6 +690,7 @@ export default {
getSharer() {
api.getSharer({shareId: this.shareId}).then(res => {
this.sharer = res.data
this.setLoginTitle()
if (res.data) {
this.sharerAvatarUrl = window.location.origin + this.imageUrl + res.data.avatar
if (this.sharer.netdiskName) {
@ -689,6 +706,17 @@ export default {
}
})
},
setLoginTitle() {
if (this.$store.getters.token) {
if (this.sharer.userId === this.$store.getters.userId) {
this.loginTitle = ''
} else {
this.loginTitle = '挂载到我的云盘'
}
} else {
this.loginTitle = '登录'
}
},
currentChange(pageIndex) {
this.pagination.pageIndex = pageIndex
if (this.pagination.fileId) {
@ -934,6 +962,44 @@ export default {
}
this.$refs.contextShow.hideMenu()
},
/**
* 登录或挂载
*/
loginOrMount() {
if (this.$store.getters.token) {
// 挂载
this.mountToVisible = true
const that = this
// setTimeout(function () {
// that.selectTreeNode = that.$refs.directoryTree.getCurrentNode()
// that.selectTreeNode.showName = ' "' + that.selectTreeNode.name + '"'
// }, 100)
} else {
// 登录
this.$router.push({path: '/login', query: {redirect: this.$route.fullPath}})
}
},
/**
* 挂载操作
*/
mountFolder() {
api.mountFolder({
userId: this.$store.getters.userId,
shareId: this.shareId,
fileId: this.selectTreeNode.id
}).then(() => {
this.$message.success("挂载成功")
this.mountToVisible = false
})
},
fileTreeAndNewFolder() {
this.$refs.fileTreeMount.fileTreeAndNewFolder(this.selectTreeNode)
},
onTreeNodeClick(row) {
this.fileTreeAndNewFolderDisabled = row.hasOwnProperty('newFolder');
this.selectTreeNode = row
this.selectTreeNode.showName = ' "' + row.name + '"'
},
downloadFile(copy) {
let totalSize = 0
if (this.indexList.length > 0) {
@ -1085,8 +1151,12 @@ export default {
text-align: center;
font-size: 18px;
font-weight: 500;
margin-top: 20px;
height: 45px;
margin-bottom: 10px;
display: flex;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
justify-content: space-between;
.logo {
font-size: 20px;
@ -1109,7 +1179,6 @@ export default {
font-size: 14px;
float: right;
top: 10px;
margin-top: -34px;
> > > .el-avatar {
margin: 0 0 0 10px;
@ -1211,5 +1280,13 @@ export default {
margin-top: 10px;
}
>>> .el-input-tree {
width: 50% !important;
}
>>> .el-input-tree-button {
margin-left: 5px !important;
}
</style>

View File

@ -124,9 +124,6 @@ export default {
secretKey: [
{required: true, message: '请填写secretKey', trigger: 'submit'}
],
region: [
{required: true, message: '请填写region', trigger: 'submit'}
],
bucket: [
{required: true, message: '请填写bucket', trigger: 'submit'}
],

View File

@ -205,13 +205,6 @@
audioCoverUrl: `${process.env.VUE_APP_BASE_API}/view/cover?jmal-token=${this.$store.state.user.token}&name=${this.$store.state.user.name}&id=`,
fileMenuActive: '',
path: this.$route.query.path,
showNewFolder: false,
isShowNewFolder: false,
listModeSearch: false,
listModeSearchOpenDir: false,
newFolderName: '新建文件夹',
renameFileName: '',
searchFileName: '',
pathList: [
{ 'folder': '', index: 0 },
{ 'folder': '+', index: 1 }
@ -252,7 +245,6 @@
name: 'expireDate', label: '过期时间', sortable: 'custom', index: 7
}
],
rowContextData: {},
selectRowData: [],
tableLoading: false,
finished: false,
@ -443,23 +435,30 @@
},
// 取消分享
cancelShare(row) {
let shareIds = []
if(row){
shareIds.push(row.id)
} else {
this.selectRowData.forEach(row => {
shareIds.push(row.id)
})
}
api.cancelShareLink({
userId: this.$store.state.user.userId,
shareId: shareIds
let title = row === false ? '确定要取消选中的' + this.selectRowData.length + '项分享吗?' : '确定要取消分享 "' + row.fileName + '" 吗?'
this.$confirm(title, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
if(shareIds.length === 1){
this.fileList.splice(row.index,1)
}else{
this.getFileList()
let shareIds = []
if(row){
shareIds.push(row.id)
} else {
this.selectRowData.forEach(row => {
shareIds.push(row.id)
})
}
api.cancelShareLink({
userId: this.$store.state.user.userId,
shareId: shareIds
}).then(() => {
if(shareIds.length === 1){
this.fileList.splice(row.index,1)
}else{
this.getFileList()
}
})
})
},
// 点击文件或文件夹