From 69257f2aa4f9afc464f99c07f860757054d2e940 Mon Sep 17 00:00:00 2001 From: Luk Date: Fri, 23 Feb 2024 13:25:53 +0800 Subject: [PATCH] u --- coco-none.js | 8 ++++++++ coco.js | 14 ++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) create mode 100644 coco-none.js diff --git a/coco-none.js b/coco-none.js new file mode 100644 index 0000000..4df0d00 --- /dev/null +++ b/coco-none.js @@ -0,0 +1,8 @@ +module.exports = { + cclog () { }, + ccinfo () { }, + ccgood () { }, + ccwarn () { }, + ccerror () { }, + ccdebug () { } +} \ No newline at end of file diff --git a/coco.js b/coco.js index aad1e89..d1f21a1 100644 --- a/coco.js +++ b/coco.js @@ -2,12 +2,14 @@ // consola works in nodejs and browser // chalk 和 colors 用法类似。 -// in uniapp: globalThis.uni && globalThis.UniApp -// in vue: globalThis.getApp?.()?.constructor?.name === 'Vue' - +// 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 = process?.release?.name === 'node' ? require('./coco-nodejs.js') - : globalThis.window && globalThis.location ? require('./coco-browser.js') - : globalThis.uniCloud ? require('./coco-unicloud.js') - : require('./coco-app.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')