From b853da18b920d653e318b994b355b683fcaf4c44 Mon Sep 17 00:00:00 2001 From: wangyaqi Date: Fri, 8 Sep 2023 17:24:40 +0800 Subject: [PATCH] feat: add import object demo --- pages.json | 6 + pages/API/call-function/call-function.uvue | 2 +- pages/API/import-object/import-object.uvue | 116 ++++++++++++++++++ pages/tabBar/API.uvue | 4 + .../cloudfunctions/todo/index.obj.js | 39 ++++++ .../cloudfunctions/todo/package.json | 6 + 6 files changed, 172 insertions(+), 1 deletion(-) create mode 100644 pages/API/import-object/import-object.uvue create mode 100644 uniCloud-aliyun/cloudfunctions/todo/index.obj.js create mode 100644 uniCloud-aliyun/cloudfunctions/todo/package.json diff --git a/pages.json b/pages.json index 910a1da3..cd4197ef 100644 --- a/pages.json +++ b/pages.json @@ -672,6 +672,12 @@ "navigationBarTitleText": "" } }, + { + "path": "pages/API/import-object/import-object", + "style": { + "navigationBarTitleText": "" + } + }, { "path": "pages/API/get-system-info/get-system-info", "style": { diff --git a/pages/API/call-function/call-function.uvue b/pages/API/call-function/call-function.uvue index 3756652e..c40f6ab2 100644 --- a/pages/API/call-function/call-function.uvue +++ b/pages/API/call-function/call-function.uvue @@ -18,7 +18,7 @@ export default { data() { return { - title: 'uniCloud.callFunction' + title: '请求云函数' } }, onLoad() { diff --git a/pages/API/import-object/import-object.uvue b/pages/API/import-object/import-object.uvue new file mode 100644 index 00000000..ec1edf74 --- /dev/null +++ b/pages/API/import-object/import-object.uvue @@ -0,0 +1,116 @@ + + + + + diff --git a/pages/tabBar/API.uvue b/pages/tabBar/API.uvue index e3f45999..57869cfc 100644 --- a/pages/tabBar/API.uvue +++ b/pages/tabBar/API.uvue @@ -385,6 +385,10 @@ name: '云函数', url: 'call-function', }, + { + name: '云对象', + url: 'import-object', + }, ] as Page[], }, /* { diff --git a/uniCloud-aliyun/cloudfunctions/todo/index.obj.js b/uniCloud-aliyun/cloudfunctions/todo/index.obj.js new file mode 100644 index 00000000..0f33ab3d --- /dev/null +++ b/uniCloud-aliyun/cloudfunctions/todo/index.obj.js @@ -0,0 +1,39 @@ +// 云对象教程: https://uniapp.dcloud.net.cn/uniCloud/cloud-obj +// jsdoc语法提示教程:https://ask.dcloud.net.cn/docs/#//ask.dcloud.net.cn/article/129 +module.exports = { + async add(title, content) { + console.log(title, content) + return { + showMessage: `Todo added, title: ${title}, content: ${content}` + } + }, + async randomFail() { + const random = Math.random() + console.log(random); + if (random > 0.5) { + return { + errCode: 'RANDOM_FAIL', + errMsg: 'todo.randomFail failed' + } + } else { + return { + errCode: 0, + errMsg: '', + showMessage: 'todo.randomFail successed' + } + } + }, + async fail() { + return { + errCode: 'TEST_ERROR_CODE', + errMsg: 'todo.fail failed', + } + }, + async success() { + return { + errCode: 0, + errMsg: '', + showMessage: 'todo.success successed' + } + } +} diff --git a/uniCloud-aliyun/cloudfunctions/todo/package.json b/uniCloud-aliyun/cloudfunctions/todo/package.json new file mode 100644 index 00000000..217bc85c --- /dev/null +++ b/uniCloud-aliyun/cloudfunctions/todo/package.json @@ -0,0 +1,6 @@ +{ + "name": "todo", + "dependencies": {}, + "extensions": { + } +} \ No newline at end of file -- GitLab