@wxshot/api 0.2.1 → 2.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 -2
- package/miniprogram_dist/index.d.ts +340 -295
- package/miniprogram_dist/index.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,295 +1,340 @@
|
|
|
1
|
-
// Generated by dts-bundle v0.7.3
|
|
2
|
-
|
|
3
|
-
declare module '@wxshot/api' {
|
|
4
|
-
import { onLoginReady, waitLogin } from '@wxshot/api/app';
|
|
5
|
-
import HttpClient, { gatewayHttpClient, baseHttpClient, apiHttpClient } from '@wxshot/api/httpClient';
|
|
6
|
-
import { injectApp, injectPage, injectComponent, hijackApp, hijackAllPage } from '@wxshot/api/injector';
|
|
7
|
-
import adManager from '@wxshot/api/adManager';
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
export
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
export function
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
*
|
|
49
|
-
* @param {
|
|
50
|
-
* @
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
*
|
|
58
|
-
* @
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
*
|
|
72
|
-
* @
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
interface
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
*
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
*
|
|
119
|
-
* @
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
*
|
|
126
|
-
* @
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
*
|
|
133
|
-
* @
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
*
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
*
|
|
142
|
-
* @
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
*
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
*
|
|
175
|
-
* @returns {void}
|
|
176
|
-
*/
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
*
|
|
180
|
-
* @returns {
|
|
181
|
-
*/
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
*
|
|
185
|
-
* @returns {void}
|
|
186
|
-
*/
|
|
187
|
-
|
|
188
|
-
/**
|
|
189
|
-
*
|
|
190
|
-
* @
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
}
|
|
243
|
-
export
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
|
|
1
|
+
// Generated by dts-bundle v0.7.3
|
|
2
|
+
|
|
3
|
+
declare module '@wxshot/api' {
|
|
4
|
+
import { onLoginReady, waitLogin } from '@wxshot/api/app';
|
|
5
|
+
import HttpClient, { gatewayHttpClient, baseHttpClient, apiHttpClient } from '@wxshot/api/httpClient';
|
|
6
|
+
import { injectApp, injectPage, injectComponent, hijackApp, hijackAllPage } from '@wxshot/api/injector';
|
|
7
|
+
import adManager from '@wxshot/api/adManager';
|
|
8
|
+
import supabase from '@wxshot/api/supabase';
|
|
9
|
+
export { onLoginReady, waitLogin, injectApp, injectPage, injectComponent, hijackApp, hijackAllPage, gatewayHttpClient, baseHttpClient, apiHttpClient, HttpClient, adManager, supabase, };
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
declare module '@wxshot/api/app' {
|
|
13
|
+
export interface AppOptions {
|
|
14
|
+
gatewayUrl?: string;
|
|
15
|
+
baseUrl?: string;
|
|
16
|
+
apiUrl?: string;
|
|
17
|
+
supaUrl?: string;
|
|
18
|
+
supaAnonKey?: string;
|
|
19
|
+
}
|
|
20
|
+
export interface PageOptions {
|
|
21
|
+
showInterstitialAd?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export function initApp(options?: AppOptions): Promise<void>;
|
|
24
|
+
export function showPage(options: PageOptions | undefined, pageId: string): Promise<void>;
|
|
25
|
+
export const checkTokenValid: () => boolean;
|
|
26
|
+
/**
|
|
27
|
+
* 确保登录完成
|
|
28
|
+
* @param {Function} callback - 回调函数
|
|
29
|
+
* @returns {void}
|
|
30
|
+
*/
|
|
31
|
+
export function onLoginReady(callback: (...args: any[]) => void): void;
|
|
32
|
+
/**
|
|
33
|
+
* 等待登录完成
|
|
34
|
+
* @returns {Promise<void>}
|
|
35
|
+
*/
|
|
36
|
+
export function waitLogin(): Promise<void>;
|
|
37
|
+
export function login(): Promise<void>;
|
|
38
|
+
export function fetchEchoData(): Promise<void>;
|
|
39
|
+
export function trackVisit(): Promise<void>;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
declare module '@wxshot/api/httpClient' {
|
|
43
|
+
import { HttpClientOptions, RequestOptions, ApiResponse } from '@wxshot/api/types';
|
|
44
|
+
class HttpClient {
|
|
45
|
+
constructor({ baseURL, timeout }: HttpClientOptions);
|
|
46
|
+
setBaseURL(baseURL: string): void;
|
|
47
|
+
/**
|
|
48
|
+
* 请求
|
|
49
|
+
* @param {string} path 路径
|
|
50
|
+
* @param {string} method 方法, 默认GET
|
|
51
|
+
* @param {Object} data 数据, 默认{}
|
|
52
|
+
* @param {Object} options 传入wx.request的其他配置, 默认{}
|
|
53
|
+
* @returns {Promise<Object>} 返回一个Promise对象
|
|
54
|
+
*/
|
|
55
|
+
request<T = any>(path: string, method?: WechatMiniprogram.RequestOption['method'], data?: Record<string, any>, options?: RequestOptions): Promise<ApiResponse<T>>;
|
|
56
|
+
/**
|
|
57
|
+
* 上传文件
|
|
58
|
+
* @param {string} filePath 文件路径
|
|
59
|
+
* @param {Object} data 数据, 默认{}
|
|
60
|
+
* @param {'avatar' | 'file'} type 类型, 默认'file'
|
|
61
|
+
* @returns {Promise<Object>} 返回一个Promise对象
|
|
62
|
+
*/
|
|
63
|
+
uploadFile<T = any>(filePath: string, data?: Record<string, any>, type?: 'avatar' | 'file'): Promise<ApiResponse<T>>;
|
|
64
|
+
/**
|
|
65
|
+
* 删除文件
|
|
66
|
+
* @param {number} fileId 文件id
|
|
67
|
+
* @returns {Promise<Object>} 返回一个Promise对象
|
|
68
|
+
*/
|
|
69
|
+
deleteFile(fileId: number): Promise<ApiResponse<null>>;
|
|
70
|
+
/**
|
|
71
|
+
* 上传头像
|
|
72
|
+
* @param {string} filePath 文件路径
|
|
73
|
+
* @returns {Promise<Object>} 返回一个Promise对象
|
|
74
|
+
*/
|
|
75
|
+
uploadAvatar<T = any>(filePath: string): Promise<ApiResponse<T>>;
|
|
76
|
+
}
|
|
77
|
+
export const gatewayHttpClient: HttpClient;
|
|
78
|
+
export const baseHttpClient: HttpClient;
|
|
79
|
+
export const apiHttpClient: HttpClient;
|
|
80
|
+
export default HttpClient;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
declare module '@wxshot/api/injector' {
|
|
84
|
+
interface AppConfig {
|
|
85
|
+
onLaunch?: (...args: any[]) => void | Promise<void>;
|
|
86
|
+
[key: string]: any;
|
|
87
|
+
}
|
|
88
|
+
interface PageConfig {
|
|
89
|
+
onShow?: (...args: any[]) => void | Promise<void>;
|
|
90
|
+
[key: string]: any;
|
|
91
|
+
}
|
|
92
|
+
interface ComponentConfig {
|
|
93
|
+
methods?: {
|
|
94
|
+
onLoad?: (...args: any[]) => void | Promise<void>;
|
|
95
|
+
onShow?: (...args: any[]) => void | Promise<void>;
|
|
96
|
+
[key: string]: any;
|
|
97
|
+
};
|
|
98
|
+
[key: string]: any;
|
|
99
|
+
}
|
|
100
|
+
interface InjectAppOptions {
|
|
101
|
+
gatewayUrl?: string;
|
|
102
|
+
baseUrl?: string;
|
|
103
|
+
apiUrl?: string;
|
|
104
|
+
}
|
|
105
|
+
interface InjectPageOptions {
|
|
106
|
+
showInterstitialAd?: boolean;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* 注入应用配置
|
|
110
|
+
* @param {Object} options - 配置选项
|
|
111
|
+
* @param {string} [options.gatewayUrl] - 网关地址,默认使用CONFIG.API.GATEWAY_URL
|
|
112
|
+
* @param {string} [options.baseUrl] - 基础地址,默认使用CONFIG.API.BASE_URL
|
|
113
|
+
* @param {string} [options.apiUrl] - api地址,默认使用CONFIG.API.API_URL
|
|
114
|
+
* @returns {Function} 返回一个接收应用配置的函数
|
|
115
|
+
*/
|
|
116
|
+
export function injectApp(options?: InjectAppOptions): (appConfig: AppConfig) => AppConfig;
|
|
117
|
+
/**
|
|
118
|
+
* 注入页面配置
|
|
119
|
+
* @param {InjectPageOptions} options - 配置选项
|
|
120
|
+
* @param {boolean} [options.showInterstitialAd] - 是否在onShow显示插屏广告,默认不显示
|
|
121
|
+
* @returns {Function} 返回一个接收页面配置的函数
|
|
122
|
+
*/
|
|
123
|
+
export function injectPage(options?: InjectPageOptions): (pageConfig?: PageConfig) => PageConfig;
|
|
124
|
+
/**
|
|
125
|
+
* 注入组件配置
|
|
126
|
+
* @param {InjectPageOptions} options - 配置选项
|
|
127
|
+
* @param {boolean} [options.showInterstitialAd] - 是否在onShow显示插屏广告,默认不显示
|
|
128
|
+
* @returns {Function} 返回一个接收组件配置的函数
|
|
129
|
+
*/
|
|
130
|
+
export function injectComponent(options?: InjectPageOptions): (pageConfig?: PageConfig) => ComponentConfig;
|
|
131
|
+
/**
|
|
132
|
+
* 劫持App
|
|
133
|
+
* @param {InjectAppOptions} options - 配置选项
|
|
134
|
+
* @param {string} [options.gatewayUrl] - 网关地址,默认使用CONFIG.API.GATEWAY_URL
|
|
135
|
+
* @param {string} [options.baseUrl] - 基础地址,默认使用CONFIG.API.BASE_URL
|
|
136
|
+
* @param {string} [options.apiUrl] - api地址,默认使用CONFIG.API.API_URL
|
|
137
|
+
* @returns {void}
|
|
138
|
+
*/
|
|
139
|
+
export const hijackApp: (options?: InjectAppOptions) => void;
|
|
140
|
+
/**
|
|
141
|
+
* 劫持所有Page
|
|
142
|
+
* @param {InjectPageOptions} options - 配置选项
|
|
143
|
+
* @param {boolean} [options.showInterstitialAd] - 是否在onShow显示插屏广告,默认不显示
|
|
144
|
+
* @returns {void}
|
|
145
|
+
*/
|
|
146
|
+
export const hijackAllPage: (options?: InjectPageOptions) => void;
|
|
147
|
+
export {};
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
declare module '@wxshot/api/adManager' {
|
|
151
|
+
import { AdData, LinkData, TopData } from '@wxshot/api/types';
|
|
152
|
+
type Ads = Partial<Record<AdData['appPage'], AdData['ads'][0]['adUnitId']>>;
|
|
153
|
+
class AdManager {
|
|
154
|
+
/**
|
|
155
|
+
* 广告数据
|
|
156
|
+
*/
|
|
157
|
+
ads: Ads;
|
|
158
|
+
/**
|
|
159
|
+
* 友情链接数据
|
|
160
|
+
*/
|
|
161
|
+
link: LinkData[];
|
|
162
|
+
/**
|
|
163
|
+
* 友情链接顶部广告数据
|
|
164
|
+
*/
|
|
165
|
+
top: TopData | null;
|
|
166
|
+
constructor();
|
|
167
|
+
/**
|
|
168
|
+
* 确保广告数据就绪
|
|
169
|
+
* @param {Function} callback - 回调函数
|
|
170
|
+
* @returns {void}
|
|
171
|
+
*/
|
|
172
|
+
onDataReady: (callback: (...args: any[]) => void) => void;
|
|
173
|
+
/**
|
|
174
|
+
* 等待广告数据加载完成
|
|
175
|
+
* @returns {Promise<void>}
|
|
176
|
+
*/
|
|
177
|
+
waitAdData: () => Promise<void>;
|
|
178
|
+
/**
|
|
179
|
+
* 初始化广告数据
|
|
180
|
+
* @returns {void}
|
|
181
|
+
*/
|
|
182
|
+
init: () => void;
|
|
183
|
+
/**
|
|
184
|
+
* 创建并展示插屏广告
|
|
185
|
+
* @returns {Promise<void>}
|
|
186
|
+
*/
|
|
187
|
+
createAndShowInterstitialAd: () => Promise<void>;
|
|
188
|
+
/**
|
|
189
|
+
* 创建并展示激励视频广告
|
|
190
|
+
* @param {any} context - 页面上下文
|
|
191
|
+
* @param {string} [pageId] - 页面ID
|
|
192
|
+
* @returns {Promise<boolean>} 是否完成播放
|
|
193
|
+
*/
|
|
194
|
+
createAndShowRewardedVideoAd: (context: any, pageId?: string) => Promise<boolean>;
|
|
195
|
+
}
|
|
196
|
+
const _default: AdManager;
|
|
197
|
+
export default _default;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
declare module '@wxshot/api/supabase' {
|
|
201
|
+
class QueryBuilder {
|
|
202
|
+
constructor(table: string);
|
|
203
|
+
select(columns?: string): this;
|
|
204
|
+
eq(col: string, val: any): this;
|
|
205
|
+
neq(col: string, val: any): this;
|
|
206
|
+
gt(col: string, val: any): this;
|
|
207
|
+
lt(col: string, val: any): this;
|
|
208
|
+
gte(col: string, val: any): this;
|
|
209
|
+
lte(col: string, val: any): this;
|
|
210
|
+
like(col: string, pattern: string): this;
|
|
211
|
+
ilike(col: string, pattern: string): this;
|
|
212
|
+
is(col: string, val: null | boolean): this;
|
|
213
|
+
not(col: string, op: string, val: any): this;
|
|
214
|
+
or(filters: string): this;
|
|
215
|
+
contains(col: string, val: any[] | Record<string, any>): this;
|
|
216
|
+
range(from: number, to: number): this;
|
|
217
|
+
inFilter(col: string, vals: any[]): this;
|
|
218
|
+
order(col: string, { ascending }?: {
|
|
219
|
+
ascending?: boolean | undefined;
|
|
220
|
+
}): this;
|
|
221
|
+
limit(n: number): this;
|
|
222
|
+
offset(n: number): this;
|
|
223
|
+
single(): this;
|
|
224
|
+
maybeSingle(): this;
|
|
225
|
+
insert(data: Record<string, any> | Record<string, any>[]): this;
|
|
226
|
+
update(data: Record<string, any>): this;
|
|
227
|
+
delete(): this;
|
|
228
|
+
upsert(data: Record<string, any> | Record<string, any>[]): this;
|
|
229
|
+
then<T>(resolve: (val: {
|
|
230
|
+
data: T | null;
|
|
231
|
+
error: any;
|
|
232
|
+
count: number | null;
|
|
233
|
+
}) => void, reject?: (err: any) => void): Promise<void>;
|
|
234
|
+
catch(reject: (err: any) => void): Promise<void | {
|
|
235
|
+
data: any;
|
|
236
|
+
error: any;
|
|
237
|
+
count: number | null;
|
|
238
|
+
}>;
|
|
239
|
+
}
|
|
240
|
+
const supabase: {
|
|
241
|
+
from(table: string): QueryBuilder;
|
|
242
|
+
};
|
|
243
|
+
export default supabase;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
declare module '@wxshot/api/types' {
|
|
247
|
+
export interface Config {
|
|
248
|
+
API: {
|
|
249
|
+
GATEWAY_URL: string;
|
|
250
|
+
BASE_URL: string;
|
|
251
|
+
API_URL: string;
|
|
252
|
+
SUPA_URL: string;
|
|
253
|
+
SUPA_ANON_KEY: string;
|
|
254
|
+
};
|
|
255
|
+
APP: {
|
|
256
|
+
APP_ID: number;
|
|
257
|
+
LOGIN_MAX_RETRY: number;
|
|
258
|
+
};
|
|
259
|
+
HTTP: {
|
|
260
|
+
TIMEOUT: number;
|
|
261
|
+
};
|
|
262
|
+
DATA: {
|
|
263
|
+
PAGE_ID: string;
|
|
264
|
+
};
|
|
265
|
+
STORAGE_KEYS: {
|
|
266
|
+
TOKEN: string;
|
|
267
|
+
BASETOKEN: string;
|
|
268
|
+
USER_INFO: string;
|
|
269
|
+
SPA_DATA: string;
|
|
270
|
+
LINK_DATA: string;
|
|
271
|
+
TOP_DATA: string;
|
|
272
|
+
};
|
|
273
|
+
EVENT_KEYS: {
|
|
274
|
+
LOGIN_SUCCESS: string;
|
|
275
|
+
AD_DATA_READY: string;
|
|
276
|
+
REWARDED_VIDEO_AD_CLOSE: string;
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
export interface HttpClientOptions {
|
|
280
|
+
baseURL: string;
|
|
281
|
+
timeout?: number;
|
|
282
|
+
}
|
|
283
|
+
export interface RequestOptions {
|
|
284
|
+
headers?: Record<string, string>;
|
|
285
|
+
[key: string]: any;
|
|
286
|
+
}
|
|
287
|
+
export interface LoginData {
|
|
288
|
+
appId: number;
|
|
289
|
+
code: string;
|
|
290
|
+
brand: string;
|
|
291
|
+
model: string;
|
|
292
|
+
platform: string;
|
|
293
|
+
}
|
|
294
|
+
export interface ApiResponse<T = any> {
|
|
295
|
+
code: number;
|
|
296
|
+
message?: string;
|
|
297
|
+
data?: T;
|
|
298
|
+
}
|
|
299
|
+
export interface UserInfo {
|
|
300
|
+
token: string;
|
|
301
|
+
base_token: string;
|
|
302
|
+
user: {
|
|
303
|
+
id: number;
|
|
304
|
+
name: string;
|
|
305
|
+
avatar: string;
|
|
306
|
+
openId: string;
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
export interface EchoData {
|
|
310
|
+
isPublished: boolean;
|
|
311
|
+
spads: AdData[];
|
|
312
|
+
links: LinkData[];
|
|
313
|
+
top: TopData;
|
|
314
|
+
version: number;
|
|
315
|
+
}
|
|
316
|
+
export interface AdData {
|
|
317
|
+
id: number;
|
|
318
|
+
status: number;
|
|
319
|
+
appPage: 'banner' | 'custom' | 'video' | 'interstitial' | 'rewarded';
|
|
320
|
+
ads: {
|
|
321
|
+
id: number;
|
|
322
|
+
type: number;
|
|
323
|
+
adId: number;
|
|
324
|
+
adUnitId: string;
|
|
325
|
+
}[];
|
|
326
|
+
}
|
|
327
|
+
export interface LinkData {
|
|
328
|
+
appId: string;
|
|
329
|
+
appLogo: string;
|
|
330
|
+
linkName: string;
|
|
331
|
+
linkPage: string;
|
|
332
|
+
}
|
|
333
|
+
export interface TopData {
|
|
334
|
+
appId: string;
|
|
335
|
+
appLogo: string;
|
|
336
|
+
linkName: string;
|
|
337
|
+
appDsc: string;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @wxshot/api
|
|
2
|
+
* @wxshot/api v2.0.9
|
|
3
3
|
*
|
|
4
|
-
*/(()=>{"use strict";var t={616:function(t,e,n){var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,a){function i(t){try{u(r.next(t))}catch(t){a(t)}}function s(t){try{u(r.throw(t))}catch(t){a(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(i,s)}u((r=r.apply(t,e||[])).next())}))},o=this&&this.__generator||function(t,e){var n,r,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=s(0),i.throw=s(1),i.return=s(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}},a=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});var i=a(n(28)),s=a(n(144)),u=function(){var t=this;this.ads={},this.link=[],this.top=null,this.adDataReady=!1,this.interstitialAd=null,this.rewardedVideoAds={},this.onDataReady=function(e){t.adDataReady?e():s.default.once(i.default.EVENT_KEYS.AD_DATA_READY,e)},this.waitAdData=function(){return new Promise((function(e){t.onDataReady(e)}))},this.init=function(){t.getData()},this.getData=function(){var e=wx.getStorageSync(i.default.STORAGE_KEYS.SPA_DATA);e&&(t.ads=e.reduce((function(t,e){return t[e.appPage]=e.ads&&e.ads.length>0?e.ads[0].adUnitId:"",t}),{}));var n=wx.getStorageSync(i.default.STORAGE_KEYS.LINK_DATA);n&&(t.link=n);var r=wx.getStorageSync(i.default.STORAGE_KEYS.TOP_DATA);r&&r.appDsc.length>40&&(r.appDsc=r.appDsc.substring(0,40)+"...",t.top=r),t.adDataReady=!0,s.default.emit(i.default.EVENT_KEYS.AD_DATA_READY)},this.createAndShowInterstitialAd=function(){return r(t,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return this.interstitialAd&&this.interstitialAd.destroy(),[4,this.waitAdData()];case 1:e.sent(),e.label=2;case 2:return e.trys.push([2,5,,6]),[4,this.createInterstitialAd()];case 3:return e.sent(),[4,this.showInterstitialAd()];case 4:return e.sent(),[3,6];case 5:return t=e.sent(),console.error("创建插屏广告失败:",t),[3,6];case 6:return[2]}}))}))},this.createInterstitialAd=function(){return r(t,void 0,void 0,(function(){var t=this;return o(this,(function(e){return[2,new Promise((function(e,n){t.ads.interstitial?(t.interstitialAd=wx.createInterstitialAd({adUnitId:t.ads.interstitial}),t.interstitialAd.onLoad((function(){console.log("插屏广告加载成功"),e()})),t.interstitialAd.onError((function(t){console.error(t),n(new Error("插屏广告加载失败"))})),t.interstitialAd.onClose((function(){console.log("插屏广告关闭")}))):n(new Error("插屏广告未配置"))}))]}))}))},this.showInterstitialAd=function(){return r(t,void 0,void 0,(function(){var t,e;return o(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),console.log("开始展示插屏广告"),[4,null===(e=this.interstitialAd)||void 0===e?void 0:e.show()];case 1:return[2,n.sent()];case 2:return t=n.sent(),console.error("插屏广告展示失败:",t),[3,3];case 3:return[2]}}))}))},this.createAndShowRewardedVideoAd=function(e,n){return r(t,void 0,void 0,(function(){var t,r,a;return o(this,(function(o){switch(o.label){case 0:return[4,this.waitAdData()];case 1:o.sent(),t=n||(null===(a=null==e?void 0:e.data)||void 0===a?void 0:a[i.default.DATA.PAGE_ID]),o.label=2;case 2:if(o.trys.push([2,6,,7]),!t)throw new Error("未指定pageId或者context");return this.rewardedVideoAds[t]?[3,4]:[4,this.createRewardedVideoAd(t)];case 3:o.sent(),o.label=4;case 4:return[4,this.showRewardedVideoAd(t)];case 5:return o.sent(),[3,7];case 6:return r=o.sent(),console.error("创建激励视频广告失败:",r),[3,7];case 7:return[2,new Promise((function(e){s.default.on(i.default.EVENT_KEYS.REWARDED_VIDEO_AD_CLOSE,(function(n,r){n===t&&e(r)}))}))]}}))}))},this.createRewardedVideoAd=function(e){return r(t,void 0,void 0,(function(){var t=this;return o(this,(function(n){return[2,new Promise((function(n,r){t.ads.rewarded?(t.rewardedVideoAds[e]=wx.createRewardedVideoAd({adUnitId:t.ads.rewarded}),t.rewardedVideoAds[e].onLoad((function(){console.log("激励视频广告加载成功"),n()})),t.rewardedVideoAds[e].onError((function(t){console.error(t),r(new Error("激励视频广告加载失败"))})),t.rewardedVideoAds[e].onClose((function(t){s.default.emit(i.default.EVENT_KEYS.REWARDED_VIDEO_AD_CLOSE,e,t.isEnded),console.log("激励视频广告关闭")}))):r(new Error("激励视频广告未配置"))}))]}))}))},this.showRewardedVideoAd=function(e){return r(t,void 0,void 0,(function(){var t,n;return o(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),console.log("开始展示激励视频广告"),[4,null===(n=this.rewardedVideoAds[e])||void 0===n?void 0:n.show()];case 1:return[2,r.sent()];case 2:return t=r.sent(),console.error("激励视频广告展示失败:",t),[3,3];case 3:return[2]}}))}))}};e.default=new u},859:function(t,e,n){var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,a){function i(t){try{u(r.next(t))}catch(t){a(t)}}function s(t){try{u(r.throw(t))}catch(t){a(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(i,s)}u((r=r.apply(t,e||[])).next())}))},o=this&&this.__generator||function(t,e){var n,r,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=s(0),i.throw=s(1),i.return=s(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}},a=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.checkTokenValid=void 0,e.initApp=function(){return r(this,arguments,void 0,(function(t){return void 0===t&&(t={}),o(this,(function(e){switch(e.label){case 0:return t.gatewayUrl&&i.gatewayHttpClient.setBaseURL(t.gatewayUrl),t.baseUrl&&i.baseHttpClient.setBaseURL(t.baseUrl),t.apiUrl&&i.apiHttpClient.setBaseURL(t.apiUrl),[4,h()];case 1:return e.sent(),[4,p()];case 2:return e.sent(),c.default.init(),[2]}}))}))},e.showPage=function(){return r(this,arguments,void 0,(function(t,e){return void 0===t&&(t={}),o(this,(function(e){switch(e.label){case 0:return t.showInterstitialAd&&c.default.createAndShowInterstitialAd(),[4,f()];case 1:return e.sent(),[4,w()];case 2:return e.sent(),[2]}}))}))},e.onLoginReady=d,e.waitLogin=f,e.login=h,e.fetchEchoData=p,e.trackVisit=w;var i=n(161),s=a(n(28)),u=a(n(144)),c=a(n(616)),l=0;function d(t){(0,e.checkTokenValid)()?t():u.default.once(s.default.EVENT_KEYS.LOGIN_SUCCESS,t)}function f(){return new Promise((function(t){d(t)}))}function h(){return r(this,void 0,void 0,(function(){var t,e,n,r;return o(this,(function(o){switch(o.label){case 0:if(wx.removeStorageSync(s.default.STORAGE_KEYS.TOKEN),wx.removeStorageSync(s.default.STORAGE_KEYS.BASETOKEN),wx.removeStorageSync(s.default.STORAGE_KEYS.USER_INFO),l>s.default.APP.LOGIN_MAX_RETRY)throw wx.showToast({title:"网络异常,无法初始化",icon:"none",duration:2e3}),new Error("网络异常,无法初始化");o.label=1;case 1:return o.trys.push([1,7,,9]),t=wx.getDeviceInfo(),[4,wx.login()];case 2:return e=o.sent().code,n={appId:s.default.APP.APP_ID,code:e,brand:t.brand,model:t.model,platform:t.platform},[4,i.gatewayHttpClient.request("/wx/v1/api/login","POST",n)];case 3:return 200===(r=o.sent()).code&&r.data?(wx.setStorageSync(s.default.STORAGE_KEYS.TOKEN,r.data.token),wx.setStorageSync(s.default.STORAGE_KEYS.BASETOKEN,r.data.base_token),wx.setStorageSync(s.default.STORAGE_KEYS.USER_INFO,r.data.user),l=0,u.default.emit(s.default.EVENT_KEYS.LOGIN_SUCCESS),[3,6]):[3,4];case 4:return l++,[4,h()];case 5:o.sent(),o.label=6;case 6:return[3,9];case 7:return o.sent(),l++,[4,h()];case 8:return o.sent(),[3,9];case 9:return[2]}}))}))}function p(){return r(this,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return wx.removeStorageSync(s.default.STORAGE_KEYS.SPA_DATA),wx.removeStorageSync(s.default.STORAGE_KEYS.LINK_DATA),wx.removeStorageSync(s.default.STORAGE_KEYS.TOP_DATA),(0,e.checkTokenValid)()?[4,i.gatewayHttpClient.request("/wx/v1/api/echo","GET")]:[2];case 1:return 200===(t=n.sent()).code&&t.data?(t.data.spads&&wx.setStorageSync(s.default.STORAGE_KEYS.SPA_DATA,t.data.spads),t.data.links&&wx.setStorageSync(s.default.STORAGE_KEYS.LINK_DATA,t.data.links),t.data.top&&wx.setStorageSync(s.default.STORAGE_KEYS.TOP_DATA,t.data.top),[3,5]):[3,2];case 2:return 401!==t.code?[3,5]:[4,h()];case 3:return n.sent(),[4,p()];case 4:n.sent(),n.label=5;case 5:return[2]}}))}))}function w(){return r(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return e.trys.push([0,5,,6]),[4,i.gatewayHttpClient.request("/wx/v1/api/visit","POST")];case 1:return 401!==e.sent().code?[3,4]:[4,h()];case 2:return e.sent(),[4,w()];case 3:e.sent(),e.label=4;case 4:return[3,6];case 5:return t=e.sent(),console.error("访问统计失败:",t),[3,6];case 6:return[2]}}))}))}e.checkTokenValid=function(){var t=wx.getStorageSync(s.default.STORAGE_KEYS.TOKEN);return!(!t||t.length<32)}},28:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0});var n={API:{GATEWAY_URL:"https://ca.wxshot.cn",BASE_URL:"https://app.wxshot.cn/v1/api",API_URL:"https://cp.wxshot.cn"},APP:{APP_ID:wx.getExtConfigSync().appId||10,LOGIN_MAX_RETRY:2},HTTP:{TIMEOUT:5e3},DATA:{PAGE_ID:"wxshot-page-id"},STORAGE_KEYS:{TOKEN:"wxshot-token",BASETOKEN:"wxshot-base-token",USER_INFO:"wxshot-userinfo",SPA_DATA:"wxshot-spadata",LINK_DATA:"wxshot-linkdata",TOP_DATA:"wxshot-topdata"},EVENT_KEYS:{LOGIN_SUCCESS:"wxshot-login-success",AD_DATA_READY:"wxshot-ad-data-ready",REWARDED_VIDEO_AD_CLOSE:"wxshot-rewarded-video-ad-close"}};e.default=n},144:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(){this.events={}}return t.prototype.on=function(t,e){if("string"!=typeof t)throw new TypeError("eventName must be a string");if("function"!=typeof e)throw new TypeError("callback must be a function");return this.events[t]||(this.events[t]=[]),this.events[t].push(e),this},t.prototype.emit=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if("string"!=typeof t)throw new TypeError("eventName must be a string");var r=this.events[t];return r&&r.forEach((function(n){try{n.apply(void 0,e)}catch(e){console.error('Error in event "'.concat(t,'" callback:'),e)}})),this},t.prototype.off=function(t,e){if("string"!=typeof t)throw new TypeError("eventName must be a string");return e?(this.events[t]&&(this.events[t]=this.events[t].filter((function(t){return t!==e}))),this):(delete this.events[t],this)},t.prototype.once=function(t,e){var n=this;if("string"!=typeof t)throw new TypeError("eventName must be a string");if("function"!=typeof e)throw new TypeError("callback must be a function");var r=function(){for(var o=[],a=0;a<arguments.length;a++)o[a]=arguments[a];n.off(t,r),e.apply(n,o)};return this.on(t,r)},t}();e.default=new n},161:function(t,e,n){var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)},o=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,a){function i(t){try{u(r.next(t))}catch(t){a(t)}}function s(t){try{u(r.throw(t))}catch(t){a(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(i,s)}u((r=r.apply(t,e||[])).next())}))},a=this&&this.__generator||function(t,e){var n,r,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=s(0),i.throw=s(1),i.return=s(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}},i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.apiHttpClient=e.baseHttpClient=e.gatewayHttpClient=void 0;var s=i(n(28)),u=function(){function t(t){var e=t.baseURL,n=t.timeout;if(!e)throw new Error("baseURL is required");this.baseURL=e,this.timeout=n||s.default.HTTP.TIMEOUT}return t.prototype.setBaseURL=function(t){this.baseURL=t},t.prototype.wxRequestPromise=function(t){return new Promise((function(e,n){wx.request(r(r({},t),{success:function(t){e(t)},fail:function(t){n(t)}}))}))},t.prototype.joinURL=function(t,e){var n=t.replace(/\/+$/,""),r=e.replace(/^\/+/,"");return"".concat(n,"/").concat(r)},t.prototype.request=function(t){return o(this,arguments,void 0,(function(t,e,n,o){var i,u,c,l,d,f,h=this;return void 0===e&&(e="GET"),void 0===n&&(n={}),void 0===o&&(o={}),a(this,(function(a){switch(a.label){case 0:i=wx.getStorageSync(s.default.STORAGE_KEYS.TOKEN),u={Authorization:i,"Content-Type":"application/json"},c=new Promise((function(t,e){setTimeout((function(){return e(new Error("请求超时"))}),h.timeout)})),a.label=1;case 1:return a.trys.push([1,4,,5]),[4,this.wxRequestPromise(r({url:this.joinURL(this.baseURL,t),method:e,data:n,header:r(r({},u),o.headers)},o))];case 2:return l=a.sent(),[4,Promise.race([l,c])];case 3:if((d=a.sent()).statusCode>=200&&d.statusCode<300)return[2,d.data];if(401===d.statusCode)return[2,{code:401,message:"未授权"}];throw new Error(d.data.message||"请求失败");case 4:throw f=a.sent(),console.error("网络错误:",f),wx.showToast({title:f instanceof Error?f.message:"网络错误",icon:"none",duration:2e3}),f;case 5:return[2]}}))}))},t.prototype.uploadFile=function(t){return o(this,arguments,void 0,(function(t,e,n){var r,o,i,u;return void 0===e&&(e={}),void 0===n&&(n="file"),a(this,(function(a){r=this.baseURL===s.default.API.GATEWAY_URL,o=wx.getStorageSync(s.default.STORAGE_KEYS.TOKEN),i="avatar"===n?"/avatar":"/file/new",u=this.joinURL(this.baseURL,"".concat(r?"/wx/v1/api":"").concat(i));try{return[2,new Promise((function(n,r){wx.uploadFile({url:u,name:"file",filePath:t,formData:e,header:{"Content-Type":"application/x-www-form-urlencoded",Authorization:o},success:function(t){if(t.statusCode>=200&&t.statusCode<300)n(JSON.parse(t.data));else{if(401!==t.statusCode)throw new Error(t.data.message||"上传失败");n(JSON.parse(t.data))}},fail:function(){throw new Error("网络错误")}}).onProgressUpdate((function(t){console.log("上传进度",t.progress),console.log("已经上传的数据长度",t.totalBytesSent),console.log("预期需要上传的数据总长度",t.totalBytesExpectedToSend)}))}))]}catch(t){throw console.error("上传失败:",t),wx.showToast({title:t instanceof Error?t.message:"上传失败",icon:"none",duration:2e3}),t}return[2]}))}))},t.prototype.upload=function(t,e){return o(this,arguments,void 0,(function(t,e,n){var r,o,i;return void 0===n&&(n={}),a(this,(function(a){r=this.baseURL===s.default.API.GATEWAY_URL,o=wx.getStorageSync(s.default.STORAGE_KEYS.TOKEN),i=this.joinURL(this.baseURL,"".concat(r?"/wx/v1/api":"").concat(t));try{return[2,new Promise((function(t,r){wx.uploadFile({url:i,name:"file",filePath:e,formData:n,header:{"Content-Type":"application/x-www-form-urlencoded",Authorization:o},success:function(e){if(e.statusCode>=200&&e.statusCode<300)t(JSON.parse(e.data));else{if(401!==e.statusCode)throw new Error(e.data.message||"上传失败");t(JSON.parse(e.data))}},fail:function(){throw new Error("网络错误")}}).onProgressUpdate((function(t){console.log("上传进度",t.progress),console.log("已经上传的数据长度",t.totalBytesSent),console.log("预期需要上传的数据总长度",t.totalBytesExpectedToSend)}))}))]}catch(t){throw console.error("上传失败:",t),wx.showToast({title:t instanceof Error?t.message:"上传失败",icon:"none",duration:2e3}),t}return[2]}))}))},t.prototype.deleteFile=function(t){return o(this,void 0,void 0,(function(){var e;return a(this,(function(n){return e=this.baseURL===s.default.API.GATEWAY_URL,[2,this.request("".concat(e?"/wx/v1/api":"","/file/del"),"GET",{id:t})]}))}))},t.prototype.uploadAvatar=function(t){return o(this,void 0,void 0,(function(){return a(this,(function(e){return[2,this.uploadFile(t,{},"avatar")]}))}))},t}();e.gatewayHttpClient=new u({baseURL:s.default.API.GATEWAY_URL,timeout:s.default.HTTP.TIMEOUT}),e.baseHttpClient=new u({baseURL:s.default.API.BASE_URL,timeout:s.default.HTTP.TIMEOUT}),e.apiHttpClient=new u({baseURL:s.default.API.API_URL,timeout:s.default.HTTP.TIMEOUT}),e.default=u},156:function(t,e,n){var r=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,o)}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),o=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),a=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&r(e,t,n);return o(e,t),e},i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.adManager=e.HttpClient=e.apiHttpClient=e.baseHttpClient=e.gatewayHttpClient=e.hijackAllPage=e.hijackApp=e.injectComponent=e.injectPage=e.injectApp=e.waitLogin=e.onLoginReady=void 0;var s=n(859);Object.defineProperty(e,"onLoginReady",{enumerable:!0,get:function(){return s.onLoginReady}}),Object.defineProperty(e,"waitLogin",{enumerable:!0,get:function(){return s.waitLogin}});var u=a(n(161));e.HttpClient=u.default,Object.defineProperty(e,"gatewayHttpClient",{enumerable:!0,get:function(){return u.gatewayHttpClient}}),Object.defineProperty(e,"baseHttpClient",{enumerable:!0,get:function(){return u.baseHttpClient}}),Object.defineProperty(e,"apiHttpClient",{enumerable:!0,get:function(){return u.apiHttpClient}});var c=n(718);Object.defineProperty(e,"injectApp",{enumerable:!0,get:function(){return c.injectApp}}),Object.defineProperty(e,"injectPage",{enumerable:!0,get:function(){return c.injectPage}}),Object.defineProperty(e,"injectComponent",{enumerable:!0,get:function(){return c.injectComponent}}),Object.defineProperty(e,"hijackApp",{enumerable:!0,get:function(){return c.hijackApp}}),Object.defineProperty(e,"hijackAllPage",{enumerable:!0,get:function(){return c.hijackAllPage}});var l=i(n(616));e.adManager=l.default},718:function(t,e,n){var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)},o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.hijackAllPage=e.hijackApp=void 0,e.injectApp=s,e.injectPage=u,e.injectComponent=c;var a=n(859),i=o(n(28));function s(t){return void 0===t&&(t={}),function(e){void 0===e&&(e={});var n=e.onLaunch;return e.onLaunch=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];a.initApp.call(this,t).catch((function(t){console.error("应用API初始化失败:",t)})),null==n||n.apply(this,e)},e}}function u(t){return void 0===t&&(t={showInterstitialAd:!1}),function(e){var n;void 0===e&&(e={}),e.data=r(r({},e.data||{}),((n={})[i.default.DATA.PAGE_ID]=Math.random().toString(36).substring(2,7),n));var o=e.onShow;return e.onShow=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];a.showPage.call(this,t,this.data[i.default.DATA.PAGE_ID]).catch((function(t){console.error("页面API初始化失败:",t)})),null==o||o.apply(this,e)},e}}function c(t){return void 0===t&&(t={showInterstitialAd:!1}),function(e){void 0===e&&(e={}),e.methods=e.methods||{};var n=!1,r=e.methods.onLoad;e.methods.onLoad=function(){for(var t,e,o=[],a=0;a<arguments.length;a++)o[a]=arguments[a];(n=!!this.route)&&!(null===(e=this.data)||void 0===e?void 0:e[i.default.DATA.PAGE_ID])&&this.setData(((t={})[i.default.DATA.PAGE_ID]=Math.random().toString(36).substring(2,7),t)),null==r||r.apply(this,o)};var o=e.methods.onShow;return e.methods.onShow=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];n&&a.showPage.call(this,t,this.data[i.default.DATA.PAGE_ID]).catch((function(t){console.error("页面API初始化失败:",t)})),null==o||o.apply(this,e)},e}}e.hijackApp=function(t){void 0===t&&(t={});var e=App;App=function(n){return e(s(t)(n))}};e.hijackAllPage=function(t){void 0===t&&(t={showInterstitialAd:!1});var e=Page;Page=function(n){return e(u(t)(n))};var n=Component;Component=function(e){return n(c(t)(e))}}}},e={};var n=function n(r){var o=e[r];if(void 0!==o)return o.exports;var a=e[r]={exports:{}};return t[r].call(a.exports,a,a.exports,n),a.exports}(156);module.exports=n})();
|
|
4
|
+
*/(()=>{"use strict";var t={616(t,e,n){var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))(function(o,a){function i(t){try{u(r.next(t))}catch(t){a(t)}}function s(t){try{u(r.throw(t))}catch(t){a(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(i,s)}u((r=r.apply(t,e||[])).next())})},o=this&&this.__generator||function(t,e){var n,r,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=s(0),i.throw=s(1),i.return=s(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}},a=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});var i=a(n(28)),s=a(n(144)),u=function(){var t=this;this.ads={},this.link=[],this.top=null,this.adDataReady=!1,this.interstitialAd=null,this.rewardedVideoAds={},this.onDataReady=function(e){t.adDataReady?e():s.default.once(i.default.EVENT_KEYS.AD_DATA_READY,e)},this.waitAdData=function(){return new Promise(function(e){t.onDataReady(e)})},this.init=function(){t.getData()},this.getData=function(){var e=wx.getStorageSync(i.default.STORAGE_KEYS.SPA_DATA);e&&(t.ads=e.reduce(function(t,e){return t[e.appPage]=e.ads&&e.ads.length>0?e.ads[0].adUnitId:"",t},{}));var n=wx.getStorageSync(i.default.STORAGE_KEYS.LINK_DATA);n&&(t.link=n);var r=wx.getStorageSync(i.default.STORAGE_KEYS.TOP_DATA);r&&r.appDsc.length>40&&(r.appDsc=r.appDsc.substring(0,40)+"...",t.top=r),t.adDataReady=!0,s.default.emit(i.default.EVENT_KEYS.AD_DATA_READY)},this.createAndShowInterstitialAd=function(){return r(t,void 0,void 0,function(){var t;return o(this,function(e){switch(e.label){case 0:return this.interstitialAd&&this.interstitialAd.destroy(),[4,this.waitAdData()];case 1:e.sent(),e.label=2;case 2:return e.trys.push([2,5,,6]),[4,this.createInterstitialAd()];case 3:return e.sent(),[4,this.showInterstitialAd()];case 4:return e.sent(),[3,6];case 5:return t=e.sent(),console.error("创建插屏广告失败:",t),[3,6];case 6:return[2]}})})},this.createInterstitialAd=function(){return r(t,void 0,void 0,function(){var t=this;return o(this,function(e){return[2,new Promise(function(e,n){t.ads.interstitial?(t.interstitialAd=wx.createInterstitialAd({adUnitId:t.ads.interstitial}),t.interstitialAd.onLoad(function(){console.log("插屏广告加载成功"),e()}),t.interstitialAd.onError(function(t){console.error(t),n(new Error("插屏广告加载失败"))}),t.interstitialAd.onClose(function(){console.log("插屏广告关闭")})):n(new Error("插屏广告未配置"))})]})})},this.showInterstitialAd=function(){return r(t,void 0,void 0,function(){var t,e;return o(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),console.log("开始展示插屏广告"),[4,null===(e=this.interstitialAd)||void 0===e?void 0:e.show()];case 1:return[2,n.sent()];case 2:return t=n.sent(),console.error("插屏广告展示失败:",t),[3,3];case 3:return[2]}})})},this.createAndShowRewardedVideoAd=function(e,n){return r(t,void 0,void 0,function(){var t,r,a;return o(this,function(o){switch(o.label){case 0:return[4,this.waitAdData()];case 1:o.sent(),t=n||(null===(a=null==e?void 0:e.data)||void 0===a?void 0:a[i.default.DATA.PAGE_ID]),o.label=2;case 2:if(o.trys.push([2,6,,7]),!t)throw new Error("未指定pageId或者context");return this.rewardedVideoAds[t]?[3,4]:[4,this.createRewardedVideoAd(t)];case 3:o.sent(),o.label=4;case 4:return[4,this.showRewardedVideoAd(t)];case 5:return o.sent(),[3,7];case 6:return r=o.sent(),console.error("创建激励视频广告失败:",r),[3,7];case 7:return[2,new Promise(function(e){s.default.on(i.default.EVENT_KEYS.REWARDED_VIDEO_AD_CLOSE,function(n,r){n===t&&e(r)})})]}})})},this.createRewardedVideoAd=function(e){return r(t,void 0,void 0,function(){var t=this;return o(this,function(n){return[2,new Promise(function(n,r){t.ads.rewarded?(t.rewardedVideoAds[e]=wx.createRewardedVideoAd({adUnitId:t.ads.rewarded}),t.rewardedVideoAds[e].onLoad(function(){console.log("激励视频广告加载成功"),n()}),t.rewardedVideoAds[e].onError(function(t){console.error(t),r(new Error("激励视频广告加载失败"))}),t.rewardedVideoAds[e].onClose(function(t){s.default.emit(i.default.EVENT_KEYS.REWARDED_VIDEO_AD_CLOSE,e,t.isEnded),console.log("激励视频广告关闭")})):r(new Error("激励视频广告未配置"))})]})})},this.showRewardedVideoAd=function(e){return r(t,void 0,void 0,function(){var t,n;return o(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),console.log("开始展示激励视频广告"),[4,null===(n=this.rewardedVideoAds[e])||void 0===n?void 0:n.show()];case 1:return[2,r.sent()];case 2:return t=r.sent(),console.error("激励视频广告展示失败:",t),[3,3];case 3:return[2]}})})}};e.default=new u},859(t,e,n){var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))(function(o,a){function i(t){try{u(r.next(t))}catch(t){a(t)}}function s(t){try{u(r.throw(t))}catch(t){a(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(i,s)}u((r=r.apply(t,e||[])).next())})},o=this&&this.__generator||function(t,e){var n,r,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=s(0),i.throw=s(1),i.return=s(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}},a=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.checkTokenValid=void 0,e.initApp=function(){return r(this,arguments,void 0,function(t){return void 0===t&&(t={}),o(this,function(e){switch(e.label){case 0:return t.gatewayUrl&&i.gatewayHttpClient.setBaseURL(t.gatewayUrl),t.baseUrl&&i.baseHttpClient.setBaseURL(t.baseUrl),t.apiUrl&&i.apiHttpClient.setBaseURL(t.apiUrl),t.supaUrl&&(s.default.API.SUPA_URL=t.supaUrl),t.supaAnonKey&&(s.default.API.SUPA_ANON_KEY=t.supaAnonKey),[4,h()];case 1:return e.sent(),[4,p()];case 2:return e.sent(),c.default.init(),[2]}})})},e.showPage=function(){return r(this,arguments,void 0,function(t,e){return void 0===t&&(t={}),o(this,function(e){switch(e.label){case 0:return t.showInterstitialAd&&c.default.createAndShowInterstitialAd(),[4,d()];case 1:return e.sent(),[4,y()];case 2:return e.sent(),[2]}})})},e.onLoginReady=f,e.waitLogin=d,e.login=h,e.fetchEchoData=p,e.trackVisit=y;var i=n(161),s=a(n(28)),u=a(n(144)),c=a(n(616)),l=0;function f(t){(0,e.checkTokenValid)()?t():u.default.once(s.default.EVENT_KEYS.LOGIN_SUCCESS,t)}function d(){return new Promise(function(t){f(t)})}function h(){return r(this,void 0,void 0,function(){var t,e,n,r;return o(this,function(o){switch(o.label){case 0:if(wx.removeStorageSync(s.default.STORAGE_KEYS.TOKEN),wx.removeStorageSync(s.default.STORAGE_KEYS.BASETOKEN),wx.removeStorageSync(s.default.STORAGE_KEYS.USER_INFO),l>s.default.APP.LOGIN_MAX_RETRY)throw wx.showToast({title:"网络异常,无法初始化",icon:"none",duration:2e3}),new Error("网络异常,无法初始化");o.label=1;case 1:return o.trys.push([1,7,,9]),t=wx.getDeviceInfo(),[4,wx.login()];case 2:return e=o.sent().code,n={appId:s.default.APP.APP_ID,code:e,brand:t.brand,model:t.model,platform:t.platform},[4,i.gatewayHttpClient.request("/wx/v1/api/login","POST",n)];case 3:return 200===(r=o.sent()).code&&r.data?(wx.setStorageSync(s.default.STORAGE_KEYS.TOKEN,r.data.token),wx.setStorageSync(s.default.STORAGE_KEYS.BASETOKEN,r.data.base_token),wx.setStorageSync(s.default.STORAGE_KEYS.USER_INFO,r.data.user),l=0,u.default.emit(s.default.EVENT_KEYS.LOGIN_SUCCESS),[3,6]):[3,4];case 4:return l++,[4,h()];case 5:o.sent(),o.label=6;case 6:return[3,9];case 7:return o.sent(),l++,[4,h()];case 8:return o.sent(),[3,9];case 9:return[2]}})})}function p(){return r(this,void 0,void 0,function(){var t;return o(this,function(n){switch(n.label){case 0:return wx.removeStorageSync(s.default.STORAGE_KEYS.SPA_DATA),wx.removeStorageSync(s.default.STORAGE_KEYS.LINK_DATA),wx.removeStorageSync(s.default.STORAGE_KEYS.TOP_DATA),(0,e.checkTokenValid)()?[4,i.gatewayHttpClient.request("/wx/v1/api/echo","GET")]:[2];case 1:return 200===(t=n.sent()).code&&t.data?(t.data.spads&&wx.setStorageSync(s.default.STORAGE_KEYS.SPA_DATA,t.data.spads),t.data.links&&wx.setStorageSync(s.default.STORAGE_KEYS.LINK_DATA,t.data.links),t.data.top&&wx.setStorageSync(s.default.STORAGE_KEYS.TOP_DATA,t.data.top),[3,5]):[3,2];case 2:return 401!==t.code?[3,5]:[4,h()];case 3:return n.sent(),[4,p()];case 4:n.sent(),n.label=5;case 5:return[2]}})})}function y(){return r(this,void 0,void 0,function(){var t;return o(this,function(e){switch(e.label){case 0:return e.trys.push([0,5,,6]),[4,i.gatewayHttpClient.request("/wx/v1/api/visit","POST")];case 1:return 401!==e.sent().code?[3,4]:[4,h()];case 2:return e.sent(),[4,y()];case 3:e.sent(),e.label=4;case 4:return[3,6];case 5:return t=e.sent(),console.error("访问统计失败:",t),[3,6];case 6:return[2]}})})}e.checkTokenValid=function(){var t=wx.getStorageSync(s.default.STORAGE_KEYS.TOKEN);return!(!t||t.length<32)}},28(t,e){Object.defineProperty(e,"__esModule",{value:!0});var n={API:{GATEWAY_URL:"https://ca.wxshot.cn",BASE_URL:"https://app.wxshot.cn/v1/api",API_URL:"https://cp.wxshot.cn",SUPA_URL:"https://supabase.aiaud.cn",SUPA_ANON_KEY:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJhbm9uIiwKICAgICJpc3MiOiAic3VwYWJhc2UtZGVtbyIsCiAgICAiaWF0IjogMTY0MTc2OTIwMCwKICAgICJleHAiOiAxNzk5NTM1NjAwCn0.dc_X5iR_VP_qT0zsiyj_I_OZ2T9FtRU2BBNWN8Bu4GE"},APP:{APP_ID:wx.getExtConfigSync().appId||10,LOGIN_MAX_RETRY:2},HTTP:{TIMEOUT:5e3},DATA:{PAGE_ID:"wxshot-page-id"},STORAGE_KEYS:{TOKEN:"wxshot-token",BASETOKEN:"wxshot-base-token",USER_INFO:"wxshot-userinfo",SPA_DATA:"wxshot-spadata",LINK_DATA:"wxshot-linkdata",TOP_DATA:"wxshot-topdata"},EVENT_KEYS:{LOGIN_SUCCESS:"wxshot-login-success",AD_DATA_READY:"wxshot-ad-data-ready",REWARDED_VIDEO_AD_CLOSE:"wxshot-rewarded-video-ad-close"}};e.default=n},144(t,e){Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(){this.events={}}return t.prototype.on=function(t,e){if("string"!=typeof t)throw new TypeError("eventName must be a string");if("function"!=typeof e)throw new TypeError("callback must be a function");return this.events[t]||(this.events[t]=[]),this.events[t].push(e),this},t.prototype.emit=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if("string"!=typeof t)throw new TypeError("eventName must be a string");var r=this.events[t];return r&&r.forEach(function(n){try{n.apply(void 0,e)}catch(e){console.error('Error in event "'.concat(t,'" callback:'),e)}}),this},t.prototype.off=function(t,e){if("string"!=typeof t)throw new TypeError("eventName must be a string");return e?(this.events[t]&&(this.events[t]=this.events[t].filter(function(t){return t!==e})),this):(delete this.events[t],this)},t.prototype.once=function(t,e){var n=this;if("string"!=typeof t)throw new TypeError("eventName must be a string");if("function"!=typeof e)throw new TypeError("callback must be a function");var r=function(){for(var o=[],a=0;a<arguments.length;a++)o[a]=arguments[a];n.off(t,r),e.apply(n,o)};return this.on(t,r)},t}();e.default=new n},161(t,e,n){var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)},o=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))(function(o,a){function i(t){try{u(r.next(t))}catch(t){a(t)}}function s(t){try{u(r.throw(t))}catch(t){a(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(i,s)}u((r=r.apply(t,e||[])).next())})},a=this&&this.__generator||function(t,e){var n,r,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=s(0),i.throw=s(1),i.return=s(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}},i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.apiHttpClient=e.baseHttpClient=e.gatewayHttpClient=void 0;var s=i(n(28)),u=function(){function t(t){var e=t.baseURL,n=t.timeout;if(!e)throw new Error("baseURL is required");this.baseURL=e,this.timeout=n||s.default.HTTP.TIMEOUT}return t.prototype.setBaseURL=function(t){this.baseURL=t},t.prototype.wxRequestPromise=function(t){return new Promise(function(e,n){wx.request(r(r({},t),{success:function(t){e(t)},fail:function(t){n(t)}}))})},t.prototype.joinURL=function(t,e){var n=t.replace(/\/+$/,""),r=e.replace(/^\/+/,"");return"".concat(n,"/").concat(r)},t.prototype.request=function(t){return o(this,arguments,void 0,function(t,e,n,o){var i,u,c,l,f,d,h=this;return void 0===e&&(e="GET"),void 0===n&&(n={}),void 0===o&&(o={}),a(this,function(a){switch(a.label){case 0:i=wx.getStorageSync(s.default.STORAGE_KEYS.TOKEN),u={Authorization:i,"Content-Type":"application/json"},c=new Promise(function(t,e){setTimeout(function(){return e(new Error("请求超时"))},h.timeout)}),a.label=1;case 1:return a.trys.push([1,4,,5]),[4,this.wxRequestPromise(r({url:this.joinURL(this.baseURL,t),method:e,data:n,header:r(r({},u),o.headers)},o))];case 2:return l=a.sent(),[4,Promise.race([l,c])];case 3:if((f=a.sent()).statusCode>=200&&f.statusCode<300)return[2,f.data];if(401===f.statusCode)return[2,{code:401,message:"未授权"}];throw new Error(f.data.message||"请求失败");case 4:throw d=a.sent(),console.error("网络错误:",d),wx.showToast({title:d instanceof Error?d.message:"网络错误",icon:"none",duration:2e3}),d;case 5:return[2]}})})},t.prototype.uploadFile=function(t){return o(this,arguments,void 0,function(t,e,n){var r,o,i,u;return void 0===e&&(e={}),void 0===n&&(n="file"),a(this,function(a){r=this.baseURL===s.default.API.GATEWAY_URL,o=wx.getStorageSync(s.default.STORAGE_KEYS.TOKEN),i="avatar"===n?"/avatar":"/file/new",u=this.joinURL(this.baseURL,"".concat(r?"/wx/v1/api":"").concat(i));try{return[2,new Promise(function(n,r){wx.uploadFile({url:u,name:"file",filePath:t,formData:e,header:{"Content-Type":"application/x-www-form-urlencoded",Authorization:o},success:function(t){if(t.statusCode>=200&&t.statusCode<300)n(JSON.parse(t.data));else{if(401!==t.statusCode)throw new Error(t.data.message||"上传失败");n(JSON.parse(t.data))}},fail:function(){throw new Error("网络错误")}}).onProgressUpdate(function(t){console.log("上传进度",t.progress),console.log("已经上传的数据长度",t.totalBytesSent),console.log("预期需要上传的数据总长度",t.totalBytesExpectedToSend)})})]}catch(t){throw console.error("上传失败:",t),wx.showToast({title:t instanceof Error?t.message:"上传失败",icon:"none",duration:2e3}),t}})})},t.prototype.deleteFile=function(t){return o(this,void 0,void 0,function(){var e;return a(this,function(n){return e=this.baseURL===s.default.API.GATEWAY_URL,[2,this.request("".concat(e?"/wx/v1/api":"","/file/del"),"GET",{id:t})]})})},t.prototype.uploadAvatar=function(t){return o(this,void 0,void 0,function(){return a(this,function(e){return[2,this.uploadFile(t,{},"avatar")]})})},t}();e.gatewayHttpClient=new u({baseURL:s.default.API.GATEWAY_URL,timeout:s.default.HTTP.TIMEOUT}),e.baseHttpClient=new u({baseURL:s.default.API.BASE_URL,timeout:s.default.HTTP.TIMEOUT}),e.apiHttpClient=new u({baseURL:s.default.API.API_URL,timeout:s.default.HTTP.TIMEOUT}),e.default=u},156(t,e,n){var r,o=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,o)}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),a=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),i=this&&this.__importStar||(r=function(t){return r=Object.getOwnPropertyNames||function(t){var e=[];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[e.length]=n);return e},r(t)},function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n=r(t),i=0;i<n.length;i++)"default"!==n[i]&&o(e,t,n[i]);return a(e,t),e}),s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.supabase=e.adManager=e.HttpClient=e.apiHttpClient=e.baseHttpClient=e.gatewayHttpClient=e.hijackAllPage=e.hijackApp=e.injectComponent=e.injectPage=e.injectApp=e.waitLogin=e.onLoginReady=void 0;var u=n(859);Object.defineProperty(e,"onLoginReady",{enumerable:!0,get:function(){return u.onLoginReady}}),Object.defineProperty(e,"waitLogin",{enumerable:!0,get:function(){return u.waitLogin}});var c=i(n(161));e.HttpClient=c.default,Object.defineProperty(e,"gatewayHttpClient",{enumerable:!0,get:function(){return c.gatewayHttpClient}}),Object.defineProperty(e,"baseHttpClient",{enumerable:!0,get:function(){return c.baseHttpClient}}),Object.defineProperty(e,"apiHttpClient",{enumerable:!0,get:function(){return c.apiHttpClient}});var l=n(718);Object.defineProperty(e,"injectApp",{enumerable:!0,get:function(){return l.injectApp}}),Object.defineProperty(e,"injectPage",{enumerable:!0,get:function(){return l.injectPage}}),Object.defineProperty(e,"injectComponent",{enumerable:!0,get:function(){return l.injectComponent}}),Object.defineProperty(e,"hijackApp",{enumerable:!0,get:function(){return l.hijackApp}}),Object.defineProperty(e,"hijackAllPage",{enumerable:!0,get:function(){return l.hijackAllPage}});var f=s(n(616));e.adManager=f.default;var d=s(n(140));e.supabase=d.default},718(t,e,n){var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)},o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.hijackAllPage=e.hijackApp=void 0,e.injectApp=s,e.injectPage=u,e.injectComponent=c;var a=n(859),i=o(n(28));function s(t){return void 0===t&&(t={}),function(e){void 0===e&&(e={});var n=e.onLaunch;return e.onLaunch=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];a.initApp.call(this,t).catch(function(t){console.error("应用API初始化失败:",t)}),null==n||n.apply(this,e)},e}}function u(t){return void 0===t&&(t={showInterstitialAd:!1}),function(e){var n;void 0===e&&(e={}),e.data=r(r({},e.data||{}),((n={})[i.default.DATA.PAGE_ID]=Math.random().toString(36).substring(2,7),n));var o=e.onShow;return e.onShow=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];a.showPage.call(this,t,this.data[i.default.DATA.PAGE_ID]).catch(function(t){console.error("页面API初始化失败:",t)}),null==o||o.apply(this,e)},e}}function c(t){return void 0===t&&(t={showInterstitialAd:!1}),function(e){void 0===e&&(e={}),e.methods=e.methods||{};var n=!1,r=e.methods.onLoad;e.methods.onLoad=function(){for(var t,e,o=[],a=0;a<arguments.length;a++)o[a]=arguments[a];(n=!!this.route)&&!(null===(e=this.data)||void 0===e?void 0:e[i.default.DATA.PAGE_ID])&&this.setData(((t={})[i.default.DATA.PAGE_ID]=Math.random().toString(36).substring(2,7),t)),null==r||r.apply(this,o)};var o=e.methods.onShow;return e.methods.onShow=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];n&&a.showPage.call(this,t,this.data[i.default.DATA.PAGE_ID]).catch(function(t){console.error("页面API初始化失败:",t)}),null==o||o.apply(this,e)},e}}e.hijackApp=function(t){void 0===t&&(t={});var e=App;App=function(n){return e(s(t)(n))}};e.hijackAllPage=function(t){void 0===t&&(t={showInterstitialAd:!1});var e=Page;Page=function(n){return e(u(t)(n))};var n=Component;Component=function(e){return n(c(t)(e))}}},140(t,e,n){var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)},o=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))(function(o,a){function i(t){try{u(r.next(t))}catch(t){a(t)}}function s(t){try{u(r.throw(t))}catch(t){a(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(i,s)}u((r=r.apply(t,e||[])).next())})},a=this&&this.__generator||function(t,e){var n,r,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=s(0),i.throw=s(1),i.return=s(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}},i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});var s=i(n(28)),u=n(859),c=function(){function t(t){this._method="GET",this._params={},this._body=null,this._extraHeaders={},this._single=!1,this._maybeSingle=!1,this._rangeFrom=null,this._rangeTo=null,this._table=t}return t.prototype.select=function(t){return void 0===t&&(t="*"),this._method="GET",this._params.select=t,this},t.prototype.eq=function(t,e){return this._params[t]="eq.".concat(e),this},t.prototype.neq=function(t,e){return this._params[t]="neq.".concat(e),this},t.prototype.gt=function(t,e){return this._params[t]="gt.".concat(e),this},t.prototype.lt=function(t,e){return this._params[t]="lt.".concat(e),this},t.prototype.gte=function(t,e){return this._params[t]="gte.".concat(e),this},t.prototype.lte=function(t,e){return this._params[t]="lte.".concat(e),this},t.prototype.like=function(t,e){return this._params[t]="like.".concat(e),this},t.prototype.ilike=function(t,e){return this._params[t]="ilike.".concat(e),this},t.prototype.is=function(t,e){return this._params[t]="is.".concat(e),this},t.prototype.not=function(t,e,n){return this._params[t]="not.".concat(e,".").concat(n),this},t.prototype.or=function(t){return this._params.or="(".concat(t,")"),this},t.prototype.contains=function(t,e){var n=Array.isArray(e)?"{".concat(e.join(","),"}"):JSON.stringify(e);return this._params[t]="cs.".concat(n),this},t.prototype.range=function(t,e){return this._rangeFrom=t,this._rangeTo=e,this},t.prototype.inFilter=function(t,e){return this._params[t]="in.(".concat(e.join(","),")"),this},t.prototype.order=function(t,e){var n=(void 0===e?{}:e).ascending,r=void 0===n||n;return this._params.order="".concat(t,".").concat(r?"asc":"desc"),this},t.prototype.limit=function(t){return this._params.limit=t,this},t.prototype.offset=function(t){return this._params.offset=t,this},t.prototype.single=function(){return this._single=!0,this},t.prototype.maybeSingle=function(){return this._maybeSingle=!0,this},t.prototype.insert=function(t){return this._method="POST",this._body=t,this._extraHeaders.Prefer="return=representation",this},t.prototype.update=function(t){return this._method="PATCH",this._body=t,this._extraHeaders.Prefer="return=representation",this},t.prototype.delete=function(){return this._method="DELETE",this._extraHeaders.Prefer="return=representation",this},t.prototype.upsert=function(t){return this._method="POST",this._body=t,this._extraHeaders.Prefer="resolution=merge-duplicates,return=representation",this},t.prototype.then=function(t,e){return this._execute().then(t,e)},t.prototype.catch=function(t){return this._execute().catch(t)},t.prototype._execute=function(){return o(this,void 0,void 0,function(){var t,e,n,o,i,c=this;return a(this,function(a){switch(a.label){case 0:return[4,(0,u.waitLogin)()];case 1:return a.sent(),t=wx.getStorageSync(s.default.STORAGE_KEYS.BASETOKEN)||"",e=r({apikey:s.default.API.SUPA_ANON_KEY,Authorization:"Bearer ".concat(t),"Content-Type":"application/json"},this._extraHeaders),(this._single||this._maybeSingle)&&(e.Accept="application/vnd.pgrst.object+json"),null!==this._rangeFrom&&null!==this._rangeTo&&(e.Range="".concat(this._rangeFrom,"-").concat(this._rangeTo),e["Range-Unit"]="items",n=e.Prefer,e.Prefer=n?"".concat(n,",count=exact"):"count=exact"),o=Object.entries(this._params).map(function(t){var e=t[0],n=t[1];return"".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(n))}).join("&"),i="".concat(s.default.API.SUPA_URL,"/rest/v1/").concat(this._table).concat(o?"?"+o:""),[2,new Promise(function(t){wx.request({url:i,method:c._method,header:e,data:c._body,success:function(e){var n,r;if(e.statusCode>=200&&e.statusCode<300){var o=(null===(n=e.header)||void 0===n?void 0:n["Content-Range"])||(null===(r=e.header)||void 0===r?void 0:r["content-range"]),a=o&&parseInt(o.split("/")[1])||null;t({data:e.data,error:null,count:a})}else 406===e.statusCode&&c._maybeSingle?t({data:null,error:null,count:null}):t({data:null,error:e.data,count:null})},fail:function(e){t({data:null,error:e,count:null})}})})]}})})},t}(),l={from:function(t){return new c(t)}};e.default=l}},e={};var n=function n(r){var o=e[r];if(void 0!==o)return o.exports;var a=e[r]={exports:{}};return t[r].call(a.exports,a,a.exports,n),a.exports}(156);module.exports=n})();
|