Skip to content

Commit

Permalink
增加在系统中打开文件目录功能
Browse files Browse the repository at this point in the history
  • Loading branch information
purocean committed Nov 10, 2018
1 parent 62d8120 commit 47ee582
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
```
+ 访问 `http://localhost:3000`
+ 新增文件:`双击目录`
+ 在系统中打开文件/目录:`Ctrl + 双击文件/目录`
+ 删除文件/目录:`Shift + 右键文件/目录`
+ 重命名文件/目录:`Ctrl + 右键文件/目录`
+ 将外链或 BASE64 图片转换为本地图片:`Ctrl + Shift + 单击图片`
Expand Down
7 changes: 6 additions & 1 deletion frontend/src/components/TreeNode.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
<details ref="dir" :open="item.path === '/'" v-if="item.type === 'dir'">
<summary
:style="{background: selected ? '#313131' : 'none'}"
@dblclick="createFile()"
@dblclick.exact="createFile()"
@dblclick.ctrl.exact="revealInExplorer()"
@contextmenu.ctrl.prevent="renameFile"
@contextmenu.shift.prevent="deleteFile"> {{ item.name }} </summary>
<tree-node
Expand All @@ -18,6 +19,7 @@
<div
v-else
@click="select(item)"
@dblclick.ctrl.exact="revealInExplorer()"
@contextmenu.ctrl.prevent="renameFile"
@contextmenu.shift.prevent="deleteFile"
:style="{background: selected ? '#313131' : 'none'}"> {{ item.name }} </div>
Expand Down Expand Up @@ -80,6 +82,9 @@ export default {
window.open(`api/attachment/${encodeURIComponent(f.name)}?repo=${f.repo}&path=${encodeURIComponent(f.path)}`)
}
},
revealInExplorer () {
File.openInOS(this.item.repo, this.item.path)
},
createFile () {
let filename = window.prompt(`[${this.item.path}] 文件名`, 'new.md')
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,5 +190,8 @@ export default {
}
})
})
},
openInOS (repo, path) {
fetch(`/api/open?repo=${encodeURIComponent(repo)}&path=${encodeURIComponent(path)}`)
}
}

0 comments on commit 47ee582

Please sign in to comment.