@etspress/netflix 0.1.12 → 0.1.13
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/config.html +1 -1
- package/public/config.js +13 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etspress/netflix",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.13",
|
|
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.13",
|
|
22
22
|
"runtime": {
|
|
23
23
|
"type": "npm-static",
|
|
24
24
|
"publicRoot": "public"
|
package/plugin.json
CHANGED
package/public/config.html
CHANGED
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
.back-button svg{width:14px;height:14px;flex:0 0 auto}
|
|
51
51
|
@media(max-width:420px){.tabs-row{align-items:flex-start}.tabs-row .back-button{padding:4px 8px}}
|
|
52
52
|
.faq-config{margin:14px 0;border:1px solid var(--border);border-radius:6px;padding:10px}.faq-config h4{font-size:13px;margin:0 0 10px}.faq-config-item{display:grid;gap:8px;margin-bottom:10px;padding-bottom:10px;border-bottom:1px solid var(--border)}.faq-config-item textarea{min-height:60px}.faq-config-item button{justify-self:start}
|
|
53
|
-
.block-editor{grid-column:1/-1;display:grid;grid-template-columns:220px minmax(0,1fr);gap:14px;margin-top:2px}.block-list,.block-detail{min-width:0;border:1px solid var(--border);border-radius:6px;padding:10px}.block-list button,.block-detail button{border:1px solid var(--border);border-radius:6px;background:var(--background);color:var(--foreground);padding:7px 10px;cursor:pointer}.block-list .block-add{width:100%;margin-bottom:8px}.block-item{display:block;width:100%;margin-top:5px;text-align:left;cursor:grab!important}.block-item:active{cursor:grabbing!important}.block-item[aria-selected=true]{background:var(--muted);font-weight:600}.
|
|
53
|
+
.block-editor{grid-column:1/-1;display:grid;grid-template-columns:220px minmax(0,1fr);gap:14px;margin-top:2px}.block-list,.block-detail{min-width:0;border:1px solid var(--border);border-radius:6px;padding:10px}.block-list button,.block-detail button{border:1px solid var(--border);border-radius:6px;background:var(--background);color:var(--foreground);padding:7px 10px;cursor:pointer}.block-list .block-add{width:100%;margin-bottom:8px}.block-item{display:block;width:100%;margin-top:5px;text-align:left;cursor:grab!important}.block-item:active{cursor:grabbing!important}.block-item[aria-selected=true]{background:var(--muted);font-weight:600}.category-select{position:relative;z-index:1}.category-select:focus-within,.category-select:has([aria-expanded=true]){z-index:20}.category-select-trigger{display:flex;width:100%;height:36px;align-items:center;justify-content:space-between;gap:8px;padding:0 11px;border:1px solid var(--border);border-radius:6px;background:var(--background);color:var(--foreground);font:inherit;font-size:13px;text-align:left;box-shadow:0 1px 2px #00000008;cursor:pointer;transition:border-color .15s,box-shadow .15s}.category-select-trigger:hover{background:var(--muted)}.category-select-trigger:focus-visible{outline:2px solid color-mix(in srgb,var(--foreground) 22%,transparent);outline-offset:2px}.category-select-trigger[aria-expanded=true]{border-color:var(--muted-foreground);box-shadow:0 0 0 2px color-mix(in srgb,var(--foreground) 10%,transparent)}.category-select-trigger svg{width:16px;height:16px;flex:none;fill:none;stroke:var(--muted-foreground);stroke-width:2;stroke-linecap:round;stroke-linejoin:round}.category-select-value{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.category-select-menu{position:absolute;top:calc(100% + 4px);left:0;right:0;z-index:50;max-height:240px;overflow:auto;padding:4px;border:1px solid var(--border);border-radius:6px;background:var(--background);color:var(--foreground);box-shadow:0 8px 24px #0003;animation:category-select-in .12s ease-out}.category-select-menu[hidden]{display:none}.category-select-option{display:flex;width:100%;min-height:34px;align-items:center;padding:6px 9px;border:0!important;border-radius:4px!important;background:transparent!important;color:var(--foreground)!important;font:inherit;font-size:13px;text-align:left;cursor:pointer}.category-select-option:hover,.category-select-option:focus-visible{background:var(--muted)!important;outline:none}.category-select-option[aria-selected=true]{font-weight:600}.category-select-option:disabled{opacity:.45;cursor:not-allowed}.block-detail-actions{display:flex;gap:8px;margin-top:10px}.block-empty{color:var(--muted-foreground);font-size:12px}@keyframes category-select-in{from{opacity:0;transform:translateY(-3px)}to{opacity:1;transform:translateY(0)}}@media(max-width:680px){.block-editor{grid-template-columns:1fr}}
|
|
54
54
|
</style>
|
|
55
55
|
</head>
|
|
56
56
|
<body><main class="shell">
|
package/public/config.js
CHANGED
|
@@ -267,19 +267,24 @@
|
|
|
267
267
|
else {
|
|
268
268
|
var productField = document.createElement('div'); productField.className = 'field';
|
|
269
269
|
var productLabel = document.createElement('label'); productLabel.textContent = '绑定原生商品分类'; productLabel.htmlFor = 'block-category';
|
|
270
|
-
var
|
|
271
|
-
var
|
|
270
|
+
var selectRoot = document.createElement('div'); selectRoot.className = 'category-select'; selectRoot.id = 'block-category';
|
|
271
|
+
var selectedCategory = productCategories.find(function (item) { return String(item.id) === String(block.categoryId); });
|
|
272
|
+
var trigger = document.createElement('button'); trigger.type = 'button'; trigger.className = 'category-select-trigger'; trigger.setAttribute('role','combobox'); trigger.setAttribute('aria-haspopup','listbox'); trigger.setAttribute('aria-expanded','false'); trigger.setAttribute('aria-label','绑定原生商品分类');
|
|
273
|
+
trigger.innerHTML = '<span class="category-select-value">' + escapeHtml(selectedCategory ? categoryName(selectedCategory) + '(' + productList.filter(function(p){return String(p.category_id)===String(selectedCategory.id)}).length + ' 个商品)' : '请选择商品分类') + '</span><svg viewBox="0 0 24 24" aria-hidden="true"><path d="m7 10 5 5 5-5"/></svg>';
|
|
274
|
+
var menu = document.createElement('div'); menu.className='category-select-menu'; menu.setAttribute('role','listbox'); menu.hidden=true;
|
|
275
|
+
var selectedValue = String(block.categoryId || '');
|
|
276
|
+
var placeholder = document.createElement('button'); placeholder.type='button'; placeholder.className='category-select-option'; placeholder.setAttribute('role','option'); placeholder.setAttribute('aria-selected',String(!selectedValue)); placeholder.textContent='请选择商品分类'; placeholder.onclick=function(){block.categoryId='';delete block.productId;blocksExplicit=true;renderBlockEditor(container)}; menu.appendChild(placeholder);
|
|
272
277
|
var usedCategories = Object.create(null);
|
|
273
278
|
productBlocks.forEach(function (item, index) { if (index !== selectedBlock && item.categoryId) usedCategories[String(item.categoryId)] = true; });
|
|
274
279
|
productCategories.forEach(function (category) {
|
|
275
|
-
var option = document.createElement('option'); option.value = String(category.id);
|
|
276
280
|
var categoryProducts = productList.filter(function (product) { return String(product.category_id) === String(category.id); });
|
|
277
|
-
option
|
|
278
|
-
option.disabled = Boolean(usedCategories[option.value]); select.appendChild(option);
|
|
281
|
+
var option = document.createElement('button'); option.type='button'; option.className='category-select-option'; option.setAttribute('role','option'); option.setAttribute('aria-selected',String(String(category.id)===selectedValue)); option.textContent=categoryName(category)+'('+categoryProducts.length+' 个商品)'; option.disabled=Boolean(usedCategories[String(category.id)]); option.onclick=function(){if(option.disabled)return;block.categoryId=String(category.id);delete block.productId;seedCategoryDefaults(block,category,true);blocksExplicit=true;renderBlockEditor(container)}; menu.appendChild(option);
|
|
279
282
|
});
|
|
280
|
-
if (block.categoryId && !
|
|
281
|
-
|
|
282
|
-
|
|
283
|
+
if (block.categoryId && !selectedCategory) { var missing=document.createElement('button'); missing.type='button'; missing.className='category-select-option'; missing.setAttribute('role','option'); missing.setAttribute('aria-selected','true'); missing.textContent='分类不可用('+block.categoryId+')'; menu.appendChild(missing); }
|
|
284
|
+
trigger.onclick=function(){var opened=trigger.getAttribute('aria-expanded')==='true';trigger.setAttribute('aria-expanded',String(!opened));menu.hidden=opened;};
|
|
285
|
+
trigger.onkeydown=function(event){if(event.key==='ArrowDown'||event.key==='Enter'||event.key===' '){event.preventDefault();trigger.setAttribute('aria-expanded','true');menu.hidden=false;menu.querySelector('.category-select-option:not(:disabled)').focus()}else if(event.key==='Escape'){menu.hidden=true;trigger.setAttribute('aria-expanded','false')}};
|
|
286
|
+
menu.addEventListener('keydown',function(event){var options=Array.prototype.filter.call(menu.querySelectorAll('.category-select-option:not(:disabled)'),function(item){return true}),index=options.indexOf(document.activeElement);if(event.key==='Escape'){menu.hidden=true;trigger.setAttribute('aria-expanded','false');trigger.focus()}else if(event.key==='ArrowDown'||event.key==='ArrowUp'){event.preventDefault();options[(index+(event.key==='ArrowDown'?1:options.length-1))%options.length].focus()}});
|
|
287
|
+
selectRoot.append(trigger,menu); productField.append(productLabel, selectRoot); detail.appendChild(productField);
|
|
283
288
|
var ribbonWrap = document.createElement('div'); ribbonWrap.className = 'field field-switch'; var ribbonLabel = document.createElement('span'); ribbonLabel.className = 'field-label'; ribbonLabel.textContent = '显示商品角标'; var ribbonSwitch = document.createElement('button'); ribbonSwitch.type = 'button'; ribbonSwitch.className = 'switch'; ribbonSwitch.setAttribute('role','switch'); ribbonSwitch.setAttribute('aria-label','显示商品角标'); ribbonSwitch.setAttribute('aria-checked',String(block.ribbonEnabled !== false)); var ribbonThumb = document.createElement('span'); ribbonThumb.className = 'switch-thumb'; ribbonSwitch.appendChild(ribbonThumb); ribbonSwitch.onclick = function () { block.ribbonEnabled = ribbonSwitch.getAttribute('aria-checked') !== 'true'; ribbonSwitch.setAttribute('aria-checked',String(block.ribbonEnabled)); }; ribbonWrap.append(ribbonLabel,ribbonSwitch); detail.appendChild(ribbonWrap);
|
|
284
289
|
[['title','卡片标题'],['tags','标签(逗号分隔)'],['description','卡片简介'],['ribbon','角标文案'],['button','购买按钮文案'],['priceUnit','价格单位'],['recentText','上车时间轮播文案(每行一条)'],['demoAvatars','上车头像 URL(每行一个)'],['supportLinks','售后支持(每行:名称|链接)']].forEach(function (entry) {
|
|
285
290
|
var wrap = document.createElement('div'); wrap.className = 'field'; var label = document.createElement('label'); label.textContent = entry[1];
|