Merge pull request #184 from jamebal/dev

fix: 修复挂载目录下打开空文件夹然后返回上级失败的问题
This commit is contained in:
jmal 2024-06-14 15:16:01 +08:00 committed by GitHub
commit 5e81750760
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 41 additions and 28 deletions

View File

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

View File

@ -158,6 +158,7 @@
<el-input <el-input
v-show="showSearchButton" v-show="showSearchButton"
ref="searchInput"
placeholder="搜索" placeholder="搜索"
v-model="searchFileName" v-model="searchFileName"
:clearable="true" :clearable="true"
@ -167,6 +168,7 @@
@blur="setInputBlur()" @blur="setInputBlur()"
@clear="searchFile(searchFileName)" @clear="searchFile(searchFileName)"
> >
<kbd v-show="!inputting" slot="suffix">f</kbd>
<el-button slot="prepend" @click="searchFile(searchFileName)"> <el-button slot="prepend" @click="searchFile(searchFileName)">
<svg-icon icon-class="search" style="font-size: 22px" /> <svg-icon icon-class="search" style="font-size: 22px" />
</el-button> </el-button>
@ -836,7 +838,6 @@ import fileConfig from '@/utils/file-config'
import EditElement from '@/views/markdown/EditElement' import EditElement from '@/views/markdown/EditElement'
import OfficePreview from '@/components/preview/OfficePreview' import OfficePreview from '@/components/preview/OfficePreview'
import ShareDialog from '@/components/ShareDialog/index.vue' import ShareDialog from '@/components/ShareDialog/index.vue'
import { getUsername } from '@/api/user'
import Clipboard from 'clipboard' import Clipboard from 'clipboard'
import TagDialog from '@/components/TagDialog/index.vue' import TagDialog from '@/components/TagDialog/index.vue'
import FileDetails from "@/components/preview/FileDetails.vue"; import FileDetails from "@/components/preview/FileDetails.vue";
@ -1400,15 +1401,30 @@ export default {
event.stopPropagation() event.stopPropagation()
} }
} }
// f键
if (keyCode === 70) {
if (!this.inputting && this.editingIndex === -1) {
this.$refs.searchInput.focus()
event.preventDefault()
event.stopPropagation()
}
}
}, },
keyup(event) { keyup(event) {
const isMac = navigator.platform.startsWith('Mac') const isMac = navigator.platform.startsWith('Mac')
const { key, c, keyCode, ctrlKey, metaKey } = event const { keyCode, ctrlKey, metaKey } = event
this.isCmd = (isMac && metaKey) || (!isMac && ctrlKey) this.isCmd = (isMac && metaKey) || (!isMac && ctrlKey)
// 松开shift建 // 松开shift键
if (event.keyCode === 16) { if (keyCode === 16) {
this.selectPin = false this.selectPin = false
} }
// f键
if (keyCode === 70) {
if (!this.inputting && this.editingIndex === -1) {
event.preventDefault()
event.stopPropagation()
}
}
}, },
onmessage(msg) { onmessage(msg) {
let fileDoc = msg.body let fileDoc = msg.body
@ -2690,7 +2706,7 @@ export default {
// 高亮新增的文件 // 高亮新增的文件
this.highlightNewFile() this.highlightNewFile()
// 设置挂载文件的用户名(文件的所有者) // 设置挂载文件的用户名(文件的所有者)
this.setMountFileOwner() this.setMountFileOwner(res.props)
const path = this.$route.query.path ? this.$route.query.path : '/' const path = this.$route.query.path ? this.$route.query.path : '/'
const basePath = this.$route.query.basePath const basePath = this.$route.query.basePath
? this.$route.query.basePath ? this.$route.query.basePath
@ -2703,14 +2719,11 @@ export default {
} }
}, },
// 设置挂载文件的用户名(文件的所有者) // 设置挂载文件的用户名(文件的所有者)
setMountFileOwner() { setMountFileOwner(props) {
localStorage.removeItem('mountFileOwner') localStorage.removeItem('mountFileOwner')
if (this.$route.query.folder && this.fileList.length > 0) { if (this.$route.query.folder) {
let firstFile = this.fileList[0] if (props && props.fileUsername && props.fileUsername !== this.$store.getters.name) {
if (firstFile.userId !== this.$store.getters.userId) { localStorage.setItem('mountFileOwner', props.fileUsername)
getUsername({ userId: firstFile.userId }).then(res => {
localStorage.setItem('mountFileOwner', res.data)
})
} }
} }
}, },
@ -2742,20 +2755,14 @@ export default {
item['search'] = true item['search'] = true
item['searchKey'] = key item['searchKey'] = key
let folder = this.$route.query.folder let folder = this.$route.query.folder ? `&folder=${this.$route.query.folder}` : ''
? `&folder=${this.$route.query.folder}`
: ''
const searchPathIndex = this.pathList.findIndex(item => item.search) const searchPathIndex = this.pathList.findIndex(item => item.search)
if (searchPathIndex < 0) { if (searchPathIndex < 0) {
this.pathList.push(item) this.pathList.push(item)
} else { } else {
this.pathList.splice( this.pathList.splice(searchPathIndex,this.pathList.length - searchPathIndex)
searchPathIndex,
this.pathList.length - searchPathIndex
)
this.pathList.push(item) this.pathList.push(item)
folder = ''
} }
const queryTagId = this.$route.query.tagId const queryTagId = this.$route.query.tagId
? `&tagId=${this.$route.query.tagId}` ? `&tagId=${this.$route.query.tagId}`

View File

@ -226,3 +226,17 @@ input {
.dark-file-history-list.el-table::before { .dark-file-history-list.el-table::before {
background-color: #3e3e3e; 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);
}