wip(Login): Login developing
This commit is contained in:
@@ -9,7 +9,8 @@ import {
|
||||
setGridProp,
|
||||
setComponentProps,
|
||||
setItemComponentSlots,
|
||||
initModel
|
||||
initModel,
|
||||
setFormItemSlots
|
||||
} from './helper'
|
||||
import { useRenderSelect } from './components/useRenderSelect'
|
||||
import { useRenderRadio } from './components/useRenderRadio'
|
||||
@@ -113,14 +114,15 @@ export default defineComponent({
|
||||
}
|
||||
return (
|
||||
<ElFormItem {...(item.formItemProps || {})} prop={item.field} label={item.label}>
|
||||
{() => {
|
||||
if (slots[item.field]) {
|
||||
return getSlot(slots, item.field, { item })
|
||||
} else {
|
||||
{{
|
||||
...setFormItemSlots(slots, item.field),
|
||||
default: () => {
|
||||
const Com = componentMap[item.component as string] as ReturnType<
|
||||
typeof defineComponent
|
||||
>
|
||||
return (
|
||||
return slots[item.field] ? (
|
||||
getSlot(slots, item.field, { item })
|
||||
) : (
|
||||
<Com
|
||||
vModel={formModel.value[item.field]}
|
||||
{...(autoSetPlaceholder && setTextPlaceholder(item))}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { useI18n } from '@/hooks/web/useI18n'
|
||||
const { t } = useI18n()
|
||||
import type { Slots } from 'vue'
|
||||
import { getSlot } from '@/utils/tsxHelper'
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
interface PlaceholderMoel {
|
||||
placeholder?: string
|
||||
startPlaceholder?: string
|
||||
@@ -131,3 +132,23 @@ export function initModel(schema: FormSchema[], formModel: Recordable) {
|
||||
})
|
||||
return model
|
||||
}
|
||||
|
||||
/**
|
||||
* @param slots 插槽
|
||||
* @param field 字段名
|
||||
* @returns 返回FormIiem插槽
|
||||
*/
|
||||
export function setFormItemSlots(slots: Slots, field: string): Recordable {
|
||||
const slotObj: Recordable = {}
|
||||
if (slots[`${field}-error`]) {
|
||||
slotObj['error'] = (data: Recordable) => {
|
||||
return getSlot(slots, `${field}-error`, data)
|
||||
}
|
||||
}
|
||||
if (slots[`${field}-label`]) {
|
||||
slotObj['label'] = (data: Recordable) => {
|
||||
return getSlot(slots, `${field}-label`, data)
|
||||
}
|
||||
}
|
||||
return slotObj
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import { computed, unref } from 'vue'
|
||||
import { ElDropdown, ElDropdownMenu, ElDropdownItem } from 'element-plus'
|
||||
import { useLocaleStore } from '@/store/modules/locale'
|
||||
import { useCssVar } from '@vueuse/core'
|
||||
@@ -7,16 +7,21 @@ import { useLocale } from '@/hooks/web/useLocale'
|
||||
|
||||
const localeStore = useLocaleStore()
|
||||
|
||||
const langMap = computed(() => localeStore.localeMap)
|
||||
const langMap = computed(() => localeStore.getLocaleMap)
|
||||
|
||||
const currentLang = computed(() => localeStore.getLocale)
|
||||
|
||||
const textColor = useCssVar('--el-text-color-primary', document.documentElement)
|
||||
|
||||
function setLang(lang: LocaleType) {
|
||||
if (lang === unref(currentLang).lang) return
|
||||
localeStore.setLocale({
|
||||
lang
|
||||
})
|
||||
const { changeLocale } = useLocale()
|
||||
changeLocale(lang)
|
||||
// 需要重新加载页面让整个语言多初始化
|
||||
window.location.reload()
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user