🔨 Refactor: upgrade vue2 -> vue3

This commit is contained in:
PiEgg
2023-01-06 17:21:27 +08:00
parent 624e5738d1
commit 66d8d714db
46 changed files with 6584 additions and 7834 deletions

View File

@@ -1,3 +1,5 @@
import { isReactive, isRef, toRaw, unref } from 'vue'
const isDevelopment = process.env.NODE_ENV !== 'production'
/* eslint-disable camelcase */
export const handleTalkingDataEvent = (data: ITalkingDataOptions) => {
@@ -16,3 +18,36 @@ export const trimValues = (obj: IStringKeyMap) => {
})
return newObj
}
/**
* get raw data from reactive or ref
*/
export const getRawData = (args: any) => {
if (Array.isArray(args)) {
const data = args.map((item: any) => {
if (isRef(item)) {
return unref(item)
}
if (isReactive(item)) {
return toRaw(item)
}
return item
})
return data
}
if (typeof args === 'object') {
const data = {} as IStringKeyMap
Object.keys(args).forEach(key => {
const item = args[key]
if (isRef(item)) {
data[key] = unref(item)
} else if (isReactive(item)) {
data[key] = toRaw(item)
} else {
data[key] = getRawData(item)
}
})
return data
}
return args
}