@etspress/netflix 0.0.0-stage → 0.1.1
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/.env.example +2 -0
- package/README.md +14 -2
- package/package.json +44 -4
- package/plugin.json +46 -0
- package/public/assets/reference-logo.png +0 -0
- package/public/assets/reference-logo.svg +1 -0
- package/public/assets/service-24hours.png +0 -0
- package/public/assets/service-fast.png +0 -0
- package/public/assets/service-replace.png +0 -0
- package/public/assets/stat-members.svg +1 -0
- package/public/assets/stat-riders.svg +1 -0
- package/public/assets/stat-shield.svg +1 -0
- package/public/assets/stat-support.svg +1 -0
- package/public/config.html +72 -0
- package/public/config.js +282 -0
- package/public/console.css +153 -0
- package/public/console.js +484 -0
- package/public/home.css +391 -0
- package/public/home.js +445 -0
- package/public/icon.svg +1 -0
- package/public/inject.js +370 -0
package/public/home.js
ADDED
|
@@ -0,0 +1,445 @@
|
|
|
1
|
+
(function () {
|
|
2
|
+
if (window.__NETFLIX_HOME_RUNTIME__) return;
|
|
3
|
+
if (window.location.pathname.indexOf('/admin') === 0 || window.location.pathname.indexOf('/plugins/') === 0) return;
|
|
4
|
+
window.__NETFLIX_HOME_RUNTIME__ = true;
|
|
5
|
+
|
|
6
|
+
var assetRoot = '/plugins/appstore/static-plugins/netflix/';
|
|
7
|
+
var root = null;
|
|
8
|
+
var stylesheet = null;
|
|
9
|
+
var host = null;
|
|
10
|
+
var hostDisplay = '';
|
|
11
|
+
var checkTimer = null;
|
|
12
|
+
var routeTimer = null;
|
|
13
|
+
var scrollHandler = null;
|
|
14
|
+
var carouselTimer = null;
|
|
15
|
+
var localeOutsideHandler = null;
|
|
16
|
+
var requestToken = 0;
|
|
17
|
+
var mountPending = false;
|
|
18
|
+
var lastMountAttempt = 0;
|
|
19
|
+
var pluginEnabled = false;
|
|
20
|
+
function releaseHomeGate() {
|
|
21
|
+
if (typeof window.__DUJIAO_RELEASE_HOME_GATE__ === 'function') window.__DUJIAO_RELEASE_HOME_GATE__();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function escapeHtml(value) {
|
|
25
|
+
return String(value == null ? '' : value).replace(/[&<>"']/g, function (char) {
|
|
26
|
+
return ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[char];
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function currentLocale() {
|
|
31
|
+
var locale = 'zh-CN';
|
|
32
|
+
try { locale = window.localStorage.getItem('locale') || document.documentElement.lang || locale; } catch (_error) {}
|
|
33
|
+
return ['zh-CN', 'zh-TW', 'en-US'].indexOf(locale) >= 0 ? locale : 'zh-CN';
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function translate(key) {
|
|
37
|
+
var messages = {
|
|
38
|
+
'zh-CN': { home: '首页', tickets: '车票', promotion: '推广', support: '工单', login: '登录', notifications: '消息通知', buy: '买票上车', sold: '已售罄', faq: '查看常见问题', language: '站点语言', mine: '我的' },
|
|
39
|
+
'zh-TW': { home: '首頁', tickets: '車票', promotion: '推廣', support: '工單', login: '登入', notifications: '消息通知', buy: '立即上車', sold: '已售罄', faq: '查看常見問題', language: '站點語言', mine: '我的' },
|
|
40
|
+
'en-US': { home: 'Home', tickets: 'Tickets', promotion: 'Promotion', support: 'Support', login: 'Sign in', notifications: 'Notifications', buy: 'Buy now', sold: 'Sold out', faq: 'Common questions', language: 'Language', mine: 'Account' }
|
|
41
|
+
};
|
|
42
|
+
return messages[currentLocale()][key] || messages['zh-CN'][key] || '';
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function configuredLabel(value, defaultValue, key) {
|
|
46
|
+
var label = String(value || '').trim();
|
|
47
|
+
return !label || label === defaultValue ? translate(key) : label;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function localized(value) {
|
|
51
|
+
if (value && typeof value === 'object') return value[currentLocale()] || value['zh-CN'] || value['zh-TW'] || value['en-US'] || '';
|
|
52
|
+
return value == null ? '' : String(value);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function rows(value) {
|
|
56
|
+
return String(value || '').split(/\r?\n/).map(function (line) {
|
|
57
|
+
var divider = line.indexOf('|');
|
|
58
|
+
return divider < 0 ? [line.trim(), ''] : [line.slice(0, divider).trim(), line.slice(divider + 1).trim()];
|
|
59
|
+
}).filter(function (row) { return row[0]; });
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function safeRichText(value) {
|
|
63
|
+
var source = String(value || '');
|
|
64
|
+
var documentFragment = new DOMParser().parseFromString(source, 'text/html');
|
|
65
|
+
var allowed = { A: true, B: true, BR: true, DIV: true, EM: true, I: true, LI: true, OL: true, P: true, SMALL: true, SPAN: true, STRONG: true, U: true, UL: true };
|
|
66
|
+
Array.prototype.slice.call(documentFragment.body.querySelectorAll('*')).forEach(function (node) {
|
|
67
|
+
if (!allowed[node.tagName]) {
|
|
68
|
+
node.replaceWith.apply(node, Array.prototype.slice.call(node.childNodes));
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
var href = node.tagName === 'A' ? node.getAttribute('href') : '';
|
|
72
|
+
Array.prototype.slice.call(node.attributes).forEach(function (attribute) { node.removeAttribute(attribute.name); });
|
|
73
|
+
if (node.tagName === 'A' && href) {
|
|
74
|
+
node.setAttribute('href', safeHref(href, '/'));
|
|
75
|
+
node.setAttribute('rel', 'noopener noreferrer');
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
return documentFragment.body.innerHTML;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function safeHref(value, fallback) {
|
|
82
|
+
var raw = String(value || '').trim();
|
|
83
|
+
if (!raw || raw === '#') return fallback || '/';
|
|
84
|
+
if (/^(\/|\.\/|\.\.\/|\?)/.test(raw)) return raw;
|
|
85
|
+
try {
|
|
86
|
+
var parsed = new URL(raw, window.location.origin);
|
|
87
|
+
if (['http:', 'https:', 'mailto:', 'tel:'].indexOf(parsed.protocol) >= 0) return parsed.href;
|
|
88
|
+
} catch (_error) {}
|
|
89
|
+
return fallback || '/';
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function defaultHref(label) {
|
|
93
|
+
var routes = {
|
|
94
|
+
'推广返现': '/me/affiliate', '推广': '/me/affiliate', '我的推广': '/me/affiliate',
|
|
95
|
+
'在线咨询': '/about', '工单': '/about', '我的工单': '/about',
|
|
96
|
+
'我的车票': '/me/orders', '车票': '/me/orders', '商品': '/products', '首页': '/', '我的': '/me',
|
|
97
|
+
'隐私政策': '/privacy', '用户协议': '/terms'
|
|
98
|
+
};
|
|
99
|
+
return routes[label] || '';
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function productFaqs(product) {
|
|
103
|
+
var value = product.faqs || product.faq || product.questions || [];
|
|
104
|
+
if (!Array.isArray(value)) return [];
|
|
105
|
+
return value.map(function (item) {
|
|
106
|
+
if (typeof item === 'string') return { question: item, answer: '' };
|
|
107
|
+
return { question: localized(item.question || item.title || item.name), answer: localized(item.answer || item.content || item.description) };
|
|
108
|
+
}).filter(function (item) { return item.question; });
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function safeProductHref(product) {
|
|
112
|
+
return '/products/' + encodeURIComponent(product.slug || String(product.id));
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function faqMarkup(product, config, href, block) {
|
|
116
|
+
if (config.productCardShowFaq === '否') return '';
|
|
117
|
+
var faqs = Array.isArray(block.faqItems) ? block.faqItems.filter(function (item) { return item.question; }) : productFaqs(product);
|
|
118
|
+
if (!faqs.length) return '<a class="nfh-faq-link" href="' + href + '"><span aria-hidden="true">?</span> ' + escapeHtml(translate('faq')) + '</a>';
|
|
119
|
+
var supports = rows(block.supportLinks == null ? '企业微信|\nTG万人用户群|' : block.supportLinks).filter(function (row) { return !/工单/.test(row[0]); }).map(function (row) { return row[1] ? '<a href="' + escapeHtml(safeHref(row[1], '/')) + '">' + escapeHtml(row[0]) + '</a>' : '<span>' + escapeHtml(row[0]) + '</span>'; }).join('');
|
|
120
|
+
return '<div class="nfh-faq"><button type="button" class="nfh-faq-trigger"><span class="nfh-faq-slides">' + faqs.map(function (faq, index) { return '<span class="nfh-slide"' + (index ? ' hidden' : '') + '>' + escapeHtml(faq.question) + '</span>'; }).join('') + '</span><svg class="nfh-faq-chevron" viewBox="0 0 24 24" aria-hidden="true"><path d="m7.41 8.59 4.59 4.58 4.59-4.58L18 10l-6 6-6-6z"/></svg></button><dialog class="nfh-faq-dialog"><div class="nfh-faq-dialog-header"><button type="button" class="nfh-faq-close" aria-label="关闭"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M15.41 7.41 14 6l-6 6 6 6 1.41-1.41L10.83 12z"/></svg></button><strong>常见问题</strong></div><div class="nfh-faq-dialog-content"><div class="nfh-faq-questions">' + faqs.map(function (faq) { return '<details><summary>' + escapeHtml(faq.question) + '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M7.41 8.59 12 13.17l4.59-4.58L18 10l-6 6-6-6z"/></svg></summary><div>' + (faq.answer ? safeRichText(faq.answer) : '') + '</div></details>'; }).join('') + '</div>' + (supports ? '<div class="nfh-faq-support"><strong>售后支持</strong><div>' + supports + '</div></div>' : '') + '</div><button type="button" class="nfh-faq-return">返回购买</button></dialog></div>';
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function card(product, config, block, cardIndex, cardCount) {
|
|
124
|
+
block = block || {};
|
|
125
|
+
var title = escapeHtml(block.title || localized(product.title) || '商品');
|
|
126
|
+
var description = safeRichText(block.description || localized(product.description) || localized(product.content));
|
|
127
|
+
var href = safeProductHref(product);
|
|
128
|
+
var tagItems = block.tags ? block.tags.split(/[,,]/).map(function (tag) { return tag.trim(); }).filter(Boolean) : product.tags;
|
|
129
|
+
var tags = Array.isArray(tagItems) ? tagItems.map(function (tag) {
|
|
130
|
+
return '<span class="nfh-tag">' + escapeHtml(localized(tag && (tag.name || tag.title) || tag)) + '</span>';
|
|
131
|
+
}).join('') : '';
|
|
132
|
+
var soldOut = product.is_sold_out === true || product.stock_status === 'out_of_stock';
|
|
133
|
+
var extraTag = block.ribbonEnabled === false ? '' : (Object.prototype.hasOwnProperty.call(block, 'ribbon') ? block.ribbon : (localized(product.extra && product.extra.tag) || localized(config.productCardRibbonLabel)));
|
|
134
|
+
var avatars = block.demoAvatars ? block.demoAvatars.split(/\r?\n/).map(function (s) { return s.trim(); }).filter(Boolean) : [];
|
|
135
|
+
if (!avatars.length) {
|
|
136
|
+
var pool = Array.from({ length: 45 }, function (_, index) { return 'https://randomuser.me/api/portraits/thumb/' + (index % 2 ? 'women' : 'men') + '/' + Math.floor(index / 2) + '.jpg'; });
|
|
137
|
+
var groups = Math.min(cardCount || 1, 9);
|
|
138
|
+
avatars = pool.filter(function (_, index) { return index % groups === cardIndex % groups; });
|
|
139
|
+
}
|
|
140
|
+
var avatarMarkup = avatars.map(function (avatar, index) {
|
|
141
|
+
var src = typeof avatar === 'string' ? avatar : (avatar && (avatar.url || avatar.src || avatar.avatar));
|
|
142
|
+
return src ? '<img src="' + escapeHtml(safeHref(src, '')) + '" alt="" loading="lazy"' + (index >= 5 ? ' hidden' : '') + '>' : '';
|
|
143
|
+
}).join('');
|
|
144
|
+
var recentSource = config.productCardShowRecentPurchase === '否' ? '' : (block.recentText || localized(product.recentlyGotOnBus || product.recent_purchase_text || product.latest_purchase_text));
|
|
145
|
+
var recentText = String(recentSource || '').split(/\r?\n/).map(function (item) { return item.replace(/^演示\s*[·•|::-]?\s*/, '').trim(); }).filter(Boolean).join('\n');
|
|
146
|
+
var sparse = !tags && !description && !avatars.length && !recentText;
|
|
147
|
+
var recentItems = recentText ? recentText.split(/\r?\n/).map(function (s) { return s.trim(); }).filter(Boolean) : [];
|
|
148
|
+
var recentMarkup = recentItems.length ? '<div class="nfh-recent-row"><div class="nfh-avatar-group"><div class="nfh-avatars">' + avatarMarkup + '</div></div><span class="nfh-recent">' + recentItems.map(function (item, index) { return '<span class="nfh-slide"' + (index ? ' hidden' : '') + '>' + escapeHtml(item) + '</span>'; }).join('') + '</span></div>' : '<div class="nfh-recent-row" aria-hidden="true"></div>';
|
|
149
|
+
var price = Number(product.price_amount != null ? product.price_amount : product.price);
|
|
150
|
+
var priceText = Number.isFinite(price) ? price.toFixed(2) : escapeHtml(product.price_amount || product.price || '0.00');
|
|
151
|
+
var priceUnit = block.priceUnit || localized(product.price_unit || product.unit_label || product.billing_period);
|
|
152
|
+
var badge = extraTag ? '<div class="nfh-ribbon"><span>' + escapeHtml(extraTag) + '</span></div>' : '';
|
|
153
|
+
|
|
154
|
+
return '<article class="nfh-card' + (sparse ? ' is-sparse' : '') + '" data-product-id="' + escapeHtml(product.id) + '"><div class="nfh-card-main">' +
|
|
155
|
+
'<a class="nfh-card-title" href="' + href + '" data-nfh-product="' + escapeHtml(product.slug || product.id) + '" data-nfh-title="' + title + '">' + title + '</a>' +
|
|
156
|
+
(tags && config.productCardShowTags !== '否' ? '<div class="nfh-tags">' + tags + '</div>' : '') +
|
|
157
|
+
(description && config.productCardShowDescription !== '否' ? '<p class="nfh-desc">' + description + '</p>' : '') +
|
|
158
|
+
faqMarkup(block.faq ? Object.assign({}, product, { faqs: block.faq.split(/\r?\n/).filter(Boolean) }) : product, config, href, block) +
|
|
159
|
+
'<div class="nfh-divider"></div>' + recentMarkup +
|
|
160
|
+
'<div class="nfh-divider"></div>' +
|
|
161
|
+
'<div class="nfh-card-bottom"><span class="nfh-price"><span class="nfh-currency">¥</span><strong>' + priceText + '</strong>' + (priceUnit ? '<small>/' + escapeHtml(priceUnit) + '</small>' : '') + '</span>' +
|
|
162
|
+
'<a class="nfh-buy' + (soldOut ? ' is-sold' : '') + '" href="' + href + '" data-nfh-product="' + escapeHtml(product.slug || product.id) + '" data-nfh-title="' + escapeHtml(block.title || localized(product.title) || '') + '"' + (soldOut ? ' aria-disabled="true"' : '') + '><span class="nfh-buy-cart" aria-hidden="true">' + cartIcon() + '</span>' +
|
|
163
|
+
escapeHtml(soldOut ? translate('sold') : (block.button || configuredLabel(config.productCardButtonLabel, '买票上车', 'buy'))) + '</a></div>' + badge + '</div></article>';
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function cartIcon() {
|
|
167
|
+
return '<svg viewBox="0 0 24 24" aria-hidden="true"><path fill="currentColor" d="M7 18c-1.1 0-1.99.9-1.99 2S5.9 22 7 22s2-.9 2-2s-.9-2-2-2m10 0c-1.1 0-1.99.9-1.99 2S15.9 22 17 22s2-.9 2-2s-.9-2-2-2m2-2c0-.55-.45-1-1-1H7l1.1-2h7.45c.75 0 1.41-.41 1.75-1.03l3.24-6.14a1 1 0 0 0-.4-1.34a.996.996 0 0 0-1.36.41L15.55 11H8.53L4.54 2.57a.99.99 0 0 0-.9-.57H2c-.55 0-1 .45-1 1s.45 1 1 1h1l3.6 7.59l-1.35 2.44C4.52 15.37 5.48 17 7 17h11c.55 0 1-.45 1-1M11.29 2.71a.996.996 0 0 1 1.41 0l2.59 2.59c.39.39.39 1.02 0 1.41L12.7 9.3a.996.996 0 1 1-1.41-1.41l.88-.89H9c-.55 0-1-.45-1-1s.45-1 1-1h3.17l-.88-.88a.996.996 0 0 1 0-1.41"/></svg>';
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function promoUserIcon() {
|
|
171
|
+
return '<svg viewBox="0 0 640 512" aria-hidden="true"><path fill="currentColor" d="M96 224c35.3 0 64-28.7 64-64s-28.7-64-64-64s-64 28.7-64 64s28.7 64 64 64m448 0c35.3 0 64-28.7 64-64s-28.7-64-64-64s-64 28.7-64 64s28.7 64 64 64m32 32h-64c-17.6 0-33.5 7.1-45.1 18.6c40.3 22.1 68.9 62 75.1 109.4h66c17.7 0 32-14.3 32-32v-32c0-35.3-28.7-64-64-64m-256 0c61.9 0 112-50.1 112-112S381.9 32 320 32S208 82.1 208 144s50.1 112 112 112m76.8 32h-8.3c-20.8 10-43.9 16-68.5 16s-47.6-6-68.5-16h-8.3C179.6 288 128 339.6 128 403.2V432c0 26.5 21.5 48 48 48h288c26.5 0 48-21.5 48-48v-28.8c0-63.6-51.6-115.2-115.2-115.2m-223.7-13.4C161.5 263.1 145.6 256 128 256H64c-35.3 0-64 28.7-64 64v32c0 17.7 14.3 32 32 32h65.9c6.3-47.4 34.9-87.3 75.2-109.4"/></svg>';
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function checkIcon() {
|
|
175
|
+
return '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="m5 12 4 4L19 6"/></svg>';
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function toolIcon(label) {
|
|
179
|
+
var icons = {
|
|
180
|
+
'优惠券': ['0 0 512 512', '<path fill="currentColor" d="M80 416a64 64 0 0 0 64 64h92a4 4 0 0 0 4-4V292a4 4 0 0 0-4-4H88a8 8 0 0 0-8 8Zm160-164V144h32v108a4 4 0 0 0 4 4h140a47.9 47.9 0 0 0 16-2.75A48.09 48.09 0 0 0 464 208v-16a48 48 0 0 0-48-48h-40.54a2 2 0 0 1-1.7-3A72 72 0 0 0 256 58.82A72 72 0 0 0 138.24 141a2 2 0 0 1-1.7 3H96a48 48 0 0 0-48 48v16a48.09 48.09 0 0 0 32 45.25A47.9 47.9 0 0 0 96 256h140a4 4 0 0 0 4-4m32-148a40 40 0 1 1 40 40h-40Zm-74.86-39.9A40 40 0 0 1 240 104v40h-40a40 40 0 0 1-2.86-79.89ZM276 480h92a64 64 0 0 0 64-64V296a8 8 0 0 0-8-8H276a4 4 0 0 0-4 4v184a4 4 0 0 0 4 4"/>'],
|
|
181
|
+
'签到': ['0 0 24 24', '<path fill="currentColor" d="m10.95 15.45 3.475-3.475q.3-.3.725-.3t.725.3t.3.725t-.3.725L11.65 17.65q-.3.3-.7.3t-.7-.3l-2.125-2.125q-.3-.3-.3-.725t.3-.725t.725-.3t.725.3zM5 22q-.825 0-1.412-.587T3 20V6q0-.825.588-1.412T5 4h1V3q0-.425.288-.712T7 2t.713.288T8 3v1h8V3q0-.425.288-.712T17 2t.713.288T18 3v1h1q.825 0 1.413.588T21 6v14q0 .825-.587 1.413T19 22zm0-2h14V10H5z"/>'],
|
|
182
|
+
'推广返现': ['0 0 16 16', '<path fill="currentColor" d="M10.307 2.105A.5.5 0 0 0 9.5 2.5v1.993l-.135.007a5.4 5.4 0 0 0-1.544.337a4.7 4.7 0 0 0-2.095 1.574c-.623.826-1.081 1.972-1.224 3.544a.5.5 0 0 0 .852.399c1.188-1.19 2.369-1.776 3.242-2.067c.36-.12.668-.19.904-.23V10a.5.5 0 0 0 .832.374l4.5-4a.5.5 0 0 0-.025-.769zm-.364 3.392h.003A.5.5 0 0 0 10.5 5V3.522l3.219 2.504l-3.219 2.86V7.5A.5.5 0 0 0 10 7h-.045l-.1.006a5 5 0 0 0-.355.038c-.3.043-.72.127-1.22.294a8.9 8.9 0 0 0-2.548 1.36c.194-.716.476-1.264.793-1.685a3.7 3.7 0 0 1 1.654-1.242A4.4 4.4 0 0 1 9.82 5.49q.068.002.1.005zM4.5 3A2.5 2.5 0 0 0 2 5.5v6A2.5 2.5 0 0 0 4.5 14h6a2.5 2.5 0 0 0 2.5-2.5v-1a.5.5 0 0 0-1 0v1a1.5 1.5 0 0 1-1.5 1.5h-6A1.5 1.5 0 0 1 3 11.5v-6A1.5 1.5 0 0 1 4.5 4h2a.5.5 0 0 0 0-1z"/>'],
|
|
183
|
+
'在线咨询': ['0 0 24 24', '<path fill="currentColor" d="M21 8a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-1.062A8 8 0 0 1 12 23v-2a6 6 0 0 0 6-6V9A6 6 0 0 0 6 9v7H3a2 2 0 0 1-2-2v-4a2 2 0 0 1 2-2h1.062a8.001 8.001 0 0 1 15.876 0zM7.76 15.785l1.06-1.696A5.97 5.97 0 0 0 12 15a5.97 5.97 0 0 0 3.18-.911l1.06 1.696A7.96 7.96 0 0 1 12 17a7.96 7.96 0 0 1-4.24-1.215"/>'],
|
|
184
|
+
'公众号': ['0 0 24 24', '<path fill="currentColor" d="M18.575 13.711a.91.91 0 0 0 .898-.898a.895.895 0 0 0-.898-.898a.894.894 0 0 0-.898.898c0 .5.4.898.898.898m-4.425 0a.91.91 0 0 0 .898-.898c0-.498-.4-.898-.898-.898a.894.894 0 0 0-.898.898c0 .5.399.898.898.898m6.567 5.04a.35.35 0 0 0-.172.37c0 .048 0 .098.025.147c.098.417.294 1.081.294 1.106c0 .073.025.122.025.172a.22.22 0 0 1-.221.22c-.05 0-.074-.024-.123-.048l-1.449-.836a.8.8 0 0 0-.344-.098c-.073 0-.147 0-.196.024c-.688.197-1.4.295-2.161.295c-3.66 0-6.607-2.457-6.607-5.505s2.947-5.505 6.607-5.505c3.659 0 6.606 2.458 6.606 5.505c0 1.647-.884 3.146-2.284 4.154M16.674 8.099a9 9 0 0 0-.28-.005c-4.174 0-7.606 2.86-7.606 6.505c0 .554.08 1.09.228 1.6h-.089a10 10 0 0 1-2.584-.368c-.074-.025-.148-.025-.222-.025a.83.83 0 0 0-.419.123l-1.747 1.005a.35.35 0 0 1-.148.05a.273.273 0 0 1-.27-.27c0-.074.024-.123.049-.197c.024-.024.246-.834.369-1.324c0-.05.024-.123.024-.172a.56.56 0 0 0-.221-.441C2.059 13.376 1 11.586 1 9.599C1.001 5.944 4.571 3 8.951 3c3.765 0 6.93 2.169 7.723 5.098"/>'],
|
|
185
|
+
'售后群': ['0 0 32 32', '<path fill="currentColor" d="m29.919 6.163l-4.225 19.925c-.319 1.406-1.15 1.756-2.331 1.094l-6.438-4.744l-3.106 2.988c-.344.344-.631.631-1.294.631l.463-6.556L24.919 8.72c.519-.462-.113-.719-.806-.256l-14.75 9.288l-6.35-1.988c-1.381-.431-1.406-1.381.288-2.044l24.837-9.569c1.15-.431 2.156.256 1.781 2.013z"/>']
|
|
186
|
+
};
|
|
187
|
+
var key = Object.keys(icons).find(function (name) { return label.indexOf(name) >= 0; });
|
|
188
|
+
var icon = icons[key] || ['0 0 24 24', '<circle cx="12" cy="12" r="9"/><path d="M12 8v8m-4-4h8"/>'];
|
|
189
|
+
return '<svg viewBox="' + icon[0] + '" aria-hidden="true">' + icon[1] + '</svg>';
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function socialIcon(label) {
|
|
193
|
+
var icons = {
|
|
194
|
+
'微信': '<path d="M18.575 13.711a.91.91 0 0 0 .898-.898a.895.895 0 0 0-.898-.898a.894.894 0 0 0-.898.898c0 .5.4.898.898.898m-4.425 0a.91.91 0 0 0 .898-.898c0-.498-.4-.898-.898-.898a.894.894 0 0 0-.898.898c0 .5.399.898.898.898m6.567 5.04a.35.35 0 0 0-.172.37c0 .048 0 .098.025.147c.098.417.294 1.081.294 1.106c0 .073.025.122.025.172a.22.22 0 0 1-.221.22c-.05 0-.074-.024-.123-.048l-1.449-.836a.8.8 0 0 0-.344-.098c-.073 0-.147 0-.196.024c-.688.197-1.4.295-2.161.295c-3.66 0-6.607-2.457-6.607-5.505s2.947-5.505 6.607-5.505c3.659 0 6.606 2.458 6.606 5.505c0 1.647-.884 3.146-2.284 4.154M16.674 8.099a9 9 0 0 0-.28-.005c-4.174 0-7.606 2.86-7.606 6.505c0 .554.08 1.09.228 1.6h-.089a10 10 0 0 1-2.584-.368c-.074-.025-.148-.025-.222-.025a.83.83 0 0 0-.419.123l-1.747 1.005a.35.35 0 0 1-.148.05a.273.273 0 0 1-.27-.27c0-.074.024-.123.049-.197c.024-.024.246-.834.369-1.324c0-.05.024-.123.024-.172a.56.56 0 0 0-.221-.441C2.059 13.376 1 11.586 1 9.599C1.001 5.944 4.571 3 8.951 3c3.765 0 6.93 2.169 7.723 5.098m-5.154.418c.573 0 1.026-.477 1.026-1.026c0-.573-.453-1.026-1.026-1.026s-1.026.453-1.026 1.026s.453 1.026 1.026 1.026m-5.26 0c.573 0 1.027-.477 1.027-1.026s-.454-1.026-1.027-1.026c-.572 0-1.026.453-1.026 1.026s.454 1.026 1.026 1.026"/>',
|
|
195
|
+
'QQ': '<path d="M12 2.5c-3.45 0-5.7 3.27-5.7 7.2 0 1.72-1.8 4.42-2.2 6.08-.3 1.2.43 1.55 1.94.44.28 1.1.78 2 1.5 2.65l-.86 1.68c-.3.57.2 1.02.75.75l2.46-1.12c.66.2 1.35.32 2.11.32s1.45-.12 2.11-.32l2.46 1.12c.55.27 1.05-.18.75-.75l-.86-1.68c.72-.65 1.22-1.55 1.5-2.65 1.5 1.11 2.24.76 1.94-.44-.4-1.66-2.2-4.36-2.2-6.08 0-3.93-2.25-7.2-5.7-7.2Z"/><ellipse cx="10" cy="9" rx=".65" ry=".85" fill="#fff" stroke="none"/><ellipse cx="14" cy="9" rx=".65" ry=".85" fill="#fff" stroke="none"/>',
|
|
196
|
+
'Telegram': '<path d="m29.919 6.163l-4.225 19.925c-.319 1.406-1.15 1.756-2.331 1.094l-6.438-4.744l-3.106 2.988c-.344.344-.631.631-1.294.631l.463-6.556L24.919 8.72c.519-.462-.113-.719-.806-.256l-14.75 9.288l-6.35-1.988c-1.381-.431-1.406-1.381.288-2.044l24.837-9.569c1.15-.431 2.156.256 1.781 2.013z"/>',
|
|
197
|
+
'YouTube': '<path d="m10 15 5.19-3L10 9zM21.56 7.17c.13.47.22 1.1.28 1.9.07.8.1 1.49.1 2.09L22 12c0 2.19-.16 3.8-.44 4.83-.25.9-.83 1.48-1.73 1.73-.47.13-1.33.22-2.65.28-1.3.07-2.49.1-3.59.1L12 19c-4.19 0-6.8-.16-7.83-.44-.9-.25-1.48-.83-1.73-1.73-.13-.47-.22-1.1-.28-1.9-.07-.8-.1-1.49-.1-2.09L2 12c0-2.19.16-3.8.44-4.83.25-.9.83-1.48 1.73-1.73.47-.13 1.33-.22 2.65-.28 1.3-.07 2.49-.1 3.59-.1L12 5c4.19 0 6.8.16 7.83.44.9.25 1.48.83 1.73 1.73"/>'
|
|
198
|
+
};
|
|
199
|
+
var key = Object.keys(icons).find(function (name) { return label.indexOf(name) >= 0; });
|
|
200
|
+
var platform = key === '微信' ? 'wechat' : key === 'QQ' ? 'qq' : key ? key.toLowerCase() : 'other';
|
|
201
|
+
var viewBox = key === 'Telegram' ? '0 0 32 32' : '0 0 24 24';
|
|
202
|
+
return { platform: platform, svg: '<svg viewBox="' + viewBox + '" aria-hidden="true">' + (icons[key] || '<circle cx="12" cy="12" r="8"/><path d="M8 12h8m-4-4v8"/>') + '</svg>' };
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
window.__NETFLIX_THEME_ICONS__ = { tool: toolIcon, social: socialIcon, promo: promoUserIcon };
|
|
206
|
+
|
|
207
|
+
function dialogIsOpen(element) { var dialog = element.closest('dialog'); return !!(dialog && dialog.open); }
|
|
208
|
+
|
|
209
|
+
function mountPurchaseDialog(settings, allProducts) {
|
|
210
|
+
var dialog=document.createElement('dialog');dialog.className='nfh-purchase-dialog';dialog.innerHTML='<div class="nfh-purchase-banner"></div><button type="button" class="nfh-purchase-close" aria-label="关闭"><svg viewBox="0 0 24 24" aria-hidden="true"><path fill="currentColor" d="M17.59 5L12 10.59L6.41 5L5 6.41L10.59 12L5 17.59L6.41 19L12 13.41L17.59 19L19 17.59L13.41 12L19 6.41L17.59 5Z"/></svg></button><main class="nfh-purchase-body"><div class="nfh-purchase-scroll"><div class="nfh-purchase-product"><img class="nfh-detail-image"><div class="nfh-purchase-meta"><div class="nfh-detail-titleline"><h2></h2><span class="nfh-detail-new"></span></div><b class="nfh-detail-price"></b><div class="nfh-detail-tags"></div></div></div><div class="nfh-detail-notice"></div><button class="nfh-detail-faq"></button><section class="nfh-detail-choices"></section><section class="nfh-detail-addons"></section><section class="nfh-detail-manual"></section></div><div class="nfh-purchase-footer"><div class="nfh-detail-coupons"><button data-coupon="券"></button><button data-coupon="码"></button><input placeholder="输入优惠码" hidden></div><div class="nfh-coupon-options" hidden></div><div class="nfh-guest-fields" hidden><input type="email"><input type="password"></div><div class="nfh-detail-total"></div><button class="nfh-detail-submit"></button><p class="nfh-detail-error"></p></div></main>';
|
|
211
|
+
root.appendChild(dialog);var product,sku,extra=[],code='',siblings=[],memberOnly=false,previewVersion=0,categoryRequest=0,couponInputTimer=null,guestInputTimer=null;
|
|
212
|
+
function manualFormData(){var data={};dialog.querySelectorAll('[data-manual-key]').forEach(function(input){var key=input.dataset.manualKey;if(input.type==='checkbox'){if(!data[key])data[key]=[];if(input.checked)data[key].push(input.value)}else if(input.type==='radio'){if(input.checked)data[key]=input.value}else data[key]=input.value.trim()});var result={};result[String(product.id)]=data;return result}function lineItems(){return [{product_id:product.id,sku_id:sku&&sku.id||undefined,quantity:1,fulfillment_type:product.fulfillment_type||undefined}].concat(extra.map(function(x){return {product_id:x.id,sku_id:x.sku||undefined,quantity:1}}))}
|
|
213
|
+
function credentials(){var token=localStorage.getItem('user_token'),email=dialog.querySelector('.nfh-guest-fields input[type=email]').value.trim(),password=dialog.querySelector('.nfh-guest-fields input[type=password]').value.trim();if(token)return {path:'/api/v1/orders',headers:{Authorization:'Bearer '+token},guest:{}};var raw=btoa(Array.from(new TextEncoder().encode(email.toLowerCase()+'\n'+password),function(x){return String.fromCharCode(x)}).join('')).replace(/\+/g,'-').replace(/\//g,'_').replace(/=+$/g,'');return {path:'/api/v1/guest/orders',headers:{Authorization:'Guest '+raw},guest:{email:email,order_password:password}}}function preview(){var version=++previewVersion,c=credentials();if(!localStorage.getItem('user_token')&&(!c.guest.email&&!c.guest.order_password)){dialog.querySelector('.nfh-detail-total').textContent='预计合计 ¥'+(sku&&sku.price_amount||product.price_amount||'0');dialog.querySelector('.nfh-detail-error').textContent='';return}if(!localStorage.getItem('user_token')&&(!c.guest.email||c.guest.order_password.length<6)){dialog.querySelector('.nfh-detail-error').textContent='填写游客邮箱和至少6位订单密码后计算优惠';return}dialog.querySelector('.nfh-detail-error').textContent='';fetch(c.path+'/preview',{method:'POST',credentials:'include',headers:Object.assign({'Content-Type':'application/json','X-Lang':currentLocale()},c.headers),body:JSON.stringify(Object.assign({items:lineItems(),coupon_code:code||undefined,manual_form_data:manualFormData()},c.guest))}).then(function(r){return r.json()}).then(function(x){if(version!==previewVersion)return;if(x.status_code&&x.status_code!==0){dialog.querySelector('.nfh-detail-total').textContent='';dialog.querySelector('.nfh-detail-error').textContent=x.msg||'价格预览失败';return}var d=x.data||{};dialog.querySelector('.nfh-detail-total').textContent='合计 ¥'+(d.total_amount||d.pay_amount||sku&&sku.price_amount||product.price_amount||'0');dialog.querySelector('.nfh-detail-error').textContent=''}).catch(function(){if(version===previewVersion)dialog.querySelector('.nfh-detail-error').textContent='价格预览失败'})}
|
|
214
|
+
function load(data,titleOverride){product=data.data||data;memberOnly=product.purchase_type==='member';siblings=(allProducts||[]).filter(function(p){return Number(p.category_id)===Number(product.category_id)});if(!siblings.some(function(p){return Number(p.id)===Number(product.id)}))siblings.unshift(product);sku=(product.skus||[]).find(function(x){return x.is_active!==false&&!x.is_sold_out})||product.skus&&product.skus[0];extra=[];dialog.querySelector('.nfh-guest-fields').hidden=true;dialog.querySelector('.nfh-purchase-banner').innerHTML='<svg viewBox="0 0 24 24" aria-hidden="true"><path fill="currentColor" d="M12 2 4 5v6c0 5.1 3.4 9.7 8 11 4.6-1.3 8-5.9 8-11V5zm-1.1 13.4-3.2-3.2 1.4-1.4 1.8 1.8 4.1-4.1 1.4 1.4z"/></svg><span>'+escapeHtml(settings.productBanner||'微信客服 · 全年无休 · 售后有保障')+'</span>';var cardTitle=titleOverride||(root.querySelector('.nfh-card[data-product-id="'+product.id+'"] .nfh-card-title')||{}).textContent;dialog.querySelector('h2').textContent=localized(product.category&&product.category.name)||cardTitle||localized(product.title)||'';dialog.querySelector('.nfh-detail-price').textContent='¥'+(sku&&sku.price_amount||product.price_amount||'0');dialog.querySelector('.nfh-detail-tags').innerHTML=(product.tags&&product.tags.length?product.tags.map(function(x){return localized(x.name||x)}):String(settings.tags||'').split(/[,,]/).filter(Boolean)).map(function(x){return '<span>'+escapeHtml(x)+'</span>'}).join('');dialog.querySelector('.nfh-detail-notice').textContent='';var cardForFaq=root.querySelector('[data-product-id="'+product.id+'"]');var cardQuestions=cardForFaq?Array.prototype.map.call(cardForFaq.querySelectorAll('.nfh-faq-slides .nfh-slide'),function(item){return item.textContent.trim()}).filter(Boolean):[];var faqRows=cardQuestions.length?cardQuestions:String(settings.faqs||'').split(/\r?\n/).filter(Boolean);var faqButtons=dialog.querySelectorAll('.nfh-detail-faq');faqButtons.forEach(function(button,index){if(index)button.remove()});var faqButton=dialog.querySelector('.nfh-detail-faq');if(faqRows.length){faqButton.innerHTML='<span class="nfh-detail-faq-slides">'+faqRows.map(function(question,index){return '<span class="nfh-slide"'+(index?' hidden':'')+'>'+escapeHtml(question)+'</span>'}).join('')+'</span><svg class="nfh-detail-faq-arrow" viewBox="0 0 24 24" aria-hidden="true"><path d="m9 5 7 7-7 7" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>';faqButton.hidden=false;faqButton.querySelector('.nfh-detail-faq-slides').dataset.nextCarousel=String(Date.now()+3500);faqButton.onclick=function(){dialog.close();var article=root.querySelector('[data-product-id="'+product.id+'"]');var trigger=article&&article.querySelector('.nfh-faq-trigger');if(trigger)trigger.click()}}else faqButton.hidden=true;var skus=(product.skus||[]).filter(function(x){return x.is_active!==false});dialog.querySelector('.nfh-detail-choices').innerHTML='<h3>商品</h3><div class="nfh-product-options">'+siblings.map(function(item){return '<button type="button" data-product-choice="'+escapeHtml(item.slug||item.id)+'" class="'+(Number(item.id)===Number(product.id)?'selected':'')+'"'+(item.is_sold_out?' disabled':'')+'>'+escapeHtml(localized(item.title)||'商品')+'</button>'}).join('')+'</div><h3>规格</h3><div class="nfh-sku-options">'+skus.map(function(item,i){return '<button type="button" data-sku="'+i+'" class="'+(item===sku?'selected':'')+'"'+(item.is_sold_out?' disabled':'')+'>'+escapeHtml(localized(item.spec_values)||item.sku_code)+' <span>¥'+escapeHtml(item.price_amount)+'</span></button>'}).join('')+'</div>';dialog.querySelectorAll('[data-product-choice]').forEach(function(b){b.onclick=function(){var request=++categoryRequest;fetch('/api/v1/public/products/'+encodeURIComponent(b.dataset.productChoice)).then(function(r){if(!r.ok)throw Error('商品加载失败');return r.json()}).then(function(data){if(data.status_code)throw Error(data.msg||'商品加载失败');if(request===categoryRequest)load(data)}).catch(function(e){if(request===categoryRequest)dialog.querySelector('.nfh-detail-error').textContent=e.message})}});dialog.querySelectorAll('[data-sku]').forEach(function(b){b.onclick=function(){sku=skus[Number(b.dataset.sku)];dialog.querySelectorAll('[data-sku]').forEach(function(option){option.classList.toggle('selected',option===b)});dialog.querySelector('.nfh-detail-price').textContent='¥'+sku.price_amount;preview()}});var schema=product.manual_form_schema&&Array.isArray(product.manual_form_schema.fields)?product.manual_form_schema.fields:[];dialog.querySelector('.nfh-detail-manual').innerHTML=schema.length?'<h3>交付信息</h3>'+schema.map(function(f){var key=String(f.key||'');if(!key)return '';var label=localized(f.title||f.label)||key,required=f.required?' required':'',safeKey=escapeHtml(key),type=f.type==='textarea'?'textarea':f.type==='select'?'select':f.type==='email'?'email':f.type==='phone'?'tel':f.type==='number'?'number':'text';if(type==='checkbox'||type==='radio'){var inputType=type;return '<fieldset class="nfh-manual-choice"><legend>'+escapeHtml(label)+(f.required?' *':'')+'</legend>'+((Array.isArray(f.options)?f.options:[]).map(function(v,index){var value=typeof v==='string'?v:localized(v);return '<label><input type="'+inputType+'" data-manual-key="'+safeKey+'" name="manual-'+safeKey+'" value="'+escapeHtml(value)+'"'+(f.required&&index===0?' required':'')+'> '+escapeHtml(value)+'</label>'}).join(''))+'</fieldset>'}if(type==='textarea')return '<label>'+escapeHtml(label)+'<textarea data-manual-key="'+safeKey+'"'+required+'></textarea></label>';if(type==='select')return '<label>'+escapeHtml(label)+'<select data-manual-key="'+safeKey+'"'+required+'><option value="">请选择</option>'+((Array.isArray(f.options)?f.options:[]).map(function(v){return '<option value="'+escapeHtml(v)+'">'+escapeHtml(v)+'</option>'}).join(''))+'</select></label>';return '<label>'+escapeHtml(label)+'<input type="'+type+'" data-manual-key="'+safeKey+'"'+required+' '+(f.placeholder?'placeholder="'+escapeHtml(localized(f.placeholder))+'"':'')+'></label>'}).join(''):'';var rows=String(settings.productAddons||'').split(/\r?\n/).filter(Boolean);dialog.querySelector('.nfh-detail-addons').innerHTML=settings.productAddonsEnabled==='是'&&rows.length?'<h3>特惠增购</h3>'+rows.map(function(r,i){var a=r.split('|');return '<label><input type="checkbox" data-addon="'+i+'"> '+escapeHtml(a[0])+' ¥'+escapeHtml(a[3]||'0')+'</label>'}).join(''):'';dialog.querySelectorAll('[data-addon]').forEach(function(b){b.onchange=function(){var a=rows[Number(b.dataset.addon)].split('|');extra=extra.filter(function(x){return x.id!==Number(a[1])});if(b.checked)extra.push({id:Number(a[1]),sku:Number(a[2])||0});preview()}});var couponRows=String(settings.productCouponOptions||'').split(/\r?\n/).map(function(line){return line.split('|')}).filter(function(row){return row[0]&&row[1]});var couponOptions=dialog.querySelector('.nfh-coupon-options');couponOptions.innerHTML=couponRows.map(function(row,index){return '<button type="button" data-coupon-option="'+index+'">'+escapeHtml(row[0])+'</button>'}).join('');couponOptions.hidden=!couponRows.length;couponOptions.querySelectorAll('[data-coupon-option]').forEach(function(button){button.onclick=function(){code=couponRows[Number(button.dataset.couponOption)][1].trim();dialog.querySelector('.nfh-detail-coupons input').value=code;preview()}});dialog.querySelector('[data-coupon="券"]').textContent=couponRows.length?(settings.productCouponLabel||'选择优惠券'):'无可用优惠券';dialog.querySelector('[data-coupon="码"]').textContent=settings.productCouponCodeLabel||'使用优惠码';dialog.querySelector('.nfh-detail-submit').textContent=memberOnly&&!localStorage.getItem('user_token')?'登录后购买':(settings.productSubmitLabel||'去付款');if(memberOnly&&!localStorage.getItem('user_token'))dialog.querySelector('.nfh-detail-error').textContent='';else preview()}
|
|
215
|
+
dialog.querySelectorAll('[data-coupon]').forEach(function(b){b.onclick=function(){if(b.dataset.coupon==='券'){var options=dialog.querySelector('.nfh-coupon-options');if(options.children.length){options.hidden=!options.hidden;dialog.querySelector('.nfh-detail-error').textContent=''}else dialog.querySelector('.nfh-detail-error').textContent='暂无可用优惠券';return}var i=dialog.querySelector('.nfh-detail-coupons input');i.hidden=false;i.focus();i.oninput=function(){clearTimeout(couponInputTimer);couponInputTimer=setTimeout(function(){code=i.value.trim();preview()},350)}}});dialog.querySelectorAll('.nfh-guest-fields input').forEach(function(i){i.addEventListener('input',function(){clearTimeout(guestInputTimer);guestInputTimer=setTimeout(preview,350)});i.addEventListener('change',preview)});dialog.querySelector('.nfh-detail-submit').onclick=function(){if(memberOnly&&!localStorage.getItem('user_token')){var back='/?buy='+encodeURIComponent(product.slug||product.id);location.href='/auth/login?redirect='+encodeURIComponent(back);return}if(!localStorage.getItem('user_token')){location.href=safeProductHref(product);return}var c=credentials();fetch(c.path+'/create-and-pay',{method:'POST',credentials:'include',headers:Object.assign({'Content-Type':'application/json','X-Lang':currentLocale()},c.headers),body:JSON.stringify(Object.assign({items:lineItems(),coupon_code:code||undefined,manual_form_data:manualFormData()},c.guest))}).then(function(r){return r.json()}).then(function(x){var d=x.data||x;if(x.status_code&&x.status_code!==0)throw Error(x.msg||'下单失败');if(!d.order_no)throw Error(x.message||'下单失败');location.href='/pay?'+(!localStorage.getItem('user_token')?'guest=1&':'')+'order_no='+encodeURIComponent(d.order_no)}).catch(function(e){dialog.querySelector('.nfh-detail-error').textContent=e.message||'下单失败'})};dialog.querySelector('.nfh-purchase-close').onclick=function(){dialog.close()};root.addEventListener('click',function(e){var b=e.target.closest('.nfh-buy[data-nfh-product],.nfh-card-title[data-nfh-product]');if(!b||b.classList.contains('is-sold'))return;e.preventDefault();dialog.showModal();fetch('/api/v1/public/products/'+encodeURIComponent(b.dataset.nfhProduct)).then(function(r){return r.json()}).then(function(data){load(data,b.dataset.nfhTitle)}).catch(function(){dialog.querySelector('.nfh-detail-error').textContent='商品加载失败'})});var pending=new URLSearchParams(location.search).get('buy');if(pending){history.replaceState(history.state,'',location.pathname);var trigger=Array.prototype.find.call(root.querySelectorAll('.nfh-buy[data-nfh-product]'),function(b){return b.dataset.nfhProduct===pending});if(trigger)trigger.click()}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
function render(config, products, productConfig) {
|
|
219
|
+
var statIcons = ['stat-support.svg', 'stat-riders.svg', 'stat-members.svg', 'stat-shield.svg'];
|
|
220
|
+
var stats = rows(config.serviceStats).slice(0, 4).map(function (row, index) {
|
|
221
|
+
return '<div class="nfh-stat"><span class="nfh-stat-icon">' + (statIcons[index] ? '<img src="' + assetRoot + 'assets/' + statIcons[index] + '" alt="">' : '') +
|
|
222
|
+
'</span><span class="nfh-stat-copy"><strong>' + escapeHtml(row[0]) + '</strong><small>' + escapeHtml(row[1]) + '</small></span></div>';
|
|
223
|
+
}).join('');
|
|
224
|
+
var promiseIcons = ['service-fast.png', 'service-24hours.png', 'service-replace.png', 'stat-support.svg'];
|
|
225
|
+
var promises = rows(config.servicePromises).slice(0, 4).map(function (row, index) {
|
|
226
|
+
return '<div class="nfh-promise"><img src="' + assetRoot + 'assets/' + promiseIcons[index] + '" alt=""><strong>' + escapeHtml(row[0].replace(/工单/g, '客服')) + '</strong></div>';
|
|
227
|
+
}).join('');
|
|
228
|
+
var blocks = null;
|
|
229
|
+
if (typeof config.productBlocks === 'string') { try { blocks = JSON.parse(config.productBlocks); if (!Array.isArray(blocks)) blocks = null; } catch (_error) { blocks = null; } }
|
|
230
|
+
var displayed = blocks === null ? products.map(function (product) { return { product: product, block: {} }; }) : blocks.map(function (block) { return { product: products.find(function (product) { return String(product.id) === String(block.productId); }), block: block }; }).filter(function (item) { return item.product; });
|
|
231
|
+
var cards = displayed.map(function (item, index) { return card(item.product, config, item.block, index, displayed.length); }).join('');
|
|
232
|
+
var cardLayoutClass = displayed.length >= 5 ? ' has-many' : '';
|
|
233
|
+
var logo = config.brandLogoUrl ? '<img src="' + escapeHtml(safeHref(config.brandLogoUrl, '/')) + '" alt="' + escapeHtml(config.brandName || '') + '">' : '<span>' + escapeHtml(config.brandName || '流媒体合租') + '</span>';
|
|
234
|
+
var tools = rows(config.quickTools).map(function (row) {
|
|
235
|
+
var href = row[1];
|
|
236
|
+
var content = '<span class="nfh-tool-icon">' + toolIcon(row[0]) + '</span><span>' + escapeHtml(row[0]) + '</span>';
|
|
237
|
+
return href ? '<a href="' + escapeHtml(safeHref(href, '/')) + '">' + content + '</a>' : '<span class="nfh-tool-static">' + content + '</span>';
|
|
238
|
+
}).join('');
|
|
239
|
+
var footerGroups = [
|
|
240
|
+
['footerProductsTitle', 'footerProducts'], ['footerNavigationTitle', 'footerNavigation'],
|
|
241
|
+
['footerPoliciesTitle', 'footerPolicies'], ['footerContactTitle', 'contactLinks']
|
|
242
|
+
].map(function (pair) {
|
|
243
|
+
var links = rows(config[pair[1]]).filter(function (row) { return pair[1] !== 'footerNavigation' || !/工单/.test(row[0]); }).map(function (row) {
|
|
244
|
+
if (pair[1] === 'contactLinks') {
|
|
245
|
+
var icon = socialIcon(row[0]);
|
|
246
|
+
var social = '<span class="nfh-contact-icon nfh-social-' + icon.platform + '">' + icon.svg + '</span>';
|
|
247
|
+
return row[1] ? '<a class="nfh-contact-action" href="' + escapeHtml(safeHref(row[1], '/')) + '" title="' + escapeHtml(row[0]) + '"' + (/^https?:/i.test(row[1]) ? ' target="_blank" rel="noopener noreferrer"' : '') + '>' + social + '</a>' : '<span class="nfh-contact-action" aria-label="' + escapeHtml(row[0]) + '">' + social + '</span>';
|
|
248
|
+
}
|
|
249
|
+
var href = row[1] || defaultHref(row[0]);
|
|
250
|
+
return href ? '<a href="' + escapeHtml(safeHref(href, '/')) + '"' + (/^https?:/i.test(href) ? ' target="_blank" rel="noopener noreferrer"' : '') + '>' + escapeHtml(row[0]) + '</a>' : '<span>' + escapeHtml(row[0]) + '</span>';
|
|
251
|
+
}).join('');
|
|
252
|
+
var contactHours = pair[1] === 'contactLinks' && config.contactHours ? '<p class="nfh-contact-hours">' + escapeHtml(config.contactHours) + '</p>' : '';
|
|
253
|
+
return '<section><h3>' + escapeHtml(config[pair[0]] || '') + '</h3>' + (pair[1] === 'contactLinks' ? '<div class="nfh-contact-socials">' + links + '</div>' : links) + contactHours + '</section>';
|
|
254
|
+
}).join('');
|
|
255
|
+
var licenseInfo = rows(config.licenseInfo).map(function (row) {
|
|
256
|
+
return row[1] ? '<a href="' + escapeHtml(safeHref(row[1], '/')) + '">' + escapeHtml(row[0]) + '</a>' : '<span>' + escapeHtml(row[0]) + '</span>';
|
|
257
|
+
}).join('<span class="nfh-license-separator">|</span>');
|
|
258
|
+
var languageOptions = [['zh-CN', '简体中文'], ['zh-TW', '繁體中文'], ['en-US', 'English']].map(function (item) {
|
|
259
|
+
return '<button type="button" role="option" class="nfh-language-option' + (item[0] === currentLocale() ? ' is-selected' : '') + '" data-locale="' + item[0] + '" aria-selected="' + (item[0] === currentLocale()) + '">' + item[1] + '</button>';
|
|
260
|
+
}).join('');
|
|
261
|
+
var defaultPromoTitle = '邀请好友购买享 20% 佣金';
|
|
262
|
+
var defaultPromoSubtitle = '专属优惠 · 实时到账 · 随时提现';
|
|
263
|
+
var promoTitle = config.promotionTitle || defaultPromoTitle;
|
|
264
|
+
var promoSubtitle = config.promotionSubtitle || defaultPromoSubtitle;
|
|
265
|
+
var promoTitleMarkup = promoTitle === defaultPromoTitle
|
|
266
|
+
? '邀请好友购买享 <span class="nfh-promo-emphasis">20%</span> 佣金'
|
|
267
|
+
: escapeHtml(promoTitle);
|
|
268
|
+
var promoSubtitleMarkup = promoSubtitle === defaultPromoSubtitle
|
|
269
|
+
? '<span>' + checkIcon() + '专属优惠</span><span>' + checkIcon() + '实时到账</span><span>' + checkIcon() + '随时提现</span>'
|
|
270
|
+
: '<small>' + escapeHtml(promoSubtitle) + '</small>';
|
|
271
|
+
var promo = config.promotionEnabled === '否' ? '' : '<div class="nfh-promo-wrap"><a class="nfh-promo" href="' + escapeHtml(safeHref(config.promotionUrl, '/me/affiliate')) + '"><span class="nfh-promo-icon">' + promoUserIcon() + '</span><span class="nfh-promo-copy"><strong>' + promoTitleMarkup + '</strong><span class="nfh-promo-benefits">' + promoSubtitleMarkup + '</span></span><b>' + escapeHtml(config.promotionButtonLabel || '去推荐') + '</b></a></div>';
|
|
272
|
+
var customHeading = (config.productsTitle && config.productsTitle !== '热门商品') || config.productsSubtitle;
|
|
273
|
+
var productHeading = customHeading ? '<div class="nfh-section-heading"><div>' + (config.productsTitle && config.productsTitle !== '热门商品' ? '<h2>' + escapeHtml(config.productsTitle) + '</h2>' : '') + (config.productsSubtitle ? '<p>' + escapeHtml(config.productsSubtitle) + '</p>' : '') + '</div></div>' : '';
|
|
274
|
+
var heroTitle = config.heroTitle ? '<h1>' + escapeHtml(config.heroTitle) + '</h1>' : '';
|
|
275
|
+
var heroSubtitle = config.heroSubtitle ? '<p class="nfh-hero-subtitle">' + escapeHtml(config.heroSubtitle) + '</p>' : '';
|
|
276
|
+
|
|
277
|
+
root = document.createElement('div');
|
|
278
|
+
root.id = 'netflix-theme-home';
|
|
279
|
+
root.innerHTML = '<header class="nfh-header"><nav class="nfh-header-inner"><a class="nfh-logo" href="/">' + logo + '</a><div class="nfh-header-right"><div class="nfh-header-nav"><a class="is-active" href="/">' + escapeHtml(configuredLabel(config.navHomeLabel, '首页', 'home')) + '</a><a href="/me/orders">' + escapeHtml(configuredLabel(config.navProductsLabel, '车票', 'tickets')) + '</a><a href="/me/affiliate">' + escapeHtml(configuredLabel(config.navPromotionLabel, '推广', 'promotion')) + '</a></div><div class="nfh-header-actions"><a class="nfh-header-icon" href="/auth/login" aria-label="' + escapeHtml(translate('login')) + '"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M15 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2m5-10a4 4 0 1 0 0-8 4 4 0 0 0 0 8Zm7-3h5m-2.5-2.5v5" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/></svg></a><a class="nfh-header-icon" href="/notice" aria-label="' + escapeHtml(translate('notifications')) + '"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M18 8a6 6 0 0 0-12 0c0 7-3 7-3 9h18c0-2-3-2-3-9m-8 12h4" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/></svg></a><a class="nfh-header-avatar" href="/me" aria-label="' + escapeHtml(translate('mine')) + '"><svg viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="8" r="3.5"/><path d="M5 21v-2a7 7 0 0 1 14 0v2z"/></svg></a></div></div></nav></header>' +
|
|
280
|
+
'<section class="nfh-hero">' + heroTitle + heroSubtitle + '<div class="nfh-stats">' + stats + '</div>' + promo + '<div class="nfh-hero-wave" aria-hidden="true"></div></section>' +
|
|
281
|
+
'<main class="nfh-main">' + productHeading + '<section class="nfh-products' + cardLayoutClass + '" aria-label="商品列表">' + (cards || '<div class="nfh-empty"><strong>暂无商品</strong><span>商品上架后会自动显示在这里</span></div>') + '</section></main>' +
|
|
282
|
+
'<aside class="nfh-tools" aria-label="快捷入口">' + tools + '</aside>' +
|
|
283
|
+
'<button class="nfh-to-top" type="button" aria-label="返回顶部"><svg viewBox="0 0 24 24" aria-hidden="true"><path fill="currentColor" d="M7.41 15.41L12 10.83l4.59 4.58L18 14l-6-6l-6 6z"/></svg></button>' +
|
|
284
|
+
'<footer class="nfh-footer"><div class="nfh-footer-inner"><div class="nfh-promises">' + promises + '</div><div class="nfh-footer-divider"></div><div class="nfh-footer-body"><div class="nfh-footer-links">' + footerGroups + '</div>' +
|
|
285
|
+
'</div><div class="nfh-language"><label for="nfh-language-select">' + escapeHtml(translate('language')) + '</label><div class="nfh-language-picker"><button id="nfh-language-select" class="nfh-language-select" type="button" aria-haspopup="listbox" aria-expanded="false"><span class="nfh-language-current"></span><svg viewBox="0 0 24 24" aria-hidden="true"><path d="m6 9 6 6 6-6"/></svg></button><div class="nfh-language-menu" role="listbox" aria-label="' + escapeHtml(translate('language')) + '" hidden>' + languageOptions + '</div></div></div>' +
|
|
286
|
+
'<div class="nfh-footer-bottom"><span>' + escapeHtml(config.copyrightText || '') + '</span><div>' + licenseInfo + '</div></div></div></footer>' +
|
|
287
|
+
'<nav class="nfh-mobile" aria-label="移动导航"><a class="is-active" href="/">⌂<span>' + escapeHtml(configuredLabel(config.navHomeLabel, '首页', 'home')) + '</span></a><a href="/me/orders">▣<span>' + escapeHtml(configuredLabel(config.navProductsLabel, '车票', 'tickets')) + '</span></a><a href="/me/affiliate">♧<span>' + escapeHtml(configuredLabel(config.navPromotionLabel, '推广', 'promotion')) + '</span></a><a href="/me">♙<span>' + escapeHtml(translate('mine')) + '</span></a></nav>';
|
|
288
|
+
|
|
289
|
+
if (config.heroBackgroundUrl) {
|
|
290
|
+
var background = safeHref(config.heroBackgroundUrl, '');
|
|
291
|
+
if (background) root.querySelector('.nfh-hero').style.backgroundImage = 'linear-gradient(rgba(239,83,80,.82),rgba(239,83,80,.82)),url("' + background.replace(/["\\]/g, '') + '")';
|
|
292
|
+
}
|
|
293
|
+
host = document.querySelector('#app');
|
|
294
|
+
if (!host) { root = null; return false; }
|
|
295
|
+
hostDisplay = host.style.display;
|
|
296
|
+
host.style.display = 'none';
|
|
297
|
+
document.body.appendChild(root);
|
|
298
|
+
mountPurchaseDialog(productConfig || {}, products);
|
|
299
|
+
root.querySelectorAll('.nfh-faq').forEach(function (faq) { var dialog = faq.querySelector('dialog'); if (!dialog) return; faq.querySelector('.nfh-faq-trigger').addEventListener('click', function () { dialog.showModal(); }); dialog.querySelectorAll('.nfh-faq-close,.nfh-faq-return').forEach(function (button) { button.addEventListener('click', function () { dialog.close(); }); }); dialog.addEventListener('click', function (event) { if (event.target === dialog) dialog.close(); }); });
|
|
300
|
+
var carouselStartedAt = Date.now();
|
|
301
|
+
root.querySelectorAll('.nfh-card').forEach(function (card, cardIndex) {
|
|
302
|
+
card.querySelectorAll('.nfh-faq-slides, .nfh-recent, .nfh-avatars').forEach(function (group) {
|
|
303
|
+
var orderGroup = group.classList.contains('nfh-recent') || group.classList.contains('nfh-avatars');
|
|
304
|
+
group.dataset.nextCarousel = String(carouselStartedAt + 2600 + cardIndex * 700 + (orderGroup ? 1300 : 0));
|
|
305
|
+
group.dataset.carouselInterval = String((orderGroup ? 4100 : 3500) + cardIndex * 350);
|
|
306
|
+
});
|
|
307
|
+
});
|
|
308
|
+
carouselTimer = window.setInterval(function () {
|
|
309
|
+
if (!root || document.hidden) return;
|
|
310
|
+
root.querySelectorAll('.nfh-faq-slides, .nfh-detail-faq-slides, .nfh-recent, .nfh-avatars').forEach(function (group) {
|
|
311
|
+
if (group.classList.contains('nfh-detail-faq-slides') && !dialogIsOpen(group)) return;
|
|
312
|
+
if (Date.now() < Number(group.dataset.nextCarousel || 0)) return;
|
|
313
|
+
group.dataset.nextCarousel = String(Date.now() + Number(group.dataset.carouselInterval || 3500));
|
|
314
|
+
if (group.closest('details[open]')) return;
|
|
315
|
+
var items = group.classList.contains('nfh-avatars') ? group.children : group.querySelectorAll('.nfh-slide');
|
|
316
|
+
if (items.length < 2) return;
|
|
317
|
+
if (group.classList.contains('nfh-avatars')) {
|
|
318
|
+
var first = items[0];
|
|
319
|
+
var animation = first.animate([{ transform: 'translateX(0)', opacity: 1 }, { transform: 'translateX(-19px)', opacity: 0 }], { duration: 450, easing: 'ease-in-out' });
|
|
320
|
+
animation.onfinish = function () { if (first.parentNode === group) { first.hidden = true; group.appendChild(first); var next = group.querySelector('img[hidden]'); if (next) next.hidden = false; } };
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
var current = Array.prototype.findIndex.call(items, function (item) { return !item.hidden; });
|
|
324
|
+
if (current < 0) current = 0;
|
|
325
|
+
var outgoing = items[current]; var incoming = items[(current + 1) % items.length];
|
|
326
|
+
var horizontal = group.classList.contains('nfh-recent');
|
|
327
|
+
incoming.hidden = false;
|
|
328
|
+
incoming.style.position = 'absolute'; incoming.style.inset = '0';
|
|
329
|
+
var framesOut = horizontal ? [{transform:'translateX(0)'},{transform:'translateX(-100%)'}] : [{transform:'translateY(0)'},{transform:'translateY(-100%)'}];
|
|
330
|
+
var framesIn = horizontal ? [{transform:'translateX(100%)'},{transform:'translateX(0)'}] : [{transform:'translateY(100%)'},{transform:'translateY(0)'}];
|
|
331
|
+
outgoing.animate(framesOut, {duration:450,easing:'ease-in-out'});
|
|
332
|
+
var transition = incoming.animate(framesIn, {duration:450,easing:'ease-in-out'});
|
|
333
|
+
transition.onfinish = function () { outgoing.hidden = true; incoming.style.position = ''; incoming.style.inset = ''; };
|
|
334
|
+
});
|
|
335
|
+
}, 100);
|
|
336
|
+
var localeSelect = root.querySelector('#nfh-language-select');
|
|
337
|
+
var localeMenu = root.querySelector('.nfh-language-menu');
|
|
338
|
+
var localePicker = root.querySelector('.nfh-language-picker');
|
|
339
|
+
function updateLocaleLabel() { var option = localeMenu.querySelector('[data-locale="' + currentLocale() + '"]'); root.querySelector('.nfh-language-current').textContent = option ? option.textContent : '简体中文'; }
|
|
340
|
+
function closeLocaleMenu() { localeMenu.hidden = true; localeSelect.setAttribute('aria-expanded', 'false'); }
|
|
341
|
+
updateLocaleLabel();
|
|
342
|
+
localeSelect.addEventListener('click', function () { var open = localeMenu.hidden; localeMenu.hidden = !open; localeSelect.setAttribute('aria-expanded', String(open)); });
|
|
343
|
+
localeMenu.addEventListener('click', function (event) {
|
|
344
|
+
var option = event.target.closest('[data-locale]'); if (!option) return;
|
|
345
|
+
if (option.dataset.locale === currentLocale()) { closeLocaleMenu(); return; }
|
|
346
|
+
try { window.localStorage.setItem('locale', option.dataset.locale); } catch (_error) {}
|
|
347
|
+
window.location.reload();
|
|
348
|
+
});
|
|
349
|
+
localeSelect.addEventListener('keydown', function (event) { if (event.key === 'Escape') closeLocaleMenu(); });
|
|
350
|
+
localeOutsideHandler = function (event) { if (root && !localePicker.contains(event.target)) closeLocaleMenu(); };
|
|
351
|
+
document.addEventListener('click', localeOutsideHandler);
|
|
352
|
+
scrollHandler = function () {
|
|
353
|
+
if (root) root.classList.toggle('has-scrolled', window.scrollY > 300);
|
|
354
|
+
};
|
|
355
|
+
window.addEventListener('scroll', scrollHandler, { passive: true });
|
|
356
|
+
root.querySelector('.nfh-to-top').addEventListener('click', function () {
|
|
357
|
+
window.scrollTo({ top: 0, behavior: 'smooth' });
|
|
358
|
+
});
|
|
359
|
+
scrollHandler();
|
|
360
|
+
return true;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
function unmount() {
|
|
364
|
+
if (root) root.remove();
|
|
365
|
+
if (host && host.isConnected) host.style.display = hostDisplay;
|
|
366
|
+
if (stylesheet) stylesheet.remove();
|
|
367
|
+
if (scrollHandler) window.removeEventListener('scroll', scrollHandler);
|
|
368
|
+
if (carouselTimer) window.clearInterval(carouselTimer);
|
|
369
|
+
if (localeOutsideHandler) document.removeEventListener('click', localeOutsideHandler);
|
|
370
|
+
carouselTimer = null;
|
|
371
|
+
localeOutsideHandler = null;
|
|
372
|
+
scrollHandler = null;
|
|
373
|
+
root = stylesheet = host = null;
|
|
374
|
+
releaseHomeGate();
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
function mount() {
|
|
378
|
+
if (root || mountPending || !pluginEnabled || window.location.pathname !== '/' || Date.now() - lastMountAttempt < 2500) return;
|
|
379
|
+
lastMountAttempt = Date.now();
|
|
380
|
+
var token = ++requestToken;
|
|
381
|
+
mountPending = true;
|
|
382
|
+
Promise.all([
|
|
383
|
+
fetch('/plugins/appstore/api/plugins/netflix/public-home-config', { cache: 'no-store' }).then(function (response) {
|
|
384
|
+
if (!response.ok) throw new Error('Homepage configuration unavailable');
|
|
385
|
+
return response.json();
|
|
386
|
+
}),
|
|
387
|
+
fetch('/api/v1/public/products?page=1&page_size=100', { cache: 'no-store' }).then(function (response) {
|
|
388
|
+
if (!response.ok) throw new Error('Product list unavailable');
|
|
389
|
+
return response.json();
|
|
390
|
+
}),
|
|
391
|
+
fetch('/plugins/appstore/api/plugins/netflix/public-product-config', { cache: 'no-store' }).then(function(response){return response.ok?response.json():{config:{}}}).catch(function(){return {config:{}}})
|
|
392
|
+
]).then(function (result) {
|
|
393
|
+
if (token !== requestToken || !pluginEnabled || window.location.pathname !== '/') return;
|
|
394
|
+
if (!result[0].ok || !Array.isArray(result[1].data)) { releaseHomeGate(); return; }
|
|
395
|
+
stylesheet = document.createElement('link');
|
|
396
|
+
stylesheet.rel = 'stylesheet';
|
|
397
|
+
stylesheet.href = assetRoot + 'home.css';
|
|
398
|
+
stylesheet.onload = function () {
|
|
399
|
+
if (token !== requestToken || !pluginEnabled || window.location.pathname !== '/') { unmount(); return; }
|
|
400
|
+
if (!render(result[0].config || {}, result[1].data, result[2].config || {})) unmount();
|
|
401
|
+
else releaseHomeGate();
|
|
402
|
+
};
|
|
403
|
+
stylesheet.onerror = function () { if (token === requestToken) unmount(); };
|
|
404
|
+
document.head.appendChild(stylesheet);
|
|
405
|
+
}).catch(function (error) {
|
|
406
|
+
if (token === requestToken) {
|
|
407
|
+
console.warn('[netflix theme] Homepage was not mounted:', error);
|
|
408
|
+
unmount();
|
|
409
|
+
}
|
|
410
|
+
}).finally(function () {
|
|
411
|
+
if (token === requestToken) mountPending = false;
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
function syncRoute() {
|
|
416
|
+
if (window.location.pathname === '/') mount();
|
|
417
|
+
else { requestToken++; mountPending = false; unmount(); }
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
function checkPlugin() {
|
|
421
|
+
fetch('/plugins/appstore/api/plugins/public-assets?context=store', { cache: 'no-store' }).then(function (response) {
|
|
422
|
+
if (!response.ok) throw new Error('Plugin registry unavailable');
|
|
423
|
+
return response.json();
|
|
424
|
+
}).then(function (registry) {
|
|
425
|
+
var enabled = Array.isArray(registry.assets) && registry.assets.some(function (plugin) { return plugin.id === 'netflix'; });
|
|
426
|
+
if (enabled === pluginEnabled) return;
|
|
427
|
+
pluginEnabled = enabled;
|
|
428
|
+
if (pluginEnabled) { lastMountAttempt = 0; mount(); }
|
|
429
|
+
else { requestToken++; mountPending = false; unmount(); }
|
|
430
|
+
}).catch(function () { if (!root) releaseHomeGate(); });
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
window.addEventListener('popstate', syncRoute);
|
|
434
|
+
window.addEventListener('hashchange', syncRoute);
|
|
435
|
+
checkPlugin();
|
|
436
|
+
checkTimer = window.setInterval(checkPlugin, 2500);
|
|
437
|
+
routeTimer = window.setInterval(syncRoute, 500);
|
|
438
|
+
window.addEventListener('pagehide', function () {
|
|
439
|
+
window.clearInterval(checkTimer);
|
|
440
|
+
window.clearInterval(routeTimer);
|
|
441
|
+
requestToken++;
|
|
442
|
+
mountPending = false;
|
|
443
|
+
unmount();
|
|
444
|
+
}, { once: true });
|
|
445
|
+
})();
|
package/public/icon.svg
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><rect width="64" height="64" rx="16" fill="#e50914"/><path d="M19 14h10l16 36H35L19 14zm0 36V14h9v36h-9zm17-36h9v36h-9V14z" fill="#fff"/></svg>
|