@etspress/netflix 0.1.22 → 0.1.24

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etspress/netflix",
3
- "version": "0.1.22",
3
+ "version": "0.1.24",
4
4
  "private": false,
5
5
  "description": "流媒体合租主题插件",
6
6
  "license": "MIT",
@@ -18,7 +18,7 @@
18
18
  "id": "netflix",
19
19
  "name": "流媒体合租主题",
20
20
  "description": "流媒体合租商店主题与页面展示配置",
21
- "version": "0.1.22",
21
+ "version": "0.1.24",
22
22
  "runtime": {
23
23
  "type": "npm-static",
24
24
  "publicRoot": "public"
package/plugin.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "schemaVersion": 1,
4
4
  "id": "netflix",
5
5
  "name": "流媒体合租主题",
6
- "version": "0.1.22",
6
+ "version": "0.1.24",
7
7
  "description": "流媒体合租商店主题与页面展示配置。",
8
8
  "author": "D&J Studio",
9
9
  "license": "MIT",
@@ -155,6 +155,28 @@
155
155
  #netflix-theme-home.nfc-console .nfc-profile-form input:focus,#netflix-theme-home.nfc-console .nfc-profile-form select:focus,.nfc-console .nfc-auth-field input:focus{border-color:#ed7776;box-shadow:0 0 0 3px #ed4f5117}
156
156
  #netflix-theme-home.nfc-console .nfc-profile-form input[readonly]{color:#999;background:#f8f8f8}
157
157
  #netflix-theme-home.nfc-console .nfc-profile-form .nfc-primary{justify-self:start}
158
+ #netflix-theme-home.nfc-console .nfc-payment-grid{display:grid;grid-template-columns:minmax(0,1.15fr) minmax(280px,.85fr);gap:14px}
159
+ #netflix-theme-home.nfc-console .nfc-payment-grid .nfc-panel{padding:20px;border-radius:12px}
160
+ #netflix-theme-home.nfc-console .nfc-payment-order h2,#netflix-theme-home.nfc-console .nfc-payment-methods h2{margin:0 0 14px;color:#222;font-size:17px;font-weight:600}
161
+ #netflix-theme-home.nfc-console .nfc-payment-order>div{display:flex;justify-content:space-between;gap:12px;padding:10px 0;border-top:1px solid #eee;font-size:13px}
162
+ #netflix-theme-home.nfc-console .nfc-payment-order>div span{color:#888}
163
+ #netflix-theme-home.nfc-console .nfc-payment-order>div strong{min-width:0;text-align:right;overflow-wrap:anywhere}
164
+ #netflix-theme-home.nfc-console .nfc-payment-order .nfc-payment-amount{color:#ed4f51;font-size:20px}
165
+ #netflix-theme-home.nfc-console .nfc-payment-channels{display:grid;gap:8px;margin-bottom:14px}
166
+ #netflix-theme-home.nfc-console .nfc-payment-channel{display:flex;min-height:48px;flex-direction:column;align-items:flex-start;justify-content:center;gap:2px;padding:8px 12px;border:1px solid #e5e5e5;border-radius:8px;background:#fff;color:#333;text-align:left;cursor:pointer}
167
+ #netflix-theme-home.nfc-console .nfc-payment-channel.is-selected{border-color:#ef5350;background:#fff7f7;box-shadow:0 0 0 1px #ef535022}
168
+ #netflix-theme-home.nfc-console .nfc-payment-channel small{color:#888;font-size:11px}
169
+ #netflix-theme-home.nfc-console .nfc-payment-result,.nfc-console .nfc-payment-success{display:grid;justify-items:center;gap:12px;padding:22px;text-align:center}
170
+ #netflix-theme-home.nfc-console .nfc-payment-result h2{margin:0;font-size:18px}
171
+ #netflix-theme-home.nfc-console .nfc-payment-result>p{margin:0;color:#777;font-size:13px}
172
+ #netflix-theme-home.nfc-console .nfc-payment-result>p strong{color:#ed4f51;font-size:18px}
173
+ #netflix-theme-home.nfc-console .nfc-payment-pending{color:#999;font-size:12px}
174
+ #netflix-theme-home.nfc-console .nfc-payment-qr{width:190px;height:190px;padding:8px;border:1px solid #eee;border-radius:8px;background:#fff;object-fit:contain}
175
+ #netflix-theme-home.nfc-console .nfc-payment-success{min-height:260px}
176
+ #netflix-theme-home.nfc-console .nfc-payment-success h1{margin:0;font-size:24px}
177
+ #netflix-theme-home.nfc-console .nfc-payment-success-icon{display:grid;width:60px;height:60px;place-items:center;border-radius:50%;background:#e9f8ef;color:#31a667;font-size:34px}
178
+ #netflix-theme-home.nfc-console .nfc-payment-success strong{color:#ed4f51;font-size:22px}
179
+ #netflix-theme-home.nfc-console .nfc-payment-loading,#netflix-theme-home.nfc-console .nfc-payment-empty,#netflix-theme-home.nfc-console .nfc-payment-error{padding:24px;border-radius:12px;background:#fff;text-align:center;color:#777}
158
180
  #netflix-theme-home.nfc-console .nfc-form-message{min-height:18px;color:#d74747;font-size:12px}
159
181
  #netflix-theme-home.nfc-auth{min-height:100vh;background:#f7f7f8}
160
182
  #netflix-theme-home.nfc-auth .nfh-header{position:relative}
@@ -181,6 +203,7 @@
181
203
  #netflix-theme-home.nfc-console .nfc-account-hero{padding:14px;gap:10px}
182
204
  #netflix-theme-home.nfc-console .nfc-account-hero>a{font-size:12px;white-space:nowrap}
183
205
  #netflix-theme-home.nfc-console .nfc-account-grid{grid-template-columns:1fr}
206
+ #netflix-theme-home.nfc-console .nfc-payment-grid{grid-template-columns:1fr}
184
207
  #netflix-theme-home.nfc-console .nfc-wallet-balance{align-items:flex-start;flex-wrap:wrap;gap:16px}
185
208
  #netflix-theme-home.nfc-console .nfc-wallet-balance>div{min-width:calc(50% - 10px)}
186
209
  #netflix-theme-home.nfc-auth .nfc-auth-main{min-height:calc(100vh - 126px);padding:22px 12px}
package/public/console.js CHANGED
@@ -28,15 +28,24 @@
28
28
  var walletTransactions = [];
29
29
  var walletPage = 1;
30
30
  var walletPageSize = 10;
31
+ var paymentPollTimer = null;
32
+ var paymentOrderNo = '';
33
+ var paymentChannelId = '';
34
+ var paymentSubmitting = false;
35
+ var paymentResult = null;
31
36
  var authConfig = {};
32
37
  var captchaData = {};
33
38
  var captchaImage = '';
34
39
  var authChallengeToken = '';
35
40
  var authInviteTicket = '';
41
+ var homeConfigCache = null;
42
+ var homeConfigCacheAt = 0;
43
+ var homeConfigRequest = null;
36
44
 
37
45
  function isThemeRoute(path) {
38
46
  path = path || location.pathname;
39
- return ['/me/orders', '/me/affiliate', '/me/wallet', '/me', '/me/profile', '/auth/login', '/auth/register'].indexOf(path) >= 0 && !(['/me/affiliate', '/auth/login', '/auth/register'].indexOf(path) >= 0 && new URLSearchParams(location.search).get('native') === '1');
47
+ var params = new URLSearchParams(location.search);
48
+ return ['/me/orders', '/me/affiliate', '/me/wallet', '/me', '/me/profile', '/auth/login', '/auth/register', '/pay'].indexOf(path) >= 0 && !(['/me/affiliate', '/auth/login', '/auth/register', '/pay'].indexOf(path) >= 0 && (params.get('native') === '1' || (path === '/pay' && params.get('guest') === '1')));
40
49
  }
41
50
 
42
51
  function animateThemePage(element) {
@@ -126,6 +135,8 @@
126
135
  }
127
136
 
128
137
  function clearPage() {
138
+ if (paymentPollTimer) window.clearInterval(paymentPollTimer);
139
+ paymentPollTimer = null;
129
140
  // The homepage owns the shared loading gate until its theme is ready.
130
141
  if (typeof window.__DUJIAO_RELEASE_CONSOLE_GATE__ === 'function' && location.pathname !== '/' && !isThemeRoute()) window.__DUJIAO_RELEASE_CONSOLE_GATE__();
131
142
  if (root) root.remove();
@@ -135,6 +146,7 @@
135
146
  }
136
147
  hostStateSaved = false;
137
148
  document.documentElement.classList.remove('nfc-active');
149
+ if (!isThemeRoute() && typeof window.__NETFLIX_THEME_RELEASE_ROUTE_GATE__ === 'function') window.__NETFLIX_THEME_RELEASE_ROUTE_GATE__();
138
150
  root = null;
139
151
  host = null;
140
152
  }
@@ -157,6 +169,24 @@
157
169
  });
158
170
  }
159
171
 
172
+ function loadThemeHomeConfig() {
173
+ if (homeConfigCache && Date.now() - homeConfigCacheAt < 60000) return Promise.resolve(homeConfigCache);
174
+ if (homeConfigRequest) return homeConfigRequest;
175
+ homeConfigRequest = fetch('/plugins/appstore/api/plugins/netflix/public-home-config', { cache: 'no-store' })
176
+ .then(function (response) {
177
+ if (!response.ok) throw new Error('主题配置暂不可用');
178
+ return response.json();
179
+ })
180
+ .then(function (payload) {
181
+ homeConfigCache = payload && payload.config || {};
182
+ homeConfigCacheAt = Date.now();
183
+ return homeConfigCache;
184
+ })
185
+ .catch(function () { return homeConfigCache || {}; })
186
+ .finally(function () { homeConfigRequest = null; });
187
+ return homeConfigRequest;
188
+ }
189
+
160
190
  function openAffiliate() {
161
191
  var headers = apiHeaders();
162
192
  headers['Content-Type'] = 'application/json';
@@ -255,6 +285,8 @@
255
285
  language.addEventListener('change', function () { localStorage.setItem('locale', language.value); location.reload(); });
256
286
  root.querySelector('.nfc-to-top').addEventListener('click', function () { window.scrollTo({ top: 0, behavior: 'smooth' }); });
257
287
  document.documentElement.classList.add('nfc-active');
288
+ document.documentElement.classList.remove('nfc-route-pending');
289
+ if (typeof window.__NETFLIX_THEME_RELEASE_ROUTE_GATE__ === 'function') window.__NETFLIX_THEME_RELEASE_ROUTE_GATE__();
258
290
  host = document.querySelector('#app');
259
291
  if (host) {
260
292
  if (!hostStateSaved) {
@@ -581,6 +613,39 @@
581
613
  apiRequest('/me').then(function (body) { if (token !== sequence || location.pathname !== '/me/profile') return; accountProfile = responseData(body); renderProfile(); }).catch(function (error) { if (token !== sequence || location.pathname !== '/me/profile') return; errorText = error.message; renderProfile(); });
582
614
  }
583
615
 
616
+ function loadPayment() {
617
+ paymentOrderNo = new URLSearchParams(location.search).get('order_no') || '';
618
+ paymentChannelId = '';
619
+ paymentResult = null;
620
+ if (!paymentOrderNo) { pageReady('payment', '<section class="nfc-panel nfc-payment-empty">订单编号缺失,请从订单列表重新进入支付。</section>'); return; }
621
+ pageReady('payment', '<section class="nfc-panel nfc-payment-loading">正在读取订单与支付信息…</section>');
622
+ requestJson('/api/v1/orders/' + encodeURIComponent(paymentOrderNo)).then(function(body) {
623
+ var order = responseData(body) || {};
624
+ var paid = ['paid','fulfilling','partially_delivered','delivered','completed'].indexOf(order.status) >= 0;
625
+ if (paid) { renderPaymentSuccess(order); return; }
626
+ if (order.status && order.status !== 'pending_payment') { pageReady('payment','<section class="nfc-panel nfc-payment-error">当前订单状态为 '+escapeHtml(statusName(order.status))+',无法继续支付。<a href="/me/orders">返回我的车票</a></section>'); return; }
627
+ var amount = order.pay_amount || order.total_amount || order.amount || '0';
628
+ return Promise.allSettled([
629
+ fetch('/api/v1/order/payment-channels',{method:'POST',credentials:'include',headers:Object.assign({'Content-Type':'application/json'},apiHeaders()),body:JSON.stringify({order_no:paymentOrderNo,amount:amount})}).then(function(r){return r.json().catch(function(){return {}})}),
630
+ requestJson('/api/v1/payments/latest?order_no='+encodeURIComponent(paymentOrderNo))
631
+ ]).then(function(results){var channelsBody=results[0].status==='fulfilled'?results[0].value:{};paymentResult=results[1].status==='fulfilled'?responseData(results[1].value):null;if(paymentResult&&paymentResult.payment_id)paymentChannelId=String(paymentResult.channel_id||'');renderPaymentPage(order,responseData(channelsBody)||[]);if(paymentResult){if(paymentPollTimer)clearInterval(paymentPollTimer);paymentPollTimer=window.setInterval(function(){requestJson('/api/v1/orders/'+encodeURIComponent(paymentOrderNo)).then(function(res){var latest=responseData(res)||{};if(['paid','fulfilling','partially_delivered','delivered','completed'].indexOf(latest.status)>=0){clearPage();renderPaymentSuccess(latest)}}).catch(function(){})},5000)}});
632
+ }).catch(function(error){pageReady('payment','<section class="nfc-panel nfc-payment-error">'+escapeHtml(error.message||'订单信息读取失败')+'</section>')});
633
+ }
634
+
635
+ function renderPaymentPage(order, channels) {
636
+ channels=Array.isArray(channels)?channels:[];
637
+ var channelMarkup=channels.map(function(channel,index){var id=String(channel.id||channel.channel_id||'');return '<button type="button" class="nfc-payment-channel'+(id===paymentChannelId?' is-selected':'')+'" data-payment-channel="'+escapeHtml(id)+'"><strong>'+escapeHtml(channel.name||channel.title||channel.channel_name||'支付方式 '+(index+1))+'</strong><small>'+escapeHtml(channel.description||'在线支付')+'</small></button>'}).join('');
638
+ var resultMarkup=paymentResult?'<section class="nfc-panel nfc-payment-result"><h2>请完成支付</h2><p>支付金额 <strong>'+escapeHtml(formatMoney(paymentResult.pay_amount||paymentResult.amount||order.pay_amount||order.total_amount))+'</strong></p>'+(paymentResult.qr_code?'<img class="nfc-payment-qr" data-payment-qr alt="支付二维码">':'')+(paymentResult.pay_url?'<a class="nfc-primary" href="'+escapeHtml(safeLink(paymentResult.pay_url))+'" target="_blank" rel="noopener">打开支付页面</a>':'')+'<p class="nfc-payment-pending">等待原生系统确认支付…</p></section>':'';
639
+ var content='<div class="nfc-section-title"><h1>订单支付</h1><a class="nfc-refresh" href="/me/orders">返回车票</a></div><div class="nfc-payment-grid"><section class="nfc-panel nfc-payment-order"><h2>订单信息</h2><div><span>订单编号</span><strong>'+escapeHtml(order.order_no||paymentOrderNo)+'</strong></div><div><span>商品</span><strong>'+escapeHtml(orderItemLabel(order))+'</strong></div><div><span>订单金额</span><strong class="nfc-payment-amount">'+escapeHtml(formatMoney(order.pay_amount||order.total_amount||order.amount))+'</strong></div></section><section class="nfc-panel nfc-payment-methods"><h2>选择支付方式</h2><div class="nfc-payment-channels">'+(channelMarkup||'<p>未获取到在线支付方式,请刷新订单或联系站点客服。</p>')+'</div><button type="button" class="nfc-primary" data-submit-payment'+(paymentSubmitting?' disabled':'')+'>'+(paymentSubmitting?'正在创建支付…':'确认支付')+'</button><p class="nfc-payment-error" aria-live="polite"></p></section></div>'+resultMarkup;
640
+ pageReady('payment',content);
641
+ root.querySelectorAll('[data-payment-channel]').forEach(function(button){button.onclick=function(){paymentChannelId=button.dataset.paymentChannel;renderPaymentPage(order,channels)}});
642
+ var qr=root.querySelector('[data-payment-qr]'); if(qr&&paymentResult.qr_code){if(/^https?:\/\//i.test(paymentResult.qr_code)||/^data:image\//i.test(paymentResult.qr_code))qr.src=paymentResult.qr_code;else if(window.qrcode){var code=window.qrcode(0,'M');code.addData(paymentResult.qr_code);code.make();qr.src=code.createDataURL(5,2)}}
643
+ var submit=root.querySelector('[data-submit-payment]'); if(submit)submit.onclick=function(){paymentSubmitting=true;renderPaymentPage(order,channels);fetch('/api/v1/payments',{method:'POST',credentials:'include',headers:Object.assign({'Content-Type':'application/json'},apiHeaders()),body:JSON.stringify({order_no:paymentOrderNo,channel_id:paymentChannelId||undefined,use_balance:false})}).then(function(r){return r.json()}).then(function(result){if(result.status_code&&result.status_code!==0)throw Error(result.msg||'支付创建失败');paymentSubmitting=false;paymentResult=responseData(result)||{};renderPaymentPage(order,channels);if(paymentPollTimer)clearInterval(paymentPollTimer);paymentPollTimer=window.setInterval(function(){requestJson('/api/v1/orders/'+encodeURIComponent(paymentOrderNo)).then(function(res){var latest=responseData(res)||{};if(['paid','fulfilling','partially_delivered','delivered','completed'].indexOf(latest.status)>=0){clearPage();renderPaymentSuccess(latest)}}).catch(function(){})},5000)}).catch(function(err){paymentSubmitting=false;renderPaymentPage(order,channels);var errorNode=root&&root.querySelector('.nfc-payment-error');if(errorNode)errorNode.textContent=err.message||'支付创建失败'})};
644
+ }
645
+
646
+ function safeLink(value){try{var url=new URL(value,location.origin);return url.protocol==='https:'||url.protocol==='http:'?url.href:'#'}catch(_error){return '#'}}
647
+ function renderPaymentSuccess(order){pageReady('payment-success','<section class="nfc-panel nfc-payment-success"><div class="nfc-payment-success-icon">✓</div><h1>支付成功</h1><p>订单 '+escapeHtml(order.order_no||paymentOrderNo)+' 已支付</p><strong>'+escapeHtml(formatMoney(order.pay_amount||order.total_amount||order.amount))+'</strong><a class="nfc-primary" href="/me/orders">查看我的车票</a></section>')}
648
+
584
649
  function loadWallet() {
585
650
  if (!requireAccount()) return;
586
651
  var token = ++sequence;
@@ -609,12 +674,13 @@
609
674
  root = document.createElement('div'); root.id = 'netflix-theme-home'; root.className = 'nfc-console nfc-auth';
610
675
  var brand = homeConfig.brandLogoUrl ? '<img src="' + escapeHtml(homeConfig.brandLogoUrl) + '" alt="' + escapeHtml(homeConfig.brandName || '奈飞小铺') + '">' : escapeHtml(homeConfig.brandName || '奈飞小铺');
611
676
  root.innerHTML = '<header class="nfh-header"><nav class="nfh-header-inner"><a class="nfh-logo" href="/">' + brand + '</a><div class="nfh-header-right"><div class="nfh-header-nav"><a href="/">' + escapeHtml(homeConfig.navHomeLabel || '首页') + '</a><a href="/me/orders">' + escapeHtml(homeConfig.navProductsLabel || '车票') + '</a><a href="/me/affiliate">' + escapeHtml(homeConfig.navPromotionLabel || '推广') + '</a></div></div></nav></header><main class="nfc-auth-main"><section class="nfc-auth-card"><a class="nfc-auth-back" href="/">‹ 返回首页</a>' + content + '</section></main><footer class="nfc-auth-footer">' + escapeHtml(homeConfig.copyrightText || '© 2019 - 2026 奈飞小铺') + '</footer>';
612
- document.body.appendChild(root); document.documentElement.classList.add('nfc-active'); document.documentElement.classList.remove('nfc-auth-route-pending'); animateThemePage(root.querySelector('.nfc-auth-card'));
677
+ document.body.appendChild(root); document.documentElement.classList.add('nfc-active'); document.documentElement.classList.remove('nfc-auth-route-pending'); document.documentElement.classList.remove('nfc-route-pending'); animateThemePage(root.querySelector('.nfc-auth-card'));
613
678
  host = document.querySelector('#app'); if (host) {
614
679
  if (!hostStateSaved) { hostDisplay = host.style.display; hostVisibility = host.style.visibility; hostStateSaved = true; }
615
680
  host.style.visibility = ''; host.style.display = 'none';
616
681
  }
617
682
  if (typeof window.__DUJIAO_RELEASE_CONSOLE_GATE__ === 'function') window.__DUJIAO_RELEASE_CONSOLE_GATE__();
683
+ if (typeof window.__NETFLIX_THEME_RELEASE_ROUTE_GATE__ === 'function') window.__NETFLIX_THEME_RELEASE_ROUTE_GATE__();
618
684
  }
619
685
 
620
686
  function loadAuthConfig(kind) {
@@ -749,18 +815,10 @@
749
815
  clearPage();
750
816
  if (!isThemeRoute()) return;
751
817
  var requestedPath = location.pathname;
752
- Promise.allSettled([
753
- fetch('/plugins/appstore/api/plugins/public-assets?context=store', { cache: 'no-store' }).then(function (response) { return response.json(); }),
754
- fetch('/plugins/appstore/api/plugins/netflix/public-home-config', { cache: 'no-store' }).then(function (response) { return response.ok ? response.json() : {}; })
755
- ]).then(function (results) {
756
- if (location.pathname !== requestedPath) return;
757
- var assets = results[0].status === 'fulfilled' ? results[0].value : {};
758
- var config = results[1].status === 'fulfilled' ? results[1].value : {};
759
- if (!Array.isArray(assets.assets) || !assets.assets.some(function (item) { return item.id === 'netflix'; })) {
760
- if (typeof window.__DUJIAO_RELEASE_CONSOLE_GATE__ === 'function') window.__DUJIAO_RELEASE_CONSOLE_GATE__();
761
- return;
762
- }
763
- homeConfig = config.config || {};
818
+ var routeToken = sequence;
819
+ loadThemeHomeConfig().then(function (config) {
820
+ if (routeToken !== sequence || location.pathname !== requestedPath) return;
821
+ homeConfig = config || {};
764
822
  host = document.querySelector('#app');
765
823
  if (!host) return;
766
824
  if (!hostStateSaved) {
@@ -775,6 +833,7 @@
775
833
  else if (requestedPath === '/me/wallet') loadWallet();
776
834
  else if (requestedPath === '/me') loadAccount();
777
835
  else if (requestedPath === '/me/profile') loadProfile();
836
+ else if (requestedPath === '/pay') loadPayment();
778
837
  else if (requestedPath === '/auth/login' || requestedPath === '/auth/register') loadAuthConfig(requestedPath === '/auth/login' ? 'login' : 'register').then(function () {
779
838
  if (location.pathname === requestedPath) renderAuth(requestedPath === '/auth/login' ? 'login' : 'register');
780
839
  });
@@ -783,8 +842,8 @@
783
842
 
784
843
  window.__NETFLIX_THEME_ROUTE_CHANGE__ = routeChanged;
785
844
  window.__NETFLIX_THEME_RELEASE__ = clearPage;
786
- timer = setInterval(routeChanged, 400);
787
845
  window.addEventListener('popstate', routeChanged);
846
+ timer = setInterval(routeChanged, 1200);
788
847
  window.addEventListener('pagehide', function () { sequence++; clearInterval(timer); clearPage(); });
789
848
  routeChanged();
790
849
  })();
package/public/home.js CHANGED
@@ -39,6 +39,9 @@
39
39
  }
40
40
  function animateThemeEnter(element) { if (window.gsap && element) window.gsap.fromTo(element,{autoAlpha:0,y:10},{autoAlpha:1,y:0,duration:.42,ease:'power2.out',clearProps:'transform'}); }
41
41
  function releaseHomeGate() {
42
+ // This shared gate also protects the destination console route. Do not
43
+ // release it while the homepage is unmounting for an in-app transition.
44
+ if (window.location.pathname !== '/') return;
42
45
  if (typeof window.__DUJIAO_RELEASE_HOME_GATE__ === 'function') window.__DUJIAO_RELEASE_HOME_GATE__();
43
46
  }
44
47
 
@@ -544,7 +547,7 @@
544
547
  window.addEventListener('hashchange', syncRoute);
545
548
  checkPlugin();
546
549
  checkTimer = window.setInterval(checkPlugin, 2500);
547
- routeTimer = window.setInterval(syncRoute, 500);
550
+ routeTimer = window.setInterval(syncRoute, 1500);
548
551
  window.addEventListener('pagehide', function () {
549
552
  window.clearInterval(checkTimer);
550
553
  window.clearInterval(routeTimer);
package/public/inject.js CHANGED
@@ -2,14 +2,43 @@
2
2
  var pluginId = 'netflix';
3
3
  var adminPath = '/admin/';
4
4
  var authPath = window.location.pathname;
5
- if ((authPath === '/auth/login' || authPath === '/auth/register') && new URLSearchParams(window.location.search).get('native') !== '1') {
6
- document.documentElement.classList.add('nfc-auth-route-pending');
7
- if (!document.getElementById('nfc-auth-route-gate')) {
8
- var authGateStyle = document.createElement('style');
9
- authGateStyle.id = 'nfc-auth-route-gate';
10
- authGateStyle.textContent = 'html.nfc-auth-route-pending #app{visibility:hidden!important}';
11
- (document.head || document.documentElement).appendChild(authGateStyle);
5
+ var routeParams = new URLSearchParams(window.location.search);
6
+ var gatedThemeRoutes = ['/me/orders', '/me/affiliate', '/me/wallet', '/me', '/me/profile', '/auth/login', '/auth/register', '/pay'];
7
+ var routeIsThemed = gatedThemeRoutes.indexOf(authPath) >= 0 &&
8
+ !(['/me/affiliate', '/auth/login', '/auth/register', '/pay'].indexOf(authPath) >= 0 && routeParams.get('native') === '1') &&
9
+ !(authPath === '/pay' && routeParams.get('guest') === '1');
10
+ if (routeIsThemed) {
11
+ document.documentElement.classList.add('nfc-route-pending');
12
+ if (!document.getElementById('nfc-route-gate-style')) {
13
+ var routeGateStyle = document.createElement('style');
14
+ routeGateStyle.id = 'nfc-route-gate-style';
15
+ routeGateStyle.textContent = 'html.nfc-route-pending #app{visibility:hidden!important}html.nfc-route-pending,html.nfc-route-pending body{background:#fff!important}.nfc-route-loader{position:fixed;inset:0;z-index:99999;display:grid;place-items:center;background:#fff;transition:opacity .18s ease}.nfc-route-loader-badge{position:relative;width:88px;height:88px;display:grid;place-items:center;border:1px solid #eee;border-radius:50%;background:#fff;box-shadow:0 6px 24px #00000014}.nfc-route-loader-inner{width:64px;height:64px;display:grid;place-items:center;border:4px solid #fff;border-radius:50%;background:#ef5350;box-shadow:0 2px 8px #0002}.nfc-route-loader-inner img{width:44px;height:22px;object-fit:contain}.nfc-route-loader-ring{position:absolute;inset:-4px;width:96px;height:96px;animation:nfc-route-loader-spin 1.1s linear infinite}.nfc-route-loader-ring circle{fill:none;stroke:#ef5350;stroke-width:3;stroke-linecap:round;stroke-dasharray:62 240}@keyframes nfc-route-loader-spin{to{transform:rotate(360deg)}}@media(prefers-reduced-motion:reduce){.nfc-route-loader-ring{animation-duration:3s}}';
16
+ (document.head || document.documentElement).appendChild(routeGateStyle);
12
17
  }
18
+ function releaseThemeRouteGate() {
19
+ document.documentElement.classList.remove('nfc-route-pending');
20
+ if (window.__NETFLIX_THEME_ROUTE_LOADER__) {
21
+ var loader = window.__NETFLIX_THEME_ROUTE_LOADER__;
22
+ window.__NETFLIX_THEME_ROUTE_LOADER__ = null;
23
+ loader.style.opacity = '0';
24
+ loader.style.pointerEvents = 'none';
25
+ window.setTimeout(function () { loader.remove(); }, 200);
26
+ }
27
+ }
28
+ if (typeof window.__NETFLIX_THEME_RELEASE_ROUTE_GATE__ !== 'function') window.__NETFLIX_THEME_RELEASE_ROUTE_GATE__ = releaseThemeRouteGate;
29
+ function showThemeRouteLoader() {
30
+ if (window.__NETFLIX_THEME_ROUTE_LOADER__ || document.querySelector('.nfh-route-loader,.nfc-route-loader') || !document.body || !document.documentElement.classList.contains('nfc-route-pending')) return;
31
+ var loader = document.createElement('div');
32
+ loader.className = 'nfc-route-loader';
33
+ loader.setAttribute('role', 'status');
34
+ loader.setAttribute('aria-label', '页面加载中');
35
+ loader.innerHTML = '<div class="nfc-route-loader-badge"><svg class="nfc-route-loader-ring" viewBox="0 0 96 96" aria-hidden="true"><circle cx="48" cy="48" r="45"/></svg><div class="nfc-route-loader-inner"><img src="/plugins/appstore/static-plugins/netflix/assets/txsw-chameleon-logo.svg" alt=""></div></div>';
36
+ window.__NETFLIX_THEME_ROUTE_LOADER__ = loader;
37
+ document.body.appendChild(loader);
38
+ }
39
+ showThemeRouteLoader();
40
+ document.addEventListener('DOMContentLoaded', showThemeRouteLoader, { once: true });
41
+ window.addEventListener('pagehide', releaseThemeRouteGate, { once: true });
13
42
  }
14
43
  if (window.location.pathname.indexOf(adminPath) !== 0) return;
15
44
  if (window.__NETFLIX_THEME_SETTINGS_INJECTOR__) return;