@ourea/doraemon-kit
Advanced tools
Comparing version 1.0.16 to 1.0.17
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("doraemon-kit",[],t):"object"==typeof exports?exports["doraemon-kit"]=t():e["doraemon-kit"]=t()}(window,(function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){"use strict";function n(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function o(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?n(Object(r),!0).forEach((function(t){a(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function a(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}r.r(t);var c=function(e,t){t.injectBefore((function(t){var r=t.url,n=t.opt,a=n.headers,c=n.params,u=e.getters["doraemon/oauth/tokenInfo"]||{},i=u.access_token,s=u.token_type,f=u.tenant_id,p=e.getters["doraemon/oauth/clientInfo"],d=p.client_id,l=p.client_secret;if(a.Authorization="Basic ".concat(btoa("".concat(d,":").concat(l))),r.indexOf("/doraemon-oauth/oauth/token")>=0){var m=c.tenantId;a["Tenant-Id"]=m||f}else{if(!s||!i)throw new Error("缺少鉴权信息");a.auth="".concat(s," ").concat(i)}return{url:r,opt:o(o({},n),{},{headers:a})}}))},u={headers:{"Content-Type":"application/x-www-form-urlencoded"}};function i(e,t,r,n,o,a,c){try{var u=e[a](c),i=u.value}catch(e){return void r(e)}u.done?t(i):Promise.resolve(i).then(n,o)}function s(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var a=e.apply(t,r);function c(e){i(a,n,o,c,u,"next",e)}function u(e){i(a,n,o,c,u,"throw",e)}c(void 0)}))}}function f(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function p(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function d(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?p(Object(r),!0).forEach((function(t){l(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):p(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function l(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function m(e,t,r,n,o,a,c){try{var u=e[a](c),i=u.value}catch(e){return void r(e)}u.done?t(i):Promise.resolve(i).then(n,o)}function h(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var a=e.apply(t,r);function c(e){m(a,n,o,c,u,"next",e)}function u(e){m(a,n,o,c,u,"throw",e)}c(void 0)}))}}var v={clientInfo:{client_id:"usercenter",client_secret:"1186045d5599de6ef2ca282347a55ca2",scope:"all"},userInfo:null,token:null},y=function(e){var t=function(e){return{login:(o=s(regeneratorRuntime.mark((function t(r){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r.grant_type="password",t.next=3,e.post("/doraemon-oauth/oauth/token",r,u);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)}))),function(e){return o.apply(this,arguments)}),refresh:(n=s(regeneratorRuntime.mark((function t(r){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r.grant_type="refresh_token",r.scope="all",t.next=4,e.post("/doraemon-oauth/oauth/token",r,u);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),t)}))),function(e){return n.apply(this,arguments)}),ssoLogin:(r=s(regeneratorRuntime.mark((function t(r){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.post("/doraemon-oauth/oauth/token",r,u);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)}))),function(e){return r.apply(this,arguments)}),getUserInfo:(t=s(regeneratorRuntime.mark((function t(r){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.get("/doraemon-user/user/getByUserName",r,u);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)}))),function(e){return t.apply(this,arguments)})};var t,r,n,o}(e);return{login:function(e,r){return h(regeneratorRuntime.mark((function n(){var o,a,c,u,i,s,p,l,m,v,y,g,b,O;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return o=e.commit,a=e.state,c=e.dispatch,u=a.clientInfo,i=d(d({},r),{},{scope:u.scope}),n.next=5,t.login(i);case 5:return(s=n.sent).code&&"200"==="".concat(s.code)&&(delete(p=d({},s)).success,delete p.code,l=p.access_token,m=p.token_type,v=p.refresh_token,y=p.expires_in,g=p.tenant_id,b=f(p,["access_token","token_type","refresh_token","expires_in","tenant_id"]),o("UPDATE_TOKEN",{access_token:l,token_type:m,refresh_token:v,expires_in:y,tenant_id:g,last:(new Date).getTime()}),O={userName:b.user_name},c("getUserInfo",O),setTimeout(h(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,c("refresh",{refresh_token:v});case 2:case"end":return e.stop()}}),e)}))),y/3*2*1e3)),n.abrupt("return",s);case 8:case"end":return n.stop()}}),n)})))()},refresh:function(e,r){return h(regeneratorRuntime.mark((function n(){var o,a,c,u,i,s,p,l,m,v,y;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return o=e.commit,e.rootGetters,a=e.dispatch,e.state,n.next=3,t.refresh(r);case 3:return(c=n.sent).code&&"200"==="".concat(c.code)&&(delete(u=d({},c)).success,delete u.code,i=u.access_token,s=u.token_type,p=u.refresh_token,l=u.expires_in,m=u.tenant_id,v=f(u,["access_token","token_type","refresh_token","expires_in","tenant_id"]),o("UPDATE_TOKEN",{access_token:i,token_type:s,refresh_token:p,expires_in:l,tenant_id:m,last:(new Date).getTime()}),y={userName:v.user_name},a("getUserInfo",y),setTimeout(h(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,a("refresh",{refresh_token:p});case 2:case"end":return e.stop()}}),e)}))),l/3*2*1e3)),n.abrupt("return",c);case 6:case"end":return n.stop()}}),n)})))()},getUserInfo:function(e,r){return h(regeneratorRuntime.mark((function n(){var o,a;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return o=e.commit,n.next=3,t.getUserInfo(r);case 3:(a=n.sent).code&&"200"==="".concat(a.code)&&o("SET_USER_INFO",a.data);case 5:case"end":return n.stop()}}),n)})))()}}},g={UPDATE_TOKEN:function(e,t){e.token=t},SET_USER_INFO:function(e,t){e.userInfo=t}},b={tokenInfo:function(e){return e.token},userInfo:function(e){return e.userInfo},clientInfo:function(e){return e.clientInfo}},O=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return{namespaced:!0,state:d(d(d({},v),t),r),actions:y(e),mutations:g,getters:b}},w=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};console.log("registerModule","->","doraemon/oauth: start"),e.hasModule("doraemon/oauth")||(console.log("registerModule","->","doraemon/oauth"),e.registerModule(["doraemon","oauth"],O(t,e.state.doraemon.oauth||{},r)))};function _(e,t,r,n,o,a,c){try{var u=e[a](c),i=u.value}catch(e){return void r(e)}u.done?t(i):Promise.resolve(i).then(n,o)}function k(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var a=e.apply(t,r);function c(e){_(a,n,o,c,u,"next",e)}function u(e){_(a,n,o,c,u,"throw",e)}c(void 0)}))}}function x(e,t,r,n,o,a,c){try{var u=e[a](c),i=u.value}catch(e){return void r(e)}u.done?t(i):Promise.resolve(i).then(n,o)}var P=function(e){return{dict:(t=regeneratorRuntime.mark((function t(r){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.post("/doraemon-propertydict/propertyDict/listByPrefix",{prefix:r},u);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})),r=function(){var e=this,r=arguments;return new Promise((function(n,o){var a=t.apply(e,r);function c(e){x(a,n,o,c,u,"next",e)}function u(e){x(a,n,o,c,u,"throw",e)}c(void 0)}))},function(e){return r.apply(this,arguments)})};var t,r};function j(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function R(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?j(Object(r),!0).forEach((function(t){D(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):j(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function D(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function E(e,t,r,n,o,a,c){try{var u=e[a](c),i=u.value}catch(e){return void r(e)}u.done?t(i):Promise.resolve(i).then(n,o)}var I={dictMap:{}},M=function(e){var t=P(e);return{getDictionary:function(e,r){return(n=regeneratorRuntime.mark((function n(){var o,a,c,u,i,s,f,p;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(o=e.commit,a=e.state,c=a.dictMap,u=r.code,i=r.cache,s=void 0===i||i,!c.hasOwnProperty(u)||!s){n.next=10;break}return n.next=7,Promise.resolve(c[u]);case 7:return n.abrupt("return",n.sent);case 10:return n.next=12,t.dict(u);case 12:(f=n.sent).code&&"200"==="".concat(f.code)&&(p=f.data.map((function(e){return{name:e.displayName,value:e.id,_data:e}})),o("UPDATE_DICT_CACHE",D({},u,p)));case 14:case"end":return n.stop()}}),n)})),function(){var e=this,t=arguments;return new Promise((function(r,o){var a=n.apply(e,t);function c(e){E(a,r,o,c,u,"next",e)}function u(e){E(a,r,o,c,u,"throw",e)}c(void 0)}))})();var n}}},T={UPDATE_DICT_CACHE:function(e,t){e.dictMap=Object.assign({},e.dictMap,t)}},S={},U=function(e,t){console.log("registerModule","->","doraemon/dictionary: start"),e.hasModule("doraemon/dictionary")||(console.log("registerModule","->","doraemon/dictionary"),e.registerModule(["doraemon","dictionary"],function(e,t){return{namespaced:!0,state:R(R({},I),t),actions:M(e),mutations:T,getters:S}}(t,e.state.doraemon.dictionary||{})))};window&&(window.__POWER_BY_DORAEMON_KIT__=!0);t.default={Oauth:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};t.hasModule("doraemon")||t.registerModule("doraemon",{namespaced:!0,state:t.state.doraemon}),w(t,r,n),c(t,r),e.prototype.do_refresh_token=k(regeneratorRuntime.mark((function e(){var r,n,o,a,c;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(r=t.getters["doraemon/oauth/tokenInfo"])||!r.refresh_token){e.next=9;break}if(n=r.expires_in,o=r.refresh_token,a=r.last,c=1e3*n,!(Date.now()-a>c)){e.next=8;break}throw new Error("超过token刷新时间请跳转到登录页。");case 8:t.dispatch("doraemon/oauth/refresh",{refresh_token:o});case 9:case"end":return e.stop()}}),e)})))},Dictionary:function(e,t,r){arguments.length>3&&void 0!==arguments[3]&&arguments[3];t.hasModule("doraemon")||t.registerModule("doraemon",{namespaced:!0,state:t.state.doraemon}),U(t,r)}}}])})); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("doraemon-kit",[],t):"object"==typeof exports?exports["doraemon-kit"]=t():e["doraemon-kit"]=t()}(window,(function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){"use strict";function n(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function o(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?n(Object(r),!0).forEach((function(t){a(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function a(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}r.r(t);var c=function(e,t){t.injectBefore((function(t){var r=t.url,n=t.opt,a=n.headers,c=n.params,u=e.getters["doraemon/oauth/tokenInfo"]||{},i=u.access_token,s=u.token_type,f=u.tenant_id,p=e.getters["doraemon/oauth/clientInfo"],d=p.client_id,l=p.client_secret;if(a.Authorization="Basic ".concat(btoa("".concat(d,":").concat(l))),r.indexOf("/doraemon-oauth/oauth/token")>=0){var m=c.tenantId;(m||f)&&(a["Tenant-Id"]=m||f)}else{if(!s||!i)throw new Error("缺少鉴权信息");a.auth="".concat(s," ").concat(i)}return{url:r,opt:o(o({},n),{},{headers:a})}}))},u={headers:{"Content-Type":"application/x-www-form-urlencoded"}};function i(e,t,r,n,o,a,c){try{var u=e[a](c),i=u.value}catch(e){return void r(e)}u.done?t(i):Promise.resolve(i).then(n,o)}function s(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var a=e.apply(t,r);function c(e){i(a,n,o,c,u,"next",e)}function u(e){i(a,n,o,c,u,"throw",e)}c(void 0)}))}}function f(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function p(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function d(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?p(Object(r),!0).forEach((function(t){l(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):p(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function l(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function m(e,t,r,n,o,a,c){try{var u=e[a](c),i=u.value}catch(e){return void r(e)}u.done?t(i):Promise.resolve(i).then(n,o)}function h(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var a=e.apply(t,r);function c(e){m(a,n,o,c,u,"next",e)}function u(e){m(a,n,o,c,u,"throw",e)}c(void 0)}))}}var v={clientInfo:{client_id:"usercenter",client_secret:"1186045d5599de6ef2ca282347a55ca2",scope:"all"},userInfo:null,token:null},y=function(e){var t=function(e){return{login:(o=s(regeneratorRuntime.mark((function t(r){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r.grant_type="password",t.next=3,e.post("/doraemon-oauth/oauth/token",r,u);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)}))),function(e){return o.apply(this,arguments)}),refresh:(n=s(regeneratorRuntime.mark((function t(r){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r.grant_type="refresh_token",r.scope="all",t.next=4,e.post("/doraemon-oauth/oauth/token",r,u);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),t)}))),function(e){return n.apply(this,arguments)}),ssoLogin:(r=s(regeneratorRuntime.mark((function t(r){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.post("/doraemon-oauth/oauth/token",r,u);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)}))),function(e){return r.apply(this,arguments)}),getUserInfo:(t=s(regeneratorRuntime.mark((function t(r){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.get("/doraemon-user/user/getByUserName",r,u);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)}))),function(e){return t.apply(this,arguments)})};var t,r,n,o}(e);return{login:function(e,r){return h(regeneratorRuntime.mark((function n(){var o,a,c,u,i,s,p,l,m,v,y,g,b,O;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return o=e.commit,a=e.state,c=e.dispatch,u=a.clientInfo,i=d(d({},r),{},{scope:u.scope}),n.next=5,t.login(i);case 5:return(s=n.sent).code&&"200"==="".concat(s.code)&&(delete(p=d({},s)).success,delete p.code,l=p.access_token,m=p.token_type,v=p.refresh_token,y=p.expires_in,g=p.tenant_id,b=f(p,["access_token","token_type","refresh_token","expires_in","tenant_id"]),o("UPDATE_TOKEN",{access_token:l,token_type:m,refresh_token:v,expires_in:y,tenant_id:g,last:(new Date).getTime()}),O={userName:b.user_name},c("getUserInfo",O),setTimeout(h(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,c("refresh",{refresh_token:v});case 2:case"end":return e.stop()}}),e)}))),y/3*2*1e3)),n.abrupt("return",s);case 8:case"end":return n.stop()}}),n)})))()},refresh:function(e,r){return h(regeneratorRuntime.mark((function n(){var o,a,c,u,i,s,p,l,m,v,y;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return o=e.commit,e.rootGetters,a=e.dispatch,e.state,n.next=3,t.refresh(r);case 3:return(c=n.sent).code&&"200"==="".concat(c.code)&&(delete(u=d({},c)).success,delete u.code,i=u.access_token,s=u.token_type,p=u.refresh_token,l=u.expires_in,m=u.tenant_id,v=f(u,["access_token","token_type","refresh_token","expires_in","tenant_id"]),o("UPDATE_TOKEN",{access_token:i,token_type:s,refresh_token:p,expires_in:l,tenant_id:m,last:(new Date).getTime()}),y={userName:v.user_name},a("getUserInfo",y),setTimeout(h(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,a("refresh",{refresh_token:p});case 2:case"end":return e.stop()}}),e)}))),l/3*2*1e3)),n.abrupt("return",c);case 6:case"end":return n.stop()}}),n)})))()},getUserInfo:function(e,r){return h(regeneratorRuntime.mark((function n(){var o,a;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return o=e.commit,n.next=3,t.getUserInfo(r);case 3:(a=n.sent).code&&"200"==="".concat(a.code)&&o("SET_USER_INFO",a.data);case 5:case"end":return n.stop()}}),n)})))()}}},g={UPDATE_TOKEN:function(e,t){e.token=t},SET_USER_INFO:function(e,t){e.userInfo=t}},b={tokenInfo:function(e){return e.token},userInfo:function(e){return e.userInfo},clientInfo:function(e){return e.clientInfo}},O=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return{namespaced:!0,state:d(d(d({},v),t),r),actions:y(e),mutations:g,getters:b}},w=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};console.log("registerModule","->","doraemon/oauth: start"),e.hasModule("doraemon/oauth")||(console.log("registerModule","->","doraemon/oauth"),e.registerModule(["doraemon","oauth"],O(t,e.state.doraemon.oauth||{},r)))};function _(e,t,r,n,o,a,c){try{var u=e[a](c),i=u.value}catch(e){return void r(e)}u.done?t(i):Promise.resolve(i).then(n,o)}function k(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var a=e.apply(t,r);function c(e){_(a,n,o,c,u,"next",e)}function u(e){_(a,n,o,c,u,"throw",e)}c(void 0)}))}}function x(e,t,r,n,o,a,c){try{var u=e[a](c),i=u.value}catch(e){return void r(e)}u.done?t(i):Promise.resolve(i).then(n,o)}var P=function(e){return{dict:(t=regeneratorRuntime.mark((function t(r){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.post("/doraemon-propertydict/propertyDict/listByPrefix",{prefix:r},u);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})),r=function(){var e=this,r=arguments;return new Promise((function(n,o){var a=t.apply(e,r);function c(e){x(a,n,o,c,u,"next",e)}function u(e){x(a,n,o,c,u,"throw",e)}c(void 0)}))},function(e){return r.apply(this,arguments)})};var t,r};function j(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function R(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?j(Object(r),!0).forEach((function(t){D(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):j(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function D(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function E(e,t,r,n,o,a,c){try{var u=e[a](c),i=u.value}catch(e){return void r(e)}u.done?t(i):Promise.resolve(i).then(n,o)}var I={dictMap:{}},M=function(e){var t=P(e);return{getDictionary:function(e,r){return(n=regeneratorRuntime.mark((function n(){var o,a,c,u,i,s,f,p;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(o=e.commit,a=e.state,c=a.dictMap,u=r.code,i=r.cache,s=void 0===i||i,!c.hasOwnProperty(u)||!s){n.next=10;break}return n.next=7,Promise.resolve(c[u]);case 7:return n.abrupt("return",n.sent);case 10:return n.next=12,t.dict(u);case 12:(f=n.sent).code&&"200"==="".concat(f.code)&&(p=f.data.map((function(e){return{name:e.displayName,value:e.id,_data:e}})),o("UPDATE_DICT_CACHE",D({},u,p)));case 14:case"end":return n.stop()}}),n)})),function(){var e=this,t=arguments;return new Promise((function(r,o){var a=n.apply(e,t);function c(e){E(a,r,o,c,u,"next",e)}function u(e){E(a,r,o,c,u,"throw",e)}c(void 0)}))})();var n}}},T={UPDATE_DICT_CACHE:function(e,t){e.dictMap=Object.assign({},e.dictMap,t)}},S={},U=function(e,t){console.log("registerModule","->","doraemon/dictionary: start"),e.hasModule("doraemon/dictionary")||(console.log("registerModule","->","doraemon/dictionary"),e.registerModule(["doraemon","dictionary"],function(e,t){return{namespaced:!0,state:R(R({},I),t),actions:M(e),mutations:T,getters:S}}(t,e.state.doraemon.dictionary||{})))};window&&(window.__POWER_BY_DORAEMON_KIT__=!0);t.default={Oauth:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};t.hasModule("doraemon")||t.registerModule("doraemon",{namespaced:!0,state:t.state.doraemon}),w(t,r,n),c(t,r),e.prototype.do_refresh_token=k(regeneratorRuntime.mark((function e(){var r,n,o,a,c;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(r=t.getters["doraemon/oauth/tokenInfo"])||!r.refresh_token){e.next=9;break}if(n=r.expires_in,o=r.refresh_token,a=r.last,c=1e3*n,!(Date.now()-a>c)){e.next=8;break}throw new Error("超过token刷新时间请跳转到登录页。");case 8:t.dispatch("doraemon/oauth/refresh",{refresh_token:o});case 9:case"end":return e.stop()}}),e)})))},Dictionary:function(e,t,r){arguments.length>3&&void 0!==arguments[3]&&arguments[3];t.hasModule("doraemon")||t.registerModule("doraemon",{namespaced:!0,state:t.state.doraemon}),U(t,r)}}}])})); |
{ | ||
"name": "@ourea/doraemon-kit", | ||
"version": "1.0.16", | ||
"version": "1.0.17", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -19,3 +19,5 @@ | ||
const { tenantId } = params | ||
headers['Tenant-Id'] = tenantId || tenant_id | ||
if (tenantId || tenant_id) { | ||
headers['Tenant-Id'] = tenantId || tenant_id | ||
} | ||
} else if (token_type && access_token) { // 其他普通接口 | ||
@@ -22,0 +24,0 @@ headers['auth'] = `${token_type} ${access_token}` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
25688
320