refactor: 确立独立子工程架构 (backend, admin, mpuniapp) 并同步更新 AGENTS.md 规范
这个提交包含在:
@@ -0,0 +1,16 @@
|
||||
'use strict';
|
||||
exports.main = async (event, context) => {
|
||||
//event为客户端上传的参数
|
||||
console.log('event : ', event)
|
||||
|
||||
//返回数据给客户端
|
||||
return {
|
||||
event,
|
||||
context,
|
||||
showMessage: 'Hello uniCloud function',
|
||||
detail: {
|
||||
functionName: 'echo-cf',
|
||||
timestamp: Date.now()
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"name": "echo-cf",
|
||||
"dependencies": {},
|
||||
"extensions": {},
|
||||
"origin-plugin-dev-name": "hello-uniapp-x",
|
||||
"origin-plugin-version": "1.0.44",
|
||||
"plugin-dev-name": "hello-uniapp-x",
|
||||
"plugin-version": "1.0.44"
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
// 云对象教程: https://uniapp.dcloud.net.cn/uniCloud/cloud-obj
|
||||
// jsdoc语法提示教程:https://ask.dcloud.net.cn/docs/#//ask.dcloud.net.cn/article/129
|
||||
module.exports = {
|
||||
_before() {
|
||||
const clientInfo = this.getClientInfo()
|
||||
const secretType = clientInfo.secretType
|
||||
const methodName = this.getMethodName()
|
||||
const clientInfos = uniCloud.getClientInfos()
|
||||
// methodName 是客户端调用的方法名
|
||||
// secretType 是客户端调用 uniCloud.importObject 传递的参数 secretMethods
|
||||
if (methodName === 'secureTest' && secretType !== 'both') {
|
||||
const error = new Error('客户端指定的secretType不为both,拒绝此次请求')
|
||||
error.code = 'INVALID_SECRET_TYPE'
|
||||
throw error // 拒绝本次请求
|
||||
}
|
||||
},
|
||||
secureTest() {
|
||||
return {
|
||||
returnBy: "encryption-object.secureTest"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"name": "encryption-object",
|
||||
"dependencies": {},
|
||||
"extensions": {
|
||||
"uni-cloud-jql": {}
|
||||
},
|
||||
"origin-plugin-dev-name": "hello-uniapp-x",
|
||||
"origin-plugin-version": "1.0.44",
|
||||
"plugin-dev-name": "hello-uniapp-x",
|
||||
"plugin-version": "1.0.44"
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
'use strict';
|
||||
exports.main = async (event, context) => {
|
||||
const secretType = context.secretType
|
||||
// secretType 是客户端调用 uniCloud.callFunction 传递的参数 secretType
|
||||
if (secretType !== 'both') {
|
||||
const error = new Error('客户端指定的secretType不为both,拒绝此次请求')
|
||||
error.code = 'INVALID_SECRET_TYPE'
|
||||
throw error // 拒绝本次请求
|
||||
}
|
||||
return {
|
||||
returnBy: 'encyption'
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"name": "encryption",
|
||||
"dependencies": {},
|
||||
"extensions": {
|
||||
"uni-cloud-jql": {}
|
||||
},
|
||||
"origin-plugin-dev-name": "hello-uniapp-x",
|
||||
"origin-plugin-version": "1.0.44",
|
||||
"plugin-dev-name": "hello-uniapp-x",
|
||||
"plugin-version": "1.0.44"
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
// 注意本文件为实人认证API示例代码,如需在业务中使用需补充业务逻辑,比如用户需要登录才能使用实人认证、限制每个用户每天能实人认证的次数等
|
||||
module.exports = {
|
||||
_before() {
|
||||
this.frvManager = uniCloud.getFacialRecognitionVerifyManager({
|
||||
requestId: this.getUniCloudRequestId()
|
||||
})
|
||||
},
|
||||
async getCertifyId({
|
||||
realName,
|
||||
idCard,
|
||||
metaInfo
|
||||
} = {}) {
|
||||
const result = await this.frvManager.getCertifyId({
|
||||
realName,
|
||||
idCard,
|
||||
metaInfo
|
||||
})
|
||||
return result
|
||||
},
|
||||
async getAuthResult(certifyId) {
|
||||
const result = await this.frvManager.getAuthResult({
|
||||
certifyId
|
||||
})
|
||||
return result
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"name": "facial-recognition-co",
|
||||
"dependencies": {},
|
||||
"extensions": {
|
||||
"uni-cloud-verify": {}
|
||||
},
|
||||
"origin-plugin-dev-name": "hello-uniapp-x",
|
||||
"origin-plugin-version": "1.0.44",
|
||||
"plugin-dev-name": "hello-uniapp-x",
|
||||
"plugin-version": "1.0.44"
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
'use strict';
|
||||
exports.main = async (event, context) => {
|
||||
const sseChannelObj = event.sseChannel
|
||||
const sseChannel = uniCloud.deserializeSSEChannel(sseChannelObj)
|
||||
return new Promise(async (resolve, reject) => {
|
||||
await sseChannel.write('message1')
|
||||
await sseChannel.write('message2')
|
||||
setTimeout(async () => {
|
||||
await sseChannel.end()
|
||||
resolve({
|
||||
errCode: 0
|
||||
})
|
||||
}, 300)
|
||||
})
|
||||
};
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"name": "sse",
|
||||
"dependencies": {},
|
||||
"extensions": {
|
||||
"uni-cloud-jql": {},
|
||||
"uni-cloud-push": {}
|
||||
},
|
||||
"origin-plugin-dev-name": "hello-uniapp-x",
|
||||
"origin-plugin-version": "1.0.44",
|
||||
"plugin-dev-name": "hello-uniapp-x",
|
||||
"plugin-version": "1.0.44"
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
// 云对象教程: 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 {
|
||||
title,
|
||||
content,
|
||||
showMessage: `Todo added, title: ${title}, content: ${content}`
|
||||
}
|
||||
},
|
||||
async randomFail() {
|
||||
const random = Math.random()
|
||||
console.log(random);
|
||||
if (random > 0.5) {
|
||||
return {
|
||||
errSubject: 'randomFail',
|
||||
errCode: 'RANDOM_FAIL',
|
||||
errMsg: '[预期内的报错]执行失败请重试'
|
||||
}
|
||||
} else {
|
||||
return {
|
||||
errCode: 0,
|
||||
errMsg: '',
|
||||
showMessage: '执行成功'
|
||||
}
|
||||
}
|
||||
},
|
||||
async fail() {
|
||||
return {
|
||||
errSubject: 'fail',
|
||||
errCode: 'TEST_ERROR_CODE',
|
||||
errMsg: '[预期内的报错]执行失败',
|
||||
tips: 'DO_NOT_TRY_AGAIN'
|
||||
}
|
||||
},
|
||||
async failWithNumberErrCode() {
|
||||
return {
|
||||
errCode: -1,
|
||||
errMsg: '[预期内的报错]执行失败',
|
||||
}
|
||||
},
|
||||
async success() {
|
||||
return {
|
||||
errCode: 0,
|
||||
errMsg: '',
|
||||
showMessage: '执行成功'
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"name": "todo",
|
||||
"dependencies": {},
|
||||
"extensions": {},
|
||||
"origin-plugin-dev-name": "hello-uniapp-x",
|
||||
"origin-plugin-version": "1.0.44",
|
||||
"plugin-dev-name": "hello-uniapp-x",
|
||||
"plugin-version": "1.0.44"
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
const configCenter = require("uni-config-center");
|
||||
const config = configCenter({ pluginId: 'uni-login-test-co' }).requireFile('config.js');
|
||||
|
||||
module.exports = {
|
||||
_before: function() {
|
||||
|
||||
},
|
||||
/**
|
||||
* App微信登录并返回openid
|
||||
* @param {string} code
|
||||
* @param {string} appid
|
||||
*/
|
||||
|
||||
async loginByWeixin(data = {}) {
|
||||
let {
|
||||
code,
|
||||
appid
|
||||
} = data;
|
||||
if (!code) {
|
||||
return { errCode: -1, errMsg: 'code参数不能为空' }
|
||||
}
|
||||
if (!appid) {
|
||||
return { errCode: -1, errMsg: 'appid参数不能为空' }
|
||||
}
|
||||
const secret = config.weixin[appid];
|
||||
if (!secret) {
|
||||
return { errCode: -1, errMsg: `appid:${appid} 未找到对应的 secret 配置` }
|
||||
}
|
||||
|
||||
const url = `https://api.weixin.qq.com/sns/oauth2/access_token`;
|
||||
const res = await uniCloud.httpclient.request(url, {
|
||||
method: 'GET',
|
||||
data: {
|
||||
appid,
|
||||
secret,
|
||||
code,
|
||||
grant_type: "authorization_code"
|
||||
},
|
||||
contentType: 'json',
|
||||
dataType: 'json'
|
||||
});
|
||||
|
||||
/* const res = {
|
||||
"data": {
|
||||
"access_token": "101_tmi6EalA41uRzkP8DScXi7BxXjRuuL_aHB8VGrMb7Ng6s1rmzWVV8dKCUXYTjpZMumRLChp_sJ-vGlH5GNwyapOWG3aXvRnPvDxW9lc0A5w",
|
||||
"expires_in": 7200,
|
||||
"refresh_token": "101_IxOQj08nKiwA86hqVJ7fIlwXabLyNwmUyOWw_ycfKt4bbfo46rjsul7CNEH5_SWS-SRt54Cj-MTZJ3pe7Dh3pgi7pR7SzaJkRPw47H8y666",
|
||||
"openid": "opjMn6YlpHJa1ZzVyAvMB5O7SabI",
|
||||
"scope": "snsapi_userinfo",
|
||||
"unionid": "oU5YytxRnXXHJlXKLQtIuJMcv9sc"
|
||||
},
|
||||
"status": 200,
|
||||
"headers": { "connection": "keep-alive", "content-type": "text/plain", "date": "Tue, 10 Mar 2026 08:42:51 GMT", "content-length": "385" }
|
||||
} */
|
||||
|
||||
const wxRes = res.data;
|
||||
if (wxRes.errcode) {
|
||||
return { errCode: wxRes.errcode, errMsg: wxRes.errmsg }
|
||||
}
|
||||
|
||||
const {
|
||||
access_token,
|
||||
openid,
|
||||
unionid
|
||||
} = res.data;
|
||||
|
||||
const userInfoRes = await uniCloud.httpclient.request(`https://api.weixin.qq.com/sns/userinfo?access_token=${access_token}&openid=${openid}$lang=zh-CN`, {
|
||||
method: 'GET',
|
||||
contentType: 'json',
|
||||
dataType: 'json'
|
||||
});
|
||||
|
||||
const {
|
||||
nickname,
|
||||
headimgurl, // 头像不一定可以拿到
|
||||
} = userInfoRes.data;
|
||||
|
||||
return {
|
||||
errCode: 0,
|
||||
openid,
|
||||
unionid,
|
||||
nickname,
|
||||
headimgurl
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"name": "uni-login-test-co",
|
||||
"dependencies": {
|
||||
"uni-config-center": "file:../../../uni_modules/uni-config-center/uniCloud/cloudfunctions/common/uni-config-center"
|
||||
},
|
||||
"extensions": {},
|
||||
"origin-plugin-dev-name": "hello-uniapp-x",
|
||||
"origin-plugin-version": "1.0.44",
|
||||
"plugin-dev-name": "hello-uniapp-x",
|
||||
"plugin-version": "1.0.44"
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
loginByWeixin({
|
||||
"code": "011rKyll2wnDjh4Ns3ml2yXW0e3rKylu",
|
||||
"appid": "wxd569c7238830733b"
|
||||
})
|
||||
@@ -0,0 +1,21 @@
|
||||
module.exports = {
|
||||
async sendPushMessage(cid) {
|
||||
// 防止非法调用
|
||||
if (!cid) {
|
||||
throw new Error('请传入推送客户端ID')
|
||||
}
|
||||
if (typeof cid !== 'string') {
|
||||
throw new Error('推送客户端ID必须为字符串')
|
||||
}
|
||||
const pushManager = uniCloud.getPushManager({appId: '__UNI__HelloUniAppX'})
|
||||
const res = await pushManager.sendMessage({
|
||||
push_clientid: cid,
|
||||
title: '测试推送标题',
|
||||
content: '测试推送内容',
|
||||
payload: {
|
||||
data: '测试推送数据'
|
||||
}
|
||||
})
|
||||
return res
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"name": "uni-push-co",
|
||||
"dependencies": {},
|
||||
"extensions": {
|
||||
"uni-cloud-jql": {},
|
||||
"uni-cloud-push": {}
|
||||
},
|
||||
"origin-plugin-dev-name": "hello-uniapp-x",
|
||||
"origin-plugin-version": "1.0.44",
|
||||
"plugin-dev-name": "hello-uniapp-x",
|
||||
"plugin-version": "1.0.44"
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
'use strict';
|
||||
exports.main = async function(event, context) {
|
||||
const res = await uniCloud.getPhoneNumber({
|
||||
appid: context.appId, // 替换成自己开通一键登录的应用的DCloud appid
|
||||
provider: 'univerify',
|
||||
access_token: event.access_token,
|
||||
openid: event.openid
|
||||
})
|
||||
// 执行入库等操作,正常情况下不要把完整手机号返回给前端
|
||||
return {
|
||||
errCode: 0,
|
||||
errMsg: '获取手机号成功',
|
||||
res: res
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"name": "univerify",
|
||||
"dependencies": {},
|
||||
"extensions": {
|
||||
"uni-cloud-verify": {}
|
||||
},
|
||||
"origin-plugin-dev-name": "hello-uniapp-x",
|
||||
"origin-plugin-version": "1.0.44",
|
||||
"plugin-dev-name": "hello-uniapp-x",
|
||||
"plugin-version": "1.0.44"
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
'use strict';
|
||||
exports.main = async (event, context) => {
|
||||
return {
|
||||
returnBy: 'verify-client'
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"name": "verify-client",
|
||||
"dependencies": {},
|
||||
"extensions": {
|
||||
"uni-cloud-jql": {}
|
||||
},
|
||||
"origin-plugin-dev-name": "hello-uniapp-x",
|
||||
"origin-plugin-version": "1.0.44",
|
||||
"plugin-dev-name": "hello-uniapp-x",
|
||||
"plugin-version": "1.0.44"
|
||||
}
|
||||
在新工单中引用
屏蔽一个用户