wo-core-coco/coco.js
2024-06-24 09:49:28 +08:00

16 lines
753 B
JavaScript

// colors only works in nodejs cli
// consola works in nodejs and browser
// chalk 和 colors 用法类似。
// globalThis.uni // 在 web/app 里都为对象
// globalThis.UniApp // 在 web 里返回一个函数,在 app 里返回 undefined
// globalThis.getApp?.()?.constructor?.name === 'Vue' // 在 web 里 true, 在 app 里 false
// typeof(globalThis.getApp)==='function' // 在 web/app 里都为 true
module.exports =
globalThis.process?.release?.name === 'node' ? require('./coco-nodejs.js')
: globalThis.uniCloud ? require('./coco-unicloud.js')
: globalThis.window && globalThis.location ? require('./coco-browser.js')
: globalThis.uni && globalThis.getApp ? require('./coco-app.js')
: require('./coco-none.js')