as shown in the figure, if you want to do a login interception based on $api.getStorage ("userId"), the desired effect of
is
1. Enter the page that can open the green box (main.html), but the other three in the red box cannot be opened directly (message.html/post.html/my.html)
2. To open it, you can only jump to the login page before you can open
3.index.html. One win opens four frameGroup, (main.html/message.html/post.html/my.html) (red box), and the green box is main.html,
< H2 > Code < / H2 >
index.html
function funIniGroup() {
var eHeaderLis = $api.domAll("header li"),
frames = [];
for (var i = 0, len = eHeaderLis.length; i < len; iPP) {
frames.push({
name: "main",
url: "./html/main.html",
bgColor: "-sharpf4f8fb",
bounces: true,
allowEdit: true
}, {
name: "post",
url: "./html/post.html",
bgColor: "-sharpf4f8fb",
bounces: true,
allowEdit: true
}, {
name: "message",
url: "./html/message.html",
bgColor: "-sharpf4f8fb",
bounces: true,
allowEdit: true
}, {
name: "my",
url: "./html/my.html",
bgColor: "-sharpf4f8fb",
bounces: true,
allowEdit: true
}, )
}
api.openFrameGroup({
name: "group",
scrollEnabled: false,
rect: {
x: 0,
y: $api.dom("header").offsetHeight,
w: api.winWidth,
h: $api.dom("-sharpmain").offsetHeight
},
index: 0,
frames: frames
}, function(ret, err) {
});
}
< H2 > Log in < / H2 >
$.ajax({
url: "https://cnodejs.org/api/v1/accesstoken",
type: "post",
data: {
accesstoken: accessToken
},
success: function(ret) {
var id = ret.id;
var loginname = ret.loginname;
var avatar_url = ret.avatar_url;
$api.setStorage("accessToken",accessToken);
$api.setStorage("userId",id);
$api.setStorage("userLoginname",loginname);
$api.setStorage("useravatarUrl",avatar_url);
open_my_win(id,loginname,avatar_url)
},
error: function(err) {
console.log(JSON.stringify(err))
}
})
< H2 > login blocking < / H2 >
main.html does not have the following judgments
message/post/my.html has the following judgments
apiready = function() {
if(!$api.getStorage("userId"))
{
api.openWin({
name: "login",
url: "./login.html",
allowEdit: true
});
}
}
< H2 > question. As soon as you open app, you jump to the login page login.html < / H2 >.