@litianxiang/portal-core 0.1.23 → 0.1.24

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/README.md CHANGED
@@ -111,12 +111,13 @@ if (shouldRefresh) {
111
111
  ### http
112
112
 
113
113
  - `createAuthHttpClient(options)`:创建带认证拦截器的 HTTP 客户端(Loading、token 注入、401 处理、刷新 token)。
114
+ - `createPortalHttpClient(options)`:业务项目 HTTP 初始化便捷封装,减少重复模板代码。
114
115
 
115
116
  最小示例:
116
117
 
117
118
  ```ts
118
119
  import axios from 'axios'
119
- import { createAuthHttpClient } from '@litianxiang/portal-core'
120
+ import { createAuthHttpClient, createPortalHttpClient } from '@litianxiang/portal-core'
120
121
 
121
122
  const { http } = createAuthHttpClient({
122
123
  axios,
@@ -125,6 +126,13 @@ const { http } = createAuthHttpClient({
125
126
  })
126
127
 
127
128
  await http.post('/api/demo', {})
129
+
130
+ // 业务项目推荐直接使用便捷封装
131
+ const { http: portalHttp } = createPortalHttpClient({
132
+ axios,
133
+ getUserStore: () => useUserStore(),
134
+ getLoadingStore: () => useLoadingStore()
135
+ })
128
136
  ```
129
137
 
130
138
  ### config
package/dist/index.d.ts CHANGED
@@ -69,6 +69,30 @@ interface CreateAuthHttpClientOptions {
69
69
  inactiveBufferMs?: number;
70
70
  onShowError?: (msg: string) => void;
71
71
  }
72
+ interface CreatePortalHttpClientOptions {
73
+ axios?: any;
74
+ baseURL?: string;
75
+ timeout?: number;
76
+ getUserStore: () => any;
77
+ getLoadingStore: () => any;
78
+ authLoginUrl?: string;
79
+ ssoStorageKey?: string;
80
+ refreshUrl?: string;
81
+ inactiveExpireMs?: number;
82
+ inactiveBufferMs?: number;
83
+ onShowError?: (msg: string) => void;
84
+ }
85
+ /**
86
+ * 创建业务项目通用 HTTP 客户端(createAuthHttpClient 的便捷封装)。
87
+ *
88
+ * 作用:
89
+ * - 统一管理端项目中的标准 HTTP 初始化写法
90
+ * - 复用 portal-core 认证拦截器能力
91
+ */
92
+ declare function createPortalHttpClient(options: CreatePortalHttpClientOptions): {
93
+ http: any;
94
+ logoutToAuth: () => void;
95
+ };
72
96
  declare function createAuthHttpClient(options: CreateAuthHttpClientOptions): {
73
97
  http: any;
74
98
  logoutToAuth: () => void;
@@ -527,4 +551,4 @@ interface CreateI18nOptions {
527
551
  */
528
552
  declare function createPortalI18n(options: CreateI18nOptions): vue_i18n.I18n<Record<string, any>, {}, {}, string, false>;
529
553
 
530
- export { AUTH_CONFIG, type AppRouterOptions, type AuthConfig, type BaseUserStoreLike, type BreadcrumbItem, type CoreMenuItem, type CoreMenuUserState, type CoreUserStoreLike, type CreateAuthHttpClientOptions, type CreateBaseUserActionsOptions, type CreateI18nOptions, type CreateMenuUserActionsOptions, DEFAULT_AUTH_LOGIN_ENV_KEY, DEFAULT_AUTH_LOGIN_PATH, DEFAULT_HOME_PATH, DEFAULT_SSO_STORAGE_KEY, type FetchUserMenuForStoreOptions, type FontSize, type InactivityConfig, type InactivityResult, type LoadingState, type LogoutToAuthOptions, type MenuHelper, type MenuHelperOptions, type PermissionHelper, type PermissionHelperOptions, type PresetRangeKey, type SetupPortalAppOptions, type SidebarMenuFilterOptions, type SyncFromAuthStoreOptions, type TabItem, type ThemeConfig, type ThemeMode, type TimeInput, type TimeRange, type TransformMenuOptions, addTab, applyTheme, buildAllMenuTree, buildPageMenuList, calcInactivityAction, closeAll, closeLeft, closeOthers, closeRight, createAppRouter, createAuthHttpClient, createBaseUserActions, createBaseUserGetters, createBaseUserState, createLoadingStoreOptions, createLogoutToAuth, createMenuHelper, createMenuUserActions, createMenuUserGetters, createMenuUserState, createPermissionHelper, createPortalI18n, createRange, createTabStoreOptions, fetchUserMenuForStore, filterSidebarMenu, findFirstPagePath, formatRange, formatTime, formatToMonthDay, formatToWanShou, formatToYi, formatWanYuanToYi, getDefaultAuthLoginUrl, getPresetRange, humanizeTime, initTheme, isInRange, removeTab, setupPortalApp, syncFromAuthStoreToStore, timeDiff, transformMenuTree, useThemeWatcher, useTime };
554
+ export { AUTH_CONFIG, type AppRouterOptions, type AuthConfig, type BaseUserStoreLike, type BreadcrumbItem, type CoreMenuItem, type CoreMenuUserState, type CoreUserStoreLike, type CreateAuthHttpClientOptions, type CreateBaseUserActionsOptions, type CreateI18nOptions, type CreateMenuUserActionsOptions, type CreatePortalHttpClientOptions, DEFAULT_AUTH_LOGIN_ENV_KEY, DEFAULT_AUTH_LOGIN_PATH, DEFAULT_HOME_PATH, DEFAULT_SSO_STORAGE_KEY, type FetchUserMenuForStoreOptions, type FontSize, type InactivityConfig, type InactivityResult, type LoadingState, type LogoutToAuthOptions, type MenuHelper, type MenuHelperOptions, type PermissionHelper, type PermissionHelperOptions, type PresetRangeKey, type SetupPortalAppOptions, type SidebarMenuFilterOptions, type SyncFromAuthStoreOptions, type TabItem, type ThemeConfig, type ThemeMode, type TimeInput, type TimeRange, type TransformMenuOptions, addTab, applyTheme, buildAllMenuTree, buildPageMenuList, calcInactivityAction, closeAll, closeLeft, closeOthers, closeRight, createAppRouter, createAuthHttpClient, createBaseUserActions, createBaseUserGetters, createBaseUserState, createLoadingStoreOptions, createLogoutToAuth, createMenuHelper, createMenuUserActions, createMenuUserGetters, createMenuUserState, createPermissionHelper, createPortalHttpClient, createPortalI18n, createRange, createTabStoreOptions, fetchUserMenuForStore, filterSidebarMenu, findFirstPagePath, formatRange, formatTime, formatToMonthDay, formatToWanShou, formatToYi, formatWanYuanToYi, getDefaultAuthLoginUrl, getPresetRange, humanizeTime, initTheme, isInRange, removeTab, setupPortalApp, syncFromAuthStoreToStore, timeDiff, transformMenuTree, useThemeWatcher, useTime };
package/dist/index.js CHANGED
@@ -458,6 +458,13 @@ function calcInactivityAction(lastActiveTime, now, config = {}) {
458
458
 
459
459
  // src/http/http.ts
460
460
  import axiosLib from "axios";
461
+ function createPortalHttpClient(options) {
462
+ return createAuthHttpClient({
463
+ baseURL: "",
464
+ timeout: 1e4,
465
+ ...options
466
+ });
467
+ }
461
468
  function createAuthHttpClient(options) {
462
469
  const {
463
470
  axios,
@@ -1200,6 +1207,7 @@ export {
1200
1207
  createMenuUserGetters,
1201
1208
  createMenuUserState,
1202
1209
  createPermissionHelper,
1210
+ createPortalHttpClient,
1203
1211
  createPortalI18n,
1204
1212
  createRange,
1205
1213
  createTabStoreOptions,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@litianxiang/portal-core",
3
- "version": "0.1.23",
3
+ "version": "0.1.24",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "dist/index.js",