mirror of
https://github.com/palxiao/poster-design.git
synced 2025-07-15 16:02:19 +08:00
feat: support typescript in util files
This commit is contained in:
parent
c159a51146
commit
420f29a272
@ -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)
|
||||
})
|
||||
|
||||
|
@ -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 注入 */
|
||||
|
@ -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) {
|
||||
|
@ -169,7 +169,7 @@ const components = [
|
||||
// ElUpload,
|
||||
]
|
||||
|
||||
const plugins: any = [
|
||||
const plugins = [
|
||||
ElInfiniteScroll,
|
||||
ElLoading,
|
||||
// ElMessage,
|
||||
|
Loading…
x
Reference in New Issue
Block a user