2024-02-25 20:38:33 +08:00
|
|
|
import { type ComputedRefImpl, computed as _computed } from '@vue/reactivity'
|
|
|
|
import { getCurrentInstance, isInSSRComponentSetup } from './component'
|
2022-01-16 18:22:18 +08:00
|
|
|
|
2023-05-19 07:49:28 +08:00
|
|
|
export const computed: typeof _computed = (
|
2024-01-09 16:37:50 +08:00
|
|
|
getterOrOptions: any,
|
2023-05-19 07:49:28 +08:00
|
|
|
debugOptions?: any,
|
|
|
|
) => {
|
2024-01-09 16:37:50 +08:00
|
|
|
// @ts-expect-error
|
2024-02-25 20:38:33 +08:00
|
|
|
const c = _computed(getterOrOptions, debugOptions, isInSSRComponentSetup)
|
|
|
|
if (__DEV__) {
|
|
|
|
const i = getCurrentInstance()
|
|
|
|
if (i && i.appContext.config.warnRecursiveComputed) {
|
|
|
|
;(c as unknown as ComputedRefImpl<any>)._warnRecursive = true
|
|
|
|
}
|
|
|
|
}
|
2024-08-14 15:11:10 +08:00
|
|
|
return c as any
|
2023-05-19 07:49:28 +08:00
|
|
|
}
|