Browse Source

fix(form): remove field binding when deleting schema #471

pull/514/head
Vben 6 years ago
parent
commit
38f5072695
  1. 1
      CHANGELOG.zh_CN.md
  2. 4
      build/vite/plugin/index.ts
  3. 3
      src/components/Form/src/hooks/useForm.ts
  4. 5
      src/components/Form/src/hooks/useFormEvents.ts
  5. 7
      src/components/Icon/README.md

1
CHANGELOG.zh_CN.md

@ -14,6 +14,7 @@
- 修复黑暗主题刷新闪烁的白屏 - 修复黑暗主题刷新闪烁的白屏
- 修复标签页关闭其他功能失效问题 - 修复标签页关闭其他功能失效问题
- 修复表单已知问题
## 2.3.0 (2021-04-10) ## 2.3.0 (2021-04-10)

4
build/vite/plugin/index.ts

@ -16,7 +16,7 @@ import { configThemePlugin } from './theme';
import { configImageminPlugin } from './imagemin'; import { configImageminPlugin } from './imagemin';
import { configWindiCssPlugin } from './windicss'; import { configWindiCssPlugin } from './windicss';
import { configSvgIconsPlugin } from './svgSprite'; import { configSvgIconsPlugin } from './svgSprite';
// import { configHmrPlugin } from './hmr'; import { configHmrPlugin } from './hmr';
export function createVitePlugins(viteEnv: ViteEnv, isBuild: boolean) { export function createVitePlugins(viteEnv: ViteEnv, isBuild: boolean) {
const { const {
@ -35,7 +35,7 @@ export function createVitePlugins(viteEnv: ViteEnv, isBuild: boolean) {
]; ];
// TODO // TODO
// !isBuild && vitePlugins.push(configHmrPlugin()); !isBuild && vitePlugins.push(configHmrPlugin());
// @vitejs/plugin-legacy // @vitejs/plugin-legacy
VITE_LEGACY && isBuild && vitePlugins.push(legacy()); VITE_LEGACY && isBuild && vitePlugins.push(legacy());

3
src/components/Form/src/hooks/useForm.ts

@ -77,8 +77,7 @@ export function useForm(props?: Props): UseFormReturnType {
}, },
removeSchemaByFiled: async (field: string | string[]) => { removeSchemaByFiled: async (field: string | string[]) => {
const form = await getForm(); unref(formRef)?.removeSchemaByFiled(field);
form.removeSchemaByFiled(field);
}, },
// TODO promisify // TODO promisify

5
src/components/Form/src/hooks/useFormEvents.ts

@ -88,7 +88,9 @@ export function useFormEvents({
*/ */
async function removeSchemaByFiled(fields: string | string[]): Promise<void> { async function removeSchemaByFiled(fields: string | string[]): Promise<void> {
const schemaList: FormSchema[] = cloneDeep(unref(getSchema)); const schemaList: FormSchema[] = cloneDeep(unref(getSchema));
if (!fields) return; if (!fields) {
return;
}
let fieldList: string[] = isString(fields) ? [fields] : fields; let fieldList: string[] = isString(fields) ? [fields] : fields;
if (isString(fields)) { if (isString(fields)) {
@ -107,6 +109,7 @@ export function useFormEvents({
if (isString(field)) { if (isString(field)) {
const index = schemaList.findIndex((schema) => schema.field === field); const index = schemaList.findIndex((schema) => schema.field === field);
if (index !== -1) { if (index !== -1) {
delete formModel[field];
schemaList.splice(index, 1); schemaList.splice(index, 1);
} }
} }

7
src/components/Icon/README.md

@ -1,7 +0,0 @@
### `Icon.vue`
```html
<Icon icon="mdi:account" />
```
The icon id follows the rules in [Iconify](https://iconify.design/) which you can use any icons from the supported icon sets.
Loading…
Cancel
Save