Skip to content

Commit 207c5b3

Browse files
style: 修改样式
1 parent 26dc886 commit 207c5b3

File tree

10 files changed

+98
-167
lines changed

10 files changed

+98
-167
lines changed

src/components/Editor/src/Editor.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ const handleChange = (editor: IDomEditor) => {
9999
// 组件销毁时,及时销毁编辑器
100100
onBeforeUnmount(() => {
101101
const editor = unref(editorRef.value)
102-
if (editor === null) return
103102
104103
// 销毁,并移除 editor
105104
editor?.destroy()
@@ -121,7 +120,7 @@ defineExpose({
121120
<Toolbar
122121
:editor="editorRef"
123122
:editorId="editorId"
124-
class="b-b-1 border-solid border-[var(--tags-view-border-color)]"
123+
class="border-0 b-b-1 border-solid border-[var(--tags-view-border-color)]"
125124
/>
126125
<!-- 编辑器 -->
127126
<Editor

src/components/Form/src/Form.vue

Lines changed: 3 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -182,41 +182,7 @@ export default defineComponent({
182182
183183
// 渲染formItem
184184
const renderFormItem = (item: FormSchema) => {
185-
// 单独给只有options属性的组件做判断
186-
// const notRenderOptions = ['SelectV2', 'Cascader', 'Transfer']
187-
188-
// if (
189-
// item?.component !== 'SelectV2' &&
190-
// item?.component !== 'Cascader' &&
191-
// item?.componentProps?.options
192-
// ) {
193-
// slotsMap.default = () => renderOptions(item)
194-
// }
195-
196-
// const formItemSlots: Recordable = setFormItemSlots(slots, item.field)
197-
// 如果有 labelMessage,自动使用插槽渲染
198-
// if (item?.labelMessage) {
199-
// formItemSlots.label = () => {
200-
// return (
201-
// <>
202-
// <span>{item.label}</span>
203-
// <ElTooltip placement="right" raw-content>
204-
// {{
205-
// content: () => <span v-html={item.labelMessage}></span>,
206-
// default: () => (
207-
// <Icon
208-
// icon="ep:warning"
209-
// size={16}
210-
// color="var(--el-color-primary)"
211-
// class="ml-2px relative top-1px"
212-
// ></Icon>
213-
// )
214-
// }}
215-
// </ElTooltip>
216-
// </>
217-
// )
218-
// }
219-
// }
185+
const formItemSlots: Recordable = setFormItemSlots(slots, item.field)
220186
return (
221187
<ElFormItem {...(item.formItemProps || {})} prop={item.field} label={item.label || ''}>
222188
{{
@@ -291,7 +257,8 @@ export default defineComponent({
291257
</Com>
292258
)
293259
}
294-
}
260+
},
261+
...formItemSlots
295262
}}
296263
</ElFormItem>
297264
)

src/components/Form/src/helper/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export const setGridProp = (col: ColProps = {}): ColProps => {
8686
export const setComponentProps = (item: FormSchema): Recordable => {
8787
// const notNeedClearable = ['ColorPicker']
8888
// 拆分事件并组合
89-
const onEvents = item?.componentProps?.on || {}
89+
const onEvents = (item?.componentProps as any)?.on || {}
9090
const newOnEvents: Recordable = {}
9191

9292
for (const key in onEvents) {
@@ -165,13 +165,13 @@ export const initModel = (schema: FormSchema[], formModel: Recordable) => {
165165
export const setFormItemSlots = (slots: Slots, field: string): Recordable => {
166166
const slotObj: Recordable = {}
167167
if (slots[`${field}-error`]) {
168-
slotObj['error'] = (data: Recordable) => {
169-
return getSlot(slots, `${field}-error`, data)
168+
slotObj['error'] = (...args: any[]) => {
169+
return getSlot(slots, `${field}-error`, args)
170170
}
171171
}
172172
if (slots[`${field}-label`]) {
173-
slotObj['label'] = (data: Recordable) => {
174-
return getSlot(slots, `${field}-label`, data)
173+
slotObj['label'] = (...args: any[]) => {
174+
return getSlot(slots, `${field}-label`, args)
175175
}
176176
}
177177
return slotObj

src/components/Form/src/types/index.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ import {
55
InputNumberProps,
66
CascaderProps,
77
CascaderNode,
8-
CascaderValue
8+
CascaderValue,
9+
FormItemRule
910
} from 'element-plus'
1011
import type { AxiosPromise } from 'axios'
12+
import { IEditorConfig } from '@wangeditor/editor'
1113

1214
export interface PlaceholderModel {
1315
placeholder?: string
@@ -731,6 +733,11 @@ export interface TimeSelectComponentProps {
731733
style?: CSSProperties
732734
}
733735

736+
export interface EditorComponentProps {
737+
editorConfig?: IEditorConfig
738+
style?: CSSProperties
739+
}
740+
734741
export interface ColProps {
735742
span?: number
736743
xs?: number
@@ -752,10 +759,13 @@ export type FormValueType = string | number | string[] | number[] | boolean | un
752759
export interface FormItemProps {
753760
labelWidth?: string | number
754761
required?: boolean
755-
rules?: Recordable
762+
rules?: FormItemRule | FormItemRule[]
756763
error?: string
757764
showMessage?: boolean
758765
inlineMessage?: boolean
766+
size?: ElementPlusSize
767+
for?: string
768+
validateStatus?: '' | 'error' | 'validating' | 'success'
759769
style?: CSSProperties
760770
}
761771

@@ -800,6 +810,7 @@ export interface FormSchema {
800810
| DatePickerComponentProps
801811
| DateTimePickerComponentProps
802812
| TimePickerComponentProps
813+
| EditorComponentProps
803814

804815
/**
805816
* formItem组件属性,具体可以查看element-plus文档

src/components/InputPassword/src/InputPassword.vue

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,19 +53,11 @@ const getPasswordStrength = computed(() => {
5353
const zxcvbnRef = zxcvbn(unref(valueRef)) as ZxcvbnResult
5454
return value ? zxcvbnRef.score : -1
5555
})
56-
57-
const getIconName = computed(() =>
58-
unref(textType) === 'password' ? 'ant-design:eye-invisible-outlined' : 'ant-design:eye-outlined'
59-
)
6056
</script>
6157

6258
<template>
6359
<div :class="[prefixCls, `${prefixCls}--${configGlobal?.size}`]">
64-
<ElInput v-bind="$attrs" v-model="valueRef" :type="textType">
65-
<template #suffix>
66-
<Icon class="el-input__icon cursor-pointer" :icon="getIconName" @click="changeTextType" />
67-
</template>
68-
</ElInput>
60+
<ElInput v-bind="$attrs" v-model="valueRef" showPassword :type="textType" />
6961
<div
7062
v-if="strength"
7163
:class="`${prefixCls}__bar`"

src/locales/en.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,10 @@ export default {
280280
set: 'Set',
281281
subitem: 'Subitem',
282282
formValidation: 'Form validation',
283-
verifyReset: 'Verify reset'
283+
verifyReset: 'Verify reset',
284+
// 富文本编辑器
285+
richText: 'Rich text',
286+
form: 'Form'
284287
},
285288
guideDemo: {
286289
guide: 'Guide',

src/locales/zh-CN.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,10 @@ export default {
279279
set: '设置',
280280
subitem: '子项',
281281
formValidation: '表单验证',
282-
verifyReset: '验证重置'
282+
verifyReset: '验证重置',
283+
// 富文本编辑器
284+
richText: '富文本编辑器',
285+
form: '表单'
283286
},
284287
guideDemo: {
285288
guide: '引导页',

src/router/index.ts

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ export const asyncRouterMap: AppRouteRecordRaw[] = [
166166
// }
167167
// }
168168
]
169-
}
169+
},
170170
// {
171171
// path: 'table',
172172
// component: getParentLayout(),
@@ -203,26 +203,26 @@ export const asyncRouterMap: AppRouteRecordRaw[] = [
203203
// }
204204
// ]
205205
// },
206-
// {
207-
// path: 'editor-demo',
208-
// component: getParentLayout(),
209-
// redirect: '/components/editor-demo/editor',
210-
// name: 'EditorDemo',
211-
// meta: {
212-
// title: t('router.editor'),
213-
// alwaysShow: true
214-
// },
215-
// children: [
216-
// {
217-
// path: 'editor',
218-
// component: () => import('@/views/Components/Editor/Editor.vue'),
219-
// name: 'Editor',
220-
// meta: {
221-
// title: t('router.richText')
222-
// }
223-
// }
224-
// ]
225-
// },
206+
{
207+
path: 'editor-demo',
208+
component: getParentLayout(),
209+
redirect: '/components/editor-demo/editor',
210+
name: 'EditorDemo',
211+
meta: {
212+
title: t('router.editor'),
213+
alwaysShow: true
214+
},
215+
children: [
216+
{
217+
path: 'editor',
218+
component: () => import('@/views/Components/Editor/Editor.vue'),
219+
name: 'Editor',
220+
meta: {
221+
title: t('router.richText')
222+
}
223+
}
224+
]
225+
}
226226
// {
227227
// path: 'search',
228228
// component: () => import('@/views/Components/Search.vue'),

src/views/Components/Form/DefaultForm.vue

Lines changed: 46 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1343,7 +1343,50 @@ const schema = reactive<FormSchema[]>([
13431343
field: 'field63',
13441344
component: 'TimeSelect',
13451345
label: t('formDemo.default')
1346-
}
1346+
},
1347+
{
1348+
field: 'field64',
1349+
component: 'Divider',
1350+
label: t('formDemo.richText')
1351+
},
1352+
{
1353+
field: 'field65',
1354+
component: 'Editor',
1355+
value: 'hello world',
1356+
label: t('formDemo.default'),
1357+
componentProps: {
1358+
editorConfig: {
1359+
placeholder: '请输入内容...'
1360+
}
1361+
},
1362+
colProps: {
1363+
span: 24
1364+
}
1365+
},
1366+
{
1367+
field: 'field66',
1368+
component: 'Divider',
1369+
label: t('formDemo.inputPassword')
1370+
},
1371+
{
1372+
field: 'field67',
1373+
component: 'InputPassword',
1374+
label: t('formDemo.default'),
1375+
componentProps: {
1376+
strength: true
1377+
}
1378+
},
1379+
{
1380+
field: 'field68',
1381+
component: 'Divider',
1382+
label: `${t('formDemo.form')} t('formDemo.slot')}`,
1383+
},
1384+
{
1385+
field: 'field69',
1386+
component: 'Input',
1387+
value: 'test',
1388+
label: `default`,
1389+
},
13471390
])
13481391
13491392
const { register, formRef, methods } = useForm({
@@ -1360,68 +1403,8 @@ const changeToggle = () => {
13601403
<template>
13611404
<button @click="changeToggle">测试</button>
13621405
<ContentWrap :title="t('formDemo.defaultForm')" :message="t('formDemo.formDes')">
1363-
<!-- <Form :schema="schema" label-width="auto" :label-position="isMobile ? 'top' : 'right'">
1364-
<template #field4-prefix>
1365-
<Icon icon="ep:calendar" class="el-input__icon" />
1366-
</template>
1367-
<template #field4-suffix>
1368-
<Icon icon="ep:calendar" class="el-input__icon" />
1369-
</template>
1370-
1371-
<template #field5-prepend> Http:// </template>
1372-
<template #field5-append> .com </template>
1373-
1374-
<template #field9-default="{ item }">
1375-
<div class="value">{{ item.value }}</div>
1376-
<span class="link">{{ item.link }}</span>
1377-
</template>
1378-
1379-
<template #field15-option="{ item }">
1380-
<span style="float: left">{{ item.label }}</span>
1381-
<span style="float: right; font-size: 13px; color: var(--el-text-color-secondary)">
1382-
{{ item.value }}
1383-
</span>
1384-
</template>
1385-
1386-
<template #field17-option="{ item }">
1387-
<span style="float: left">{{ item.label }}</span>
1388-
<span style="float: right; font-size: 13px; color: var(--el-text-color-secondary)">
1389-
{{ item.value }}
1390-
</span>
1391-
</template>
1392-
1393-
<template #field20-default="{ item }">
1394-
<span style="float: left">{{ item.label }}</span>
1395-
<span style="float: right; font-size: 13px; color: var(--el-text-color-secondary)">
1396-
{{ item.value }}
1397-
</span>
1398-
</template>
1399-
1400-
<template #field22-default="{ item }">
1401-
<span style="float: left">{{ item.label }}</span>
1402-
<span style="float: right; font-size: 13px; color: var(--el-text-color-secondary)">
1403-
{{ item.value }}
1404-
</span>
1405-
</template>
1406-
1407-
<template #field25-default="{ node, data }">
1408-
<span>{{ data.label }}</span>
1409-
<span v-if="!node.isLeaf"> ({{ data.children.length }}) </span>
1410-
</template>
1411-
1412-
<template #field36-default="{ option }">
1413-
<span>{{ option.value }} - {{ option.desc }}</span>
1414-
</template>
1415-
1416-
<template #field55-default="cell">
1417-
<div class="cell" :class="{ current: cell.isCurrent }">
1418-
<span class="text">{{ cell.text }}</span>
1419-
<span v-if="isHoliday(cell)" class="holiday"></span>
1420-
</div>
1421-
</template>
1422-
</Form> -->
1423-
1424-
<Form @register="register" />
1406+
<Form @register="register" label-width="auto" :label-position="isMobile ? 'top' : 'right'">
1407+
</Form>
14251408
</ContentWrap>
14261409
</template>
14271410

types/custom-types.d.ts

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)