feat: support typescript in util files

This commit is contained in:
IchliebedichZhu 2024-02-26 19:35:43 +00:00
parent c159a51146
commit 420f29a272
4 changed files with 16 additions and 10 deletions

View File

@ -2,8 +2,8 @@
* @Author: ShawnPhang
* @Date: 2022-03-03 14:13:16
* @Description:
* @LastEditors: ShawnPhang <site: book.palxp.com>
* @LastEditTime: 2023-06-29 15:11:46
* @LastEditors: Jeremy Yu <https://github.com/JeremyYu-cn>
* @LastEditTime: 2024-02-26 17:54:00
*/
import { createApp } from 'vue'
import App from './App.vue'
@ -20,7 +20,7 @@ elementConfig.components.forEach((component) => {
app.component(component.name, component)
})
elementConfig.plugins.forEach((plugin: any) => {
elementConfig.plugins.forEach((plugin) => {
app.use(plugin)
})

View File

@ -11,12 +11,13 @@ import * as utils from './utils'
import _config from '@/config'
import modules from './plugins/modules'
import cssLoader from './plugins/cssLoader'
import type {App} from 'vue'
/**
*
*/
export default {
install(myVue: Type.Object) {
install(myVue: App) {
/** 全局组件注册 */
modules(myVue)
/** iconfont 注入 */

View File

@ -1,6 +1,8 @@
import app_config from '@/config'
export const config = app_config
type TComObj = Record<string,any>
/**
*
* @param {String} 'YYYY-MM-DD'
@ -47,21 +49,24 @@ export const isInArray = (arr: Type.Object[], value: any) => {
}
return false
}
/** 删除多个对象元素 */
export const deleteSome = (obj: Type.Object, arr: string[]) => {
export const deleteSome = <R extends TComObj, T extends TComObj = TComObj>(obj: T, arr: string[]) => {
arr.forEach((key) => {
delete obj[key]
})
return obj
return obj as R extends T ? R : Partial<T>
}
/** 拾取对象元素 */
export const pickSome = (obj: Type.Object, arr: string[]) => {
const newObj: Type.Object = {}
export const pickSome = <R extends TComObj, T extends TComObj = TComObj>(obj: T, arr: string[]) => {
const newObj: Record<string, any> = {}
arr.forEach((key) => {
newObj[key] = obj[key]
})
return newObj
return newObj as R extends T ? R : Partial<T>
}
/** String长度 */
// export const getBLen = (str: string | any) => {
// if (str === null) {

View File

@ -169,7 +169,7 @@ const components = [
// ElUpload,
]
const plugins: any = [
const plugins = [
ElInfiniteScroll,
ElLoading,
// ElMessage,