gant-core 2.0.5 → 2.0.6
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.
- package/CHANGELOG.md +6 -0
- package/lib/cli/create/module/index.mjs +1 -1
- package/lib/core/index.js +1 -1
- package/lib/core/store/index.js +1 -1
- package/lib/types/index.d.ts +4 -22
- package/package.json +1 -1
package/lib/core/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{r as request,a as requestInstance}from"./request/index.js";export{e as expireCache}from"./cache/index.js";export{M as MENU_BREADCRUMBS_UPDATE,a as MENU_HISTORY_UPDATE,c as codeListStore,i as companydataStore,
|
|
1
|
+
export{r as request,a as requestInstance}from"./request/index.js";export{e as expireCache}from"./cache/index.js";export{M as MENU_BREADCRUMBS_UPDATE,a as MENU_HISTORY_UPDATE,c as codeListStore,i as companydataStore,l as loginStore,m as menuStore,p as parameterStore,s as storageStore,u as userStore}from"./store/index.js";export{i as initI18n}from"./i18n/index.js";export{P as PresetColors,T as TinyColor,b as bounds,c as cmykToRgb,d as compactAlgorithm,a as convertDecimalToHex,e as convertHexToDecimal,f as darkAlgorithm,g as defaultAlgorithm,h as formatAliasToken,i as fromRatio,j as getAliasToken,k as getAlphaColor,l as getBackgroundColor,m as getDarkenSolidColor,n as getLightenSolidColor,o as getTokenCssVar,p as hslToRgb,q as hsvToRgb,r as inputToRGB,s as isReadable,t as isValidCSSUnit,u as legacyRandom,v as lighten,w as meetingDerivative,x as mostReadable,y as names,z as numberInputToObject,A as parseIntFromHex,B as random,C as readability,D as rgbToCmyk,E as rgbToHex,F as rgbToHsl,G as rgbToHsv,H as rgbToRgb,I as rgbaToArgbHex,J as rgbaToHex,K as seed,L as stringInputToObject,M as toMsFilter,N as token}from"./theme/index.js";export*from"axios";import"lodash-es";import"mitt";var S;!function(a){a.development="development",a.production="production",a.test="test"}(S||(S={}));export{S as Env};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/lib/core/store/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as t}from"../request/index.js";import{groupBy as e,get as s,reduce as a,find as i,keyBy as n,pick as r,isEmpty as o,findIndex as c,isPlainObject as h,cloneDeep as u,mapValues as d,uniqBy as g}from"lodash-es";import m from"mitt";const l=new class{codeLists=[];codeMaps={};async findAllCodeList(){const s=await t("/codeList/findAll",{data:{},serviceId:"fwPlatform"})||[],a=e(s,"type");this.codeLists=s,this.codeMaps=a}getCodeLocaleList=t=>s(this.codeMaps,t,[]);getCodeLocaleName=(t,e)=>{const s=this.getCodeLocaleList(t);function n(t){const e=i(s,e=>e.value===String(t));return e?.name||""}if(Array.isArray(e)){const t=a(e,(t="",e="")=>t+","+n(e),"");return t.slice(1,t.length)}if(String(e).indexOf(",")>=0){const t=e.replace("[","").replace("]","").split(","),s=a(t,(t="",e="")=>t+","+n(e),"");return s.slice(1,s.length)}return n(e)}};l.getCodeLocaleList,l.getCodeLocaleName;const p=new class{parameterList=[];parameterMap={};findAllParameters=async()=>{const e=await t("/parameter/findAll",{serviceId:"fwPlatform",data:{}},{showError:!1})||[],s=n(e,"name");this.parameterList=e,this.parameterMap=s};getSystemParameterByName=t=>"string"==typeof t?this.parameterMap[t]:r(this.parameterMap,t)};const y=(({prefixKey:t="",storage:e=localStorage}={})=>new class{storage=e;prefixKey=t;getKey(t){return`${this.prefixKey}${t}`.toUpperCase()}set(t,e,s=604800){const a=JSON.stringify({value:e,expire:null!==s?(new Date).getTime()+1e3*s:null});this.storage.setItem(this.getKey(t),a)}get(t,e=null){const s=this.storage.getItem(this.getKey(t));if(s)try{const e=JSON.parse(s),{value:a,expire:i}=e;if(null===i||i>=Date.now())return a;this.remove(t)}catch(t){return console.error(t),e}return e}remove(t){this.storage.removeItem(this.getKey(t))}clear(){this.storage.clear()}setCookie(t,e,s=604800){document.cookie=`${this.getKey(t)}=${e}; Max-Age=${s}`}getCookie(t){const e=document.cookie.split("; ");for(let s=0,a=e.length;s<a;s++){const a=e[s].split("=");if(a[0]===this.getKey(t))return a[1]}return""}removeCookie(t){this.setCookie(t,1,-1)}clearCookie(){const t=document.cookie.match(/[^ =;]+(?==)/g);if(t)for(let e=t.length;e--;)document.cookie=t[e]+"=0;expire="+new Date(0).toUTCString()}})();class f{userIdentity={};currentUser={};isSuperAdmin=!1;roles=[];functions=[];delegations=[];userSetting={};users=[];getUserIdentity(){if(!o(this.userIdentity))return this.userIdentity;const t=y?.get("userIdentity");return t||{}}setUserIdentity(t){return this.userIdentity={...this.userIdentity,...t},y.set("userIdentity",this.userIdentity),this.userIdentity}clearUserIdentity(){y.remove("userIdentity"),this.userIdentity={}}setUserAggregateInfo=({delegations:t,roles:e,functions:s,isSuperAdmin:a,currentUser:i})=>{this.delegations=t,this.roles=e,this.functions=s,this.isSuperAdmin=a,this.currentUser=i};getUserSettingType=t=>`${this.currentUser.id}-${t}`;getUserSetting=async e=>{const s=this.getUserSettingType(e),a=this.currentUser.id;if(this.userSetting[s])return this.userSetting[s];const i=await async function(e){return t("/accountUserSelf/getUserData",{data:e,serviceId:"fwSecurity"})}({dataType:e,dataId:a+e}),n=i?.bigData?JSON.parse(i.bigData):void 0;return this.userSetting[s]=n,n};updateUserSetting=async(e,s)=>{const a=this.getUserSettingType(e),i=this.currentUser.id;return await async function(e,s){return t("/accountUserSelf/setUserData",{data:e,serviceId:"fwSecurity"},s)}({dataType:e,dataId:i+e,bigData:JSON.stringify(s)}),this.userSetting[a]=s,s};removeUserSetting=async e=>{const s=this.getUserSettingType(e),a=this.currentUser.id;await async function(e,s){return t("/accountUserSelf/delUserData",{data:e,serviceId:"fwSecurity"},s)}({dataType:e,dataId:a}),delete this.userSetting[s]};getUserInfo=async(e,a)=>{const i=c(this.users,t=>a?t.userLoginName===e:t.id===e);if(i>-1)return s(this.users,`[${i}]`);const n=a?await async function(e){return t("/security/getUserByUserLoginName",{method:"POST",data:{userLoginName:e},serviceId:"fwSecurity"})}(e):await async function(e){return t("/security/getUserById",{method:"POST",data:{id:e},serviceId:"fwSecurity"})}(e);return h(n)&&this.users.push(n),n}}const w=/^https?:\/\/(([a-zA-Z0-9_-])+(\.)?)*(:\d+)?(\/((\.)?(\?)?=?&?[a-zA-Z0-9_-](\?)?)*)*$/i,S=/^https?:\/\/(([a-zA-Z0-9_-])+(\.)?)*(:\d+)?(\/((\.)?(\?)?=?&?[a-zA-Z0-9_-](\?)?)*)*$/i,L=t=>w.test(t)||S.test(t)||0===t?.indexOf("/")?t:"/"+t,I="MENU_HISTORY_UPDATE",P="MENU_BREADCRUMBS_UPDATE";m();class U{menuDataMaps={};menuData=[];menuPathMaps={};breadcrumbs=[];menuHistorys=[];userId;emitter;constructor(){this.emitter=m()}addListenerMenuHistorys=t=>{this.emitter.on(I,t)};removeListenerMenuHistorys=t=>this.emitter.off(I,t);addListenerBreadcrumbs=t=>this.emitter.on(P,t);removeListenerBreadcrumbs=t=>this.emitter.off(P,t);getTreeMenuData=(t,e,s)=>t.map(t=>{const{id:a,path:i,leaf:n}=t,r=e[a],o={...t,key:a,path:s?s+L(i):L(i)};if(r&&!n){const t=this.getTreeMenuData(r,e,o.path);o.children=t}return this.menuDataMaps[o.path]=o,o}).sort((t,e)=>t.seqNum-e.seqNum);init=(t,s)=>{const a=u(t);if(o(a))return;const i=e(a,"parentResourceId"),{ROOT:n,...r}=i;this.menuData=this.getTreeMenuData(n,r),this.menuData=[...this.menuData];const c=d(this.menuDataMaps,"name");this.updateMenuMaps(c),this.initMenuHistorys(s)};updateMenuMaps=t=>{this.menuPathMaps={...this.menuPathMaps,...t};const e=this.menuHistorys.map(t=>{const e=this.menuPathMaps[t.pathname];return{pathname:t.pathname,name:e||t.name}}),s=this.breadcrumbs.map(t=>{const e=this.menuPathMaps[t.pathname];return{...t,name:e||t.name}});this.updatehistorys(e),this.updateBreadcrumbs(s)};liseterHistorys=t=>{let e=this.menuHistorys;this.menuDataMaps[t]?.leaf&&!e.some(e=>e.pathname===t)&&(e=[{pathname:t,name:this.menuPathMaps[t]},...e],this.updatehistorys(e))};updatehistorys=t=>{if(!this.userId)return;const e=t.map(t=>({...t,name:t.name?t.name:this.menuPathMaps[t.pathname]}));this.menuHistorys=e,this.menuHistorys=g(this.menuHistorys,"pathname"),this.emitter.emit(I,this.menuHistorys),y.set(`${this.userId}-menu-history`,this.menuHistorys)};initMenuHistorys=t=>{this.userId=t;const e=y.get(`${t}-menu-history`,this.menuHistorys);this.updatehistorys(e)};liseterBreadcrumbs=t=>{const e=t.split("/");let s=1;const a=[],i={pathname:t,name:this.menuPathMaps[t]};for(;s<e.length;){const t=e.slice(0,s).join("/");this.menuPathMaps[t]&&a.push({name:this.menuPathMaps[t],pathname:t}),s++}a.push(i),this.updateBreadcrumbs(a)};updateBreadcrumbs=t=>{this.breadcrumbs=t,this.breadcrumbs=g(this.breadcrumbs,"pathname"),this.emitter.emit(P,t)}}class C{loginPathname;BASE="/";get baseLoginPathname(){return`${this.BASE}${this.loginPathname?.replace("/","")}`}tokenValue="";get isLoginPathname(){const t=window.location.pathname;return this.baseLoginPathname==t}getRealPath=t=>`${this.BASE}${t.replace("/","")}`;chekToken=async()=>{const e=await t("/authentication/checkToken",{serviceId:"fwSecurity"},{showError:!1});return e&&this.isLoginPathname&&window.location.replace(this.BASE),e};getLoginMethod=async()=>t("/authentication/getLoginMethod",{serviceId:"fwSecurity"});redirectBaseLogin=async()=>{const t=window.location.pathname,e=window.location.href;if(this.isLoginPathname)return!0;const s=new URLSearchParams(window.location.search),a=new URLSearchParams;"true"===s.get("forceLocal")&&a.append("forceLocal","true"),t!==this.BASE&&"/"!==t&&a.append("redirectUrl",e);const i=decodeURIComponent(a.toString());return window.location.replace(`${this.baseLoginPathname}${i?"?"+decodeURIComponent(a.toString()):""}`),!1};checkPassword=async()=>"noPass"!==await t("/security/checkPasswordUpdateTime",{data:{}},{showError:!1})||(this.tokenValue=await t("/authentication/extractToken",{data:{}}),!1);refactorToken=async()=>{var e;await(e=this.tokenValue,t("/authentication/refactorToken",{data:{value:e}}))};login=async t=>{const e=await this.baseLogin(t);return e.error,e};baseLogin=async e=>{const s={error:void 0,data:void 0};try{const a=await function(e){return t("/authentication/login",{data:e,serviceId:"fwSecurity"})}(e),{userToken:i,traceId:n}=a;if(i){s.data=a;return await this.checkPassword()||(s.error="passwordExpiration"),s}return n?(s.data=a,s.error="SLIDER_VERIFICATION_LOGIN",s):(s.error="passwordError",s)}catch(t){return s.error="validateError",s}};loginSuccess=()=>{let t=new URLSearchParams(window.location.search).get("redirectUrl");t?window.location.href=t:window.location.replace(this.BASE)};baseLoginOut=async e=>{const s=new URLSearchParams,a=window.location.href;window.location.pathname!==this.BASE&&s.append("redirectUrl",a),await t("/authentication/logout",{data:{},serviceId:"fwSecurity"}),e?window.location.replace(`${this.baseLoginPathname}?${s.toString()}`):window.location.replace(this.baseLoginPathname)}}const k={sso:!1,ssoUrlSearchParams:["ticket"],ssoSuccessUrlkey:"successUrl",ssoLoginUrl:window.location.origin+"/fwSecurity/ssoAuth/login.api",ssologinOutUrl:window.location.origin+"/fwSecurity/ssoAuth/logout.api",ssoCheckTokenUrl:window.location.origin+"/fwSecurity/ssoAuth/checkToken.api"};class v{init(t){this.ssoConfig={...this.ssoConfig,...t}}ssoConfig=k;isSso=async e=>{if(!this.ssoConfig.sso)return!1;let s=!1;try{s=await(a=this.ssoConfig.ssoCheckTokenUrl,t(a,{},{showError:!1}))}catch(t){console.error("sso",t)}var a;return e&&(s=await e()),!!s};ssoLogin=()=>{const{ssoSuccessUrlkey:t,ssoUrlSearchParams:e,ssoLoginUrl:s}=this.ssoConfig,a=new URLSearchParams(window.location.search.slice(1)),i=new URLSearchParams,n=window.location.href;return i.append(t,encodeURIComponent(n)),e.map(t=>{const e=a.get(t);e&&i.append(t,e)}),window.location.href=`${s}?${i.toString()}`,!1};ssoLoginOut=()=>{window.location.href=this.ssoConfig.ssologinOutUrl}}class D{getValidateCodeImage=e=>function(e={}){return t("/authentication/getValidateCode",{data:e,serviceId:"fwSecurity"})}(e);sliderVerificationCodeImage=()=>t("/authentication/sliderVerificationCode",{method:"POST",serviceId:"fwSecurity"});checkCaptcha=e=>{return s=e,t("/authentication/checkCaptcha",{method:"POST",data:{...s},serviceId:"fwSecurity"});var s}}class T extends C{ssoLogin;validate;noCheckPermissionsPath=[];ssoCallback;constructor(){super(),this.ssoLogin=new v,this.validate=new D}init=(t,e="/",s)=>{this.BASE=e,this.ssoCallback=s,this.noCheckPermissionsPath=t?.noCheckPermissionsPath,this.ssoLogin.init(t),this.loginPathname=t?.loginPathname||"/login"};isNoLoginRequiredPage=()=>{const t=window.location.pathname,e=this.noCheckPermissionsPath?.some(e=>this.getRealPath(e)==t);return e};loginOut=async()=>{await this.ssoLogin.isSso(this.ssoCallback)&&this.ssoLogin.ssoLoginOut(),await this.baseLoginOut()};loginAuthentication=async e=>{var s;await(s=e,t("/authentication/beforeLoginCheckCode",{method:"POST",data:{...s},serviceId:"fwSecurity"})),this.loginSuccess()};redirectLogin=async()=>{if(this.ssoLogin.ssoConfig.sso){if(await this.ssoLogin.isSso())return this.ssoCallback()?(this.ssoLogin.ssoLogin(),!1):!!this.isNoLoginRequiredPage()||this.redirectBaseLogin()}return!!this.isNoLoginRequiredPage()||(!!this.isLoginPathname||await this.redirectBaseLogin())}}const A=new class{userStore;menuStore;loginStore;isSuperAdmin=!1;loginCallback;constructor(){this.userStore=new f,this.menuStore=new U,this.loginStore=new T}platformLanguages=[];productInfo={isProdEnv:!1,productName:""};get isPrd(){return this.productInfo?.isProdEnv}get userInfo(){return this.userStore.currentUser}get menuData(){return this.menuStore.menuData}findPlantform=async()=>{const e=await t("/platformManage/getPlatformAggregateInfo",{method:"POST"},{showError:!1});this.platformLanguages=e.platformLanguages,this.productInfo=e.productInfo};getAggregateInfo=async e=>{const s=await async function(){return t("/security/findUserAggregateInfo",{method:"POST"})}(),{user:a,startMenus:i,isSuperAdmin:n,...r}=s;this.userStore.setUserAggregateInfo({...r,currentUser:a}),this.isSuperAdmin=n;const c="function"==typeof e?await e(s):e;this.menuStore.init(o(c)?i:c,a.id)};init=async t=>{const{base:e="/",menuData:s,loginSuccessCallback:a,ssoCallback:i}=t;this.loginStore.init(t?.loginConfig,e,i);try{const t=await this.loginStore.chekToken();return t?(this.userStore.setUserIdentity(t),await this.getAggregateInfo(s),await l.findAllCodeList(),await p.findAllParameters(),await(a?.()),!0):await this.loginStore.redirectLogin()}catch(t){console.error(t)}return!1}};const M="company-v1";var b=new class{data={};getCompanyDataType=t=>`${M}-${t}`;getCompanyData=async e=>{const s=this.getCompanyDataType(e);if(this.data[s])return this.data[s];const a=await async function(e){return t("/companyData/getCompanyData",{data:e,serviceId:"fwSecurity"})}({dataType:e,dataId:M}),i=a?.bigData?JSON.parse(a.bigData):void 0;return this.data[s]=i,i};updateCompanyData=async(e,s)=>{const a=this.getCompanyDataType(e);return await async function(e){return t("/companyData/setCompanyData",{data:e,serviceId:"fwSecurity"})}({dataType:e,dataId:M,bigData:JSON.stringify(s)}),this.data[a]=s,s};removeCompanyData=async e=>{const s=this.getCompanyDataType(e);await async function(e){return t("/companyData/delCompanyData",{data:e,serviceId:"fwSecurity"})}({dataType:e,dataId:M}),delete this.data[s]}};const O=l,E=p,$=A.userStore,B=A.loginStore,N=A.menuStore;export{P as M,I as a,O as c,A as g,b as i,B as l,N as m,E as p,y as s,$ as u};
|
|
1
|
+
import{r as t}from"../request/index.js";import{groupBy as e,get as s,reduce as a,find as i,keyBy as n,pick as r,isEmpty as o,findIndex as c,isPlainObject as h,cloneDeep as u,mapValues as d,uniqBy as g}from"lodash-es";import m from"mitt";const l=new class{codeLists=[];codeMaps={};async findAllCodeList(){const s=await t("/codeList/findAll",{data:{},serviceId:"fwPlatform"})||[],a=e(s,"type");this.codeLists=s,this.codeMaps=a}getCodeLocaleList=t=>s(this.codeMaps,t,[]);getCodeLocaleName=(t,e)=>{const s=this.getCodeLocaleList(t);function n(t){const e=i(s,e=>e.value===String(t));return e?.name||""}if(Array.isArray(e)){const t=a(e,(t="",e="")=>t+","+n(e),"");return t.slice(1,t.length)}if(String(e).indexOf(",")>=0){const t=e.replace("[","").replace("]","").split(","),s=a(t,(t="",e="")=>t+","+n(e),"");return s.slice(1,s.length)}return n(e)}};l.getCodeLocaleList,l.getCodeLocaleName;const p=new class{parameterList=[];parameterMap={};findAllParameters=async()=>{const e=await t("/parameter/findAll",{serviceId:"fwPlatform",data:{}},{showError:!1})||[],s=n(e,"name");this.parameterList=e,this.parameterMap=s};getSystemParameterByName=t=>"string"==typeof t?this.parameterMap[t]:r(this.parameterMap,t)};const y=(({prefixKey:t="",storage:e=localStorage}={})=>new class{storage=e;prefixKey=t;getKey(t){return`${this.prefixKey}${t}`.toUpperCase()}set(t,e,s=604800){const a=JSON.stringify({value:e,expire:null!==s?(new Date).getTime()+1e3*s:null});this.storage.setItem(this.getKey(t),a)}get(t,e=null){const s=this.storage.getItem(this.getKey(t));if(s)try{const e=JSON.parse(s),{value:a,expire:i}=e;if(null===i||i>=Date.now())return a;this.remove(t)}catch(t){return console.error(t),e}return e}remove(t){this.storage.removeItem(this.getKey(t))}clear(){this.storage.clear()}setCookie(t,e,s=604800){document.cookie=`${this.getKey(t)}=${e}; Max-Age=${s}`}getCookie(t){const e=document.cookie.split("; ");for(let s=0,a=e.length;s<a;s++){const a=e[s].split("=");if(a[0]===this.getKey(t))return a[1]}return""}removeCookie(t){this.setCookie(t,1,-1)}clearCookie(){const t=document.cookie.match(/[^ =;]+(?==)/g);if(t)for(let e=t.length;e--;)document.cookie=t[e]+"=0;expire="+new Date(0).toUTCString()}})();class w{userIdentity={};currentUser={};isSuperAdmin=!1;roles=[];functions=[];delegations=[];userSetting={};users=[];getUserIdentity(){if(!o(this.userIdentity))return this.userIdentity;const t=y?.get("userIdentity");return t||{}}setUserIdentity(t){return this.userIdentity={...this.userIdentity,...t},y.set("userIdentity",this.userIdentity),this.userIdentity}clearUserIdentity(){y.remove("userIdentity"),this.userIdentity={}}setUserAggregateInfo=({delegations:t,roles:e,functions:s,isSuperAdmin:a,currentUser:i})=>{this.delegations=t,this.roles=e,this.functions=s,this.isSuperAdmin=a,this.currentUser=i};getUserSettingType=t=>`${this.currentUser.id}-${t}`;getUserSetting=async e=>{const s=this.getUserSettingType(e),a=this.currentUser.id;if(this.userSetting[s])return this.userSetting[s];const i=await async function(e){return t("/accountUserSelf/getUserData",{data:e,serviceId:"fwSecurity"})}({dataType:e,dataId:a+e}),n=i?.bigData?JSON.parse(i.bigData):void 0;return this.userSetting[s]=n,n};updateUserSetting=async(e,s)=>{const a=this.getUserSettingType(e),i=this.currentUser.id;return await async function(e,s){return t("/accountUserSelf/setUserData",{data:e,serviceId:"fwSecurity"},s)}({dataType:e,dataId:i+e,bigData:JSON.stringify(s)}),this.userSetting[a]=s,s};removeUserSetting=async e=>{const s=this.getUserSettingType(e),a=this.currentUser.id;await async function(e,s){return t("/accountUserSelf/delUserData",{data:e,serviceId:"fwSecurity"},s)}({dataType:e,dataId:a}),delete this.userSetting[s]};getUserInfo=async(e,a)=>{const i=c(this.users,t=>a?t.userLoginName===e:t.id===e);if(i>-1)return s(this.users,`[${i}]`);const n=a?await async function(e){return t("/security/getUserByUserLoginName",{method:"POST",data:{userLoginName:e},serviceId:"fwSecurity"})}(e):await async function(e){return t("/security/getUserById",{method:"POST",data:{id:e},serviceId:"fwSecurity"})}(e);return h(n)&&this.users.push(n),n}}const f=/^https?:\/\/(([a-zA-Z0-9_-])+(\.)?)*(:\d+)?(\/((\.)?(\?)?=?&?[a-zA-Z0-9_-](\?)?)*)*$/i,S=/^https?:\/\/(([a-zA-Z0-9_-])+(\.)?)*(:\d+)?(\/((\.)?(\?)?=?&?[a-zA-Z0-9_-](\?)?)*)*$/i,L=t=>f.test(t)||S.test(t)||0===t?.indexOf("/")?t:"/"+t,I="MENU_HISTORY_UPDATE",P="MENU_BREADCRUMBS_UPDATE";m();class U{menuDataMaps={};menuData=[];menuPathMaps={};breadcrumbs=[];menuHistorys=[];userId;emitter;constructor(){this.emitter=m()}addListenerMenuHistorys=t=>{this.emitter.on(I,t)};removeListenerMenuHistorys=t=>this.emitter.off(I,t);addListenerBreadcrumbs=t=>this.emitter.on(P,t);removeListenerBreadcrumbs=t=>this.emitter.off(P,t);getTreeMenuData=(t,e,s)=>t.map(t=>{const{id:a,path:i,leaf:n}=t,r=e[a],o={...t,key:a,path:s?s+L(i):L(i)};if(r&&!n){const t=this.getTreeMenuData(r,e,o.path);o.children=t}return this.menuDataMaps[o.path]=o,o}).sort((t,e)=>t.seqNum-e.seqNum);init=(t,s)=>{const a=u(t);if(o(a))return;const i=e(a,"parentResourceId"),{ROOT:n,...r}=i;this.menuData=this.getTreeMenuData(n,r),this.menuData=[...this.menuData];const c=d(this.menuDataMaps,"name");this.updateMenuMaps(c),this.initMenuHistorys(s)};updateMenuMaps=t=>{this.menuPathMaps={...this.menuPathMaps,...t};const e=this.menuHistorys.map(t=>{const e=this.menuPathMaps[t.pathname];return{pathname:t.pathname,name:e||t.name}}),s=this.breadcrumbs.map(t=>{const e=this.menuPathMaps[t.pathname];return{...t,name:e||t.name}});this.updatehistorys(e),this.updateBreadcrumbs(s)};liseterHistorys=t=>{let e=this.menuHistorys;this.menuDataMaps[t]?.leaf&&!e.some(e=>e.pathname===t)&&(e=[{pathname:t,name:this.menuPathMaps[t]},...e],this.updatehistorys(e))};updatehistorys=t=>{if(!this.userId)return;const e=t.map(t=>({...t,name:t.name?t.name:this.menuPathMaps[t.pathname]}));this.menuHistorys=e,this.menuHistorys=g(this.menuHistorys,"pathname"),this.emitter.emit(I,this.menuHistorys),y.set(`${this.userId}-menu-history`,this.menuHistorys)};initMenuHistorys=t=>{this.userId=t;const e=y.get(`${t}-menu-history`,this.menuHistorys);this.updatehistorys(e)};liseterBreadcrumbs=t=>{const e=t.split("/");let s=1;const a=[],i={pathname:t,name:this.menuPathMaps[t]};for(;s<e.length;){const t=e.slice(0,s).join("/");this.menuPathMaps[t]&&a.push({name:this.menuPathMaps[t],pathname:t}),s++}a.push(i),this.updateBreadcrumbs(a)};updateBreadcrumbs=t=>{this.breadcrumbs=t,this.breadcrumbs=g(this.breadcrumbs,"pathname"),this.emitter.emit(P,t)}}function C(){return t("/authentication/logout",{data:{},serviceId:"fwSecurity"})}class k{loginPathname;BASE="/";get baseLoginPathname(){return`${this.BASE}${this.loginPathname?.replace("/","")}`}tokenValue="";get isLoginPathname(){const t=window.location.pathname;return this.baseLoginPathname==t}getRealPath=t=>`${this.BASE}${t.replace("/","")}`;chekToken=async()=>{const e=await t("/authentication/checkToken",{serviceId:"fwSecurity"},{showError:!1});return e&&this.isLoginPathname&&window.location.replace(this.BASE),e};getLoginMethod=async()=>t("/authentication/getLoginMethod",{serviceId:"fwSecurity"});redirectBaseLogin=async()=>{const t=window.location.pathname,e=window.location.href;if(this.isLoginPathname)return!0;const s=new URLSearchParams(window.location.search),a=new URLSearchParams;"true"===s.get("forceLocal")&&a.append("forceLocal","true"),t!==this.BASE&&"/"!==t&&a.append("redirectUrl",e);const i=decodeURIComponent(a.toString());return window.location.replace(`${this.baseLoginPathname}${i?"?"+decodeURIComponent(a.toString()):""}`),!1};checkPassword=async()=>"noPass"!==await t("/security/checkPasswordUpdateTime",{data:{}},{showError:!1})||(this.tokenValue=await t("/authentication/extractToken",{data:{}}),!1);refactorToken=async()=>{var e;await(e=this.tokenValue,t("/authentication/refactorToken",{data:{value:e}}))};login=async t=>{const e=await this.baseLogin(t);return e.error,e};baseLogin=async e=>{const s={error:void 0,data:void 0};try{const a=await function(e){return t("/authentication/login",{data:e,serviceId:"fwSecurity"})}(e),{userToken:i,traceId:n}=a;if(i){s.data=a;return await this.checkPassword()||(s.error="passwordExpiration"),s}return n?(s.data=a,s.error="SLIDER_VERIFICATION_LOGIN",s):(s.error="passwordError",s)}catch(t){return s.error="validateError",s}};loginSuccess=()=>{let t=new URLSearchParams(window.location.search).get("redirectUrl");t?window.location.href=t:window.location.replace(this.BASE)};baseLoginOut=async t=>{const e=new URLSearchParams,s=window.location.href;window.location.pathname!==this.BASE&&e.append("redirectUrl",s),await C(),t?window.location.replace(`${this.baseLoginPathname}?${e.toString()}`):window.location.replace(this.baseLoginPathname)}}const v={sso:!1,ssoUrlSearchParams:["ticket"],ssoSuccessUrlkey:"successUrl",ssoLoginUrl:window.location.origin+"/fwSecurity/ssoAuth/login.api",ssologinOutUrl:window.location.origin+"/fwSecurity/ssoAuth/logout.api",ssoCheckTokenUrl:window.location.origin+"/fwSecurity/ssoAuth/checkToken.api"};class D{init(t){this.ssoConfig={...this.ssoConfig,...t}}ssoConfig=v;isSso=async(e,s)=>{if(!this.ssoConfig.sso)return!1;let a=!0,i=!1;try{if(i=await(n=this.ssoConfig.ssoCheckTokenUrl,t(n,{},{showError:!1})),!i)return!1}catch(t){console.error("sso",t)}var n;return e&&(a=await e(s)),a};ssoLogin=()=>{const{ssoSuccessUrlkey:t,ssoUrlSearchParams:e,ssoLoginUrl:s}=this.ssoConfig,a=new URLSearchParams(window.location.search.slice(1)),i=new URLSearchParams,n=window.location.href;return i.append(t,encodeURIComponent(n)),e.map(t=>{const e=a.get(t);e&&i.append(t,e)}),window.location.href=`${s}?${i.toString()}`,!1};ssoLoginOut=()=>{window.location.href=this.ssoConfig.ssologinOutUrl}}class A{getValidateCodeImage=e=>function(e={}){return t("/authentication/getValidateCode",{data:e,serviceId:"fwSecurity"})}(e);sliderVerificationCodeImage=()=>t("/authentication/sliderVerificationCode",{method:"POST",serviceId:"fwSecurity"});checkCaptcha=e=>{return s=e,t("/authentication/checkCaptcha",{method:"POST",data:{...s},serviceId:"fwSecurity"});var s}}class T extends k{ssoLogin;validate;noCheckPermissionsPath=[];ssoCallback;constructor(){super(),this.ssoLogin=new D,this.validate=new A}init=(t,e="/",s)=>{this.BASE=e,this.ssoCallback=s,this.noCheckPermissionsPath=t?.noCheckPermissionsPath,this.ssoLogin.init(t),this.loginPathname=t?.loginPathname||"/login"};isNoLoginRequiredPage=()=>{const t=window.location.pathname,e=this.noCheckPermissionsPath?.some(e=>this.getRealPath(e)==t);return e};loginOut=async t=>{await C();if(await this.ssoLogin.isSso(this.ssoCallback,!1))return void this.ssoLogin.ssoLoginOut();const e=new URLSearchParams,s=window.location.href;window.location.pathname!==this.BASE&&e.append("redirectUrl",s),t?window.location.replace(`${this.baseLoginPathname}?${e.toString()}`):window.location.replace(this.baseLoginPathname)};loginAuthentication=async e=>{var s;await(s=e,t("/authentication/beforeLoginCheckCode",{method:"POST",data:{...s},serviceId:"fwSecurity"})),this.loginSuccess()};redirectLogin=async()=>{if(this.ssoLogin.ssoConfig.sso){if(await this.ssoLogin.isSso())return this.ssoCallback(!0)?(this.ssoLogin.ssoLogin(),!1):!!this.isNoLoginRequiredPage()||this.redirectBaseLogin()}return!!this.isNoLoginRequiredPage()||(!!this.isLoginPathname||await this.redirectBaseLogin())}}const b=new class{userStore;menuStore;loginStore;isSuperAdmin=!1;loginCallback;constructor(){this.userStore=new w,this.menuStore=new U,this.loginStore=new T}platformLanguages=[];productInfo={isProdEnv:!1,productName:""};get isPrd(){return this.productInfo?.isProdEnv}get userInfo(){return this.userStore.currentUser}get menuData(){return this.menuStore.menuData}findPlantform=async()=>{const e=await t("/platformManage/getPlatformAggregateInfo",{method:"POST"},{showError:!1});this.platformLanguages=e.platformLanguages,this.productInfo=e.productInfo};getAggregateInfo=async e=>{const s=await async function(){return t("/security/findUserAggregateInfo",{method:"POST"})}(),{user:a,startMenus:i,isSuperAdmin:n,...r}=s;this.userStore.setUserAggregateInfo({...r,currentUser:a}),this.isSuperAdmin=n;const c="function"==typeof e?await e(s):e;this.menuStore.init(o(c)?i:c,a.id)};init=async t=>{const{base:e="/",menuData:s,loginSuccessCallback:a,ssoCallback:i}=t;this.loginStore.init(t?.loginConfig,e,i);try{const t=await this.loginStore.chekToken();return t?(this.userStore.setUserIdentity(t),await this.getAggregateInfo(s),await l.findAllCodeList(),await p.findAllParameters(),await(a?.()),!0):await this.loginStore.redirectLogin()}catch(t){console.error(t)}return!1}};const M="company-v1";var E=new class{data={};getCompanyDataType=t=>`${M}-${t}`;getCompanyData=async e=>{const s=this.getCompanyDataType(e);if(this.data[s])return this.data[s];const a=await async function(e){return t("/companyData/getCompanyData",{data:e,serviceId:"fwSecurity"})}({dataType:e,dataId:M}),i=a?.bigData?JSON.parse(a.bigData):void 0;return this.data[s]=i,i};updateCompanyData=async(e,s)=>{const a=this.getCompanyDataType(e);return await async function(e){return t("/companyData/setCompanyData",{data:e,serviceId:"fwSecurity"})}({dataType:e,dataId:M,bigData:JSON.stringify(s)}),this.data[a]=s,s};removeCompanyData=async e=>{const s=this.getCompanyDataType(e);await async function(e){return t("/companyData/delCompanyData",{data:e,serviceId:"fwSecurity"})}({dataType:e,dataId:M}),delete this.data[s]}};const O=l,$=p,B=b.userStore,N=b.loginStore,R=b.menuStore;export{P as M,I as a,O as c,E as i,N as l,R as m,$ as p,y as s,B as u};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/lib/types/index.d.ts
CHANGED
|
@@ -2151,7 +2151,7 @@ declare class BaseLogin {
|
|
|
2151
2151
|
declare class SSOLogin {
|
|
2152
2152
|
init(ssoConfig?: SSOConfigType): void;
|
|
2153
2153
|
ssoConfig: Required<SSOConfigType>;
|
|
2154
|
-
isSso: (ssoCallback?: () => boolean) => Promise<boolean>;
|
|
2154
|
+
isSso: (ssoCallback?: (isLogin?: boolean) => boolean, isLogin?: boolean) => Promise<boolean>;
|
|
2155
2155
|
ssoLogin: () => boolean;
|
|
2156
2156
|
ssoLoginOut: () => void;
|
|
2157
2157
|
}
|
|
@@ -2166,11 +2166,11 @@ declare class LoginStore extends BaseLogin {
|
|
|
2166
2166
|
ssoLogin: SSOLogin;
|
|
2167
2167
|
validate: ValidateLogin;
|
|
2168
2168
|
noCheckPermissionsPath?: string[];
|
|
2169
|
-
ssoCallback?: () => boolean;
|
|
2169
|
+
ssoCallback?: (isLogin: boolean) => boolean;
|
|
2170
2170
|
constructor();
|
|
2171
2171
|
init: (loginConfig?: LOGIN_CONFIG, base?: string, ssoCallback?: () => boolean) => void;
|
|
2172
2172
|
isNoLoginRequiredPage: () => boolean;
|
|
2173
|
-
loginOut: () => Promise<void>;
|
|
2173
|
+
loginOut: (redirectUrl?: boolean) => Promise<void>;
|
|
2174
2174
|
loginAuthentication: (params: BeforeLoginCheckCodeParams) => Promise<void>;
|
|
2175
2175
|
redirectLogin: () => Promise<boolean>;
|
|
2176
2176
|
}
|
|
@@ -2229,24 +2229,6 @@ type CodeMaps = {
|
|
|
2229
2229
|
[name: string]: CodeList;
|
|
2230
2230
|
};
|
|
2231
2231
|
|
|
2232
|
-
declare class GlobalStoreClass {
|
|
2233
|
-
userStore: UserStore;
|
|
2234
|
-
menuStore: MenuStore;
|
|
2235
|
-
loginStore: LoginStore;
|
|
2236
|
-
isSuperAdmin: boolean;
|
|
2237
|
-
loginCallback?: () => void;
|
|
2238
|
-
constructor();
|
|
2239
|
-
platformLanguages: Language[];
|
|
2240
|
-
productInfo: ProductInfo;
|
|
2241
|
-
get isPrd(): boolean;
|
|
2242
|
-
get userInfo(): User;
|
|
2243
|
-
get menuData(): ServerMenuData;
|
|
2244
|
-
findPlantform: () => Promise<void>;
|
|
2245
|
-
getAggregateInfo: (menus?: ServerMenuData | ((res: UserAggregateInfo) => ServerMenuData)) => Promise<void>;
|
|
2246
|
-
init: (options: GlobalOptions) => Promise<boolean>;
|
|
2247
|
-
}
|
|
2248
|
-
declare const globalStore: GlobalStoreClass;
|
|
2249
|
-
|
|
2250
2232
|
declare class CompanyData {
|
|
2251
2233
|
data: any;
|
|
2252
2234
|
getCompanyDataType: (dataType: string) => string;
|
|
@@ -2331,5 +2313,5 @@ declare const initI18n: (language: string, options?: {
|
|
|
2331
2313
|
i18nCallback?: Callback;
|
|
2332
2314
|
}) => Promise<(key: string, agrs?: string[], type?: "fe" | "workflow") => string>;
|
|
2333
2315
|
|
|
2334
|
-
export { Env, MENU_BREADCRUMBS_UPDATE, MENU_HISTORY_UPDATE, PresetColors, codeListStore, derivative$1 as compactAlgorithm, _default as companydataStore, derivative$2 as darkAlgorithm, derivative$3 as defaultAlgorithm, expireCache, formatToken as formatAliasToken, getAliasToken, getAlphaColor, getBackgroundColor, getDarkenSolidColor, getLightenSolidColor, getTokenCssVar,
|
|
2316
|
+
export { Env, MENU_BREADCRUMBS_UPDATE, MENU_HISTORY_UPDATE, PresetColors, codeListStore, derivative$1 as compactAlgorithm, _default as companydataStore, derivative$2 as darkAlgorithm, derivative$3 as defaultAlgorithm, expireCache, formatToken as formatAliasToken, getAliasToken, getAlphaColor, getBackgroundColor, getDarkenSolidColor, getLightenSolidColor, getTokenCssVar, initI18n, lighten, loginStore, derivative as meetingDerivative, menuStore, parameterStore, request, requestInstance, seedToken as seed, storage as storageStore, token, userStore };
|
|
2335
2317
|
export type { AliasToken, BASE_CONFIG_TYPE, ColorMapToken, ColorNeutralMapToken, ColorPalettes, CommonMapToken, ConfigMFA, DerivativeFunc, FontMapToken, FrameworkType, GantAxiosRequestConfig, GantCustomConfig, GantServerOptions, GantTypes, GantUserConfig, GlobalOptions, GlobalToken, HeightMapToken, InternalAxiosRequestConfig, KeepAliveConfig, LOGIN_CONFIG, Language, LegacyColorPalettes, LoginResultData, MAIN_CONFIG_TYPE, MapToken, MappingAlgorithm, Perferences, PresetColorKey, PresetColorType, ProductInfo, Route, SETTING_CONFIG_TYPE, SSOConfigType, SYSMGMT_CONFIG_TYPE, SeedToken, ServerMenu, ServerMenuData, ServerMenuMap, SizeMapToken, StyleMapToken, THEME_TYPE, ThemeType, TokenType, User, UserAggregateInfo, GantUserConfig as UserConfig, UserIdentityType, WATER_MARK_CONFIG_TYPE };
|