@zxiaosi/sdk 0.1.6 → 0.1.8

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/dist/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import { AxiosInstance, AxiosRequestConfig, AxiosResponse, CreateAxiosDefaults } from "axios";
2
2
  import { ConfigProviderProps } from "antd";
3
+ import intl from "react-intl-universal";
4
+ import * as zustand0 from "zustand";
3
5
  import { Location, NavigateFunction, RouteObject, UIMatch } from "react-router-dom";
4
6
  import { MenuDataItem, ProLayoutProps } from "@ant-design/pro-layout";
5
7
  import { MicroApp, ObjectType, RegistrableApp } from "qiankun";
@@ -173,6 +175,62 @@ interface ConfigResults extends Required<ConfigOptions> {}
173
175
  */
174
176
  declare const SdkConfigPlugin: Plugin<'config'>;
175
177
  //#endregion
178
+ //#region src/plugins/i18n/index.d.ts
179
+ interface I18nOptions {
180
+ /**
181
+ * React Intl Universal
182
+ * - 不要解构使用, const { get } = useIntl() 会报错
183
+ * - 如果项目不使用 React Compiler, 可以直接使用 sdk.i18n.intl
184
+ * @example const intl = useIntl(); intl.get(key).d(defaultValue)
185
+ */
186
+ intl?: typeof intl;
187
+ /**
188
+ * React Intl Universal 配置的语言包
189
+ * @example
190
+ * {
191
+ * 'zh-CN': {
192
+ * test: '测试国际化'
193
+ * },
194
+ * 'en-US': {
195
+ * test: 'Test Intl'
196
+ * }
197
+ * }
198
+ */
199
+ intlConfig?: Record<string, any>;
200
+ /**
201
+ * 加载 Antd 语言包
202
+ * @param locale 语言包名
203
+ * @example
204
+ * import enUS from 'antd/es/locale/en_US';
205
+ * import zhCN from 'antd/es/locale/zh_CN';
206
+ * import dayjs from 'dayjs';
207
+ * import 'dayjs/locale/en';
208
+ * import 'dayjs/locale/zh';
209
+ *
210
+ * const loadLocale = (locale: string) => {
211
+ * switch (locale) {
212
+ * case 'en-US':
213
+ * dayjs.locale('en');
214
+ * return enUS;
215
+ * case 'zh-CN':
216
+ * dayjs.locale('zh');
217
+ * return zhCN;
218
+ * default:
219
+ * return undefined;
220
+ * }
221
+ * }
222
+ */
223
+ loadLocale?: (locale: string) => any;
224
+ }
225
+ interface I18nResults extends Required<I18nOptions> {}
226
+ /**
227
+ * 多语言
228
+ * - 详情参考 {@link I18nOptions} {@link I18nResults}
229
+ * - 集成 React Intl Universal 和 Antd 国际化
230
+ * - 需要从外部引入语言包, 详见 intlConfig 和 loadLocale 配置项
231
+ */
232
+ declare const SdkI18nPlugin: Plugin<'i18n'>;
233
+ //#endregion
176
234
  //#region src/plugins/storage/index.d.ts
177
235
  interface StorageOptions {
178
236
  /** 国际化存储名称 */
@@ -213,6 +271,70 @@ interface StorageResults extends Required<StorageOptions> {
213
271
  */
214
272
  declare const SdkStoragePlugin: Plugin<'storage'>;
215
273
  //#endregion
274
+ //#region src/plugins/store/createInitState.d.ts
275
+ interface InitStateStoreProps {
276
+ /** 初始变量 */
277
+ initState: UserInfo;
278
+ /** 设置初始变量 */
279
+ setInitState: (initState: UserInfo) => void;
280
+ }
281
+ /** 初始变量状态 */
282
+ //#endregion
283
+ //#region src/plugins/store/createLocale.d.ts
284
+ interface LocaleStoreProps {
285
+ /** 国际化 */
286
+ locale: LocaleProps;
287
+ /** 设置国际化 */
288
+ setLocale: (locale: LocaleProps) => void;
289
+ }
290
+ /** 国际化状态 */
291
+ //#endregion
292
+ //#region src/plugins/store/createMicroAppLoading.d.ts
293
+ interface MicroAppStateStoreProps {
294
+ /** 子应用加载状态 */
295
+ microAppLoading: boolean;
296
+ /** 设置子应用加载状态 */
297
+ setMicroAppLoading: (state: boolean) => void;
298
+ }
299
+ /** 子应用状态 */
300
+ //#endregion
301
+ //#region src/plugins/store/createTheme.d.ts
302
+ interface ThemeStoreProps {
303
+ /** 主题 */
304
+ theme: ThemeProps;
305
+ /** 设置主题 */
306
+ setTheme: (theme: ThemeProps) => void;
307
+ }
308
+ /** 主题状态 */
309
+ //#endregion
310
+ //#region src/plugins/store/index.d.ts
311
+ type StoreOptions = InitStateStoreProps & LocaleStoreProps & MicroAppStateStoreProps & ThemeStoreProps;
312
+ type StoreResults = typeof globalStore;
313
+ /**
314
+ * 创建 Store
315
+ * - 这里单独声明变量, 主要是为了使用返回类型 StoreResults 🤔
316
+ */
317
+ declare const globalStore: Omit<zustand0.StoreApi<StoreOptions>, "subscribe"> & {
318
+ subscribe: {
319
+ (listener: (selectedState: StoreOptions, previousSelectedState: StoreOptions) => void): () => void;
320
+ <U>(selector: (state: StoreOptions) => U, listener: (selectedState: U, previousSelectedState: U) => void, options?: {
321
+ equalityFn?: (a: U, b: U) => boolean;
322
+ fireImmediately?: boolean;
323
+ }): () => void;
324
+ };
325
+ };
326
+ /**
327
+ * 全局状态管理
328
+ * - 详情参考 {@link StoreOptions} {@link StoreResults}
329
+ * - 此插件不会合并传入属性
330
+ * @example const setTheme = useStore(sdk.store, (state) => state.setTheme)
331
+ * @example const { theme, setTheme } = useStore(sdk.store, useShallow((state) => { theme: state.theme, setTheme: state.setTheme }))
332
+ * @example const [theme, setTheme] = useStore(sdk.store, useShallow((state) => [state.theme, state.setTheme]))
333
+ * @example sdk.store?.getState()?.setTheme('light')
334
+ * @example sdk.store.subscribe((state) => state.theme, (theme) => { console.log('theme', theme) }, { fireImmediately: true }) // fireImmediately 立即变更
335
+ */
336
+ declare const SdkStorePlugin: Plugin<'store'>;
337
+ //#endregion
216
338
  //#region src/types.d.ts
217
339
  type ThemeProps = 'light' | 'dark' | (string & {});
218
340
  type LocaleProps = 'zh-CN' | 'en-US' | (string & {});
@@ -238,8 +360,12 @@ interface PluginOptions {
238
360
  client?: ClientOptions;
239
361
  /** Sdk 配置信息 */
240
362
  config?: ConfigOptions;
363
+ /** 多语言 */
364
+ i18n?: I18nOptions;
241
365
  /** 本地缓存 */
242
366
  storage?: StorageOptions;
367
+ /** 全局状态管理 */
368
+ store?: StoreOptions;
243
369
  }
244
370
  interface PluginResults {
245
371
  /** 全局请求 */
@@ -250,8 +376,12 @@ interface PluginResults {
250
376
  client: ClientResults;
251
377
  /** Sdk 配置信息 */
252
378
  config: ConfigResults;
379
+ /** 多语言 */
380
+ i18n: I18nResults;
253
381
  /** 本地缓存 */
254
382
  storage: StorageResults;
383
+ /** 全局状态管理 */
384
+ store: StoreResults;
255
385
  }
256
386
  type PluginName = keyof PluginOptions;
257
387
  interface Plugin<K extends PluginName> {
@@ -284,7 +414,9 @@ declare class Sdk implements SdkResult {
284
414
  app: SdkResult['app'];
285
415
  client: SdkResult['client'];
286
416
  config: SdkResult['config'];
417
+ i18n: SdkResult['i18n'];
287
418
  storage: SdkResult['storage'];
419
+ store: SdkResult['store'];
288
420
  constructor();
289
421
  mount(name: string): void;
290
422
  extend(name: string): void;
@@ -295,5 +427,5 @@ declare class Sdk implements SdkResult {
295
427
  */
296
428
  declare const sdk: Sdk;
297
429
  //#endregion
298
- export { type ApiOptions, type ApiResults, type AppOptions, type AppResults, type ClientOptions, type ClientResults, type ConfigOptions, type ConfigResults, SdkApiPlugin, SdkAppPlugin, SdkClientPlugin, SdkConfigPlugin, SdkStoragePlugin, type StorageOptions, type StorageResults, sdk };
430
+ export { type ApiOptions, type ApiResults, type AppOptions, type AppResults, type ClientOptions, type ClientResults, type ConfigOptions, type ConfigResults, type I18nOptions, type I18nResults, SdkApiPlugin, SdkAppPlugin, SdkClientPlugin, SdkConfigPlugin, SdkI18nPlugin, SdkStoragePlugin, SdkStorePlugin, type StorageOptions, type StorageResults, type StoreOptions, type StoreResults, sdk };
299
431
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import e from"axios";import{message as t}from"antd";const n=new class{name;_plugins;api;app;client;config;storage;constructor(){this.name=``,this._plugins=new Map}mount(e){if(window[e])throw Error(`The SDK already exists - ${e}`);console.log(`%c SDK mounted:`,`color: pink; font-weight: bold;`,e),this.name=e;let t=new Proxy(this,{get:(e,t,n)=>e?Reflect.get(e,t,n):null,set:()=>(console.error(`The SDK cannot be modified.`),!1),deleteProperty:()=>(console.error(`The SDK cannot be deleted.`),!1)});window[this.name]=t}extend(e){if(!window[e])throw Error(`The SDK not found - ${e}`);console.log(`%c SDK extended:`,`color: pink; font-weight: bold;`,e),Object.assign(this,window[e])}use(e,t){let{name:n,install:r}=e;if(!n)throw Error(`${n} plugin has no name`);if(typeof r!=`function`)throw Error(`${n} plugin is not a function`);return r(this,t),this._plugins.set(n,{...e,options:t}),this}};function r(e){if(!e||typeof e!=`object`)return!1;let t=Object.getPrototypeOf(e);return t===null||t===Object.prototype||Object.getPrototypeOf(t)===null?Object.prototype.toString.call(e)===`[object Object]`:!1}function i(e){return e===`__proto__`}function a(e,t){let n=Object.keys(t);for(let o=0;o<n.length;o++){let s=n[o];if(i(s))continue;let c=t[s],l=e[s];Array.isArray(c)?Array.isArray(l)?e[s]=a(l,c):e[s]=a([],c):r(c)?r(l)?e[s]=a(l,c):e[s]=a({},c):(l===void 0||c!==void 0)&&(e[s]=c)}return e}const o=e=>{let{requestId:t,url:n,method:r,params:i,data:a}=e;return t||`${r}:${n}?${JSON.stringify(i)}&${JSON.stringify(a)}`},s=e=>{let t=o(e),r=n.api.controllers.get(t);r&&(r.abort(),n.api.controllers.delete(t))};var c=class{instance;constructor(t={}){this.instance=e.create(t),this.defaultRequestInterceptor(),this.defaultResponseInterceptor()}defaultRequestInterceptor(){this.instance.interceptors.request.use(function(e){if(e?.isCancelRequest){let t=o(e);s(e);let r=new AbortController;n.api.controllers.set(t,r),e.requestId=t,e.signal=r.signal}let t=n.storage.getToken();return e.headers.lang=n.config.locale,e.headers.Authorization=t,a(e.headers,n.api.config.headers||{}),e},function(e){return console.error(`请求错误`),Promise.reject(e)})}defaultResponseInterceptor(){this.instance.interceptors.response.use(function(e){let{data:r,config:i}=e,{isOriginalData:a,isShowFailMsg:o,isCancelRequest:s}=i,{code:c,msg:l}=r;return c!==0&&(o&&t.error(l),console.error(`response error: `,i.url,l),c==20041&&n.app.pageToLogin()),s&&n.api.controllers.delete(i.requestId),a?e:e.data},function(r){let{response:i,config:a}=r,{isShowFailMsg:o}=a;if(e.isCancel(r))return Promise.reject(r);if(i){let{status:e,data:r,statusText:a}=i;o&&t.error(r.msg||a),e==401&&n.app.pageToLogin()}else o&&t.error(`请求超时或服务器异常,请检查网络或联系管理员`),console.error(`Request error:`,a.url,r);return Promise.reject(r)})}getInstance(){return this.instance}};const l={name:`api`,install(e,t={}){let n={baseURL:`/`,timeout:0,...t.config},r=t?.instance||new c(n).getInstance();e.api=a({config:n,controllers:new Map,instance:null,request:(e,t={})=>r.request({url:e,isOriginalData:!1,isShowFailMsg:!0,isCancelRequest:!0,...t}),getUserInfoApi:()=>e.api.request(`/getUserInfo`,{method:`GET`}),getRoutesApi:()=>e.api.request(`/routes`,{method:`GET`})},t)}},u={name:`app`,install(e,t={}){e.app=a({menuData:[],allRoutes:[],microApps:[],microAppsInstance:new Map,user:null,permissions:[],roles:[],settings:{},clearData:()=>{e.app.menuData=[],e.app.allRoutes=e.app.allRoutes.filter(e=>e.path!==`/`),e.app.microApps=[],e.app.microAppsInstance.forEach(e=>e.unmount()),e.app.microAppsInstance.clear(),e.app.user=null,e.app.permissions=[],e.app.roles=[],e.app.settings={}},pageToLogin:()=>{e.storage.clearToken();let t=window.location.pathname||`/`,n=e.config.loginPath,r=t===n?n:`${n}?redirect=${encodeURIComponent(t)}`;e.config.qiankunMode===`router`?window.location.replace(r):(e.app.clearData(),e.client.navigate(r,{replace:!0}))},getRedirectPath:()=>{let t=e.config.defaultPath;if(t)return t;let n=new URLSearchParams(window.location.search);return decodeURIComponent(n.get(`redirect`)||``)||`/`}},t)}},d=`client`,f={name:d,install(e,t={}){e[d]=a({location:null,navigate:null,matches:null},t)}},p=`config`,m={name:p,install(e,t={}){e[p]=a({env:{},qiankunMode:`router`,theme:null,locale:null,loginPath:`/login`,defaultPath:``,customRoutes:[],antdConfig:{},proLayoutConfig:{title:`Demo`}},t)}},h=`storage`,g={name:h,install(e,t={}){e[h]=a({localeKey:`locale`,themeKey:`theme`,tokenKey:`token`,getLocale:()=>localStorage.getItem(e.storage.localeKey),setLocale:t=>{localStorage.setItem(e.storage.localeKey,t)},clearLocale:()=>{localStorage.removeItem(e.storage.localeKey)},getTheme:()=>localStorage.getItem(e.storage.themeKey),setTheme:t=>{localStorage.setItem(e.storage.themeKey,t)},clearTheme:()=>{localStorage.removeItem(e.storage.themeKey)},getToken:()=>localStorage.getItem(e.storage.tokenKey),setToken:t=>{localStorage.setItem(e.storage.tokenKey,t)},clearToken:()=>{localStorage.removeItem(e.storage.tokenKey)}},t)}};export{l as SdkApiPlugin,u as SdkAppPlugin,f as SdkClientPlugin,m as SdkConfigPlugin,g as SdkStoragePlugin,n as sdk};
1
+ import e from"axios";import{message as t}from"antd";import n from"react-intl-universal";import{createStore as r}from"zustand";import{subscribeWithSelector as i}from"zustand/middleware";const a=new class{name;_plugins;api;app;client;config;i18n;storage;store;constructor(){this.name=``,this._plugins=new Map}mount(e){if(window[e])throw Error(`The SDK already exists - ${e}`);console.log(`%c SDK mounted:`,`color: pink; font-weight: bold;`,e),this.name=e;let t=new Proxy(this,{get:(e,t,n)=>e?Reflect.get(e,t,n):null,set:()=>(console.error(`The SDK cannot be modified.`),!1),deleteProperty:()=>(console.error(`The SDK cannot be deleted.`),!1)});window[this.name]=t}extend(e){if(!window[e])throw Error(`The SDK not found - ${e}`);console.log(`%c SDK extended:`,`color: pink; font-weight: bold;`,e),Object.assign(this,window[e])}use(e,t){let{name:n,install:r}=e;if(!n)throw Error(`${n} plugin has no name`);if(typeof r!=`function`)throw Error(`${n} plugin is not a function`);return r(this,t),this._plugins.set(n,{...e,options:t}),this}};function o(e){if(!e||typeof e!=`object`)return!1;let t=Object.getPrototypeOf(e);return t===null||t===Object.prototype||Object.getPrototypeOf(t)===null?Object.prototype.toString.call(e)===`[object Object]`:!1}function s(e){return e===`__proto__`}function c(e,t){let n=Object.keys(t);for(let r=0;r<n.length;r++){let i=n[r];if(s(i))continue;let a=t[i],l=e[i];Array.isArray(a)?Array.isArray(l)?e[i]=c(l,a):e[i]=c([],a):o(a)?o(l)?e[i]=c(l,a):e[i]=c({},a):(l===void 0||a!==void 0)&&(e[i]=a)}return e}const l=e=>{let{requestId:t,url:n,method:r,params:i,data:a}=e;return t||`${r}:${n}?${JSON.stringify(i)}&${JSON.stringify(a)}`},u=e=>{let t=l(e),n=a.api.controllers.get(t);n&&(n.abort(),a.api.controllers.delete(t))};var d=class{instance;constructor(t={}){this.instance=e.create(t),this.defaultRequestInterceptor(),this.defaultResponseInterceptor()}defaultRequestInterceptor(){this.instance.interceptors.request.use(function(e){if(e?.isCancelRequest){let t=l(e);u(e);let n=new AbortController;a.api.controllers.set(t,n),e.requestId=t,e.signal=n.signal}let t=a.storage.getToken();return e.headers.lang=a.config.locale,e.headers.Authorization=t,c(e.headers,a.api.config.headers||{}),e},function(e){return console.error(`请求错误`),Promise.reject(e)})}defaultResponseInterceptor(){this.instance.interceptors.response.use(function(e){let{data:n,config:r}=e,{isOriginalData:i,isShowFailMsg:o,isCancelRequest:s}=r,{code:c,msg:l}=n;return c!==0&&(o&&t.error(l),console.error(`response error: `,r.url,l),c==20041&&a.app.pageToLogin()),s&&a.api.controllers.delete(r.requestId),i?e:e.data},function(n){let{response:r,config:i}=n,{isShowFailMsg:o}=i;if(e.isCancel(n))return Promise.reject(n);if(r){let{status:e,data:n,statusText:i}=r;o&&t.error(n.msg||i),e==401&&a.app.pageToLogin()}else o&&t.error(`请求超时或服务器异常,请检查网络或联系管理员`),console.error(`Request error:`,i.url,n);return Promise.reject(n)})}getInstance(){return this.instance}};const f={name:`api`,install(e,t={}){let n={baseURL:`/`,timeout:0,...t.config},r=t?.instance||new d(n).getInstance();e.api=c({config:n,controllers:new Map,instance:null,request:(e,t={})=>r.request({url:e,isOriginalData:!1,isShowFailMsg:!0,isCancelRequest:!0,...t}),getUserInfoApi:()=>e.api.request(`/getUserInfo`,{method:`GET`}),getRoutesApi:()=>e.api.request(`/routes`,{method:`GET`})},t)}},p={name:`app`,install(e,t={}){e.app=c({menuData:[],allRoutes:[],microApps:[],microAppsInstance:new Map,user:null,permissions:[],roles:[],settings:{},clearData:()=>{e.app.menuData=[],e.app.allRoutes=e.app.allRoutes.filter(e=>e.path!==`/`),e.app.microApps=[],e.app.microAppsInstance.forEach(e=>e.unmount()),e.app.microAppsInstance.clear(),e.app.user=null,e.app.permissions=[],e.app.roles=[],e.app.settings={}},pageToLogin:()=>{e.storage.clearToken();let t=window.location.pathname||`/`,n=e.config.loginPath,r=t===n?n:`${n}?redirect=${encodeURIComponent(t)}`;e.config.qiankunMode===`router`?window.location.replace(r):(e.app.clearData(),e.client.navigate(r,{replace:!0}))},getRedirectPath:()=>{let t=e.config.defaultPath;if(t)return t;let n=new URLSearchParams(window.location.search);return decodeURIComponent(n.get(`redirect`)||``)||`/`}},t)}},m=`client`,h={name:m,install(e,t={}){e[m]=c({location:null,navigate:null,matches:null},t)}},g=`config`,_={name:g,install(e,t={}){e[g]=c({env:{},qiankunMode:`router`,theme:null,locale:null,loginPath:`/login`,defaultPath:``,customRoutes:[],antdConfig:{},proLayoutConfig:{title:`Demo`}},t)}},v=`i18n`,y={name:v,install(e,t={}){e[v]=c({intl:n,intlConfig:{},loadLocale:e=>void 0},t)}},b=`storage`,x={name:b,install(e,t={}){e[b]=c({localeKey:`locale`,themeKey:`theme`,tokenKey:`token`,getLocale:()=>localStorage.getItem(e.storage.localeKey),setLocale:t=>{localStorage.setItem(e.storage.localeKey,t)},clearLocale:()=>{localStorage.removeItem(e.storage.localeKey)},getTheme:()=>localStorage.getItem(e.storage.themeKey),setTheme:t=>{localStorage.setItem(e.storage.themeKey,t)},clearTheme:()=>{localStorage.removeItem(e.storage.themeKey)},getToken:()=>localStorage.getItem(e.storage.tokenKey),setToken:t=>{localStorage.setItem(e.storage.tokenKey,t)},clearToken:()=>{localStorage.removeItem(e.storage.tokenKey)}},t)}},S=(e,t)=>({initState:{},setInitState:t=>{e(()=>({initState:t})),a.app={...a.app,...t}}}),C=(e,t)=>({locale:null,setLocale:t=>{e(()=>({locale:t})),a.config.locale=t,a.storage.setLocale(t),document.documentElement.setAttribute(`lang`,t);let r=a.i18n.intlConfig;n.init({currentLocale:t,locales:r});try{let e=a.i18n.loadLocale?.(t)||void 0;a.config.antdConfig.locale=e}catch(e){console.error(`sdk.i18n.loadLocale error:`,e)}}}),w=(e,t)=>({microAppLoading:!1,setMicroAppLoading:t=>e(()=>({microAppLoading:t}))}),T=(e,t)=>({theme:null,setTheme:t=>{e(()=>({theme:t})),a.config.theme=t,a.storage.setTheme(t),document.documentElement.setAttribute(`theme`,t)}}),E=r()(i((...e)=>({...S(...e),...C(...e),...w(...e),...T(...e)}))),D=`store`,O={name:D,install(e,t={}){e[D]=E}};export{f as SdkApiPlugin,p as SdkAppPlugin,h as SdkClientPlugin,_ as SdkConfigPlugin,y as SdkI18nPlugin,x as SdkStoragePlugin,O as SdkStorePlugin,a as sdk};
2
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["pluginName","SdkApiPlugin: Plugin<'api'>","Http","options","sdk","pluginName","SdkAppPlugin: Plugin<'app'>","sdk","pluginName","SdkClientPlugin: Plugin<'client'>","pluginName","SdkConfigPlugin: Plugin<'config'>","SdkStoragePlugin: Plugin<'storage'>","sdk"],"sources":["../src/core/index.ts","../../node_modules/.pnpm/es-toolkit@1.42.0/node_modules/es-toolkit/dist/predicate/isPlainObject.mjs","../../node_modules/.pnpm/es-toolkit@1.42.0/node_modules/es-toolkit/dist/_internal/isUnsafeProperty.mjs","../../node_modules/.pnpm/es-toolkit@1.42.0/node_modules/es-toolkit/dist/object/merge.mjs","../src/utils/request.ts","../src/plugins/api/http.ts","../src/plugins/api/index.ts","../src/plugins/app/index.tsx","../src/plugins/client/index.ts","../src/plugins/config/index.ts","../src/plugins/storage/index.ts"],"sourcesContent":["import type { Plugin, PluginOptions, SdkResult } from '@/types';\n\nclass Sdk implements SdkResult {\n name: SdkResult['name'];\n _plugins: SdkResult['_plugins'];\n\n api: SdkResult['api'];\n app: SdkResult['app'];\n client: SdkResult['client'];\n config: SdkResult['config'];\n storage: SdkResult['storage'];\n\n constructor() {\n this.name = '';\n this._plugins = new Map();\n }\n\n mount(name: string) {\n if (window[name]) throw new Error(`The SDK already exists - ${name}`);\n console.log('%c SDK mounted:', 'color: pink; font-weight: bold;', name);\n\n // 设置名称\n this.name = name;\n\n // 使用 new Proxy 禁止控制台对sdk属性的操作 (仅第一层属性)\n const _this = new Proxy(this, {\n get: (target, key, receiver) => {\n if (!target) return null;\n return Reflect.get(target, key, receiver);\n },\n set: () => {\n console.error('The SDK cannot be modified.');\n return false;\n },\n deleteProperty: () => {\n console.error('The SDK cannot be deleted.');\n return false;\n },\n });\n\n // 挂载到 Window 上\n window[this.name] = _this;\n }\n\n extend(name: string) {\n if (!window[name]) throw new Error(`The SDK not found - ${name}`);\n console.log('%c SDK extended:', 'color: pink; font-weight: bold;', name);\n\n // 合并实例属性\n Object.assign(this, window[name]);\n }\n\n use<K extends keyof PluginOptions>(\n plugin: Plugin<K>,\n options?: PluginOptions[K],\n ) {\n const { name, install } = plugin;\n\n if (!name) throw new Error(`${name} plugin has no name`);\n\n if (typeof install !== 'function')\n throw new Error(`${name} plugin is not a function`);\n\n // 插件安装\n install(this, options);\n\n // 添加到插件列表\n this._plugins.set(name, { ...plugin, options });\n\n // 链式调用\n return this;\n }\n}\n\n/**\n * sdk 实例\n */\nconst sdk = new Sdk();\n\nexport { sdk };\n","function isPlainObject(value) {\n if (!value || typeof value !== 'object') {\n return false;\n }\n const proto = Object.getPrototypeOf(value);\n const hasObjectPrototype = proto === null ||\n proto === Object.prototype ||\n Object.getPrototypeOf(proto) === null;\n if (!hasObjectPrototype) {\n return false;\n }\n return Object.prototype.toString.call(value) === '[object Object]';\n}\n\nexport { isPlainObject };\n","function isUnsafeProperty(key) {\n return key === '__proto__';\n}\n\nexport { isUnsafeProperty };\n","import { isUnsafeProperty } from '../_internal/isUnsafeProperty.mjs';\nimport { isPlainObject } from '../predicate/isPlainObject.mjs';\n\nfunction merge(target, source) {\n const sourceKeys = Object.keys(source);\n for (let i = 0; i < sourceKeys.length; i++) {\n const key = sourceKeys[i];\n if (isUnsafeProperty(key)) {\n continue;\n }\n const sourceValue = source[key];\n const targetValue = target[key];\n if (Array.isArray(sourceValue)) {\n if (Array.isArray(targetValue)) {\n target[key] = merge(targetValue, sourceValue);\n }\n else {\n target[key] = merge([], sourceValue);\n }\n }\n else if (isPlainObject(sourceValue)) {\n if (isPlainObject(targetValue)) {\n target[key] = merge(targetValue, sourceValue);\n }\n else {\n target[key] = merge({}, sourceValue);\n }\n }\n else if (targetValue === undefined || sourceValue !== undefined) {\n target[key] = sourceValue;\n }\n }\n return target;\n}\n\nexport { merge };\n","import { sdk } from '@/core';\nimport type { ApiRequestOption } from '@/plugins/api/http';\nimport type { AxiosResponse } from 'axios';\n\n/**\n * 生成请求id\n * @param config\n */\nexport const generateRequestIdUtil = (config: any) => {\n const { requestId, url, method, params, data } = config as ApiRequestOption;\n if (requestId) return requestId;\n\n return `${method}:${url}?${JSON.stringify(params)}&${JSON.stringify(data)}`;\n};\n\n/**\n * 取消请求\n * @param config 请求配置\n */\nexport const cancelRequestUtil = (config: any) => {\n const requestId = generateRequestIdUtil(config);\n\n const controller = sdk.api.controllers.get(requestId);\n if (!controller) return;\n\n controller.abort();\n sdk.api.controllers.delete(requestId);\n};\n\n/**\n * 下载文件\n * @param resp 响应数据\n */\nexport const downloadFileUtil = (resp: AxiosResponse) => {\n // 1. 从响应头中解析文件名\n const contentDisposition = resp.headers['content-disposition'];\n let filename = 'data.txt';\n\n if (contentDisposition) {\n // 使用正则匹配文件名(兼容带引号和不带引号的情况)\n const filenameMatch = contentDisposition.match(/filename=\"?(.+)\"?/);\n if (filenameMatch && filenameMatch[1]) {\n filename = filenameMatch[1];\n }\n }\n\n // 2. 创建 blob 对象\n const blob = new Blob([resp.data], { type: 'application/pdf' });\n\n // 3. 创建下载链接\n const url = window.URL.createObjectURL(blob);\n const link = document.createElement('a');\n link.href = url;\n link.download = filename; // Specify the file name\n document.body.appendChild(link);\n link.click();\n\n // 4. 释放 blob 对象\n window.URL.revokeObjectURL(url);\n document.body.removeChild(link);\n};\n","import { sdk } from '@/core';\nimport { cancelRequestUtil, generateRequestIdUtil } from '@/utils';\nimport { message } from 'antd';\nimport axios, {\n AxiosError,\n type AxiosInstance,\n type AxiosRequestConfig,\n type AxiosResponse,\n type CreateAxiosDefaults,\n type InternalAxiosRequestConfig,\n} from 'axios';\nimport { merge } from 'es-toolkit';\n\nexport interface ApiRequestOption extends AxiosRequestConfig {\n /** 请求唯一key(默认自动生成) */\n requestId?: string;\n /** 是否取消重复请求 */\n isCancelRequest?: boolean;\n /** 是否需要原始数据 */\n isOriginalData?: boolean;\n /** 是否显示错误信息 */\n isShowFailMsg?: boolean;\n}\n\n/** 请求类 */\nclass Http {\n instance: AxiosInstance;\n\n constructor(options: CreateAxiosDefaults = {}) {\n this.instance = axios.create(options); // 创建实例\n this.defaultRequestInterceptor(); // 添加默认请求拦截器\n this.defaultResponseInterceptor(); // 添加默认响应拦截器\n }\n\n /** 默认请求拦截器 */\n defaultRequestInterceptor() {\n this.instance.interceptors.request.use(\n function (config: InternalAxiosRequestConfig) {\n // @ts-ignore\n if (config?.isCancelRequest) {\n const requestId = generateRequestIdUtil(config); // 设置请求唯一标识\n cancelRequestUtil(config); // 取消重复请求\n const controller = new AbortController(); // 创建取消请求控制器\n sdk.api.controllers.set(requestId, controller); // 存储取消请求控制器\n\n config['requestId'] = requestId; // 记录请求id\n config.signal = controller.signal; // 取消请求标识\n }\n\n const token = sdk.storage.getToken();\n config.headers.lang = sdk.config.locale; // 添加语言到请求头\n config.headers.Authorization = token; // 添加token到请求头\n merge(config.headers, sdk.api.config.headers || {}); // 合并请求头\n return config;\n },\n function (error: AxiosError) {\n console.error(`请求错误`);\n return Promise.reject(error);\n },\n );\n }\n\n /** 默认响应拦截器 */\n defaultResponseInterceptor() {\n this.instance.interceptors.response.use(\n function (response: AxiosResponse) {\n const { data, config } = response;\n const { isOriginalData, isShowFailMsg, isCancelRequest } =\n config as ApiRequestOption;\n\n const { code, msg } = data;\n\n // 跟后端定义的成功标识 非0的都是失败\n if (code !== 0) {\n if (isShowFailMsg) message.error(msg);\n console.error('response error: ', config.url, msg);\n\n if (code == 20041) sdk.app.pageToLogin(); // 登录过期,跳转登录页\n }\n\n if (isCancelRequest) sdk.api.controllers.delete(config['requestId']);\n\n return isOriginalData ? response : response.data;\n },\n function (error: AxiosError) {\n const { response, config } = error;\n const { isShowFailMsg } = config as ApiRequestOption;\n\n // 如果是取消请求,则不显示错误信息\n if (axios.isCancel(error)) return Promise.reject(error);\n\n if (response) {\n // 请求成功发出且服务器也响应了状态码,但状态代码超出了 2xx 的范围\n const { status, data, statusText } = response as AxiosResponse;\n\n if (isShowFailMsg) message.error(data.msg || statusText);\n\n if (status == 401) sdk.app.pageToLogin(); // 登录过期,跳转登录页\n } else {\n // 请求已经成功发起,但没有收到响应\n if (isShowFailMsg)\n message.error('请求超时或服务器异常,请检查网络或联系管理员');\n\n console.error('Request error:', config.url, error);\n }\n\n return Promise.reject(error);\n },\n );\n }\n\n /** 获取实例 */\n getInstance() {\n return this.instance;\n }\n}\n\nexport default Http;\n","import type { Plugin, UserInfo } from '@/types';\nimport {\n type AxiosInstance,\n type AxiosResponse,\n type CreateAxiosDefaults,\n} from 'axios';\nimport { merge } from 'es-toolkit';\nimport type { RouteObject } from 'react-router-dom';\nimport Http, { type ApiRequestOption } from './http';\n\ninterface ApiOptions {\n /** Axios配置 */\n config?: CreateAxiosDefaults;\n\n /** 取消请求控制器 */\n controllers?: Map<string, AbortController>;\n\n /**\n * 自定义请求实例\n * - 替换 SDK 内置的请求实例\n * @example instance = axios.create(options)\n */\n instance?: AxiosInstance;\n\n /**\n * 获取用户信息\n * {@link UserInfo}\n * @example { data: { user: { ... }, permissions: [], roles: [], settings: {} }, code: 200 }\n */\n getUserInfoApi?: () => Promise<AxiosResponse<UserInfo>>;\n /**\n * 获取路由数据\n * {@link RouteObject}\n * @example { data: [{path: '/', name: '首页', element: 'Home'}], code: 200 }\n */\n getRoutesApi?: () => Promise<AxiosResponse<RouteObject[]>>;\n}\n\ninterface ApiResults extends Required<ApiOptions> {\n /**\n * 请求\n * @param url 请求地址\n * @param options 自定义配置项\n */\n readonly request: (\n url: string,\n options?: ApiRequestOption,\n ) => Promise<AxiosResponse<any, any>>;\n}\n\n/** 插件名称 */\nconst pluginName = 'api';\n\n/**\n * 请求插件\n * - 详情参考 {@link ApiOptions} {@link ApiResults}\n * - 内置了请求, 通过 sdk.api.request 发起请求\n * - 可通过外部传入 instance 自定义请求实例\n * - 预置了获取用户信息, 获取路由接口, 以便组件使用\n * @example sdk.api.request('/getTemp', { method: 'POST', ... })\n * @example sdk.api.request('/getTemp', { method: 'POST', isOriginalData: true }) // 返回原始数据\n * @example sdk.api.request('/getTemp', { method: 'POST', isShowFailMsg: false }) // 不显示错误信息\n * @example sdk.api.request('/getTemp', { method: 'POST', isCancelRequest: false }) // 不自动取消重复请求\n */\nconst SdkApiPlugin: Plugin<'api'> = {\n name: pluginName,\n install(sdk, options = {}) {\n // Axios 配置\n const axiosConfig = {\n baseURL: '/',\n timeout: 0,\n ...options.config,\n } satisfies ApiOptions['config'];\n\n // 创建 Axios 实例\n const instance = options?.instance || new Http(axiosConfig).getInstance();\n\n // 默认插件配置\n const defaultOptions = {\n config: axiosConfig,\n controllers: new Map(),\n\n instance: null,\n\n request: (url, options = {}) => {\n return instance.request({\n url,\n isOriginalData: false,\n isShowFailMsg: true,\n isCancelRequest: true,\n ...options,\n });\n },\n\n getUserInfoApi: () => sdk.api.request('/getUserInfo', { method: 'GET' }),\n getRoutesApi: () => sdk.api.request('/routes', { method: 'GET' }),\n } satisfies ApiResults;\n\n sdk[pluginName] = merge(defaultOptions, options);\n },\n};\n\nexport { SdkApiPlugin };\nexport type { ApiOptions, ApiResults };\n","import type { Plugin, UserInfo } from '@/types';\nimport type { MenuDataItem } from '@ant-design/pro-layout';\nimport { merge } from 'es-toolkit';\nimport type { MicroApp, ObjectType, RegistrableApp } from 'qiankun';\nimport type { RouteObject } from 'react-router-dom';\n\ninterface AppOptions {\n /** 菜单数据 */\n menuData?: MenuDataItem[];\n /** 所有路由信息 */\n allRoutes?: RouteObject[];\n\n /** 微应用信息 */\n microApps?: RegistrableApp<ObjectType>[];\n /** 微应用实例 */\n microAppsInstance?: Map<string, MicroApp>;\n\n /** 用户信息 */\n user?: UserInfo['user'];\n /** 用户权限 */\n permissions?: UserInfo['permissions'];\n /** 用户角色 */\n roles?: UserInfo['roles'];\n /** 用户设置 */\n settings?: UserInfo['settings'];\n}\n\ninterface AppResults extends Required<AppOptions> {\n /**\n * 清空数据\n */\n clearData(): void;\n /**\n * 跳转登录页\n */\n pageToLogin(): void;\n /**\n * 获取重定向路径\n */\n getRedirectPath(): string;\n}\n\n/** 插件名称 */\nconst pluginName = 'app';\n\n/**\n * 项目信息\n * - 详情参考 {@link AppOptions} {@link AppResults}\n * - 菜单信息 sdk.app.menuData\n * - 路由信息 sdk.app.allRoutes\n * - 微应用信息 sdk.app.microApps\n * - 用户信息 sdk.app.user\n * - 用户权限 sdk.app.permissions\n * - 用户角色 sdk.app.roles\n * - 用户设置 sdk.app.settings\n */\nconst SdkAppPlugin: Plugin<'app'> = {\n name: pluginName,\n install(sdk, options = {}) {\n // 默认插件配置\n const defaultOptions = {\n menuData: [],\n allRoutes: [],\n\n microApps: [],\n microAppsInstance: new Map(),\n\n user: null,\n permissions: [],\n roles: [],\n settings: {},\n\n clearData: () => {\n sdk.app.menuData = [];\n sdk.app.allRoutes = sdk.app.allRoutes.filter((_) => _.path !== '/');\n\n sdk.app.microApps = [];\n sdk.app.microAppsInstance.forEach((_) => _.unmount());\n sdk.app.microAppsInstance.clear();\n\n sdk.app.user = null;\n sdk.app.permissions = [];\n sdk.app.roles = [];\n sdk.app.settings = {};\n },\n pageToLogin: () => {\n // 清除 Token\n sdk.storage.clearToken();\n\n // 获取当前页路由\n const pathname = window.location.pathname || '/';\n const loginPath = sdk.config.loginPath;\n const path =\n pathname === loginPath\n ? loginPath\n : `${loginPath}?redirect=${encodeURIComponent(pathname)}`;\n\n // 跳转登录页\n if (sdk.config.qiankunMode === 'router') {\n window.location.replace(path); // 这里必须刷新一下页面, 否则qiankun实例不会销毁, 登录后会直接mount子应用, 而不是bootstrap子应用\n } else {\n sdk.app.clearData(); // 手动清空数据\n sdk.client.navigate(path, { replace: true }); // 使用客户端路由跳转\n }\n },\n getRedirectPath: () => {\n // 1. 优先使用指定值\n const defaultPath = sdk.config.defaultPath;\n if (defaultPath) return defaultPath;\n\n // 2. 其次使用重定向的值\n const param = new URLSearchParams(window.location.search);\n const redirect = decodeURIComponent(param.get('redirect') || '');\n if (redirect) return redirect;\n\n // 3. 最后使用菜单中第一项\n return '/';\n },\n } satisfies AppResults;\n\n sdk[pluginName] = merge(defaultOptions, options);\n },\n};\n\nexport { SdkAppPlugin };\nexport type { AppOptions, AppResults };\n","import type { Plugin } from '@/types';\nimport { merge } from 'es-toolkit';\nimport type { Location, NavigateFunction, UIMatch } from 'react-router-dom';\n\ninterface ClientOptions {}\n\ninterface ClientResults extends Required<ClientOptions> {\n /** 主应用 location */\n location: Location;\n /** 主应用navigate(解决子应用跳转问题) */\n navigate: NavigateFunction;\n /** 路由匹配(用于面包屑) */\n matches: UIMatch[];\n}\n\n/** 插件名称 */\nconst pluginName = 'client';\n\n/**\n * 全局路由信息\n * - 详情参考 {@link ClientOptions} {@link ClientResults}\n * - 路由信息 sdk.client.location\n * - 路由跳转 sdk.client.navigate\n * - 面包屑信息 sdk.client.matches\n */\nconst SdkClientPlugin: Plugin<'client'> = {\n name: pluginName,\n install(sdk, options = {}) {\n // 默认插件配置\n const defaultOptions = {\n location: null,\n navigate: null,\n matches: null,\n } satisfies ClientResults;\n\n sdk[pluginName] = merge(defaultOptions, options);\n },\n};\n\nexport { SdkClientPlugin };\nexport type { ClientOptions, ClientResults };\n","import type { LocaleProps, Plugin, ThemeProps } from '@/types';\nimport type { ProLayoutProps } from '@ant-design/pro-layout';\nimport type { ConfigProviderProps } from 'antd';\nimport { merge } from 'es-toolkit';\nimport type { RouteObject } from 'react-router-dom';\n\ninterface ConfigOptions {\n /** 环境变量(主应用共享给子应用变量) */\n env?: Record<string, any>;\n\n /** 主题 */\n theme?: ThemeProps;\n /** 国际化 */\n locale?: LocaleProps;\n\n /**\n * Qiankun模式(切换模式后请重新打开页面)\n * - router: 基于路由模式\n * - load: 手动加载模式\n */\n qiankunMode?: 'router' | 'load';\n\n /** 登录页路由 */\n loginPath?: string;\n /**\n * 登录后跳转的路由\n * - 优先使用指定值\n * - 其次使用重定向的值\n * - 最后使用菜单中第一项\n */\n defaultPath?: string;\n /**\n * 自定义路由信息\n * - 目前只支持最外层路由自定义\n * - 会合并到 sdk.app.allRoutes 中\n */\n customRoutes?: RouteObject[];\n\n /** Antd 配置 */\n antdConfig?: ConfigProviderProps;\n /** ProLayout 配置 */\n proLayoutConfig?: ProLayoutProps;\n}\n\ninterface ConfigResults extends Required<ConfigOptions> {}\n\n/** 插件名称 */\nconst pluginName = 'config';\n\n/**\n * Sdk 配置信息\n * - 详情参考 {@link ConfigOptions} {@link ConfigResults}\n * - 配置 env 环境变量\n * - 配置 默认主题、国际化\n * - 配置 Qiankun 模式\n * - 配置 默认登录路径、跳转路径、自定义路由\n * - 配置 Antd 配置、ProLayout 配置\n */\nconst SdkConfigPlugin: Plugin<'config'> = {\n name: pluginName,\n install(sdk, options = {}) {\n // 默认插件配置\n const defaultOptions = {\n env: {},\n\n qiankunMode: 'router',\n\n theme: null,\n locale: null,\n\n loginPath: '/login',\n defaultPath: '',\n customRoutes: [],\n\n antdConfig: {},\n proLayoutConfig: {\n title: 'Demo',\n },\n } satisfies ConfigResults;\n\n sdk[pluginName] = merge(defaultOptions, options);\n },\n};\n\nexport { SdkConfigPlugin };\nexport type { ConfigOptions, ConfigResults };\n","import type { LocaleProps, Plugin, ThemeProps } from '@/types';\nimport { merge } from 'es-toolkit';\n\ninterface StorageOptions {\n /** 国际化存储名称 */\n localeKey?: string;\n /** 主题存储名称 */\n themeKey?: string;\n /** Token存储名称 */\n tokenKey?: string;\n}\n\ninterface StorageResults extends Required<StorageOptions> {\n /** 获取当前国际化 */\n getLocale(): LocaleProps;\n /** 设置/切换切换国际化 */\n setLocale(locale: LocaleProps): void;\n /** 清空国际化 */\n clearLocale(): void;\n\n /** 获取当前主题 */\n getTheme(): ThemeProps;\n /** 设置/切换主题 */\n setTheme(theme: ThemeProps): void;\n /** 清空主题 */\n clearTheme(): void;\n\n /** 获取当前 Token */\n getToken(): string;\n /** 设置 Token */\n setToken(token: string): void;\n /** 清空 Token */\n clearToken(): void;\n}\n\n/** 插件名称 */\nconst pluginName = 'storage';\n\n/**\n * 本地缓存\n * - 详情参考 {@link StorageOptions} {@link StorageResults}\n * - 配置 localStorage 变量名称\n * - 提供 国际化、主题、Token 的 get、change、clear 方法\n * @example sdk.storage.getToken() // 获取 Token\n * @example sdk.storage.setTheme('dark') // 设置主题\n * @example sdk.storage.clearLocale() // 清空国际化\n */\nconst SdkStoragePlugin: Plugin<'storage'> = {\n name: pluginName,\n install(sdk, options = {}) {\n // 默认插件配置\n const defaultOptions = {\n localeKey: 'locale',\n themeKey: 'theme',\n tokenKey: 'token',\n\n getLocale: () => {\n return localStorage.getItem(sdk.storage.localeKey);\n },\n setLocale: (locale: string) => {\n localStorage.setItem(sdk.storage.localeKey, locale);\n },\n clearLocale: () => {\n localStorage.removeItem(sdk.storage.localeKey);\n },\n getTheme: () => {\n return localStorage.getItem(sdk.storage.themeKey);\n },\n setTheme: (theme: string) => {\n localStorage.setItem(sdk.storage.themeKey, theme);\n },\n clearTheme: () => {\n localStorage.removeItem(sdk.storage.themeKey);\n },\n getToken: () => {\n return localStorage.getItem(sdk.storage.tokenKey);\n },\n setToken: (token: string) => {\n localStorage.setItem(sdk.storage.tokenKey, token);\n },\n clearToken: () => {\n localStorage.removeItem(sdk.storage.tokenKey);\n },\n } satisfies StorageResults;\n\n sdk[pluginName] = merge(defaultOptions, options);\n },\n};\n\nexport { SdkStoragePlugin };\nexport type { StorageOptions, StorageResults };\n"],"x_google_ignoreList":[1,2,3],"mappings":"oDA6EA,MAAM,EAAM,IA3EZ,KAA+B,CAC7B,KACA,SAEA,IACA,IACA,OACA,OACA,QAEA,aAAc,CACZ,KAAK,KAAO,GACZ,KAAK,SAAW,IAAI,IAGtB,MAAM,EAAc,CAClB,GAAI,OAAO,GAAO,MAAU,MAAM,4BAA4B,IAAO,CACrE,QAAQ,IAAI,kBAAmB,kCAAmC,EAAK,CAGvE,KAAK,KAAO,EAGZ,IAAM,EAAQ,IAAI,MAAM,KAAM,CAC5B,KAAM,EAAQ,EAAK,IACZ,EACE,QAAQ,IAAI,EAAQ,EAAK,EAAS,CADrB,KAGtB,SACE,QAAQ,MAAM,8BAA8B,CACrC,IAET,oBACE,QAAQ,MAAM,6BAA6B,CACpC,IAEV,CAAC,CAGF,OAAO,KAAK,MAAQ,EAGtB,OAAO,EAAc,CACnB,GAAI,CAAC,OAAO,GAAO,MAAU,MAAM,uBAAuB,IAAO,CACjE,QAAQ,IAAI,mBAAoB,kCAAmC,EAAK,CAGxE,OAAO,OAAO,KAAM,OAAO,GAAM,CAGnC,IACE,EACA,EACA,CACA,GAAM,CAAE,OAAM,WAAY,EAE1B,GAAI,CAAC,EAAM,MAAU,MAAM,GAAG,EAAK,qBAAqB,CAExD,GAAI,OAAO,GAAY,WACrB,MAAU,MAAM,GAAG,EAAK,2BAA2B,CASrD,OANA,EAAQ,KAAM,EAAQ,CAGtB,KAAK,SAAS,IAAI,EAAM,CAAE,GAAG,EAAQ,UAAS,CAAC,CAGxC,OCtEX,SAAS,EAAc,EAAO,CAC1B,GAAI,CAAC,GAAS,OAAO,GAAU,SAC3B,MAAO,GAEX,IAAM,EAAQ,OAAO,eAAe,EAAM,CAO1C,OAN2B,IAAU,MACjC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Aa,QAAQA,EAAI,QAAQ,SAAU,EAAM,EAEnD,eAAkB,CAChB,aAAa,WAAWA,EAAI,QAAQ,SAAS,EAE/C,aACS,aAAa,QAAQA,EAAI,QAAQ,SAAS,CAEnD,SAAW,GAAkB,CAC3B,aAAa,QAAQA,EAAI,QAAQ,SAAU,EAAM,EAEnD,eAAkB,CAChB,aAAa,WAAWA,EAAI,QAAQ,SAAS,EAEhD,CAEuC,EAAQ,EAEnD"}
1
+ {"version":3,"file":"index.js","names":["pluginName","SdkApiPlugin: Plugin<'api'>","Http","options","sdk","pluginName","SdkAppPlugin: Plugin<'app'>","sdk","pluginName","SdkClientPlugin: Plugin<'client'>","pluginName","SdkConfigPlugin: Plugin<'config'>","pluginName","SdkI18nPlugin: Plugin<'i18n'>","pluginName","SdkStoragePlugin: Plugin<'storage'>","sdk","createInitStateSlice: StateCreator<InitStateStoreProps>","createLocaleSlice: StateCreator<LocaleStoreProps>","createMicroAppStateSlice: StateCreator<MicroAppStateStoreProps>","createThemeSlice: StateCreator<ThemeStoreProps>","SdkStorePlugin: Plugin<'store'>"],"sources":["../src/core/index.ts","../../node_modules/.pnpm/es-toolkit@1.42.0/node_modules/es-toolkit/dist/predicate/isPlainObject.mjs","../../node_modules/.pnpm/es-toolkit@1.42.0/node_modules/es-toolkit/dist/_internal/isUnsafeProperty.mjs","../../node_modules/.pnpm/es-toolkit@1.42.0/node_modules/es-toolkit/dist/object/merge.mjs","../src/utils/request.ts","../src/plugins/api/http.ts","../src/plugins/api/index.ts","../src/plugins/app/index.tsx","../src/plugins/client/index.ts","../src/plugins/config/index.ts","../src/plugins/i18n/index.ts","../src/plugins/storage/index.ts","../src/plugins/store/createInitState.ts","../src/plugins/store/createLocale.ts","../src/plugins/store/createMicroAppLoading.ts","../src/plugins/store/createTheme.ts","../src/plugins/store/index.ts"],"sourcesContent":["import type { Plugin, PluginOptions, SdkResult } from '@/types';\n\nclass Sdk implements SdkResult {\n name: SdkResult['name'];\n _plugins: SdkResult['_plugins'];\n\n api: SdkResult['api'];\n app: SdkResult['app'];\n client: SdkResult['client'];\n config: SdkResult['config'];\n i18n: SdkResult['i18n'];\n storage: SdkResult['storage'];\n store: SdkResult['store'];\n\n constructor() {\n this.name = '';\n this._plugins = new Map();\n }\n\n mount(name: string) {\n if (window[name]) throw new Error(`The SDK already exists - ${name}`);\n console.log('%c SDK mounted:', 'color: pink; font-weight: bold;', name);\n\n // 设置名称\n this.name = name;\n\n // 使用 new Proxy 禁止控制台对sdk属性的操作 (仅第一层属性)\n const _this = new Proxy(this, {\n get: (target, key, receiver) => {\n if (!target) return null;\n return Reflect.get(target, key, receiver);\n },\n set: () => {\n console.error('The SDK cannot be modified.');\n return false;\n },\n deleteProperty: () => {\n console.error('The SDK cannot be deleted.');\n return false;\n },\n });\n\n // 挂载到 Window 上\n window[this.name] = _this;\n }\n\n extend(name: string) {\n if (!window[name]) throw new Error(`The SDK not found - ${name}`);\n console.log('%c SDK extended:', 'color: pink; font-weight: bold;', name);\n\n // 合并实例属性\n Object.assign(this, window[name]);\n }\n\n use<K extends keyof PluginOptions>(\n plugin: Plugin<K>,\n options?: PluginOptions[K],\n ) {\n const { name, install } = plugin;\n\n if (!name) throw new Error(`${name} plugin has no name`);\n\n if (typeof install !== 'function')\n throw new Error(`${name} plugin is not a function`);\n\n // 插件安装\n install(this, options);\n\n // 添加到插件列表\n this._plugins.set(name, { ...plugin, options });\n\n // 链式调用\n return this;\n }\n}\n\n/**\n * sdk 实例\n */\nconst sdk = new Sdk();\n\nexport { sdk };\n","function isPlainObject(value) {\n if (!value || typeof value !== 'object') {\n return false;\n }\n const proto = Object.getPrototypeOf(value);\n const hasObjectPrototype = proto === null ||\n proto === Object.prototype ||\n Object.getPrototypeOf(proto) === null;\n if (!hasObjectPrototype) {\n return false;\n }\n return Object.prototype.toString.call(value) === '[object Object]';\n}\n\nexport { isPlainObject };\n","function isUnsafeProperty(key) {\n return key === '__proto__';\n}\n\nexport { isUnsafeProperty };\n","import { isUnsafeProperty } from '../_internal/isUnsafeProperty.mjs';\nimport { isPlainObject } from '../predicate/isPlainObject.mjs';\n\nfunction merge(target, source) {\n const sourceKeys = Object.keys(source);\n for (let i = 0; i < sourceKeys.length; i++) {\n const key = sourceKeys[i];\n if (isUnsafeProperty(key)) {\n continue;\n }\n const sourceValue = source[key];\n const targetValue = target[key];\n if (Array.isArray(sourceValue)) {\n if (Array.isArray(targetValue)) {\n target[key] = merge(targetValue, sourceValue);\n }\n else {\n target[key] = merge([], sourceValue);\n }\n }\n else if (isPlainObject(sourceValue)) {\n if (isPlainObject(targetValue)) {\n target[key] = merge(targetValue, sourceValue);\n }\n else {\n target[key] = merge({}, sourceValue);\n }\n }\n else if (targetValue === undefined || sourceValue !== undefined) {\n target[key] = sourceValue;\n }\n }\n return target;\n}\n\nexport { merge };\n","import { sdk } from '@/core';\nimport type { ApiRequestOption } from '@/plugins/api/http';\nimport type { AxiosResponse } from 'axios';\n\n/**\n * 生成请求id\n * @param config\n */\nexport const generateRequestIdUtil = (config: any) => {\n const { requestId, url, method, params, data } = config as ApiRequestOption;\n if (requestId) return requestId;\n\n return `${method}:${url}?${JSON.stringify(params)}&${JSON.stringify(data)}`;\n};\n\n/**\n * 取消请求\n * @param config 请求配置\n */\nexport const cancelRequestUtil = (config: any) => {\n const requestId = generateRequestIdUtil(config);\n\n const controller = sdk.api.controllers.get(requestId);\n if (!controller) return;\n\n controller.abort();\n sdk.api.controllers.delete(requestId);\n};\n\n/**\n * 下载文件\n * @param resp 响应数据\n */\nexport const downloadFileUtil = (resp: AxiosResponse) => {\n // 1. 从响应头中解析文件名\n const contentDisposition = resp.headers['content-disposition'];\n let filename = 'data.txt';\n\n if (contentDisposition) {\n // 使用正则匹配文件名(兼容带引号和不带引号的情况)\n const filenameMatch = contentDisposition.match(/filename=\"?(.+)\"?/);\n if (filenameMatch && filenameMatch[1]) {\n filename = filenameMatch[1];\n }\n }\n\n // 2. 创建 blob 对象\n const blob = new Blob([resp.data], { type: 'application/pdf' });\n\n // 3. 创建下载链接\n const url = window.URL.createObjectURL(blob);\n const link = document.createElement('a');\n link.href = url;\n link.download = filename; // Specify the file name\n document.body.appendChild(link);\n link.click();\n\n // 4. 释放 blob 对象\n window.URL.revokeObjectURL(url);\n document.body.removeChild(link);\n};\n","import { sdk } from '@/core';\nimport { cancelRequestUtil, generateRequestIdUtil } from '@/utils';\nimport { message } from 'antd';\nimport axios, {\n AxiosError,\n type AxiosInstance,\n type AxiosRequestConfig,\n type AxiosResponse,\n type CreateAxiosDefaults,\n type InternalAxiosRequestConfig,\n} from 'axios';\nimport { merge } from 'es-toolkit';\n\nexport interface ApiRequestOption extends AxiosRequestConfig {\n /** 请求唯一key(默认自动生成) */\n requestId?: string;\n /** 是否取消重复请求 */\n isCancelRequest?: boolean;\n /** 是否需要原始数据 */\n isOriginalData?: boolean;\n /** 是否显示错误信息 */\n isShowFailMsg?: boolean;\n}\n\n/** 请求类 */\nclass Http {\n instance: AxiosInstance;\n\n constructor(options: CreateAxiosDefaults = {}) {\n this.instance = axios.create(options); // 创建实例\n this.defaultRequestInterceptor(); // 添加默认请求拦截器\n this.defaultResponseInterceptor(); // 添加默认响应拦截器\n }\n\n /** 默认请求拦截器 */\n defaultRequestInterceptor() {\n this.instance.interceptors.request.use(\n function (config: InternalAxiosRequestConfig) {\n // @ts-ignore\n if (config?.isCancelRequest) {\n const requestId = generateRequestIdUtil(config); // 设置请求唯一标识\n cancelRequestUtil(config); // 取消重复请求\n const controller = new AbortController(); // 创建取消请求控制器\n sdk.api.controllers.set(requestId, controller); // 存储取消请求控制器\n\n config['requestId'] = requestId; // 记录请求id\n config.signal = controller.signal; // 取消请求标识\n }\n\n const token = sdk.storage.getToken();\n config.headers.lang = sdk.config.locale; // 添加语言到请求头\n config.headers.Authorization = token; // 添加token到请求头\n merge(config.headers, sdk.api.config.headers || {}); // 合并请求头\n return config;\n },\n function (error: AxiosError) {\n console.error(`请求错误`);\n return Promise.reject(error);\n },\n );\n }\n\n /** 默认响应拦截器 */\n defaultResponseInterceptor() {\n this.instance.interceptors.response.use(\n function (response: AxiosResponse) {\n const { data, config } = response;\n const { isOriginalData, isShowFailMsg, isCancelRequest } =\n config as ApiRequestOption;\n\n const { code, msg } = data;\n\n // 跟后端定义的成功标识 非0的都是失败\n if (code !== 0) {\n if (isShowFailMsg) message.error(msg);\n console.error('response error: ', config.url, msg);\n\n if (code == 20041) sdk.app.pageToLogin(); // 登录过期,跳转登录页\n }\n\n if (isCancelRequest) sdk.api.controllers.delete(config['requestId']);\n\n return isOriginalData ? response : response.data;\n },\n function (error: AxiosError) {\n const { response, config } = error;\n const { isShowFailMsg } = config as ApiRequestOption;\n\n // 如果是取消请求,则不显示错误信息\n if (axios.isCancel(error)) return Promise.reject(error);\n\n if (response) {\n // 请求成功发出且服务器也响应了状态码,但状态代码超出了 2xx 的范围\n const { status, data, statusText } = response as AxiosResponse;\n\n if (isShowFailMsg) message.error(data.msg || statusText);\n\n if (status == 401) sdk.app.pageToLogin(); // 登录过期,跳转登录页\n } else {\n // 请求已经成功发起,但没有收到响应\n if (isShowFailMsg)\n message.error('请求超时或服务器异常,请检查网络或联系管理员');\n\n console.error('Request error:', config.url, error);\n }\n\n return Promise.reject(error);\n },\n );\n }\n\n /** 获取实例 */\n getInstance() {\n return this.instance;\n }\n}\n\nexport default Http;\n","import type { Plugin, UserInfo } from '@/types';\nimport {\n type AxiosInstance,\n type AxiosResponse,\n type CreateAxiosDefaults,\n} from 'axios';\nimport { merge } from 'es-toolkit';\nimport type { RouteObject } from 'react-router-dom';\nimport Http, { type ApiRequestOption } from './http';\n\ninterface ApiOptions {\n /** Axios配置 */\n config?: CreateAxiosDefaults;\n\n /** 取消请求控制器 */\n controllers?: Map<string, AbortController>;\n\n /**\n * 自定义请求实例\n * - 替换 SDK 内置的请求实例\n * @example instance = axios.create(options)\n */\n instance?: AxiosInstance;\n\n /**\n * 获取用户信息\n * {@link UserInfo}\n * @example { data: { user: { ... }, permissions: [], roles: [], settings: {} }, code: 200 }\n */\n getUserInfoApi?: () => Promise<AxiosResponse<UserInfo>>;\n /**\n * 获取路由数据\n * {@link RouteObject}\n * @example { data: [{path: '/', name: '首页', element: 'Home'}], code: 200 }\n */\n getRoutesApi?: () => Promise<AxiosResponse<RouteObject[]>>;\n}\n\ninterface ApiResults extends Required<ApiOptions> {\n /**\n * 请求\n * @param url 请求地址\n * @param options 自定义配置项\n */\n readonly request: (\n url: string,\n options?: ApiRequestOption,\n ) => Promise<AxiosResponse<any, any>>;\n}\n\n/** 插件名称 */\nconst pluginName = 'api';\n\n/**\n * 请求插件\n * - 详情参考 {@link ApiOptions} {@link ApiResults}\n * - 内置了请求, 通过 sdk.api.request 发起请求\n * - 可通过外部传入 instance 自定义请求实例\n * - 预置了获取用户信息, 获取路由接口, 以便组件使用\n * @example sdk.api.request('/getTemp', { method: 'POST', ... })\n * @example sdk.api.request('/getTemp', { method: 'POST', isOriginalData: true }) // 返回原始数据\n * @example sdk.api.request('/getTemp', { method: 'POST', isShowFailMsg: false }) // 不显示错误信息\n * @example sdk.api.request('/getTemp', { method: 'POST', isCancelRequest: false }) // 不自动取消重复请求\n */\nconst SdkApiPlugin: Plugin<'api'> = {\n name: pluginName,\n install(sdk, options = {}) {\n // Axios 配置\n const axiosConfig = {\n baseURL: '/',\n timeout: 0,\n ...options.config,\n } satisfies ApiOptions['config'];\n\n // 创建 Axios 实例\n const instance = options?.instance || new Http(axiosConfig).getInstance();\n\n // 默认插件配置\n const defaultOptions = {\n config: axiosConfig,\n controllers: new Map(),\n\n instance: null,\n\n request: (url, options = {}) => {\n return instance.request({\n url,\n isOriginalData: false,\n isShowFailMsg: true,\n isCancelRequest: true,\n ...options,\n });\n },\n\n getUserInfoApi: () => sdk.api.request('/getUserInfo', { method: 'GET' }),\n getRoutesApi: () => sdk.api.request('/routes', { method: 'GET' }),\n } satisfies ApiResults;\n\n sdk[pluginName] = merge(defaultOptions, options);\n },\n};\n\nexport { SdkApiPlugin };\nexport type { ApiOptions, ApiResults };\n","import type { Plugin, UserInfo } from '@/types';\nimport type { MenuDataItem } from '@ant-design/pro-layout';\nimport { merge } from 'es-toolkit';\nimport type { MicroApp, ObjectType, RegistrableApp } from 'qiankun';\nimport type { RouteObject } from 'react-router-dom';\n\ninterface AppOptions {\n /** 菜单数据 */\n menuData?: MenuDataItem[];\n /** 所有路由信息 */\n allRoutes?: RouteObject[];\n\n /** 微应用信息 */\n microApps?: RegistrableApp<ObjectType>[];\n /** 微应用实例 */\n microAppsInstance?: Map<string, MicroApp>;\n\n /** 用户信息 */\n user?: UserInfo['user'];\n /** 用户权限 */\n permissions?: UserInfo['permissions'];\n /** 用户角色 */\n roles?: UserInfo['roles'];\n /** 用户设置 */\n settings?: UserInfo['settings'];\n}\n\ninterface AppResults extends Required<AppOptions> {\n /**\n * 清空数据\n */\n clearData(): void;\n /**\n * 跳转登录页\n */\n pageToLogin(): void;\n /**\n * 获取重定向路径\n */\n getRedirectPath(): string;\n}\n\n/** 插件名称 */\nconst pluginName = 'app';\n\n/**\n * 项目信息\n * - 详情参考 {@link AppOptions} {@link AppResults}\n * - 菜单信息 sdk.app.menuData\n * - 路由信息 sdk.app.allRoutes\n * - 微应用信息 sdk.app.microApps\n * - 用户信息 sdk.app.user\n * - 用户权限 sdk.app.permissions\n * - 用户角色 sdk.app.roles\n * - 用户设置 sdk.app.settings\n */\nconst SdkAppPlugin: Plugin<'app'> = {\n name: pluginName,\n install(sdk, options = {}) {\n // 默认插件配置\n const defaultOptions = {\n menuData: [],\n allRoutes: [],\n\n microApps: [],\n microAppsInstance: new Map(),\n\n user: null,\n permissions: [],\n roles: [],\n settings: {},\n\n clearData: () => {\n sdk.app.menuData = [];\n sdk.app.allRoutes = sdk.app.allRoutes.filter((_) => _.path !== '/');\n\n sdk.app.microApps = [];\n sdk.app.microAppsInstance.forEach((_) => _.unmount());\n sdk.app.microAppsInstance.clear();\n\n sdk.app.user = null;\n sdk.app.permissions = [];\n sdk.app.roles = [];\n sdk.app.settings = {};\n },\n pageToLogin: () => {\n // 清除 Token\n sdk.storage.clearToken();\n\n // 获取当前页路由\n const pathname = window.location.pathname || '/';\n const loginPath = sdk.config.loginPath;\n const path =\n pathname === loginPath\n ? loginPath\n : `${loginPath}?redirect=${encodeURIComponent(pathname)}`;\n\n // 跳转登录页\n if (sdk.config.qiankunMode === 'router') {\n window.location.replace(path); // 这里必须刷新一下页面, 否则qiankun实例不会销毁, 登录后会直接mount子应用, 而不是bootstrap子应用\n } else {\n sdk.app.clearData(); // 手动清空数据\n sdk.client.navigate(path, { replace: true }); // 使用客户端路由跳转\n }\n },\n getRedirectPath: () => {\n // 1. 优先使用指定值\n const defaultPath = sdk.config.defaultPath;\n if (defaultPath) return defaultPath;\n\n // 2. 其次使用重定向的值\n const param = new URLSearchParams(window.location.search);\n const redirect = decodeURIComponent(param.get('redirect') || '');\n if (redirect) return redirect;\n\n // 3. 最后使用菜单中第一项\n return '/';\n },\n } satisfies AppResults;\n\n sdk[pluginName] = merge(defaultOptions, options);\n },\n};\n\nexport { SdkAppPlugin };\nexport type { AppOptions, AppResults };\n","import type { Plugin } from '@/types';\nimport { merge } from 'es-toolkit';\nimport type { Location, NavigateFunction, UIMatch } from 'react-router-dom';\n\ninterface ClientOptions {}\n\ninterface ClientResults extends Required<ClientOptions> {\n /** 主应用 location */\n location: Location;\n /** 主应用navigate(解决子应用跳转问题) */\n navigate: NavigateFunction;\n /** 路由匹配(用于面包屑) */\n matches: UIMatch[];\n}\n\n/** 插件名称 */\nconst pluginName = 'client';\n\n/**\n * 全局路由信息\n * - 详情参考 {@link ClientOptions} {@link ClientResults}\n * - 路由信息 sdk.client.location\n * - 路由跳转 sdk.client.navigate\n * - 面包屑信息 sdk.client.matches\n */\nconst SdkClientPlugin: Plugin<'client'> = {\n name: pluginName,\n install(sdk, options = {}) {\n // 默认插件配置\n const defaultOptions = {\n location: null,\n navigate: null,\n matches: null,\n } satisfies ClientResults;\n\n sdk[pluginName] = merge(defaultOptions, options);\n },\n};\n\nexport { SdkClientPlugin };\nexport type { ClientOptions, ClientResults };\n","import type { LocaleProps, Plugin, ThemeProps } from '@/types';\nimport type { ProLayoutProps } from '@ant-design/pro-layout';\nimport type { ConfigProviderProps } from 'antd';\nimport { merge } from 'es-toolkit';\nimport type { RouteObject } from 'react-router-dom';\n\ninterface ConfigOptions {\n /** 环境变量(主应用共享给子应用变量) */\n env?: Record<string, any>;\n\n /** 主题 */\n theme?: ThemeProps;\n /** 国际化 */\n locale?: LocaleProps;\n\n /**\n * Qiankun模式(切换模式后请重新打开页面)\n * - router: 基于路由模式\n * - load: 手动加载模式\n */\n qiankunMode?: 'router' | 'load';\n\n /** 登录页路由 */\n loginPath?: string;\n /**\n * 登录后跳转的路由\n * - 优先使用指定值\n * - 其次使用重定向的值\n * - 最后使用菜单中第一项\n */\n defaultPath?: string;\n /**\n * 自定义路由信息\n * - 目前只支持最外层路由自定义\n * - 会合并到 sdk.app.allRoutes 中\n */\n customRoutes?: RouteObject[];\n\n /** Antd 配置 */\n antdConfig?: ConfigProviderProps;\n /** ProLayout 配置 */\n proLayoutConfig?: ProLayoutProps;\n}\n\ninterface ConfigResults extends Required<ConfigOptions> {}\n\n/** 插件名称 */\nconst pluginName = 'config';\n\n/**\n * Sdk 配置信息\n * - 详情参考 {@link ConfigOptions} {@link ConfigResults}\n * - 配置 env 环境变量\n * - 配置 默认主题、国际化\n * - 配置 Qiankun 模式\n * - 配置 默认登录路径、跳转路径、自定义路由\n * - 配置 Antd 配置、ProLayout 配置\n */\nconst SdkConfigPlugin: Plugin<'config'> = {\n name: pluginName,\n install(sdk, options = {}) {\n // 默认插件配置\n const defaultOptions = {\n env: {},\n\n qiankunMode: 'router',\n\n theme: null,\n locale: null,\n\n loginPath: '/login',\n defaultPath: '',\n customRoutes: [],\n\n antdConfig: {},\n proLayoutConfig: {\n title: 'Demo',\n },\n } satisfies ConfigResults;\n\n sdk[pluginName] = merge(defaultOptions, options);\n },\n};\n\nexport { SdkConfigPlugin };\nexport type { ConfigOptions, ConfigResults };\n","import type { Plugin } from '@/types';\nimport { merge } from 'es-toolkit';\nimport intl from 'react-intl-universal';\n\ninterface I18nOptions {\n /**\n * React Intl Universal\n * - 不要解构使用, const { get } = useIntl() 会报错\n * - 如果项目不使用 React Compiler, 可以直接使用 sdk.i18n.intl\n * @example const intl = useIntl(); intl.get(key).d(defaultValue)\n */\n intl?: typeof intl;\n /**\n * React Intl Universal 配置的语言包\n * @example\n * {\n * 'zh-CN': {\n * test: '测试国际化'\n * },\n * 'en-US': {\n * test: 'Test Intl'\n * }\n * }\n */\n intlConfig?: Record<string, any>;\n /**\n * 加载 Antd 语言包\n * @param locale 语言包名\n * @example\n * import enUS from 'antd/es/locale/en_US';\n * import zhCN from 'antd/es/locale/zh_CN';\n * import dayjs from 'dayjs';\n * import 'dayjs/locale/en';\n * import 'dayjs/locale/zh';\n *\n * const loadLocale = (locale: string) => {\n * switch (locale) {\n * case 'en-US':\n * dayjs.locale('en');\n * return enUS;\n * case 'zh-CN':\n * dayjs.locale('zh');\n * return zhCN;\n * default:\n * return undefined;\n * }\n * }\n */\n loadLocale?: (locale: string) => any;\n}\n\ninterface I18nResults extends Required<I18nOptions> {}\n\n/** 插件名称 */\nconst pluginName = 'i18n';\n\n/**\n * 多语言\n * - 详情参考 {@link I18nOptions} {@link I18nResults}\n * - 集成 React Intl Universal 和 Antd 国际化\n * - 需要从外部引入语言包, 详见 intlConfig 和 loadLocale 配置项\n */\nconst SdkI18nPlugin: Plugin<'i18n'> = {\n name: pluginName,\n install(sdk, options = {}) {\n // 默认插件配置\n const defaultOptions = {\n intl: intl,\n intlConfig: {},\n loadLocale: (locale: string) => undefined,\n } satisfies I18nResults;\n\n sdk[pluginName] = merge(defaultOptions, options);\n },\n};\n\nexport { SdkI18nPlugin };\nexport type { I18nOptions, I18nResults };\n","import type { LocaleProps, Plugin, ThemeProps } from '@/types';\nimport { merge } from 'es-toolkit';\n\ninterface StorageOptions {\n /** 国际化存储名称 */\n localeKey?: string;\n /** 主题存储名称 */\n themeKey?: string;\n /** Token存储名称 */\n tokenKey?: string;\n}\n\ninterface StorageResults extends Required<StorageOptions> {\n /** 获取当前国际化 */\n getLocale(): LocaleProps;\n /** 设置/切换切换国际化 */\n setLocale(locale: LocaleProps): void;\n /** 清空国际化 */\n clearLocale(): void;\n\n /** 获取当前主题 */\n getTheme(): ThemeProps;\n /** 设置/切换主题 */\n setTheme(theme: ThemeProps): void;\n /** 清空主题 */\n clearTheme(): void;\n\n /** 获取当前 Token */\n getToken(): string;\n /** 设置 Token */\n setToken(token: string): void;\n /** 清空 Token */\n clearToken(): void;\n}\n\n/** 插件名称 */\nconst pluginName = 'storage';\n\n/**\n * 本地缓存\n * - 详情参考 {@link StorageOptions} {@link StorageResults}\n * - 配置 localStorage 变量名称\n * - 提供 国际化、主题、Token 的 get、change、clear 方法\n * @example sdk.storage.getToken() // 获取 Token\n * @example sdk.storage.setTheme('dark') // 设置主题\n * @example sdk.storage.clearLocale() // 清空国际化\n */\nconst SdkStoragePlugin: Plugin<'storage'> = {\n name: pluginName,\n install(sdk, options = {}) {\n // 默认插件配置\n const defaultOptions = {\n localeKey: 'locale',\n themeKey: 'theme',\n tokenKey: 'token',\n\n getLocale: () => {\n return localStorage.getItem(sdk.storage.localeKey);\n },\n setLocale: (locale: string) => {\n localStorage.setItem(sdk.storage.localeKey, locale);\n },\n clearLocale: () => {\n localStorage.removeItem(sdk.storage.localeKey);\n },\n getTheme: () => {\n return localStorage.getItem(sdk.storage.themeKey);\n },\n setTheme: (theme: string) => {\n localStorage.setItem(sdk.storage.themeKey, theme);\n },\n clearTheme: () => {\n localStorage.removeItem(sdk.storage.themeKey);\n },\n getToken: () => {\n return localStorage.getItem(sdk.storage.tokenKey);\n },\n setToken: (token: string) => {\n localStorage.setItem(sdk.storage.tokenKey, token);\n },\n clearToken: () => {\n localStorage.removeItem(sdk.storage.tokenKey);\n },\n } satisfies StorageResults;\n\n sdk[pluginName] = merge(defaultOptions, options);\n },\n};\n\nexport { SdkStoragePlugin };\nexport type { StorageOptions, StorageResults };\n","import { sdk } from '@/core';\nimport type { UserInfo } from '@/types';\nimport type { StateCreator } from 'zustand';\n\ninterface InitStateStoreProps {\n /** 初始变量 */\n initState: UserInfo;\n /** 设置初始变量 */\n setInitState: (initState: UserInfo) => void;\n}\n\n/** 初始变量状态 */\nconst createInitStateSlice: StateCreator<InitStateStoreProps> = (set, get) => ({\n initState: {},\n setInitState: (initState) => {\n set(() => ({ initState }));\n sdk.app = { ...sdk.app, ...initState };\n },\n});\n\nexport { createInitStateSlice };\nexport type { InitStateStoreProps };\n","import { sdk } from '@/core';\nimport type { LocaleProps } from '@/types';\nimport intl from 'react-intl-universal';\nimport type { StateCreator } from 'zustand';\n\ninterface LocaleStoreProps {\n /** 国际化 */\n locale: LocaleProps;\n /** 设置国际化 */\n setLocale: (locale: LocaleProps) => void;\n}\n\n/** 国际化状态 */\nconst createLocaleSlice: StateCreator<LocaleStoreProps> = (set, get) => ({\n locale: null,\n\n setLocale: (locale) => {\n set(() => ({ locale })); // 自动合并其他\n\n // 记录值\n sdk.config.locale = locale;\n sdk.storage.setLocale(locale);\n\n // 设置作用域\n document.documentElement.setAttribute('lang', locale);\n\n // 设置 React Intl Universal 语言包\n const intlConfig = sdk.i18n.intlConfig;\n intl.init({ currentLocale: locale, locales: intlConfig });\n\n // 加载 Antd 语言包\n try {\n const localeData = sdk.i18n.loadLocale?.(locale) || undefined;\n sdk.config.antdConfig.locale = localeData;\n } catch (e) {\n console.error('sdk.i18n.loadLocale error:', e);\n }\n },\n});\n\nexport { createLocaleSlice };\nexport type { LocaleStoreProps };\n","import type { StateCreator } from 'zustand';\n\ninterface MicroAppStateStoreProps {\n /** 子应用加载状态 */\n microAppLoading: boolean;\n /** 设置子应用加载状态 */\n setMicroAppLoading: (state: boolean) => void;\n}\n\n/** 子应用状态 */\nconst createMicroAppStateSlice: StateCreator<MicroAppStateStoreProps> = (\n set,\n get,\n) => ({\n microAppLoading: false,\n setMicroAppLoading: (microAppLoading) => set(() => ({ microAppLoading })),\n});\n\nexport { createMicroAppStateSlice };\nexport type { MicroAppStateStoreProps };\n","import { sdk } from '@/core';\nimport type { ThemeProps } from '@/types';\nimport type { StateCreator } from 'zustand';\n\ninterface ThemeStoreProps {\n /** 主题 */\n theme: ThemeProps;\n /** 设置主题 */\n setTheme: (theme: ThemeProps) => void;\n}\n\n/** 主题状态 */\nconst createThemeSlice: StateCreator<ThemeStoreProps> = (set, get) => ({\n theme: null,\n\n setTheme: (theme) => {\n set(() => ({ theme })); // 自动合并其他\n\n // 记录值\n sdk.config.theme = theme;\n sdk.storage.setTheme(theme);\n\n // 设置作用域\n document.documentElement.setAttribute('theme', theme);\n },\n});\n\nexport { createThemeSlice };\nexport type { ThemeStoreProps };\n","import type { Plugin } from '@/types';\nimport { createStore } from 'zustand';\nimport { subscribeWithSelector } from 'zustand/middleware';\nimport {\n createInitStateSlice,\n type InitStateStoreProps,\n} from './createInitState';\nimport { createLocaleSlice, type LocaleStoreProps } from './createLocale';\nimport {\n createMicroAppStateSlice,\n type MicroAppStateStoreProps,\n} from './createMicroAppLoading';\nimport { createThemeSlice, type ThemeStoreProps } from './createTheme';\n\ntype StoreOptions = InitStateStoreProps &\n LocaleStoreProps &\n MicroAppStateStoreProps &\n ThemeStoreProps;\n\ntype StoreResults = typeof globalStore;\n\n/**\n * 创建 Store\n * - 这里单独声明变量, 主要是为了使用返回类型 StoreResults 🤔\n */\nconst globalStore = createStore<StoreOptions>()(\n subscribeWithSelector((...a) => ({\n ...createInitStateSlice(...a),\n ...createLocaleSlice(...a),\n ...createMicroAppStateSlice(...a),\n ...createThemeSlice(...a),\n })),\n);\n\n/** 插件名称 */\nconst pluginName = 'store';\n\n/**\n * 全局状态管理\n * - 详情参考 {@link StoreOptions} {@link StoreResults}\n * - 此插件不会合并传入属性\n * @example const setTheme = useStore(sdk.store, (state) => state.setTheme)\n * @example const { theme, setTheme } = useStore(sdk.store, useShallow((state) => { theme: state.theme, setTheme: state.setTheme }))\n * @example const [theme, setTheme] = useStore(sdk.store, useShallow((state) => [state.theme, state.setTheme]))\n * @example sdk.store?.getState()?.setTheme('light')\n * @example sdk.store.subscribe((state) => state.theme, (theme) => { console.log('theme', theme) }, { fireImmediately: true }) // fireImmediately 立即变更\n */\nconst SdkStorePlugin: Plugin<'store'> = {\n name: pluginName,\n install(sdk, options = {}) {\n sdk[pluginName] = globalStore satisfies StoreResults;\n },\n};\n\nexport { SdkStorePlugin };\nexport type { StoreOptions, StoreResults };\n"],"x_google_ignoreList":[1,2,3],"mappings":"yLA+EA,MAAM,EAAM,IA7EZ,KAA+B,CAC7B,KACA,SAEA,IACA,IACA,OACA,OACA,KACA,QACA,MAEA,aAAc,CACZ,KAAK,KAAO,GACZ,KAAK,SAAW,IAAI,IAGtB,MAAM,EAAc,CAClB,GAAI,OAAO,GAAO,MAAU,MAAM,4BAA4B,IAAO,CACrE,QAAQ,IAAI,kBAAmB,kCAAmC,EAAK,CAGvE,KAAK,KAAO,EAGZ,IAAM,EAAQ,IAAI,MAAM,KAAM,CAC5B,KAAM,EAAQ,EAAK,IACZ,EACE,QAAQ,IAAI,EAAQ,EAAK,EAAS,CADrB,KAGtB,SACE,QAAQ,MAAM,8BAA8B,CACrC,IAET,oBACE,QAAQ,MAAM,6BAA6B,CACpC,IAEV,CAAC,CAGF,OAAO,KAAK,MAAQ,EAGtB,OAAO,EAAc,CACnB,GAAI,CAAC,OAAO,GAAO,MAAU,MAAM,uBAAuB,IAAO,CACjE,QAAQ,IAAI,mBAAoB,kCAAmC,EAAK,CAGxE,OAAO,OAAO,KAAM,OAAO,GAAM,CAGnC,IACE,EACA,EACA,CACA,GAAM,CAAE,OAAM,WAAY,EAE1B,GAAI,CAAC,EAAM,MAAU,MAAM,GAAG,EAAK,qBAAqB,CAExD,GAAI,OAAO,GAAY,WACrB,MAAU,MAAM,GAAG,EAAK,2BAA2B,CASrD,OANA,EAAQ,KAAM,EAAQ,CAGtB,KAAK,SAAS,IAAI,EAAM,CAAE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KACI,CACJ,gBAAiB,GACjB,mBAAqB,GAAoB,OAAW,CAAE,kBAAiB,EAAE,CAC1E,ECJKC,GAAmD,EAAK,KAAS,CACrE,MAAO,KAEP,SAAW,GAAU,CACnB,OAAW,CAAE,QAAO,EAAE,CAGtB,EAAI,OAAO,MAAQ,EACnB,EAAI,QAAQ,SAAS,EAAM,CAG3B,SAAS,gBAAgB,aAAa,QAAS,EAAM,EAExD,ECAK,EAAc,GAA2B,CAC7C,GAAuB,GAAG,KAAO,CAC/B,GAAG,EAAqB,GAAG,EAAE,CAC7B,GAAG,EAAkB,GAAG,EAAE,CAC1B,GAAG,EAAyB,GAAG,EAAE,CACjC,GAAG,EAAiB,GAAG,EAAE,CAC1B,EAAE,CACJ,CAGK,EAAa,QAYbC,EAAkC,CACtC,KAAM,EACN,QAAQ,EAAK,EAAU,EAAE,CAAE,CACzB,EAAI,GAAc,GAErB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zxiaosi/sdk",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "description": "A micro frontend kit",
5
5
  "keywords": [
6
6
  "micro frontend",
@@ -46,7 +46,8 @@
46
46
  "antd": "^5.29.1",
47
47
  "react": "^18.3.1",
48
48
  "react-dom": "^18.3.1",
49
- "react-router-dom": "^6.30.2"
49
+ "react-router-dom": "^6.30.2",
50
+ "zustand": "^5.0.9"
50
51
  },
51
52
  "publishConfig": {
52
53
  "access": "public",