From 4389770f713bc016e35571c18cc7daa0f6311875 Mon Sep 17 00:00:00 2001 From: jmal Date: Fri, 14 Jun 2024 15:15:21 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=8C=82=E8=BD=BD?= =?UTF-8?q?=E7=9B=AE=E5=BD=95=E4=B8=8B=E6=89=93=E5=BC=80=E7=A9=BA=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=A4=B9=E7=84=B6=E5=90=8E=E8=BF=94=E5=9B=9E=E4=B8=8A?= =?UTF-8?q?=E7=BA=A7=E5=A4=B1=E8=B4=A5=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/user.js | 8 ----- src/components/ShowFile/ShowFile.vue | 47 ++++++++++++++++------------ src/styles/index.scss | 14 +++++++++ 3 files changed, 41 insertions(+), 28 deletions(-) diff --git a/src/api/user.js b/src/api/user.js index b90a0e7..a4f7b22 100644 --- a/src/api/user.js +++ b/src/api/user.js @@ -62,14 +62,6 @@ export function getUserInfo(params) { }) } -export function getUsername(params) { - return request({ - url: 'user/username', - method: 'get', - params - }) -} - export function userList(params) { return request({ url: 'user/userList', diff --git a/src/components/ShowFile/ShowFile.vue b/src/components/ShowFile/ShowFile.vue index 7bc9fc7..8b7da54 100644 --- a/src/components/ShowFile/ShowFile.vue +++ b/src/components/ShowFile/ShowFile.vue @@ -158,6 +158,7 @@ + f @@ -836,7 +838,6 @@ import fileConfig from '@/utils/file-config' import EditElement from '@/views/markdown/EditElement' import OfficePreview from '@/components/preview/OfficePreview' import ShareDialog from '@/components/ShareDialog/index.vue' -import { getUsername } from '@/api/user' import Clipboard from 'clipboard' import TagDialog from '@/components/TagDialog/index.vue' import FileDetails from "@/components/preview/FileDetails.vue"; @@ -1400,15 +1401,30 @@ export default { event.stopPropagation() } } + // f键 + if (keyCode === 70) { + if (!this.inputting && this.editingIndex === -1) { + this.$refs.searchInput.focus() + event.preventDefault() + event.stopPropagation() + } + } }, keyup(event) { const isMac = navigator.platform.startsWith('Mac') - const { key, c, keyCode, ctrlKey, metaKey } = event + const { keyCode, ctrlKey, metaKey } = event this.isCmd = (isMac && metaKey) || (!isMac && ctrlKey) - // 松开shift建 - if (event.keyCode === 16) { + // 松开shift键 + if (keyCode === 16) { this.selectPin = false } + // f键 + if (keyCode === 70) { + if (!this.inputting && this.editingIndex === -1) { + event.preventDefault() + event.stopPropagation() + } + } }, onmessage(msg) { let fileDoc = msg.body @@ -2690,7 +2706,7 @@ export default { // 高亮新增的文件 this.highlightNewFile() // 设置挂载文件的用户名(文件的所有者) - this.setMountFileOwner() + this.setMountFileOwner(res.props) const path = this.$route.query.path ? this.$route.query.path : '/' const basePath = this.$route.query.basePath ? this.$route.query.basePath @@ -2703,14 +2719,11 @@ export default { } }, // 设置挂载文件的用户名(文件的所有者) - setMountFileOwner() { + setMountFileOwner(props) { localStorage.removeItem('mountFileOwner') - if (this.$route.query.folder && this.fileList.length > 0) { - let firstFile = this.fileList[0] - if (firstFile.userId !== this.$store.getters.userId) { - getUsername({ userId: firstFile.userId }).then(res => { - localStorage.setItem('mountFileOwner', res.data) - }) + if (this.$route.query.folder) { + if (props && props.fileUsername && props.fileUsername !== this.$store.getters.name) { + localStorage.setItem('mountFileOwner', props.fileUsername) } } }, @@ -2742,20 +2755,14 @@ export default { item['search'] = true item['searchKey'] = key - let folder = this.$route.query.folder - ? `&folder=${this.$route.query.folder}` - : '' + let folder = this.$route.query.folder ? `&folder=${this.$route.query.folder}` : '' const searchPathIndex = this.pathList.findIndex(item => item.search) if (searchPathIndex < 0) { this.pathList.push(item) } else { - this.pathList.splice( - searchPathIndex, - this.pathList.length - searchPathIndex - ) + this.pathList.splice(searchPathIndex,this.pathList.length - searchPathIndex) this.pathList.push(item) - folder = '' } const queryTagId = this.$route.query.tagId ? `&tagId=${this.$route.query.tagId}` diff --git a/src/styles/index.scss b/src/styles/index.scss index c4e7c0c..7d07ee8 100644 --- a/src/styles/index.scss +++ b/src/styles/index.scss @@ -226,3 +226,17 @@ input { .dark-file-history-list.el-table::before { background-color: #3e3e3e; } +kbd { + display: inline-block; + margin: 6px 2px; + padding: 8px 8px; + font: 14px var(--fontStack-monospace, ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, Liberation Mono, monospace); + line-height: 10px; + color: #1f2328; + vertical-align: middle; + background-color: #f6f8fa; + border: solid 1px rgba(175, 184, 193, .2); + border-radius: 6px; + -webkit-box-shadow: inset 0 -1px 0 rgba(175, 184, 193, .2); + box-shadow: inset 0 -1px 0 rgba(175, 184, 193, .2); +}