wip(form): perf form

This commit is contained in:
vben
2020-12-25 01:09:44 +08:00
parent 3c3e640d69
commit 4ff1c408dc
45 changed files with 901 additions and 862 deletions

View File

@@ -7,8 +7,8 @@ const ls = createStorage(localStorage);
const ss = createStorage();
interface CacheStore {
local: Record<string, any>;
session: Record<string, any>;
local: Recordable;
session: Recordable;
}
/**

View File

@@ -35,7 +35,7 @@ export function extendSlots(slots: Slots, excludeKeys: string[] = []) {
}
// Get events on attrs
export function getListeners(attrs: Record<string, unknown>) {
export function getListeners(attrs: Recordable<unknown>) {
const listeners: any = {};
Object.keys(attrs).forEach((key) => {
if (/^on/.test(key)) {

View File

@@ -9,6 +9,7 @@ import {
reactive,
ComponentInternalInstance,
} from 'vue';
import { error } from '../log';
export function explicitComputed<T, S>(source: WatchSource<S>, fn: () => T) {
const v = reactive<any>({ value: fn() });
@@ -39,6 +40,6 @@ export function tryTsxEmit<T extends any = ComponentInternalInstance>(
export function isInSetup() {
if (!getCurrentInstance()) {
throw new Error('Please put useForm function in the setup function!');
error('Please put useForm function in the setup function!');
}
}

View File

@@ -35,7 +35,7 @@ export interface Result<T = any> {
// multipart/form-data上传文件
export interface UploadFileParams {
// 其他参数
data?: { [key: string]: any };
data?: Indexable;
// 文件参数的接口字段名
name?: string;
// 文件

View File

@@ -38,7 +38,7 @@ export function setObjToUrlParams(baseUrl: string, obj: any): string {
return url;
}
export function deepMerge<T = any>(src: any, target: any): T {
export function deepMerge<T = any>(src: any = {}, target: any = {}): T {
let key: string;
for (key in target) {
src[key] = isObject(src[key]) ? deepMerge(src[key], target[key]) : (src[key] = target[key]);

View File

@@ -3,3 +3,7 @@ const projectName = import.meta.env.VITE_GLOB_APP_TITLE;
export function warn(message: string) {
console.warn(`[${projectName} warn]:${message}`);
}
export function error(message: string) {
throw new Error(`[${projectName} error]:${message}`);
}