@hlw-uni/mp-vue 2.1.52 → 2.1.55
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/app.d.ts +2 -20
- package/dist/composables/ad/index.d.ts +11 -73
- package/dist/composables/device/index.d.ts +5 -70
- package/dist/composables/index.d.ts +6 -14
- package/dist/composables/navigator/index.d.ts +15 -39
- package/dist/composables/request/client.d.ts +21 -0
- package/dist/composables/request/index.d.ts +6 -0
- package/dist/composables/request/service.d.ts +30 -0
- package/dist/composables/{http → request}/types.d.ts +0 -3
- package/dist/composables/share/index.d.ts +7 -66
- package/dist/composables/utils/index.d.ts +25 -32
- package/dist/hlw.d.ts +2 -4
- package/dist/index.d.ts +2 -3
- package/dist/index.js +614 -1253
- package/dist/index.mjs +613 -1252
- package/package.json +2 -1
- package/src/app.ts +3 -143
- package/src/components/hlw-ad/index.vue +6 -5
- package/src/components/hlw-page/index.vue +1 -1
- package/src/composables/ad/README.md +58 -0
- package/src/composables/ad/index.ts +117 -376
- package/src/composables/device/README.md +50 -0
- package/src/composables/device/index.ts +110 -83
- package/src/composables/index.ts +10 -39
- package/src/composables/msg/README.md +79 -0
- package/src/composables/navigator/README.md +71 -0
- package/src/composables/navigator/index.ts +77 -77
- package/src/composables/refs/README.md +40 -0
- package/src/composables/request/README.md +124 -0
- package/src/composables/{http → request}/adapters/oss.ts +1 -0
- package/src/composables/request/client.ts +204 -0
- package/src/composables/request/index.ts +15 -0
- package/src/composables/request/service.ts +54 -0
- package/src/composables/{http → request}/types.ts +0 -4
- package/src/composables/share/README.md +53 -0
- package/src/composables/share/index.ts +64 -168
- package/src/composables/theme/README.md +131 -0
- package/src/composables/theme/index.ts +4 -2
- package/src/composables/theme/palette.ts +22 -4
- package/src/composables/utils/README.md +81 -0
- package/src/composables/utils/index.ts +131 -95
- package/src/hlw.ts +6 -14
- package/src/index.ts +2 -3
- package/dist/composables/_internal/unwrap.d.ts +0 -15
- package/dist/composables/algo/index.d.ts +0 -7
- package/dist/composables/algo/uuid.d.ts +0 -17
- package/dist/composables/color/index.d.ts +0 -8
- package/dist/composables/contact/index.d.ts +0 -32
- package/dist/composables/format/index.d.ts +0 -9
- package/dist/composables/http/client.d.ts +0 -66
- package/dist/composables/http/index.d.ts +0 -8
- package/dist/composables/loading/index.d.ts +0 -7
- package/dist/composables/page-meta/index.d.ts +0 -18
- package/dist/composables/storage/index.d.ts +0 -16
- package/dist/composables/validate/index.d.ts +0 -12
- package/dist/error.d.ts +0 -1
- package/src/composables/_internal/unwrap.ts +0 -19
- package/src/composables/algo/index.ts +0 -7
- package/src/composables/algo/uuid.ts +0 -27
- package/src/composables/color/index.ts +0 -44
- package/src/composables/contact/index.ts +0 -92
- package/src/composables/format/index.ts +0 -48
- package/src/composables/http/client.ts +0 -237
- package/src/composables/http/index.ts +0 -8
- package/src/composables/http/useRequest.ts +0 -107
- package/src/composables/loading/index.ts +0 -23
- package/src/composables/page-meta/index.ts +0 -49
- package/src/composables/storage/index.ts +0 -76
- package/src/composables/validate/index.ts +0 -58
- package/src/error.ts +0 -5
- /package/dist/composables/{http → request}/adapters/alist.d.ts +0 -0
- /package/dist/composables/{http → request}/adapters/base.d.ts +0 -0
- /package/dist/composables/{http → request}/adapters/cos.d.ts +0 -0
- /package/dist/composables/{http → request}/adapters/index.d.ts +0 -0
- /package/dist/composables/{http → request}/adapters/oss.d.ts +0 -0
- /package/dist/composables/{http → request}/adapters/qiniu.d.ts +0 -0
- /package/src/composables/{http → request}/adapters/alist.ts +0 -0
- /package/src/composables/{http → request}/adapters/base.ts +0 -0
- /package/src/composables/{http → request}/adapters/cos.ts +0 -0
- /package/src/composables/{http → request}/adapters/index.ts +0 -0
- /package/src/composables/{http → request}/adapters/qiniu.ts +0 -0
package/dist/app.d.ts
CHANGED
|
@@ -1,19 +1,7 @@
|
|
|
1
1
|
import { App, Component } from 'vue';
|
|
2
2
|
import { HlwInstance } from './hlw';
|
|
3
|
-
import {
|
|
3
|
+
import { RequestClient } from './composables/request';
|
|
4
4
|
|
|
5
|
-
export interface InterceptorOptions {
|
|
6
|
-
/** API 基础地址 */
|
|
7
|
-
baseURL?: string;
|
|
8
|
-
/** 自动注入 Token 的 header 键名 */
|
|
9
|
-
tokenHeader?: string;
|
|
10
|
-
/** Token 来源函数 */
|
|
11
|
-
getToken?: () => string;
|
|
12
|
-
/** 登录失效时的处理函数 */
|
|
13
|
-
onLogout?: () => void;
|
|
14
|
-
/** 接口业务错误码是否自动 toast */
|
|
15
|
-
autoToastError?: boolean;
|
|
16
|
-
}
|
|
17
5
|
/**
|
|
18
6
|
* 创建 uni-app 应用入口工具。
|
|
19
7
|
*/
|
|
@@ -23,11 +11,5 @@ export declare function useApp(): {
|
|
|
23
11
|
};
|
|
24
12
|
use: (pluginOrInstaller: any) => void;
|
|
25
13
|
hlw: HlwInstance;
|
|
26
|
-
|
|
14
|
+
request: RequestClient;
|
|
27
15
|
};
|
|
28
|
-
/**
|
|
29
|
-
* 注册默认请求、响应和错误拦截器。
|
|
30
|
-
*/
|
|
31
|
-
export declare function setupInterceptors(options?: InterceptorOptions & {
|
|
32
|
-
sigSecret?: string;
|
|
33
|
-
}): void;
|
|
@@ -1,78 +1,16 @@
|
|
|
1
|
-
import { AdapterPayload } from '../_internal/unwrap';
|
|
2
|
-
import { ComputedRef, Ref } from 'vue';
|
|
3
|
-
|
|
4
|
-
/** 6 种广告类型 */
|
|
5
|
-
export type AdType = "banner" | "grid" | "custom" | "video" | "reward" | "popup";
|
|
6
|
-
/** 广告配置 —— 字段名跟后端表列名对齐(plugin_qz_mp.{type}_unit_id) */
|
|
7
|
-
export interface AdConfig {
|
|
8
|
-
banner_unit_id: string;
|
|
9
|
-
grid_unit_id: string;
|
|
10
|
-
custom_unit_id: string;
|
|
11
|
-
video_unit_id: string;
|
|
12
|
-
reward_unit_id: string;
|
|
13
|
-
popup_unit_id: string;
|
|
14
|
-
/** VIP 屏蔽展示型广告(reward 除外):0=否,1=屏蔽 banner/grid/custom/video/popup */
|
|
15
|
-
vip_no_ad?: 0 | 1;
|
|
16
|
-
}
|
|
17
|
-
/** 广告错误对象(onError 回调参数) */
|
|
18
|
-
export interface AdError {
|
|
19
|
-
errCode: number;
|
|
20
|
-
errMsg: string;
|
|
21
|
-
}
|
|
22
1
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* getConfig 支持两种返回:
|
|
26
|
-
* - 已解包:直接返回 AdConfig 或 null
|
|
27
|
-
* - ThinkAdmin envelope:返回 { code, data } 对象,库自动按 code===1 解包
|
|
28
|
-
*
|
|
29
|
-
* 业务方可以直接传 envelope-returning 的接口函数引用:
|
|
30
|
-
* setConfigAd({ getConfig: getAdConfig })
|
|
2
|
+
* 小程序广告工具。
|
|
31
3
|
*/
|
|
32
|
-
export interface
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
/** 是否 VIP;配合 config.vip_no_ad=1 时屏蔽展示型广告(reward 不受影响) */
|
|
37
|
-
isVip?: () => boolean;
|
|
38
|
-
/**
|
|
39
|
-
* 用户级强制屏蔽:返回 true 直接屏蔽展示型广告(reward 不受影响),
|
|
40
|
-
* 优先级高于 mp.vip_no_ad + isVip 的联合判断;不传 = 不强制。
|
|
41
|
-
*/
|
|
42
|
-
userNoAd?: () => boolean;
|
|
4
|
+
export interface AdRes {
|
|
5
|
+
ok: boolean;
|
|
6
|
+
isEnded?: boolean;
|
|
7
|
+
err?: unknown;
|
|
43
8
|
}
|
|
44
|
-
|
|
45
|
-
export
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
* 注入业务回调,应用启动时调用一次。
|
|
51
|
-
* 不调用也不会崩,但 loadConfig / showReward 会无效。
|
|
52
|
-
*/
|
|
53
|
-
export declare function setConfigAd(a: AdAdapter): void;
|
|
54
|
-
export declare function useAd(): {
|
|
55
|
-
config: ComputedRef<AdConfig>;
|
|
56
|
-
loaded: Ref<boolean, boolean>;
|
|
57
|
-
loadConfig: (force?: boolean) => Promise<void>;
|
|
58
|
-
getUnitId: (type: AdType) => string;
|
|
59
|
-
showReward: (onClose?: ((res: AdCloseResult) => void | Promise<void>) | undefined) => Promise<void>;
|
|
60
|
-
showPopup: (delayMs?: number) => Promise<boolean>;
|
|
61
|
-
confirm: typeof confirmModal;
|
|
9
|
+
type AdDone = (res: AdRes) => void;
|
|
10
|
+
export declare function useHlwAd(): {
|
|
11
|
+
setAdPopup: (adId: string, done?: ((ok: boolean) => void) | undefined) => boolean;
|
|
12
|
+
showAdPopup: (delay?: number) => Promise<boolean>;
|
|
13
|
+
setAdReward: (adId: string, done?: AdDone) => Promise<AdRes>;
|
|
14
|
+
showAdReward: () => Promise<AdRes>;
|
|
62
15
|
};
|
|
63
|
-
/**
|
|
64
|
-
* 激励视频中途关闭挽留弹窗 —— 通过 useAd().confirm 暴露给业务方:
|
|
65
|
-
*
|
|
66
|
-
* const { showReward, confirm } = useAd();
|
|
67
|
-
* showReward(async ({ isEnded }) => {
|
|
68
|
-
* if (!isEnded) return { ok: false, retry: await confirm() };
|
|
69
|
-
* const r = await claimAdReward();
|
|
70
|
-
* return r.code === 1 ? { ok: true, reward: r.data?.reward } : { ok: false, msg: r.info };
|
|
71
|
-
* });
|
|
72
|
-
*
|
|
73
|
-
* @returns true=用户选「继续观看」 / false=放弃
|
|
74
|
-
*/
|
|
75
|
-
declare function confirmModal(): Promise<boolean>;
|
|
76
|
-
/** 销毁全部广告实例并清空缓存(业务一般不用,hot reload 时调) */
|
|
77
|
-
export declare function destroyAds(): void;
|
|
78
16
|
export {};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Ref } from 'vue';
|
|
2
1
|
export interface DeviceInfo {
|
|
3
2
|
/** 小程序 appId */
|
|
4
3
|
appid: string;
|
|
@@ -57,73 +56,9 @@ export interface DeviceInfo {
|
|
|
57
56
|
/** 客户端版本号 */
|
|
58
57
|
version: string;
|
|
59
58
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
app_name: string;
|
|
66
|
-
app_version: string;
|
|
67
|
-
app_version_code: string;
|
|
68
|
-
app_channel: string;
|
|
69
|
-
device_brand: string;
|
|
70
|
-
device_model: string;
|
|
71
|
-
device_id: string;
|
|
72
|
-
device_type: string;
|
|
73
|
-
device_orientation: "portrait" | "landscape";
|
|
74
|
-
brand: string;
|
|
75
|
-
model: string;
|
|
76
|
-
system: string;
|
|
77
|
-
os: string;
|
|
78
|
-
pixel_ratio: number;
|
|
79
|
-
screen_width: number;
|
|
80
|
-
screen_height: number;
|
|
81
|
-
window_width: number;
|
|
82
|
-
window_height: number;
|
|
83
|
-
status_bar_height: number;
|
|
84
|
-
sdk_version: string;
|
|
85
|
-
host_name: string;
|
|
86
|
-
host_version: string;
|
|
87
|
-
host_language: string;
|
|
88
|
-
host_theme: string;
|
|
89
|
-
platform: string;
|
|
90
|
-
language: string;
|
|
91
|
-
version: string;
|
|
92
|
-
} | null, DeviceInfo | {
|
|
93
|
-
appid: string;
|
|
94
|
-
app_name: string;
|
|
95
|
-
app_version: string;
|
|
96
|
-
app_version_code: string;
|
|
97
|
-
app_channel: string;
|
|
98
|
-
device_brand: string;
|
|
99
|
-
device_model: string;
|
|
100
|
-
device_id: string;
|
|
101
|
-
device_type: string;
|
|
102
|
-
device_orientation: "portrait" | "landscape";
|
|
103
|
-
brand: string;
|
|
104
|
-
model: string;
|
|
105
|
-
system: string;
|
|
106
|
-
os: string;
|
|
107
|
-
pixel_ratio: number;
|
|
108
|
-
screen_width: number;
|
|
109
|
-
screen_height: number;
|
|
110
|
-
window_width: number;
|
|
111
|
-
window_height: number;
|
|
112
|
-
status_bar_height: number;
|
|
113
|
-
sdk_version: string;
|
|
114
|
-
host_name: string;
|
|
115
|
-
host_version: string;
|
|
116
|
-
host_language: string;
|
|
117
|
-
host_theme: string;
|
|
118
|
-
platform: string;
|
|
119
|
-
language: string;
|
|
120
|
-
version: string;
|
|
121
|
-
} | null>;
|
|
122
|
-
/**
|
|
123
|
-
* 把 deviceInfo 对象转成 URL query string(不含前导 ?)
|
|
124
|
-
*/
|
|
125
|
-
export declare function deviceToQuery(): string;
|
|
126
|
-
/**
|
|
127
|
-
* 手动清除缓存(切换账号等场景可能需要)
|
|
128
|
-
*/
|
|
59
|
+
export type DeviceQueryInfo = Pick<DeviceInfo, "appid" | "device_brand" | "device_model" | "device_id" | "device_type" | "device_orientation" | "platform" | "system" | "os" | "version" | "sdk_version" | "host_name" | "host_version" | "host_language" | "language" | "app_version" | "app_version_code" | "screen_width" | "screen_height">;
|
|
60
|
+
export declare function useDevice(): {
|
|
61
|
+
info: DeviceInfo;
|
|
62
|
+
query: string;
|
|
63
|
+
};
|
|
129
64
|
export declare function clearDeviceCache(): void;
|
|
@@ -1,22 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Composables 统一导出
|
|
3
3
|
*/
|
|
4
|
-
export * from './
|
|
5
|
-
export { useLoading } from './loading';
|
|
4
|
+
export * from './request';
|
|
6
5
|
export { useMsg, type HlwMsg, type ToastOptions, type ModalOptions, type ToastIcon } from './msg';
|
|
7
|
-
export { useDevice,
|
|
6
|
+
export { useDevice, clearDeviceCache, type DeviceInfo, type DeviceQueryInfo, } from './device';
|
|
8
7
|
export { useRefs } from './refs';
|
|
9
|
-
export {
|
|
10
|
-
export {
|
|
11
|
-
export {
|
|
12
|
-
export {
|
|
13
|
-
export { useAd, setConfigAd, destroyAds, type AdType, type AdConfig, type AdError, type AdAdapter, type AdCloseResult, } from './ad';
|
|
14
|
-
export { useShare, useShareConfig, setConfigShare, type ShareConfig, type ShareConfigResolver, type ShareFrom, type ShareAppMessageContent, type ShareTimelineContent, type ShareConfigMap, type ShareConfigAdapter, type PageShareItem, type PageShareFallback, type SharePayload, } from './share';
|
|
15
|
-
export { useContact, setConfigContact, type ContactConfig, type ContactAdapter, type ContactBindProps, } from './contact';
|
|
16
|
-
export { useUtils, type DownloadFileOptions, type DownloadFileResult, type TapEvent } from './utils';
|
|
17
|
-
export { useColor } from './color';
|
|
18
|
-
export { useRouter, type NavigateType, type NavigateOptions } from './navigator';
|
|
19
|
-
export { useUuid } from './algo';
|
|
8
|
+
export { useShare, type ShareConfig, } from './share';
|
|
9
|
+
export { useHlwAd, type AdRes } from './ad';
|
|
10
|
+
export { useUtils, type DownloadOpt, type DownloadRes } from './utils';
|
|
11
|
+
export { useNavigate, type NavigateType, type NavigateOptions } from './navigator';
|
|
20
12
|
export type { FontScale, FontPreset } from './theme';
|
|
21
13
|
export { FONT_SCALE_KEY, FONT_PRESETS, getCurrentFontScale, getCurrentFontVars, THEME_CHANGE_EVENT, buildThemeStyle, useThemePageStyle, } from './theme';
|
|
22
14
|
export type { ThemeColor } from './theme';
|
|
@@ -1,47 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* 使用:
|
|
5
|
-
* const { navigate } = useRouter();
|
|
6
|
-
* navigate(tool.jump_type, tool.jump_value);
|
|
7
|
-
*
|
|
8
|
-
* 未装 vue-router 也能用;命名风格对齐 Vue Router,熟悉的 push/replace/back
|
|
9
|
-
* 会在后续迭代中补齐。
|
|
2
|
+
* useNavigate - uni-app 跳转工具
|
|
10
3
|
*/
|
|
11
|
-
|
|
12
|
-
export type NavigateType = "navigateTo" | "redirectTo" | "switchTab" | "reLaunch" | "webview" | "miniprogram" | (string & {});
|
|
4
|
+
export type NavigateType = "navigateTo" | "redirectTo" | "switchTab" | "reLaunch" | "navigateBack" | "miniprogram" | "webview" | (string & {});
|
|
13
5
|
export interface NavigateOptions {
|
|
14
|
-
/** 失败回调,收到 uni 返回的错误信息 */
|
|
15
|
-
onFail?: (errMsg: string) => void;
|
|
16
|
-
/** 是否禁用默认的 Toast 错误提示,默认 false */
|
|
17
6
|
silent?: boolean;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
7
|
+
onFail?: (message: string) => void;
|
|
8
|
+
delta?: number;
|
|
9
|
+
path?: string;
|
|
21
10
|
envVersion?: "develop" | "trial" | "release";
|
|
22
|
-
|
|
23
|
-
extraData?: Record<string, unknown> | null;
|
|
11
|
+
extraData?: Record<string, unknown>;
|
|
24
12
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
* - `miniprogram` → uni.navigateToMiniProgram,value 格式 `appid:path`
|
|
35
|
-
*/
|
|
36
|
-
declare function doNavigate(type: NavigateType, value: string, options?: NavigateOptions): void;
|
|
37
|
-
/**
|
|
38
|
-
* 路由 composable:返回跳转方法集合。
|
|
39
|
-
*
|
|
40
|
-
* @example
|
|
41
|
-
* const { navigate } = useRouter();
|
|
42
|
-
* navigate("switchTab", "/pages/index/index");
|
|
43
|
-
*/
|
|
44
|
-
export declare function useRouter(): {
|
|
45
|
-
navigate: typeof doNavigate;
|
|
13
|
+
declare function navigate(type?: NavigateType, url?: string, options?: NavigateOptions): void;
|
|
14
|
+
export declare function useNavigate(): {
|
|
15
|
+
navigate: typeof navigate;
|
|
16
|
+
to: (url: string, options?: NavigateOptions) => void;
|
|
17
|
+
redirect: (url: string, options?: NavigateOptions) => void;
|
|
18
|
+
tab: (url: string, options?: NavigateOptions) => void;
|
|
19
|
+
reLaunch: (url: string, options?: NavigateOptions) => void;
|
|
20
|
+
back: (delta?: number, options?: NavigateOptions) => void;
|
|
21
|
+
miniProgram: (appId: string, options?: NavigateOptions) => void;
|
|
46
22
|
};
|
|
47
23
|
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ApiResponse, ErrorInterceptor, RequestConfig, RequestInterceptor, ResponseInterceptor, UploadConfig, UploadResult } from './types';
|
|
2
|
+
import { Ref } from 'vue';
|
|
3
|
+
|
|
4
|
+
export interface RequestClient {
|
|
5
|
+
request<T = unknown>(config: RequestConfig): Promise<ApiResponse<T>>;
|
|
6
|
+
get<T = unknown>(url: string, data?: unknown): Promise<ApiResponse<T>>;
|
|
7
|
+
post<T = unknown>(url: string, data?: unknown): Promise<ApiResponse<T>>;
|
|
8
|
+
put<T = unknown>(url: string, data?: unknown): Promise<ApiResponse<T>>;
|
|
9
|
+
del<T = unknown>(url: string, data?: unknown): Promise<ApiResponse<T>>;
|
|
10
|
+
upload(config: UploadConfig): Promise<UploadResult>;
|
|
11
|
+
setBaseURL(url: string): void;
|
|
12
|
+
resolveServiceUrl(namespace: string, url: string, servicePrefix?: string): string;
|
|
13
|
+
onRequest(fn: RequestInterceptor): () => void;
|
|
14
|
+
onResponse<T = unknown>(fn: ResponseInterceptor<T>): () => void;
|
|
15
|
+
onError(fn: ErrorInterceptor): () => void;
|
|
16
|
+
}
|
|
17
|
+
export declare function useRequest(): RequestClient;
|
|
18
|
+
export declare function useUpload(): {
|
|
19
|
+
uploading: Ref<boolean, boolean>;
|
|
20
|
+
upload: (options: UploadConfig) => Promise<UploadResult>;
|
|
21
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { useRequest, useUpload } from './client';
|
|
2
|
+
export { BaseService, ServiceNamespace, ServicePrefix } from './service';
|
|
3
|
+
export type { RequestClient } from './client';
|
|
4
|
+
export type { ApiResponse, PageResult, RequestConfig, RequestInterceptor, ResponseInterceptor, ErrorInterceptor, UploadConfig, UploadResult, } from './types';
|
|
5
|
+
export type { ServiceNamespaceOptions, ServicePrefixOptions, ServiceRequestConfig } from './service';
|
|
6
|
+
export * from './adapters';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ApiResponse, RequestConfig } from './types';
|
|
2
|
+
|
|
3
|
+
export type ServiceRequestConfig = Omit<RequestConfig, "url"> & {
|
|
4
|
+
url: string;
|
|
5
|
+
};
|
|
6
|
+
export interface ServiceNamespaceOptions {
|
|
7
|
+
namespace: string;
|
|
8
|
+
}
|
|
9
|
+
export interface ServicePrefixOptions {
|
|
10
|
+
prefix: string;
|
|
11
|
+
}
|
|
12
|
+
export declare class BaseService {
|
|
13
|
+
namespace: string;
|
|
14
|
+
servicePrefix: string;
|
|
15
|
+
request<T = unknown>(options: ServiceRequestConfig): Promise<ApiResponse<T>>;
|
|
16
|
+
get<T = unknown>(url: string, data?: unknown): Promise<ApiResponse<T>>;
|
|
17
|
+
post<T = unknown>(url: string, data?: unknown): Promise<ApiResponse<T>>;
|
|
18
|
+
put<T = unknown>(url: string, data?: unknown): Promise<ApiResponse<T>>;
|
|
19
|
+
del<T = unknown>(url: string, data?: unknown): Promise<ApiResponse<T>>;
|
|
20
|
+
}
|
|
21
|
+
export declare function ServiceNamespace(value: string | ServiceNamespaceOptions): (target: {
|
|
22
|
+
prototype: {
|
|
23
|
+
namespace?: string;
|
|
24
|
+
};
|
|
25
|
+
}) => void;
|
|
26
|
+
export declare function ServicePrefix(value: string | ServicePrefixOptions): (target: {
|
|
27
|
+
prototype: {
|
|
28
|
+
servicePrefix?: string;
|
|
29
|
+
};
|
|
30
|
+
}) => void;
|
|
@@ -1,71 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export interface ShareAppMessageContent {
|
|
4
|
-
/** 分享标题 */
|
|
1
|
+
export interface ShareConfig {
|
|
5
2
|
title?: string;
|
|
6
|
-
/** 分享路径,必须是以 / 开头的完整路径 */
|
|
7
3
|
path?: string;
|
|
8
|
-
/** 自定义图片路径 */
|
|
9
4
|
imageUrl?: string;
|
|
10
5
|
}
|
|
11
|
-
export
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
/** 自定义图片路径 */
|
|
17
|
-
imageUrl?: string;
|
|
18
|
-
}
|
|
19
|
-
export interface ShareConfig extends ShareAppMessageContent {
|
|
20
|
-
/** 朋友圈专属配置,不填则复用朋友分享配置 */
|
|
21
|
-
timeline?: ShareTimelineContent;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* 分享来源。
|
|
25
|
-
* - `button` 页面内转发按钮
|
|
26
|
-
* - `menu` 右上角菜单
|
|
27
|
-
*/
|
|
28
|
-
export type ShareFrom = 'button' | 'menu';
|
|
29
|
-
export type ShareConfigResolver = (from: ShareFrom) => ShareConfig;
|
|
30
|
-
/**
|
|
31
|
-
* 注册小程序分享钩子。
|
|
32
|
-
*/
|
|
33
|
-
export declare function useShare(config: ShareConfig | ShareConfigResolver): void;
|
|
34
|
-
/** 单页分享配置 */
|
|
35
|
-
export interface PageShareItem {
|
|
36
|
-
title: string;
|
|
37
|
-
image: string;
|
|
38
|
-
}
|
|
39
|
-
/** 后端返回的页面 key → 配置映射 */
|
|
40
|
-
export type ShareConfigMap = Record<string, PageShareItem>;
|
|
41
|
-
/**
|
|
42
|
-
* Adapter 注入接口 —— getConfig 支持「已解包」或「ThinkAdmin envelope」两种返回值。
|
|
43
|
-
* 业务方可以直接传 envelope-returning 接口:setConfigShare({ getConfig: getShareConfig })
|
|
44
|
-
*/
|
|
45
|
-
export interface ShareConfigAdapter {
|
|
46
|
-
getConfig: () => Promise<AdapterPayload<ShareConfigMap>>;
|
|
47
|
-
}
|
|
48
|
-
/** 页面声明的兜底文案 / 跳转路径 */
|
|
49
|
-
export interface PageShareFallback {
|
|
50
|
-
/** 后端 title 为空时用 */
|
|
51
|
-
title: string;
|
|
52
|
-
/** 分享跳转路径(必须 / 开头);path 不走后端,由页面自定义 */
|
|
53
|
-
path: string;
|
|
54
|
-
/** 后端 image 为空时用;通常留空让微信自动截图 */
|
|
55
|
-
image?: string;
|
|
56
|
-
}
|
|
57
|
-
/** 分享 payload —— 同时喂给 onShareAppMessage / onShareTimeline */
|
|
58
|
-
export interface SharePayload {
|
|
59
|
-
title: string;
|
|
60
|
-
path: string;
|
|
61
|
-
imageUrl?: string;
|
|
6
|
+
export type ShareConfigResolver = ShareConfig | (() => ShareConfig);
|
|
7
|
+
export interface ShareHandlers {
|
|
8
|
+
onShareAppMessage: (config?: ShareConfigResolver) => void;
|
|
9
|
+
onShareTimeline: (config?: ShareConfigResolver) => void;
|
|
10
|
+
showShareMenu: () => void;
|
|
62
11
|
}
|
|
63
|
-
|
|
64
|
-
* 注入业务回调(应用启动时调用一次;不调用则始终用 fallback)。
|
|
65
|
-
*/
|
|
66
|
-
export declare function setConfigShare(a: ShareConfigAdapter): void;
|
|
67
|
-
/**
|
|
68
|
-
* 业务级分享配置 helper —— 返回 resolver,可直接喂 onShareAppMessage / onShareTimeline。
|
|
69
|
-
* 后端配置异步加载,加载完成前先用 fallback、加载完后自动切到后端值。
|
|
70
|
-
*/
|
|
71
|
-
export declare function useShareConfig(pageKey: string, fallback: PageShareFallback): () => SharePayload;
|
|
12
|
+
export declare function useShare(config?: ShareConfigResolver): ShareHandlers;
|
|
@@ -1,42 +1,35 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 小程序通用工具。
|
|
3
3
|
*/
|
|
4
|
-
export interface
|
|
5
|
-
/** 下载地址 */
|
|
4
|
+
export interface DownloadOpt {
|
|
6
5
|
url: string;
|
|
7
|
-
|
|
8
|
-
filePath?: string;
|
|
9
|
-
/** HTTP 请求头,可选 */
|
|
6
|
+
path?: string;
|
|
10
7
|
header?: Record<string, string>;
|
|
11
|
-
|
|
12
|
-
onProgress?: (progress: number, totalBytesWritten: number, totalBytesExpectedToWrite: number) => void;
|
|
8
|
+
progress?: (value: number, done: number, total: number) => void;
|
|
13
9
|
}
|
|
14
|
-
export interface
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
/** 状态码 */
|
|
20
|
-
statusCode?: number;
|
|
21
|
-
/** 错误信息 */
|
|
22
|
-
errMsg?: string;
|
|
10
|
+
export interface DownloadRes {
|
|
11
|
+
ok: boolean;
|
|
12
|
+
path?: string;
|
|
13
|
+
code?: number;
|
|
14
|
+
msg?: string;
|
|
23
15
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
dataset?: Record<string, any>;
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
/**
|
|
33
|
-
* 剪贴板、下载与相册保存工具集合。
|
|
34
|
-
*/
|
|
16
|
+
declare function withQuery(url: string, qs: string): string;
|
|
17
|
+
declare function toQuery(data: Record<string, unknown>): string;
|
|
18
|
+
declare function signText(url: string): string;
|
|
19
|
+
declare function toNumber(val: unknown, def: number): number;
|
|
20
|
+
declare function toBoolean(val: unknown, def: boolean): boolean;
|
|
35
21
|
export declare function useUtils(): {
|
|
36
|
-
|
|
37
|
-
|
|
22
|
+
withQuery: typeof withQuery;
|
|
23
|
+
toQuery: typeof toQuery;
|
|
24
|
+
signText: typeof signText;
|
|
25
|
+
toNumber: typeof toNumber;
|
|
26
|
+
toBoolean: typeof toBoolean;
|
|
27
|
+
copy: (text: string, tip?: boolean) => Promise<boolean>;
|
|
38
28
|
paste: () => Promise<string>;
|
|
39
|
-
saveImage: (
|
|
40
|
-
|
|
41
|
-
|
|
29
|
+
saveImage: (path: string) => Promise<boolean>;
|
|
30
|
+
saveVideo: (path: string) => Promise<boolean>;
|
|
31
|
+
download: (opt: DownloadOpt) => Promise<DownloadRes>;
|
|
32
|
+
saveImageUrl: (url: string, progress?: ((value: number) => void) | undefined) => Promise<boolean>;
|
|
33
|
+
saveVideoUrl: (url: string, progress?: ((value: number) => void) | undefined) => Promise<boolean>;
|
|
42
34
|
};
|
|
35
|
+
export {};
|
package/dist/hlw.d.ts
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { useMsg } from './composables/msg';
|
|
2
2
|
import { DeviceInfo } from './composables/device';
|
|
3
|
-
import {
|
|
3
|
+
import { useRequest } from './composables/request';
|
|
4
4
|
import { useUtils } from './composables/utils';
|
|
5
|
-
import { useColor } from './composables/color';
|
|
6
5
|
|
|
7
6
|
export interface HlwInstance {
|
|
8
7
|
$msg: ReturnType<typeof useMsg>;
|
|
9
8
|
$device: DeviceInfo;
|
|
10
|
-
$
|
|
9
|
+
$request: ReturnType<typeof useRequest>;
|
|
11
10
|
$utils: ReturnType<typeof useUtils>;
|
|
12
|
-
$color: ReturnType<typeof useColor>;
|
|
13
11
|
}
|
|
14
12
|
export declare const hlw: HlwInstance;
|
package/dist/index.d.ts
CHANGED
|
@@ -3,15 +3,14 @@
|
|
|
3
3
|
*
|
|
4
4
|
* 2.0 起合并了原 @hlw-uni/mp-core 全部内容。
|
|
5
5
|
* 业务方一处 import,无需再分包:
|
|
6
|
-
* import {
|
|
6
|
+
* import { useMsg, useThemePageStyle, ... } from "@hlw-uni/mp-vue";
|
|
7
7
|
*
|
|
8
8
|
* UI 组件(hlw-page / hlw-button / hlw-ad 等)走 easycom 自动注册,不在这里 export。
|
|
9
9
|
*/
|
|
10
10
|
export * from './composables';
|
|
11
|
-
export { getErrorMessage } from './error';
|
|
12
11
|
export type { HlwMenuItem } from './components/hlw-menu/types';
|
|
13
12
|
export type { HlwPagingRef, HlwPagingInstance } from './components/hlw-paging/types';
|
|
14
13
|
export { useThemeStore } from './stores/theme';
|
|
15
|
-
export { useApp
|
|
14
|
+
export { useApp } from './app';
|
|
16
15
|
export { hlw, type HlwInstance } from './hlw';
|
|
17
16
|
export { vCopy } from './directives';
|