我试图弄清楚如何在用户首次登录我的应用程序时显示表单(填写个人资料信息),之后他们可以进入常规网站。
有人能指出我正确的方向吗?
由于
答案 0 :(得分:2)
你可以使用app启动脚本制作技巧: https://devsite.googleplex.com/appmaker/settings#app_start
假设您有Profile模型/数据源,启动脚本中的代码将类似于:
loader.suspendLoad();
var profileDs = app.datasources.Profile;
// It would be more secure to move this filtering to the server side
profileDs.query.filters.UserEmail._equals = app.user.email;
profileDs.load({
success: function() {
if (profileDs.item === null) {
app.showPage(app.pages.CreateProfile);
} else {
app.showPage(app.pages.HomePage);
}
loader.resumeLoad();
},
failure: function() {
loader.resumeLoad();
// your fallback code goes here
}
});
如果配置文件是绝对必须的,我还建议对每个页面强制执行onAttach事件检查但CreateProfile(以防止通过直接链接导航):
// Profile datasource should be already loaded by startup script
// when onAttach event is fired
if (app.datasources.Profile.item === null) {
throw new Error('Invalid operation!');
}
答案 1 :(得分:0)
我建议您在登录时检查用户个人资料。如果配置文件不存在,则显示配置文件表单,否则,请继续访问常规站点。