- 添加 .editorconfig 文件统一代码风格 - 添加 .env.development 和 .env.example 环境配置文件 - 添加 .eslintignore 和 .eslintrc.js 代码检查配置 - 添加 .gitignore 版本控制忽略文件配置 - 添加 .prettierignore 格式化忽略配置 - 添加隐私协议HTML文件 - 添加API密钥管理组件基础结构
28 lines
539 B
TypeScript
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
|
|
};
|
|
}
|