@wxshot/api 0.2.8 → 2.2.6
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 +12 -0
- package/miniprogram_dist/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -205,7 +205,15 @@ declare module '@wxshot/api/supabase' {
|
|
|
205
205
|
neq(col: string, val: any): this;
|
|
206
206
|
gt(col: string, val: any): this;
|
|
207
207
|
lt(col: string, val: any): this;
|
|
208
|
+
gte(col: string, val: any): this;
|
|
209
|
+
lte(col: string, val: any): this;
|
|
208
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;
|
|
209
217
|
inFilter(col: string, vals: any[]): this;
|
|
210
218
|
order(col: string, { ascending }?: {
|
|
211
219
|
ascending?: boolean | undefined;
|
|
@@ -213,16 +221,20 @@ declare module '@wxshot/api/supabase' {
|
|
|
213
221
|
limit(n: number): this;
|
|
214
222
|
offset(n: number): this;
|
|
215
223
|
single(): this;
|
|
224
|
+
maybeSingle(): this;
|
|
216
225
|
insert(data: Record<string, any> | Record<string, any>[]): this;
|
|
217
226
|
update(data: Record<string, any>): this;
|
|
218
227
|
delete(): this;
|
|
228
|
+
upsert(data: Record<string, any> | Record<string, any>[]): this;
|
|
219
229
|
then<T>(resolve: (val: {
|
|
220
230
|
data: T | null;
|
|
221
231
|
error: any;
|
|
232
|
+
count: number | null;
|
|
222
233
|
}) => void, reject?: (err: any) => void): Promise<void>;
|
|
223
234
|
catch(reject: (err: any) => void): Promise<void | {
|
|
224
235
|
data: any;
|
|
225
236
|
error: any;
|
|
237
|
+
count: number | null;
|
|
226
238
|
}>;
|
|
227
239
|
}
|
|
228
240
|
const supabase: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* @wxshot/api v2.0.9
|
|
3
3
|
*
|
|
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})();
|
|
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="*"),["POST","PATCH","DELETE"].includes(this._method)||(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})();
|