From 3834c04f163f3a9d252fc180574e466158a8b06a Mon Sep 17 00:00:00 2001 From: wangyaqi Date: Mon, 4 Sep 2023 20:53:28 +0800 Subject: [PATCH] feat: add cloudfunction demo --- pages.json | 58 +++++++++-------- pages/API/call-function/call-function.uvue | 62 +++++++++++++++++++ pages/tabBar/API.uvue | 4 ++ .../cloudfunctions/echo-cf/index.js | 12 ++++ .../cloudfunctions/echo-cf/package.json | 5 ++ 5 files changed, 115 insertions(+), 26 deletions(-) create mode 100644 pages/API/call-function/call-function.uvue create mode 100644 uniCloud-aliyun/cloudfunctions/echo-cf/index.js create mode 100644 uniCloud-aliyun/cloudfunctions/echo-cf/package.json diff --git a/pages.json b/pages.json index d5bc0b79..0e909f74 100644 --- a/pages.json +++ b/pages.json @@ -55,24 +55,24 @@ "style": { "navigationBarTitleText": "radio" } - }, - { - "path": "pages/component/rich-text/rich-text", - "style": { - "navigationBarTitleText": "rich-text" - } - }, - { - "path": "pages/component/rich-text/rich-text-tags", - "style": { - "navigationBarTitleText": "rich-text-tags" - } - }, - { - "path": "pages/component/rich-text/rich-text-complex", - "style": { - "navigationBarTitleText": "rich-text-complex" - } + }, + { + "path": "pages/component/rich-text/rich-text", + "style": { + "navigationBarTitleText": "rich-text" + } + }, + { + "path": "pages/component/rich-text/rich-text-tags", + "style": { + "navigationBarTitleText": "rich-text-tags" + } + }, + { + "path": "pages/component/rich-text/rich-text-complex", + "style": { + "navigationBarTitleText": "rich-text-complex" + } }, { "path": "pages/component/checkbox/checkbox", @@ -660,6 +660,12 @@ "navigationBarTitleText": "" } }, + { + "path": "pages/API/call-function/call-function", + "style": { + "navigationBarTitleText": "" + } + }, { "path": "pages/API/get-system-info/get-system-info", "style": { @@ -767,12 +773,12 @@ "style": { "navigationBarTitleText": "swiper-list" } - }, - { - "path": "pages/template/swiper-list2/swiper-list2", - "style": { - "navigationBarTitleText": "swiper-list2" - } + }, + { + "path": "pages/template/swiper-list2/swiper-list2", + "style": { + "navigationBarTitleText": "swiper-list2" + } }, { "path": "pages/template/swiper-vertical-video/swiper-vertical-video", @@ -832,7 +838,7 @@ { "path": "pages/template/long-list/long-list", "style": { - "navigationBarTitleText": "复杂长列表", + "navigationBarTitleText": "复杂长列表", "enablePullDownRefresh": true } }, @@ -859,7 +865,7 @@ "style": { "navigationBarTitleText": "自定义下拉刷新的scroll-view属性示例" } - }, + }, { "path": "pages/template/pull-zoom-image/pull-zoom-image", "style": { diff --git a/pages/API/call-function/call-function.uvue b/pages/API/call-function/call-function.uvue new file mode 100644 index 00000000..9e74d443 --- /dev/null +++ b/pages/API/call-function/call-function.uvue @@ -0,0 +1,62 @@ + + + + diff --git a/pages/tabBar/API.uvue b/pages/tabBar/API.uvue index e311853a..58b5562d 100644 --- a/pages/tabBar/API.uvue +++ b/pages/tabBar/API.uvue @@ -157,6 +157,10 @@ name: '全局websocket', url: 'websocket-global', api: ["connectSocket", "onSocketOpen", "onSocketError", "sendSocketMessage", "onSocketMessage", "closeSocket", "onSocketClose"] + }, + { + name: '请求云函数', + url: 'call-function', }, ] as Page[], }, diff --git a/uniCloud-aliyun/cloudfunctions/echo-cf/index.js b/uniCloud-aliyun/cloudfunctions/echo-cf/index.js new file mode 100644 index 00000000..ab513765 --- /dev/null +++ b/uniCloud-aliyun/cloudfunctions/echo-cf/index.js @@ -0,0 +1,12 @@ +'use strict'; +exports.main = async (event, context) => { + //event为客户端上传的参数 + console.log('event : ', event) + + //返回数据给客户端 + return { + event, + context, + showMessage: 'Hello uniCloud function' + } +}; diff --git a/uniCloud-aliyun/cloudfunctions/echo-cf/package.json b/uniCloud-aliyun/cloudfunctions/echo-cf/package.json new file mode 100644 index 00000000..1618abf4 --- /dev/null +++ b/uniCloud-aliyun/cloudfunctions/echo-cf/package.json @@ -0,0 +1,5 @@ +{ + "name": "echo-cf", + "dependencies": {}, + "extensions": {} +} -- GitLab