mirror of
				https://github.com/continew-org/continew-admin-ui.git
				synced 2025-10-31 22:57:15 +08:00 
			
		
		
		
	refactor: 彻底删除 useForm 组合函数
This commit is contained in:
		| @@ -3,7 +3,6 @@ export * from './modules/usePagination' | |||||||
| export * from './modules/useRequest' | export * from './modules/useRequest' | ||||||
| export * from './modules/useChart' | export * from './modules/useChart' | ||||||
| export * from './modules/useTable' | export * from './modules/useTable' | ||||||
| export * from './modules/useForm' |  | ||||||
| export * from './modules/useDevice' | export * from './modules/useDevice' | ||||||
| export * from './modules/useBreakpoint' | export * from './modules/useBreakpoint' | ||||||
| export * from './modules/useDownload' | export * from './modules/useDownload' | ||||||
|   | |||||||
| @@ -1,17 +0,0 @@ | |||||||
| import { reactive } from 'vue' |  | ||||||
| import { cloneDeep } from 'lodash-es' |  | ||||||
|  |  | ||||||
| export function useForm<F extends object>(initValue: F) { |  | ||||||
|   const getInitValue = () => cloneDeep(initValue) |  | ||||||
|  |  | ||||||
|   const form = reactive(getInitValue()) |  | ||||||
|  |  | ||||||
|   const resetForm = () => { |  | ||||||
|     for (const key in form) { |  | ||||||
|       delete form[key] |  | ||||||
|     } |  | ||||||
|     Object.assign(form, getInitValue()) |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   return { form, resetForm } |  | ||||||
| } |  | ||||||
| @@ -130,14 +130,14 @@ import { | |||||||
|   updateOption, |   updateOption, | ||||||
| } from '@/apis/system' | } from '@/apis/system' | ||||||
| import { useAppStore } from '@/stores' | import { useAppStore } from '@/stores' | ||||||
| import { useForm } from '@/hooks' | import { useResetReactive } from '@/hooks' | ||||||
| import { fileToBase64 } from '@/utils' | import { fileToBase64 } from '@/utils' | ||||||
|  |  | ||||||
| defineOptions({ name: 'BasicSetting' }) | defineOptions({ name: 'BasicSetting' }) | ||||||
|  |  | ||||||
| const loading = ref<boolean>(false) | const loading = ref<boolean>(false) | ||||||
| const formRef = ref<FormInstance>() | const formRef = ref<FormInstance>() | ||||||
| const { form } = useForm({ | const [form] = useResetReactive({ | ||||||
|   SITE_FAVICON: '', |   SITE_FAVICON: '', | ||||||
|   SITE_LOGO: '', |   SITE_LOGO: '', | ||||||
|   SITE_TITLE: '', |   SITE_TITLE: '', | ||||||
|   | |||||||
| @@ -69,13 +69,13 @@ import { | |||||||
|   resetOptionValue, |   resetOptionValue, | ||||||
|   updateOption, |   updateOption, | ||||||
| } from '@/apis/system' | } from '@/apis/system' | ||||||
| import { useForm } from '@/hooks' | import { useResetReactive } from '@/hooks' | ||||||
|  |  | ||||||
| defineOptions({ name: 'MailSetting' }) | defineOptions({ name: 'MailSetting' }) | ||||||
| const { width } = useWindowSize() | const { width } = useWindowSize() | ||||||
| const loading = ref<boolean>(false) | const loading = ref<boolean>(false) | ||||||
| const formRef = ref<FormInstance>() | const formRef = ref<FormInstance>() | ||||||
| const { form } = useForm({ | const [form] = useResetReactive({ | ||||||
|   MAIL_PROTOCOL: '', |   MAIL_PROTOCOL: '', | ||||||
|   MAIL_HOST: '', |   MAIL_HOST: '', | ||||||
|   MAIL_PORT: 0, |   MAIL_PORT: 0, | ||||||
|   | |||||||
| @@ -112,14 +112,14 @@ | |||||||
| import { useWindowSize } from '@vueuse/core' | import { useWindowSize } from '@vueuse/core' | ||||||
| import { type FormInstance, Message, Modal } from '@arco-design/web-vue' | import { type FormInstance, Message, Modal } from '@arco-design/web-vue' | ||||||
| import { type OptionResp, type SecurityConfig, listOption, resetOptionValue, updateOption } from '@/apis/system' | import { type OptionResp, type SecurityConfig, listOption, resetOptionValue, updateOption } from '@/apis/system' | ||||||
| import { useForm } from '@/hooks' | import { useResetReactive } from '@/hooks' | ||||||
|  |  | ||||||
| defineOptions({ name: 'SecuritySetting' }) | defineOptions({ name: 'SecuritySetting' }) | ||||||
| const { width } = useWindowSize() | const { width } = useWindowSize() | ||||||
|  |  | ||||||
| const loading = ref<boolean>(false) | const loading = ref<boolean>(false) | ||||||
| const formRef = ref<FormInstance>() | const formRef = ref<FormInstance>() | ||||||
| const { form } = useForm({ | const [form] = useResetReactive({ | ||||||
|   PASSWORD_ERROR_LOCK_COUNT: 0, |   PASSWORD_ERROR_LOCK_COUNT: 0, | ||||||
|   PASSWORD_ERROR_LOCK_MINUTES: 0, |   PASSWORD_ERROR_LOCK_MINUTES: 0, | ||||||
|   PASSWORD_EXPIRATION_DAYS: 0, |   PASSWORD_EXPIRATION_DAYS: 0, | ||||||
|   | |||||||
| @@ -105,7 +105,7 @@ import { type UserResp, deleteUser, exportUser, listUser } from '@/apis/system/u | |||||||
| import type { Columns, Options } from '@/components/GiForm' | import type { Columns, Options } from '@/components/GiForm' | ||||||
| import type { TableInstanceColumns } from '@/components/GiTable/type' | import type { TableInstanceColumns } from '@/components/GiTable/type' | ||||||
| import { DisEnableStatusList } from '@/constant/common' | import { DisEnableStatusList } from '@/constant/common' | ||||||
| import { useDownload, useForm, useTable } from '@/hooks' | import { useDownload, useResetReactive, useTable } from '@/hooks' | ||||||
| import { isMobile } from '@/utils' | import { isMobile } from '@/utils' | ||||||
| import has from '@/utils/has' | import has from '@/utils/has' | ||||||
|  |  | ||||||
| @@ -116,7 +116,7 @@ const options: Options = reactive({ | |||||||
|   grid: { cols: { xs: 1, sm: 1, md: 2, lg: 3, xl: 3, xxl: 3 } }, |   grid: { cols: { xs: 1, sm: 1, md: 2, lg: 3, xl: 3, xxl: 3 } }, | ||||||
|   fold: { enable: true, index: 1, defaultCollapsed: true }, |   fold: { enable: true, index: 1, defaultCollapsed: true }, | ||||||
| }) | }) | ||||||
| const { form: queryForm, resetForm } = useForm({ | const [queryForm, resetForm] = useResetReactive({ | ||||||
|   sort: ['t1.id,desc'], |   sort: ['t1.id,desc'], | ||||||
| }) | }) | ||||||
| const queryFormColumns: Columns = reactive([ | const queryFormColumns: Columns = reactive([ | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user