fix(vue): 工具栏列表不显示快捷键 #57
This commit is contained in:
parent
329be7e41e
commit
759ba6de57
|
@ -2,12 +2,12 @@
|
||||||
<div
|
<div
|
||||||
:class="['toolbar-dropdown-list',`toolbar-dropdown-${direction || 'vertical'}`,{'toolbar-dropdown-dot': hasDot !== false},className]"
|
:class="['toolbar-dropdown-list',`toolbar-dropdown-${direction || 'vertical'}`,{'toolbar-dropdown-dot': hasDot !== false},className]"
|
||||||
>
|
>
|
||||||
<a-tooltip v-for="{ key , placement , title , hotkey , direction , hasDot , content , className , icon, disabled } in items" :key="key" :placement="placement || 'right'"
|
<a-tooltip v-for="{ key , placement , title , direction , hasDot , content , className , icon, disabled } in items" :key="key" :placement="placement || 'right'"
|
||||||
:overlayStyle="(!!title || !!hotkey) && !isMobile ? {} : {display:'none'}"
|
:overlayStyle="(!!title || !!hotkeys[key]) && !isMobile ? {} : {display:'none'}"
|
||||||
>
|
>
|
||||||
<template #title>
|
<template #title>
|
||||||
<div v-if="!!title" class="toolbar-tooltip-title">{{title}}</div>
|
<div v-if="!!title" class="toolbar-tooltip-title">{{title}}</div>
|
||||||
<div v-if="!!hotkey" class="toolbar-tooltip-hotkey" v-html="hotkey"></div>
|
<div v-if="!!hotkeys[key]" class="toolbar-tooltip-hotkey" v-html="hotkeys[key]"></div>
|
||||||
</template>
|
</template>
|
||||||
<a
|
<a
|
||||||
:class="['toolbar-dropdown-list-item',className, {'toolbar-dropdown-list-item-disabled': disabled}]"
|
:class="['toolbar-dropdown-list-item',className, {'toolbar-dropdown-list-item-disabled': disabled}]"
|
||||||
|
@ -37,13 +37,15 @@ export default defineComponent({
|
||||||
props:dropdownListProps,
|
props:dropdownListProps,
|
||||||
setup(props){
|
setup(props){
|
||||||
const getHotkey = (item:DropdownListItem) => {
|
const getHotkey = (item:DropdownListItem) => {
|
||||||
const { command } = item
|
const { command, key } = item
|
||||||
let { hotkey } = item
|
let { hotkey } = item
|
||||||
//默认获取插件的热键
|
//默认获取插件的热键
|
||||||
if (props.engine && (hotkey === true || hotkey === undefined)) {
|
if (props.engine && (hotkey === true || hotkey === undefined)) {
|
||||||
|
console.log(item)
|
||||||
hotkey = autoGetHotkey(
|
hotkey = autoGetHotkey(
|
||||||
props.engine,
|
props.engine,
|
||||||
command && !Array.isArray(command) ? command.name : props.name,
|
command && !Array.isArray(command) ? command.name : props.name,
|
||||||
|
key
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (typeof hotkey === 'string' && hotkey !== '') {
|
if (typeof hotkey === 'string' && hotkey !== '') {
|
||||||
|
@ -52,10 +54,10 @@ export default defineComponent({
|
||||||
return hotkey
|
return hotkey
|
||||||
}
|
}
|
||||||
|
|
||||||
const hotkeys = props.items.map(item => {
|
const hotkeys:{[key: string]: any} = {}
|
||||||
return {[item.key]:getHotkey(item)}
|
props.items.forEach(item => {
|
||||||
|
hotkeys[item.key] = getHotkey(item)
|
||||||
})
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
isMobile,
|
isMobile,
|
||||||
hotkeys
|
hotkeys
|
||||||
|
|
Loading…
Reference in New Issue