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
|
* @Author: ShawnPhang
|
||||||
* @Date: 2022-03-03 14:13:16
|
* @Date: 2022-03-03 14:13:16
|
||||||
* @Description:
|
* @Description:
|
||||||
* @LastEditors: ShawnPhang <site: book.palxp.com>
|
* @LastEditors: Jeremy Yu <https://github.com/JeremyYu-cn>
|
||||||
* @LastEditTime: 2023-06-29 15:11:46
|
* @LastEditTime: 2024-02-26 17:54:00
|
||||||
*/
|
*/
|
||||||
import { createApp } from 'vue'
|
import { createApp } from 'vue'
|
||||||
import App from './App.vue'
|
import App from './App.vue'
|
||||||
@ -20,7 +20,7 @@ elementConfig.components.forEach((component) => {
|
|||||||
app.component(component.name, component)
|
app.component(component.name, component)
|
||||||
})
|
})
|
||||||
|
|
||||||
elementConfig.plugins.forEach((plugin: any) => {
|
elementConfig.plugins.forEach((plugin) => {
|
||||||
app.use(plugin)
|
app.use(plugin)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -11,12 +11,13 @@ import * as utils from './utils'
|
|||||||
import _config from '@/config'
|
import _config from '@/config'
|
||||||
import modules from './plugins/modules'
|
import modules from './plugins/modules'
|
||||||
import cssLoader from './plugins/cssLoader'
|
import cssLoader from './plugins/cssLoader'
|
||||||
|
import type {App} from 'vue'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 全局组件方法
|
* 全局组件方法
|
||||||
*/
|
*/
|
||||||
export default {
|
export default {
|
||||||
install(myVue: Type.Object) {
|
install(myVue: App) {
|
||||||
/** 全局组件注册 */
|
/** 全局组件注册 */
|
||||||
modules(myVue)
|
modules(myVue)
|
||||||
/** iconfont 注入 */
|
/** iconfont 注入 */
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
import app_config from '@/config'
|
import app_config from '@/config'
|
||||||
export const config = app_config
|
export const config = app_config
|
||||||
|
|
||||||
|
type TComObj = Record<string,any>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 星期换算
|
* 星期换算
|
||||||
* @param {String} 'YYYY-MM-DD'
|
* @param {String} 'YYYY-MM-DD'
|
||||||
@ -47,21 +49,24 @@ export const isInArray = (arr: Type.Object[], value: any) => {
|
|||||||
}
|
}
|
||||||
return false
|
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) => {
|
arr.forEach((key) => {
|
||||||
delete obj[key]
|
delete obj[key]
|
||||||
})
|
})
|
||||||
return obj
|
return obj as R extends T ? R : Partial<T>
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 拾取对象元素 */
|
/** 拾取对象元素 */
|
||||||
export const pickSome = (obj: Type.Object, arr: string[]) => {
|
export const pickSome = <R extends TComObj, T extends TComObj = TComObj>(obj: T, arr: string[]) => {
|
||||||
const newObj: Type.Object = {}
|
const newObj: Record<string, any> = {}
|
||||||
arr.forEach((key) => {
|
arr.forEach((key) => {
|
||||||
newObj[key] = obj[key]
|
newObj[key] = obj[key]
|
||||||
})
|
})
|
||||||
return newObj
|
return newObj as R extends T ? R : Partial<T>
|
||||||
}
|
}
|
||||||
|
|
||||||
/** String长度 */
|
/** String长度 */
|
||||||
// export const getBLen = (str: string | any) => {
|
// export const getBLen = (str: string | any) => {
|
||||||
// if (str === null) {
|
// if (str === null) {
|
||||||
|
@ -169,7 +169,7 @@ const components = [
|
|||||||
// ElUpload,
|
// ElUpload,
|
||||||
]
|
]
|
||||||
|
|
||||||
const plugins: any = [
|
const plugins = [
|
||||||
ElInfiniteScroll,
|
ElInfiniteScroll,
|
||||||
ElLoading,
|
ElLoading,
|
||||||
// ElMessage,
|
// ElMessage,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user