支持复制路径
This commit is contained in:
parent
3467a6ee09
commit
1286c42d4c
@ -14,6 +14,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<explorer-node v-for="node in node.files" :key="node.item.id" :node="node" :depth="depth + 1"></explorer-node>
|
<explorer-node v-for="node in node.files" :key="node.item.id" :node="node" :depth="depth + 1"></explorer-node>
|
||||||
</div>
|
</div>
|
||||||
|
<button ref="copyId" v-clipboard="copyPath()" @click="info('路径已复制到剪切板!')" style="display: none;"></button>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -23,6 +24,7 @@ import workspaceSvc from '../services/workspaceSvc';
|
|||||||
import explorerSvc from '../services/explorerSvc';
|
import explorerSvc from '../services/explorerSvc';
|
||||||
import store from '../store';
|
import store from '../store';
|
||||||
import badgeSvc from '../services/badgeSvc';
|
import badgeSvc from '../services/badgeSvc';
|
||||||
|
import utils from '../services/utils';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'explorer-node', // Required for recursivity
|
name: 'explorer-node', // Required for recursivity
|
||||||
@ -80,6 +82,9 @@ export default {
|
|||||||
...mapActions('explorer', [
|
...mapActions('explorer', [
|
||||||
'setDragTarget',
|
'setDragTarget',
|
||||||
]),
|
]),
|
||||||
|
...mapActions('notification', [
|
||||||
|
'info',
|
||||||
|
]),
|
||||||
select(id = this.node.item.id, doOpen = true) {
|
select(id = this.node.item.id, doOpen = true) {
|
||||||
const node = store.getters['explorer/nodeMap'][id];
|
const node = store.getters['explorer/nodeMap'][id];
|
||||||
if (!node) {
|
if (!node) {
|
||||||
@ -144,6 +149,11 @@ export default {
|
|||||||
// See https://stackoverflow.com/a/3977637/1333165
|
// See https://stackoverflow.com/a/3977637/1333165
|
||||||
evt.dataTransfer.setData('Text', '');
|
evt.dataTransfer.setData('Text', '');
|
||||||
},
|
},
|
||||||
|
copyPath() {
|
||||||
|
let path = utils.getAbsoluteDir(this.node).replaceAll(' ', '%20');
|
||||||
|
path = path.indexOf('/') === 0 ? path : `/${path}`;
|
||||||
|
return this.node.isFolder ? path : `${path}.md`;
|
||||||
|
},
|
||||||
onDrop() {
|
onDrop() {
|
||||||
const sourceNode = store.getters['explorer/dragSourceNode'];
|
const sourceNode = store.getters['explorer/dragSourceNode'];
|
||||||
const targetNode = store.getters['explorer/dragTargetNodeFolder'];
|
const targetNode = store.getters['explorer/dragTargetNodeFolder'];
|
||||||
@ -169,22 +179,26 @@ export default {
|
|||||||
top: evt.clientY,
|
top: evt.clientY,
|
||||||
},
|
},
|
||||||
items: [{
|
items: [{
|
||||||
name: 'New file',
|
name: '新建文件',
|
||||||
disabled: !this.node.isFolder || this.node.isTrash,
|
disabled: !this.node.isFolder || this.node.isTrash,
|
||||||
perform: () => explorerSvc.newItem(false),
|
perform: () => explorerSvc.newItem(false),
|
||||||
}, {
|
}, {
|
||||||
name: 'New folder',
|
name: '新建文件夹',
|
||||||
disabled: !this.node.isFolder || this.node.isTrash || this.node.isTemp,
|
disabled: !this.node.isFolder || this.node.isTrash || this.node.isTemp,
|
||||||
perform: () => explorerSvc.newItem(true),
|
perform: () => explorerSvc.newItem(true),
|
||||||
}, {
|
}, {
|
||||||
type: 'separator',
|
type: 'separator',
|
||||||
}, {
|
}, {
|
||||||
name: 'Rename',
|
name: '重命名',
|
||||||
disabled: this.node.isTrash || this.node.isTemp,
|
disabled: this.node.isTrash || this.node.isTemp,
|
||||||
perform: () => this.setEditingId(this.node.item.id),
|
perform: () => this.setEditingId(this.node.item.id),
|
||||||
}, {
|
}, {
|
||||||
name: 'Delete',
|
name: '删除',
|
||||||
perform: () => explorerSvc.deleteItem(),
|
perform: () => explorerSvc.deleteItem(),
|
||||||
|
}, {
|
||||||
|
name: '复制路径',
|
||||||
|
disabled: this.node.isTrash || this.node.isTemp,
|
||||||
|
perform: () => this.$refs.copyId.click(),
|
||||||
}],
|
}],
|
||||||
});
|
});
|
||||||
if (item) {
|
if (item) {
|
||||||
|
Loading…
Reference in New Issue
Block a user