@wxshot/api 0.2.0 → 0.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,295 +1,328 @@
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
- export { onLoginReady, waitLogin, injectApp, injectPage, injectComponent, hijackApp, hijackAllPage, gatewayHttpClient, baseHttpClient, apiHttpClient, HttpClient, adManager, };
9
- }
10
-
11
- declare module '@wxshot/api/app' {
12
- export interface AppOptions {
13
- gatewayUrl?: string;
14
- baseUrl?: string;
15
- apiUrl?: string;
16
- }
17
- export interface PageOptions {
18
- showInterstitialAd?: boolean;
19
- }
20
- export function initApp(options?: AppOptions): Promise<void>;
21
- export function showPage(options: PageOptions | undefined, pageId: string): Promise<void>;
22
- export const checkTokenValid: () => boolean;
23
- /**
24
- * 确保登录完成
25
- * @param {Function} callback - 回调函数
26
- * @returns {void}
27
- */
28
- export function onLoginReady(callback: (...args: any[]) => void): void;
29
- /**
30
- * 等待登录完成
31
- * @returns {Promise<void>}
32
- */
33
- export function waitLogin(): Promise<void>;
34
- export function login(): Promise<void>;
35
- export function fetchEchoData(): Promise<void>;
36
- export function trackVisit(): Promise<void>;
37
- }
38
-
39
- declare module '@wxshot/api/httpClient' {
40
- import { HttpClientOptions, RequestOptions, ApiResponse } from '@wxshot/api/types';
41
- class HttpClient {
42
- constructor({ baseURL, timeout }: HttpClientOptions);
43
- setBaseURL(baseURL: string): void;
44
- /**
45
- * 请求
46
- * @param {string} path 路径
47
- * @param {string} method 方法, 默认GET
48
- * @param {Object} data 数据, 默认{}
49
- * @param {Object} options 传入wx.request的其他配置, 默认{}
50
- * @returns {Promise<Object>} 返回一个Promise对象
51
- */
52
- request<T = any>(path: string, method?: WechatMiniprogram.RequestOption['method'], data?: Record<string, any>, options?: RequestOptions): Promise<ApiResponse<T>>;
53
- /**
54
- * 上传文件
55
- * @param {string} filePath 文件路径
56
- * @param {Object} data 数据, 默认{}
57
- * @param {'avatar' | 'file'} type 类型, 默认'file'
58
- * @returns {Promise<Object>} 返回一个Promise对象
59
- */
60
- uploadFile<T = any>(filePath: string, data?: Record<string, any>, type?: 'avatar' | 'file'): Promise<ApiResponse<T>>;
61
- /**
62
- * 上传文件
63
- * @param {string} filePath 文件路径
64
- * @param {Object} data 数据, 默认{}
65
- * @param {'avatar' | 'file'} type 类型, 默认'file'
66
- * @returns {Promise<Object>} 返回一个Promise对象
67
- */
68
- upload<T = any>(path: string, filePath: string, data?: Record<string, any>): Promise<ApiResponse<T>>;
69
- /**
70
- * 删除文件
71
- * @param {number} fileId 文件id
72
- * @returns {Promise<Object>} 返回一个Promise对象
73
- */
74
- deleteFile(fileId: number): Promise<ApiResponse<null>>;
75
- /**
76
- * 上传头像
77
- * @param {string} filePath 文件路径
78
- * @returns {Promise<Object>} 返回一个Promise对象
79
- */
80
- uploadAvatar<T = any>(filePath: string): Promise<ApiResponse<T>>;
81
- }
82
- export const gatewayHttpClient: HttpClient;
83
- export const baseHttpClient: HttpClient;
84
- export const apiHttpClient: HttpClient;
85
- export default HttpClient;
86
- }
87
-
88
- declare module '@wxshot/api/injector' {
89
- interface AppConfig {
90
- onLaunch?: (...args: any[]) => void | Promise<void>;
91
- [key: string]: any;
92
- }
93
- interface PageConfig {
94
- onShow?: (...args: any[]) => void | Promise<void>;
95
- [key: string]: any;
96
- }
97
- interface ComponentConfig {
98
- methods?: {
99
- onLoad?: (...args: any[]) => void | Promise<void>;
100
- onShow?: (...args: any[]) => void | Promise<void>;
101
- [key: string]: any;
102
- };
103
- [key: string]: any;
104
- }
105
- interface InjectAppOptions {
106
- gatewayUrl?: string;
107
- baseUrl?: string;
108
- apiUrl?: string;
109
- }
110
- interface InjectPageOptions {
111
- showInterstitialAd?: boolean;
112
- }
113
- /**
114
- * 注入应用配置
115
- * @param {Object} options - 配置选项
116
- * @param {string} [options.gatewayUrl] - 网关地址,默认使用CONFIG.API.GATEWAY_URL
117
- * @param {string} [options.baseUrl] - 基础地址,默认使用CONFIG.API.BASE_URL
118
- * @param {string} [options.apiUrl] - api地址,默认使用CONFIG.API.API_URL
119
- * @returns {Function} 返回一个接收应用配置的函数
120
- */
121
- export function injectApp(options?: InjectAppOptions): (appConfig: AppConfig) => AppConfig;
122
- /**
123
- * 注入页面配置
124
- * @param {InjectPageOptions} options - 配置选项
125
- * @param {boolean} [options.showInterstitialAd] - 是否在onShow显示插屏广告,默认不显示
126
- * @returns {Function} 返回一个接收页面配置的函数
127
- */
128
- export function injectPage(options?: InjectPageOptions): (pageConfig?: PageConfig) => PageConfig;
129
- /**
130
- * 注入组件配置
131
- * @param {InjectPageOptions} options - 配置选项
132
- * @param {boolean} [options.showInterstitialAd] - 是否在onShow显示插屏广告,默认不显示
133
- * @returns {Function} 返回一个接收组件配置的函数
134
- */
135
- export function injectComponent(options?: InjectPageOptions): (pageConfig?: PageConfig) => ComponentConfig;
136
- /**
137
- * 劫持App
138
- * @param {InjectAppOptions} options - 配置选项
139
- * @param {string} [options.gatewayUrl] - 网关地址,默认使用CONFIG.API.GATEWAY_URL
140
- * @param {string} [options.baseUrl] - 基础地址,默认使用CONFIG.API.BASE_URL
141
- * @param {string} [options.apiUrl] - api地址,默认使用CONFIG.API.API_URL
142
- * @returns {void}
143
- */
144
- export const hijackApp: (options?: InjectAppOptions) => void;
145
- /**
146
- * 劫持所有Page
147
- * @param {InjectPageOptions} options - 配置选项
148
- * @param {boolean} [options.showInterstitialAd] - 是否在onShow显示插屏广告,默认不显示
149
- * @returns {void}
150
- */
151
- export const hijackAllPage: (options?: InjectPageOptions) => void;
152
- export {};
153
- }
154
-
155
- declare module '@wxshot/api/adManager' {
156
- import { AdData, LinkData, TopData } from '@wxshot/api/types';
157
- type Ads = Partial<Record<AdData['appPage'], AdData['ads'][0]['adUnitId']>>;
158
- class AdManager {
159
- /**
160
- * 广告数据
161
- */
162
- ads: Ads;
163
- /**
164
- * 友情链接数据
165
- */
166
- link: LinkData[];
167
- /**
168
- * 友情链接顶部广告数据
169
- */
170
- top: TopData | null;
171
- constructor();
172
- /**
173
- * 确保广告数据就绪
174
- * @param {Function} callback - 回调函数
175
- * @returns {void}
176
- */
177
- onDataReady: (callback: (...args: any[]) => void) => void;
178
- /**
179
- * 等待广告数据加载完成
180
- * @returns {Promise<void>}
181
- */
182
- waitAdData: () => Promise<void>;
183
- /**
184
- * 初始化广告数据
185
- * @returns {void}
186
- */
187
- init: () => void;
188
- /**
189
- * 创建并展示插屏广告
190
- * @returns {Promise<void>}
191
- */
192
- createAndShowInterstitialAd: () => Promise<void>;
193
- /**
194
- * 创建并展示激励视频广告
195
- * @param {any} context - 页面上下文
196
- * @param {string} [pageId] - 页面ID
197
- * @returns {Promise<boolean>} 是否完成播放
198
- */
199
- createAndShowRewardedVideoAd: (context: any, pageId?: string) => Promise<boolean>;
200
- }
201
- const _default: AdManager;
202
- export default _default;
203
- }
204
-
205
- declare module '@wxshot/api/types' {
206
- export interface Config {
207
- API: {
208
- GATEWAY_URL: string;
209
- BASE_URL: string;
210
- API_URL: string;
211
- };
212
- APP: {
213
- APP_ID: number;
214
- LOGIN_MAX_RETRY: number;
215
- };
216
- HTTP: {
217
- TIMEOUT: number;
218
- };
219
- DATA: {
220
- PAGE_ID: string;
221
- };
222
- STORAGE_KEYS: {
223
- TOKEN: string;
224
- USER_INFO: string;
225
- SPA_DATA: string;
226
- LINK_DATA: string;
227
- TOP_DATA: string;
228
- };
229
- EVENT_KEYS: {
230
- LOGIN_SUCCESS: string;
231
- AD_DATA_READY: string;
232
- REWARDED_VIDEO_AD_CLOSE: string;
233
- };
234
- }
235
- export interface HttpClientOptions {
236
- baseURL: string;
237
- timeout?: number;
238
- }
239
- export interface RequestOptions {
240
- headers?: Record<string, string>;
241
- [key: string]: any;
242
- }
243
- export interface LoginData {
244
- appId: number;
245
- code: string;
246
- brand: string;
247
- model: string;
248
- platform: string;
249
- }
250
- export interface ApiResponse<T = any> {
251
- code: number;
252
- message?: string;
253
- data?: T;
254
- }
255
- export interface UserInfo {
256
- token: string;
257
- user: {
258
- id: number;
259
- name: string;
260
- avatar: string;
261
- openId: string;
262
- };
263
- }
264
- export interface EchoData {
265
- isPublished: boolean;
266
- spads: AdData[];
267
- links: LinkData[];
268
- top: TopData;
269
- version: number;
270
- }
271
- export interface AdData {
272
- id: number;
273
- status: number;
274
- appPage: 'banner' | 'custom' | 'video' | 'interstitial' | 'rewarded';
275
- ads: {
276
- id: number;
277
- type: number;
278
- adId: number;
279
- adUnitId: string;
280
- }[];
281
- }
282
- export interface LinkData {
283
- appId: string;
284
- appLogo: string;
285
- linkName: string;
286
- linkPage: string;
287
- }
288
- export interface TopData {
289
- appId: string;
290
- appLogo: string;
291
- linkName: string;
292
- appDsc: string;
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
+ like(col: string, pattern: string): this;
209
+ inFilter(col: string, vals: any[]): this;
210
+ order(col: string, { ascending }?: {
211
+ ascending?: boolean | undefined;
212
+ }): this;
213
+ limit(n: number): this;
214
+ offset(n: number): this;
215
+ single(): this;
216
+ insert(data: Record<string, any> | Record<string, any>[]): this;
217
+ update(data: Record<string, any>): this;
218
+ delete(): this;
219
+ then<T>(resolve: (val: {
220
+ data: T | null;
221
+ error: any;
222
+ }) => void, reject?: (err: any) => void): Promise<void>;
223
+ catch(reject: (err: any) => void): Promise<void | {
224
+ data: any;
225
+ error: any;
226
+ }>;
227
+ }
228
+ const supabase: {
229
+ from(table: string): QueryBuilder;
230
+ };
231
+ export default supabase;
232
+ }
233
+
234
+ declare module '@wxshot/api/types' {
235
+ export interface Config {
236
+ API: {
237
+ GATEWAY_URL: string;
238
+ BASE_URL: string;
239
+ API_URL: string;
240
+ SUPA_URL: string;
241
+ SUPA_ANON_KEY: string;
242
+ };
243
+ APP: {
244
+ APP_ID: number;
245
+ LOGIN_MAX_RETRY: number;
246
+ };
247
+ HTTP: {
248
+ TIMEOUT: number;
249
+ };
250
+ DATA: {
251
+ PAGE_ID: string;
252
+ };
253
+ STORAGE_KEYS: {
254
+ TOKEN: string;
255
+ BASETOKEN: string;
256
+ USER_INFO: string;
257
+ SPA_DATA: string;
258
+ LINK_DATA: string;
259
+ TOP_DATA: string;
260
+ };
261
+ EVENT_KEYS: {
262
+ LOGIN_SUCCESS: string;
263
+ AD_DATA_READY: string;
264
+ REWARDED_VIDEO_AD_CLOSE: string;
265
+ };
266
+ }
267
+ export interface HttpClientOptions {
268
+ baseURL: string;
269
+ timeout?: number;
270
+ }
271
+ export interface RequestOptions {
272
+ headers?: Record<string, string>;
273
+ [key: string]: any;
274
+ }
275
+ export interface LoginData {
276
+ appId: number;
277
+ code: string;
278
+ brand: string;
279
+ model: string;
280
+ platform: string;
281
+ }
282
+ export interface ApiResponse<T = any> {
283
+ code: number;
284
+ message?: string;
285
+ data?: T;
286
+ }
287
+ export interface UserInfo {
288
+ token: string;
289
+ base_token: string;
290
+ user: {
291
+ id: number;
292
+ name: string;
293
+ avatar: string;
294
+ openId: string;
295
+ };
296
+ }
297
+ export interface EchoData {
298
+ isPublished: boolean;
299
+ spads: AdData[];
300
+ links: LinkData[];
301
+ top: TopData;
302
+ version: number;
303
+ }
304
+ export interface AdData {
305
+ id: number;
306
+ status: number;
307
+ appPage: 'banner' | 'custom' | 'video' | 'interstitial' | 'rewarded';
308
+ ads: {
309
+ id: number;
310
+ type: number;
311
+ adId: number;
312
+ adUnitId: string;
313
+ }[];
314
+ }
315
+ export interface LinkData {
316
+ appId: string;
317
+ appLogo: string;
318
+ linkName: string;
319
+ linkPage: string;
320
+ }
321
+ export interface TopData {
322
+ appId: string;
323
+ appLogo: string;
324
+ linkName: string;
325
+ appDsc: string;
326
+ }
327
+ }
328
+
@@ -1,4 +1,4 @@
1
1
  /*!
2
- * @wxshot/api v1.0.10
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.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.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",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,w()];case 2:return e.sent(),[2]}})})},e.onLoginReady=f,e.waitLogin=d,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 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 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",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._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.like=function(t,e){return this._params[t]="like.".concat(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.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.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=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&&(e.Accept="application/vnd.pgrst.object+json"),n=Object.entries(this._params).map(function(t){var e=t[0],n=t[1];return"".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(n))}).join("&"),o="".concat(s.default.API.SUPA_URL,"/rest/v1/").concat(this._table).concat(n?"?"+n:""),[2,new Promise(function(t){wx.request({url:o,method:i._method,header:e,data:i._body,success:function(e){e.statusCode>=200&&e.statusCode<300?t({data:e.data,error:null}):t({data:null,error:e.data})},fail:function(e){t({data:null,error:e})}})})]}})})},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})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wxshot/api",
3
- "version": "0.2.0",
3
+ "version": "0.2.8",
4
4
  "main": "miniprogram_dist/index.js",
5
5
  "files": [
6
6
  "miniprogram_dist"