feat(I18n): Add Ii8n

feat(LocaleDropdown): Add LocaleDropdown Component

feat(store): Add localeStore
This commit is contained in:
kailong321200875
2022-01-03 09:41:34 +08:00
parent 45d657d44c
commit 3810b8c3b2
42 changed files with 1033 additions and 625 deletions

View File

@@ -1,4 +1,4 @@
import VFrom from './src/VForm.vue'
import VFrom from './src/Form.vue'
export interface VFormExpose {
count: number

View File

@@ -20,7 +20,7 @@ export default defineComponent({
props: {
// Form
schema: {
type: Array as PropType<VFormSchema[]>,
type: Array as PropType<FormSchema[]>,
required: true,
default: () => []
},
@@ -98,7 +98,7 @@ export default defineComponent({
}
// formItem
function renderFormItem(item: VFormSchema) {
function renderFormItem(item: FormSchema) {
// options
const notRenderOptions = ['SelectV2', 'Cascader', 'Transfer']
const slotsMap: Recordable = {
@@ -134,7 +134,7 @@ export default defineComponent({
}
// options
function renderOptions(item: VFormSchema) {
function renderOptions(item: FormSchema) {
switch (item.component) {
case 'Select':
const { renderSelectOptions } = useRenderSelect(slots)

View File

@@ -18,7 +18,7 @@ import {
ElAutocomplete,
ElDivider
} from 'element-plus'
import { VInputPassword } from '@/components/InputPassword'
import { InputPassword } from '@/components/InputPassword'
const componentMap: Recordable<Component, ComponentName> = {
Radio: ElRadioGroup,
@@ -40,7 +40,7 @@ const componentMap: Recordable<Component, ComponentName> = {
TimeSelect: ElTimeSelect,
SelectV2: ElSelectV2,
RadioButton: ElRadioGroup,
InputPassword: VInputPassword
InputPassword: InputPassword
}
export { componentMap }

View File

@@ -2,7 +2,7 @@ import { ElCheckbox, ElCheckboxButton } from 'element-plus'
import { defineComponent } from 'vue'
export function useRenderChcekbox() {
function renderChcekboxOptions(item: VFormSchema) {
function renderChcekboxOptions(item: FormSchema) {
// 如果有别名,就取别名
const labelAlias = item?.componentProps?.optionsAlias?.labelField
const valueAlias = item?.componentProps?.optionsAlias?.valueField

View File

@@ -2,7 +2,7 @@ import { ElRadio, ElRadioButton } from 'element-plus'
import { defineComponent } from 'vue'
export function useRenderRadio() {
function renderRadioOptions(item: VFormSchema) {
function renderRadioOptions(item: FormSchema) {
// 如果有别名,就取别名
const labelAlias = item?.componentProps?.optionsAlias?.labelField
const valueAlias = item?.componentProps?.optionsAlias?.valueField

View File

@@ -4,7 +4,7 @@ import { Slots } from 'vue'
export function useRenderSelect(slots: Slots) {
// 渲染 select options
function renderSelectOptions(item: VFormSchema) {
function renderSelectOptions(item: FormSchema) {
// 如果有别名,就取别名
const labelAlias = item?.componentProps?.optionsAlias?.labelField
return item?.componentProps?.options?.map((option) => {
@@ -25,7 +25,7 @@ export function useRenderSelect(slots: Slots) {
}
// 渲染 select option item
function renderSelectOptionItem(item: VFormSchema, option: ComponentOptions) {
function renderSelectOptionItem(item: FormSchema, option: ComponentOptions) {
// 如果有别名,就取别名
const labelAlias = item?.componentProps?.optionsAlias?.labelField
const valueAlias = item?.componentProps?.optionsAlias?.valueField

View File

@@ -16,7 +16,7 @@ interface PlaceholderMoel {
* @returns 返回提示信息对象
* @description 用于自动设置placeholder
*/
export function setTextPlaceholder(schema: VFormSchema): PlaceholderMoel {
export function setTextPlaceholder(schema: FormSchema): PlaceholderMoel {
const textMap = ['Input', 'Autocomplete', 'InputNumber', 'InputPassword']
const selectMap = ['Select', 'TimePicker', 'DatePicker', 'TimeSelect', 'TimeSelect']
if (textMap.includes(schema?.component as string)) {
@@ -74,7 +74,7 @@ export function setGridProp(col: ColProps = {}): ColProps {
* @param item 传入的组件属性
* @returns 默认添加 clearable 属性
*/
export function setComponentProps(item: VFormSchema): Recordable {
export function setComponentProps(item: FormSchema): Recordable {
const notNeedClearable = ['ColorPicker']
const componentProps: Recordable = notNeedClearable.includes(item.component as string)
? { ...item.componentProps }
@@ -117,7 +117,7 @@ export function setItemComponentSlots(
* @returns FormMoel
* @description 生成对应的formModel
*/
export function initModel(schema: VFormSchema[], formModel: Recordable) {
export function initModel(schema: FormSchema[], formModel: Recordable) {
const model: Recordable = { ...formModel }
schema.map((v) => {
// 如果是hidden就删除对应的值