import { computed, defineComponent, reactive, ref, watch } from 'vue'
import useLayoutStore from '../useLayoutStore'
import { ConfigProvider, Form, Input, theme } from 'ant-design-vue'
import { OhVueIcon, addIcons } from 'oh-vue-icons'
import { MdUpload, MdImage, MdCheck } from 'oh-vue-icons/icons'
import clsx from 'clsx'
import ImageUploader from '@/utils/ImageUploader'
import useLink from './useLink'
addIcons(MdUpload, MdImage, MdCheck)
const TypeSelector = defineComponent({
props: {
value: {
type: Number,
default: 0
},
icon: {
type: String,
default: ''
},
text: {
type: String,
default: ''
},
color: {
type: String,
default: ''
},
background: {
type: String,
default: ''
}
},
emits: {
'update:value': (() => true) as (val: number) => boolean,
'update:icon': (() => true) as (val: string) => boolean
},
setup(props, ctx) {
return () => (
{
ctx.emit('update:value', 0)
}}
>
{!props.icon &&
}
{props.value === 0 && (
)}
默认
{
ctx.emit('update:value', 1)
}}
>
{props.text ? props.text.substring(0, 2) : 'A'}
{props.value === 1 && (
)}
文字
{
ctx.emit('update:icon', e)
}}
>
自定义
)
}
})
export default defineComponent({
props: {
mode: {
type: Number,
default: 0
},
page: {
type: Number,
default: 0
}
},
setup(props, ctx) {
const layout = useLayoutStore()
const form = reactive({
link: '',
name: '',
text: '',
background: '#f7a94e',
color: 'rgba(255,255,255,1)',
icon: '',
type: 0 // 0 默认,1 文字
})
const isGame = computed(() => layout.state.current === 0)
const debounced = ref('')
watch(
() => form.link,
(val, _, onCleanup) => {
const it = setTimeout(() => {
debounced.value = val
}, 500)
onCleanup(() => {
clearTimeout(it)
})
}
)
const info = useLink(debounced)
console.log(info);
watch(info, (val) => {
console.log(val);
if (val.name) form.name = val.name
if (val.icon) form.icon = val.icon
})
return () => (
)
}
})