🐛 修复 icon-picker 选择图标自动隐藏内容
This commit is contained in:
		
							parent
							
								
									43e4ab7ade
								
							
						
					
					
						commit
						7873134d81
					
				@ -22,6 +22,7 @@
 | 
				
			|||||||
          <li>[新增] layer 组件 resize 属性, 开启弹层尺寸拉伸, 常用于 页面层 与 Iframe 层。</li>
 | 
					          <li>[新增] layer 组件 resize 属性, 开启弹层尺寸拉伸, 常用于 页面层 与 Iframe 层。</li>
 | 
				
			||||||
          <li>[加强] layer 组件 area 属性, 支持 字符串 与 数组 类型, 默认 auto 宽高根据内容自适应。</li>
 | 
					          <li>[加强] layer 组件 area 属性, 支持 字符串 与 数组 类型, 默认 auto 宽高根据内容自适应。</li>
 | 
				
			||||||
          <li>[修复] layer 组件 body 禁用拖动, 仅支持标题拖动窗体。</li>
 | 
					          <li>[修复] layer 组件 body 禁用拖动, 仅支持标题拖动窗体。</li>
 | 
				
			||||||
 | 
					          <li>[修复] dropdown 组件触发方式为 hover 时,移动不到菜单子项的问题</li>
 | 
				
			||||||
          <li>[集成] utteranc.es 插件, 基于 issues 提供为文档提供留言能力。</li>
 | 
					          <li>[集成] utteranc.es 插件, 基于 issues 提供为文档提供留言能力。</li>
 | 
				
			||||||
          <li>[升级] layer-vue 1.2.0, 更稳定的 layer 版本。</li>
 | 
					          <li>[升级] layer-vue 1.2.0, 更稳定的 layer 版本。</li>
 | 
				
			||||||
          <li>[升级] vue 3.2.26 版本。</li>
 | 
					          <li>[升级] vue 3.2.26 版本。</li>
 | 
				
			||||||
 | 
				
			|||||||
@ -1,3 +1,49 @@
 | 
				
			|||||||
 | 
					<script lang="ts">
 | 
				
			||||||
 | 
					export default {
 | 
				
			||||||
 | 
					  name: "LayDropdown"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					</script>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<script setup lang="ts">
 | 
				
			||||||
 | 
					import { defineProps, provide, ref, watch } from 'vue'
 | 
				
			||||||
 | 
					import { useClickOutside } from '@layui/hooks-vue'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const dropdownRef = ref<null | HTMLElement>(null)
 | 
				
			||||||
 | 
					const isClickOutside = useClickOutside(dropdownRef)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export interface LayDropdownProps {
 | 
				
			||||||
 | 
					    trigger?: string
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const props = withDefaults(defineProps<LayDropdownProps>(),{
 | 
				
			||||||
 | 
					    trigger: 'click',
 | 
				
			||||||
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const openState = ref(false)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const open = function () {
 | 
				
			||||||
 | 
					  openState.value = true
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const hide = function () {
 | 
				
			||||||
 | 
					  openState.value = false
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const toggle = function () {
 | 
				
			||||||
 | 
					  openState.value = !openState.value
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					watch(isClickOutside, () => {
 | 
				
			||||||
 | 
					  if (isClickOutside.value) {
 | 
				
			||||||
 | 
					    openState.value = false
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					provide('openState', openState)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					defineExpose({ open, hide, toggle });
 | 
				
			||||||
 | 
					</script>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<template>
 | 
					<template>
 | 
				
			||||||
  <div
 | 
					  <div
 | 
				
			||||||
    v-if="trigger === 'click'"
 | 
					    v-if="trigger === 'click'"
 | 
				
			||||||
@ -30,43 +76,4 @@
 | 
				
			|||||||
      </ul>
 | 
					      </ul>
 | 
				
			||||||
    </dl>
 | 
					    </dl>
 | 
				
			||||||
  </div>
 | 
					  </div>
 | 
				
			||||||
</template>
 | 
					</template>
 | 
				
			||||||
 | 
					 | 
				
			||||||
<script setup name="LaySelect" lang="ts">
 | 
					 | 
				
			||||||
import { defineProps, provide, ref, watch } from 'vue'
 | 
					 | 
				
			||||||
import { useClickOutside } from '@layui/hooks-vue'
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
const dropdownRef = ref<null | HTMLElement>(null)
 | 
					 | 
				
			||||||
const isClickOutside = useClickOutside(dropdownRef)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
const props = withDefaults(
 | 
					 | 
				
			||||||
  defineProps<{
 | 
					 | 
				
			||||||
    trigger?: string
 | 
					 | 
				
			||||||
  }>(),
 | 
					 | 
				
			||||||
  {
 | 
					 | 
				
			||||||
    trigger: 'click',
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
const openState = ref(false)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
const open = function () {
 | 
					 | 
				
			||||||
  openState.value = true
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
const hide = function () {
 | 
					 | 
				
			||||||
  openState.value = false
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
const toggle = function () {
 | 
					 | 
				
			||||||
  openState.value = !openState.value
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
watch(isClickOutside, () => {
 | 
					 | 
				
			||||||
  if (isClickOutside.value) {
 | 
					 | 
				
			||||||
    openState.value = false
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
})
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
provide('openState', openState)
 | 
					 | 
				
			||||||
</script>
 | 
					 | 
				
			||||||
@ -1,5 +1,5 @@
 | 
				
			|||||||
<template>
 | 
					<template>
 | 
				
			||||||
  <lay-dropdown>
 | 
					  <lay-dropdown ref="dropdownRef">
 | 
				
			||||||
    <div
 | 
					    <div
 | 
				
			||||||
      class="
 | 
					      class="
 | 
				
			||||||
        layui-inline layui-border-box layui-iconpicker layui-iconpicker-split
 | 
					        layui-inline layui-border-box layui-iconpicker layui-iconpicker-split
 | 
				
			||||||
@ -85,17 +85,18 @@
 | 
				
			|||||||
import { defineProps, Ref, ref } from 'vue'
 | 
					import { defineProps, Ref, ref } from 'vue'
 | 
				
			||||||
import { LayIconList as icons } from "@layui/icons-vue"
 | 
					import { LayIconList as icons } from "@layui/icons-vue"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const props = withDefaults(
 | 
					export interface LayIconPickerProps {
 | 
				
			||||||
  defineProps<{
 | 
					    page?: boolean,
 | 
				
			||||||
    modelValue?: string
 | 
					    modelValue?: string,
 | 
				
			||||||
    page?: boolean
 | 
					 | 
				
			||||||
    showSearch?: boolean
 | 
					    showSearch?: boolean
 | 
				
			||||||
  }>(),
 | 
					}
 | 
				
			||||||
  {
 | 
					
 | 
				
			||||||
 | 
					const props = withDefaults(defineProps<LayIconPickerProps>(),{
 | 
				
			||||||
    modelValue: 'layui-icon-face-smile',
 | 
					    modelValue: 'layui-icon-face-smile',
 | 
				
			||||||
    page: false,
 | 
					    page: false,
 | 
				
			||||||
  }
 | 
					})
 | 
				
			||||||
)
 | 
					
 | 
				
			||||||
 | 
					const dropdownRef = ref<null | HTMLElement>(null);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const emit = defineEmits(['update:modelValue'])
 | 
					const emit = defineEmits(['update:modelValue'])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -104,6 +105,8 @@ const selectedIcon: Ref<string> = ref(props.modelValue as string)
 | 
				
			|||||||
const selectIcon = function (icon: string) {
 | 
					const selectIcon = function (icon: string) {
 | 
				
			||||||
  emit('update:modelValue', icon)
 | 
					  emit('update:modelValue', icon)
 | 
				
			||||||
  selectedIcon.value = icon
 | 
					  selectedIcon.value = icon
 | 
				
			||||||
 | 
					  // @ts-ignore
 | 
				
			||||||
 | 
					  dropdownRef.value.hide()
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const icones: Ref = ref([])
 | 
					const icones: Ref = ref([])
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user