Files
mp-10584/src/utils/use-search.ts
赵忠林 482e2a2718 chore(config): 添加项目配置文件和隐私协议
- 添加 .editorconfig 文件统一代码风格
- 添加 .env.development 和 .env.example 环境配置文件
- 添加 .eslintignore 和 .eslintrc.js 代码检查配置
- 添加 .gitignore 版本控制忽略文件配置
- 添加 .prettierignore 格式化忽略配置
- 添加隐私协议HTML文件
- 添加API密钥管理组件基础结构
2026-01-26 14:05:01 +08:00

28 lines
539 B
TypeScript

import { reactive } from 'vue';
/**
* 搜索表单 hook
* @param initValue 默认值
*/
export default function <T extends object>(initValue?: T) {
const where = reactive<T>({ ...initValue } as T);
const resetFields = () => {
Object.keys(where).forEach((key) => {
where[key] = initValue ? initValue[key] : void 0;
});
};
const assignFields = (data: object) => {
Object.keys(where).forEach((key) => {
where[key] = data[key];
});
};
return {
where,
resetFields,
assignFields
};
}