efront 4.14.3 → 4.15.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -15,11 +15,12 @@ var proto = {
15
15
  loginPath: null,
16
16
  session_time: 300000,
17
17
  session: "",
18
+ clean: null,
18
19
  loadSession: function () {
19
20
  var object = userInstance;
20
21
  if (object.session && !(new Date() > object.session_time)) {
21
- proto.session_time = object.session_time;
22
- proto.session = object.session;
22
+ this.session_time = object.session_time;
23
+ this.session = object.session;
23
24
  this.Login(object);
24
25
  }
25
26
  return object.session || "";
@@ -27,58 +28,57 @@ var proto = {
27
28
  saveSession: function (session = this.session) {
28
29
  this.session = session;
29
30
  data.setInstance(USERINFO, {
30
- roles: proto.roles,
31
- name: proto.name,
32
- _id: proto._id,
31
+ roles: this.roles,
32
+ name: this.name,
33
+ _id: this._id,
33
34
  session: session,
34
35
  _passport: this._passport,
35
36
  isLogin: !!session,
36
- session_time: +new Date() + proto.session_time
37
+ session_time: +new Date() + this.session_time
37
38
  });
38
39
  },
40
+ setLoginPath(pathname) {
41
+ this.loginPath = pathname;
42
+ },
43
+ setUserDataLoader(method) {
44
+ loadUserData = method;
45
+ },
46
+ setSessionTime(session_time) {
47
+ this.session_time = session_time;
48
+ },
49
+ refresh() {
50
+ loadUserData instanceof Function && loadUserData();
51
+ },
52
+ getPassport() {
53
+ if (!passport) {
54
+ passport = encode62.timeencode(encode62.decode62(user._passport, user.session));
55
+ }
56
+ return passport = encode62.timeupdate(passport);
57
+ },
39
58
  Login(userinfo) {
40
59
  this.login(userinfo);
41
60
  },
61
+ login(userinfo) {
62
+ this.roles = userinfo.roles || [];
63
+ this.isLogin = true;
64
+ this.name = userinfo.name;
65
+ this._id = "org.couchdb.user:" + userinfo.name;
66
+ this.clean?.(this.loginPath);
67
+ this.refresh();
68
+ },
42
69
  Logout() {
43
70
  this.logout();
44
- }
71
+ },
72
+ logout() {
73
+ delete user.isLogin;
74
+ delete user.roles;
75
+ delete user._passport;
76
+ this._passport = "";
77
+ this.roles = null;
78
+ this.isLogin = false;
79
+ passport = '';
80
+ this.saveSession("");
81
+ },
45
82
  };
46
83
  extend(proto, emptyProto, userInstance);
47
84
  var user = enrich(proto);
48
- user.setLoginPath = function (pathname) {
49
- proto.loginPath = pathname;
50
- };
51
- user.setUserDataLoader = function (method) {
52
- loadUserData = method;
53
- };
54
- user.setSessionTime = function (session_time) {
55
- proto.session_time = session_time;
56
- };
57
- user.refresh = function () {
58
- loadUserData instanceof Function && loadUserData();
59
- };
60
-
61
- user.getPassport = function () {
62
- if (!passport) {
63
- passport = encode62.timeencode(encode62.decode62(user._passport, user.session));
64
- }
65
- return passport = encode62.timeupdate(passport);
66
- };
67
- user.login = function (userinfo) {
68
- proto.roles = userinfo.roles || [];
69
- proto.isLogin = true;
70
- proto.name = userinfo.name;
71
- proto._id = "org.couchdb.user:" + userinfo.name;
72
- user.clean && user.clean(proto.loginPath);
73
- this.refresh();
74
- };
75
- user.logout = function () {
76
- delete user.isLogin;
77
- delete user.roles;
78
- delete user._passport;
79
- proto._passport = "";
80
- proto.roles = null;
81
- proto.isLogin = false;
82
- passport = '';
83
- this.saveSession("");
84
- };
@@ -296,11 +296,7 @@ function prepare(pgpath, ok) {
296
296
  }
297
297
  return url;
298
298
  };
299
- state.init = function () {
300
- var [a] = arguments;
301
- a = state.path(a);
302
- return init.apply(this, [a].concat([].slice.call(arguments, 1)));
303
- };
299
+
304
300
  state.go = function (url, args, _history_name) {
305
301
  // if (arguments.length === 1 && isFinite(url)) return window_history.go(url | 0);
306
302
  var to = function (_url, args, _history_name) {
@@ -382,7 +378,7 @@ function prepare(pgpath, ok) {
382
378
  extendIfNeeded(pg, state);
383
379
  if (roles) return prepare(user.loginPath, () => emit(pg));
384
380
  emit(pg);
385
- }, state);
381
+ }, state, true);
386
382
  }
387
383
  function create(pagepath, args, from, needroles) {
388
384
  if (typeof pagepath === 'string') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efront",
3
- "version": "4.14.3",
3
+ "version": "4.15.2",
4
4
  "description": "简化前端开发,优化web性能",
5
5
  "main": "public/efront.js",
6
6
  "directories": {