@etspress/netflix 0.1.23 → 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 +2 -2
- package/plugin.json +1 -1
- package/public/console.js +32 -14
- package/public/home.js +4 -1
- package/public/inject.js +36 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etspress/netflix",
|
|
3
|
-
"version": "0.1.
|
|
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.
|
|
21
|
+
"version": "0.1.24",
|
|
22
22
|
"runtime": {
|
|
23
23
|
"type": "npm-static",
|
|
24
24
|
"publicRoot": "public"
|
package/plugin.json
CHANGED
package/public/console.js
CHANGED
|
@@ -38,6 +38,9 @@
|
|
|
38
38
|
var captchaImage = '';
|
|
39
39
|
var authChallengeToken = '';
|
|
40
40
|
var authInviteTicket = '';
|
|
41
|
+
var homeConfigCache = null;
|
|
42
|
+
var homeConfigCacheAt = 0;
|
|
43
|
+
var homeConfigRequest = null;
|
|
41
44
|
|
|
42
45
|
function isThemeRoute(path) {
|
|
43
46
|
path = path || location.pathname;
|
|
@@ -143,6 +146,7 @@
|
|
|
143
146
|
}
|
|
144
147
|
hostStateSaved = false;
|
|
145
148
|
document.documentElement.classList.remove('nfc-active');
|
|
149
|
+
if (!isThemeRoute() && typeof window.__NETFLIX_THEME_RELEASE_ROUTE_GATE__ === 'function') window.__NETFLIX_THEME_RELEASE_ROUTE_GATE__();
|
|
146
150
|
root = null;
|
|
147
151
|
host = null;
|
|
148
152
|
}
|
|
@@ -165,6 +169,24 @@
|
|
|
165
169
|
});
|
|
166
170
|
}
|
|
167
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
|
+
|
|
168
190
|
function openAffiliate() {
|
|
169
191
|
var headers = apiHeaders();
|
|
170
192
|
headers['Content-Type'] = 'application/json';
|
|
@@ -263,6 +285,8 @@
|
|
|
263
285
|
language.addEventListener('change', function () { localStorage.setItem('locale', language.value); location.reload(); });
|
|
264
286
|
root.querySelector('.nfc-to-top').addEventListener('click', function () { window.scrollTo({ top: 0, behavior: 'smooth' }); });
|
|
265
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__();
|
|
266
290
|
host = document.querySelector('#app');
|
|
267
291
|
if (host) {
|
|
268
292
|
if (!hostStateSaved) {
|
|
@@ -599,6 +623,7 @@
|
|
|
599
623
|
var order = responseData(body) || {};
|
|
600
624
|
var paid = ['paid','fulfilling','partially_delivered','delivered','completed'].indexOf(order.status) >= 0;
|
|
601
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; }
|
|
602
627
|
var amount = order.pay_amount || order.total_amount || order.amount || '0';
|
|
603
628
|
return Promise.allSettled([
|
|
604
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 {}})}),
|
|
@@ -649,12 +674,13 @@
|
|
|
649
674
|
root = document.createElement('div'); root.id = 'netflix-theme-home'; root.className = 'nfc-console nfc-auth';
|
|
650
675
|
var brand = homeConfig.brandLogoUrl ? '<img src="' + escapeHtml(homeConfig.brandLogoUrl) + '" alt="' + escapeHtml(homeConfig.brandName || '奈飞小铺') + '">' : escapeHtml(homeConfig.brandName || '奈飞小铺');
|
|
651
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>';
|
|
652
|
-
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'));
|
|
653
678
|
host = document.querySelector('#app'); if (host) {
|
|
654
679
|
if (!hostStateSaved) { hostDisplay = host.style.display; hostVisibility = host.style.visibility; hostStateSaved = true; }
|
|
655
680
|
host.style.visibility = ''; host.style.display = 'none';
|
|
656
681
|
}
|
|
657
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__();
|
|
658
684
|
}
|
|
659
685
|
|
|
660
686
|
function loadAuthConfig(kind) {
|
|
@@ -789,18 +815,10 @@
|
|
|
789
815
|
clearPage();
|
|
790
816
|
if (!isThemeRoute()) return;
|
|
791
817
|
var requestedPath = location.pathname;
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
if (location.pathname !== requestedPath) return;
|
|
797
|
-
var assets = results[0].status === 'fulfilled' ? results[0].value : {};
|
|
798
|
-
var config = results[1].status === 'fulfilled' ? results[1].value : {};
|
|
799
|
-
if (!Array.isArray(assets.assets) || !assets.assets.some(function (item) { return item.id === 'netflix'; })) {
|
|
800
|
-
if (typeof window.__DUJIAO_RELEASE_CONSOLE_GATE__ === 'function') window.__DUJIAO_RELEASE_CONSOLE_GATE__();
|
|
801
|
-
return;
|
|
802
|
-
}
|
|
803
|
-
homeConfig = config.config || {};
|
|
818
|
+
var routeToken = sequence;
|
|
819
|
+
loadThemeHomeConfig().then(function (config) {
|
|
820
|
+
if (routeToken !== sequence || location.pathname !== requestedPath) return;
|
|
821
|
+
homeConfig = config || {};
|
|
804
822
|
host = document.querySelector('#app');
|
|
805
823
|
if (!host) return;
|
|
806
824
|
if (!hostStateSaved) {
|
|
@@ -824,8 +842,8 @@
|
|
|
824
842
|
|
|
825
843
|
window.__NETFLIX_THEME_ROUTE_CHANGE__ = routeChanged;
|
|
826
844
|
window.__NETFLIX_THEME_RELEASE__ = clearPage;
|
|
827
|
-
timer = setInterval(routeChanged, 400);
|
|
828
845
|
window.addEventListener('popstate', routeChanged);
|
|
846
|
+
timer = setInterval(routeChanged, 1200);
|
|
829
847
|
window.addEventListener('pagehide', function () { sequence++; clearInterval(timer); clearPage(); });
|
|
830
848
|
routeChanged();
|
|
831
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,
|
|
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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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;
|