@litianxiang/portal-core 0.1.24 → 0.2.0
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 +1 -9
- package/dist/index.d.ts +1 -25
- package/dist/index.js +0 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -111,13 +111,12 @@ if (shouldRefresh) {
|
|
|
111
111
|
### http
|
|
112
112
|
|
|
113
113
|
- `createAuthHttpClient(options)`:创建带认证拦截器的 HTTP 客户端(Loading、token 注入、401 处理、刷新 token)。
|
|
114
|
-
- `createPortalHttpClient(options)`:业务项目 HTTP 初始化便捷封装,减少重复模板代码。
|
|
115
114
|
|
|
116
115
|
最小示例:
|
|
117
116
|
|
|
118
117
|
```ts
|
|
119
118
|
import axios from 'axios'
|
|
120
|
-
import { createAuthHttpClient
|
|
119
|
+
import { createAuthHttpClient } from '@litianxiang/portal-core'
|
|
121
120
|
|
|
122
121
|
const { http } = createAuthHttpClient({
|
|
123
122
|
axios,
|
|
@@ -126,13 +125,6 @@ const { http } = createAuthHttpClient({
|
|
|
126
125
|
})
|
|
127
126
|
|
|
128
127
|
await http.post('/api/demo', {})
|
|
129
|
-
|
|
130
|
-
// 业务项目推荐直接使用便捷封装
|
|
131
|
-
const { http: portalHttp } = createPortalHttpClient({
|
|
132
|
-
axios,
|
|
133
|
-
getUserStore: () => useUserStore(),
|
|
134
|
-
getLoadingStore: () => useLoadingStore()
|
|
135
|
-
})
|
|
136
128
|
```
|
|
137
129
|
|
|
138
130
|
### config
|
package/dist/index.d.ts
CHANGED
|
@@ -69,30 +69,6 @@ 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
|
-
};
|
|
96
72
|
declare function createAuthHttpClient(options: CreateAuthHttpClientOptions): {
|
|
97
73
|
http: any;
|
|
98
74
|
logoutToAuth: () => void;
|
|
@@ -551,4 +527,4 @@ interface CreateI18nOptions {
|
|
|
551
527
|
*/
|
|
552
528
|
declare function createPortalI18n(options: CreateI18nOptions): vue_i18n.I18n<Record<string, any>, {}, {}, string, false>;
|
|
553
529
|
|
|
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,
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -458,13 +458,6 @@ 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
|
-
}
|
|
468
461
|
function createAuthHttpClient(options) {
|
|
469
462
|
const {
|
|
470
463
|
axios,
|
|
@@ -1207,7 +1200,6 @@ export {
|
|
|
1207
1200
|
createMenuUserGetters,
|
|
1208
1201
|
createMenuUserState,
|
|
1209
1202
|
createPermissionHelper,
|
|
1210
|
-
createPortalHttpClient,
|
|
1211
1203
|
createPortalI18n,
|
|
1212
1204
|
createRange,
|
|
1213
1205
|
createTabStoreOptions,
|