我的需求是,大部分的云对象函数都需要实现用户级数据隔离啊,增删改都要和用户绑定的这是一个很普通的需求啊,但是为啥通过uni-ids-pages的登录之后,在页面上直接调用云对象,没有context呢,难道每一个云函数都得单独通过uniIdIns.checkToken来获取uid吗???
_before: async function() {
console.log('context.uid:', this.context.uid);
const token = this.getUniIdToken();
if (!token) {
throw new Error('请登录后再访问');
}
const clientInfo = this.getClientInfo()
const uniIdIns = uniID.createInstance({
clientInfo: clientInfo
});
const {
uid
} = await uniIdIns.checkToken(token)
this.currentUid = uid;
},
忧等生 (作者)
写工具函数吗? 这不是需要每次调接口都需要走这一遭,本来想写个基类,但是云对象又不支持继承
2025-07-08 15:47