mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-05-11 18:10:32 +08:00
🔨 Refactor: upgrade vue2 -> vue3
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user