diff --git a/plugins/addon/theme_configurator/template/admin/index.html b/plugins/addon/theme_configurator/template/admin/index.html index df05522..694938d 100644 --- a/plugins/addon/theme_configurator/template/admin/index.html +++ b/plugins/addon/theme_configurator/template/admin/index.html @@ -179,81 +179,6 @@ - - -
-
-
-

顶部导航

-
-
-
- -
-
-
-
-

底部导航

-
-
-
- -
-
-
- - -
-
-
-

友情链接

-
-
- - -
-
-
-
-

侧边浮窗

-
-
-
- -
-
-
-
-

反馈类型

-
-
-
- -
-
-
- - -
-
-
-

JSON配置编辑器

-

直接编辑完整JSON配置

-
-
-
- 使用说明: 点击"同步"按钮将所有表单数据转为JSON,编辑后点击"应用"更新表单 -
- -
- - - -
-
-
-
- @@ -316,15 +241,6 @@ // 渲染荣誉列表 renderHonors(data.honor || []); - - // 渲染导航 - renderHeaderNav(data.header_nav || []); - renderFooterNav(data.footer_nav || []); - - // 渲染其他配置 - renderFriendlyLinks(data.friendly_link || []); - renderSides(data.side || []); - renderFeedbackTypes(data.feedback_type || []); } // 获取嵌套属性值 @@ -349,14 +265,11 @@ setNestedValue(data, name, input.value); }); - // 收集动态列表数据 + // 收集轮播数据 data.banner = collectBanners(); + + // 收集荣誉数据 data.honor = collectHonors(); - data.friendly_link = collectFriendlyLinks(); - data.side = collectSides(); - data.feedback_type = collectFeedbackTypes(); - data.header_nav = collectHeaderNav(); - data.footer_nav = collectFooterNav(); return data; } @@ -489,451 +402,12 @@ renderHonors(honors); }; - // ========== 友情链接 ========== - function renderFriendlyLinks(links) { - const container = document.getElementById('friendlyLinkList'); - container.innerHTML = ''; - links.forEach((link, index) => { - const item = document.createElement('div'); - item.className = 'config-item'; - item.innerHTML = ` -
-

链接 ${index + 1}

- -
-
-
-
- - -
-
- - -
-
-
- `; - container.appendChild(item); - }); - } - - function collectFriendlyLinks() { - const links = []; - document.querySelectorAll('[data-friendly]').forEach(input => { - const index = parseInt(input.dataset.friendly); - const field = input.dataset.field; - if (!links[index]) links[index] = {}; - links[index][field] = input.value; - }); - return links.filter(l => l); - } - - window.addFriendlyLink = function () { - const links = collectFriendlyLinks(); - links.push({ name: '', url: '' }); - renderFriendlyLinks(links); - }; - - window.removeFriendlyLink = function (index) { - const links = collectFriendlyLinks(); - links.splice(index, 1); - renderFriendlyLinks(links); - }; - - // ========== 侧边浮窗 ========== - function renderSides(sides) { - const container = document.getElementById('sideList'); - container.innerHTML = ''; - sides.forEach((side, index) => { - const item = document.createElement('div'); - item.className = 'config-item'; - item.innerHTML = ` -
-

浮窗 ${index + 1}

- -
-
-
-
- - -
-
- -
- - -
-
-
- - -
-
-
- `; - container.appendChild(item); - }); - } - - function collectSides() { - const sides = []; - document.querySelectorAll('[data-side]').forEach(input => { - const index = parseInt(input.dataset.side); - const field = input.dataset.field; - if (!sides[index]) sides[index] = {}; - sides[index][field] = input.value; - }); - return sides.filter(s => s); - } - - window.addSide = function () { - const sides = collectSides(); - sides.push({ name: '', icon: '', content: '' }); - renderSides(sides); - }; - - window.removeSide = function (index) { - const sides = collectSides(); - sides.splice(index, 1); - renderSides(sides); - }; - - // ========== 反馈类型 ========== - function renderFeedbackTypes(types) { - const container = document.getElementById('feedbackTypeList'); - container.innerHTML = ''; - types.forEach((type, index) => { - const item = document.createElement('div'); - item.className = 'config-item'; - item.innerHTML = ` -
-

类型 ${index + 1}

- -
-
-
-
- - -
-
- - -
-
- - -
-
-
- `; - container.appendChild(item); - }); - } - - function collectFeedbackTypes() { - const types = []; - document.querySelectorAll('[data-feedback]').forEach(input => { - const index = parseInt(input.dataset.feedback); - const field = input.dataset.field; - if (!types[index]) types[index] = {}; - types[index][field] = input.value; - }); - return types.filter(t => t); - } - - window.addFeedbackType = function () { - const types = collectFeedbackTypes(); - types.push({ id: '', name: '', description: '' }); - renderFeedbackTypes(types); - }; - - window.removeFeedbackType = function (index) { - const types = collectFeedbackTypes(); - types.splice(index, 1); - renderFeedbackTypes(types); - }; - - // ========== 顶部导航 ========== - function renderHeaderNav(navs) { - const container = document.getElementById('headerNavList'); - container.innerHTML = ''; - - navs.forEach((nav, index) => { - const item = document.createElement('div'); - item.className = 'config-item'; - const hasChildren = Array.isArray(nav.children) && nav.children.length > 0; - - item.innerHTML = ` -
-

导航 ${index + 1}: ${nav.name || '(未命名)'}

-
- - -
-
-
-
-
- - -
-
- - -
-
-
- - -
-
-
-
-
子菜单
-
- -
-
- `; - container.appendChild(item); - - if (hasChildren) { - renderHeaderNavChildren(index, nav.children); - } - }); - } - - function renderHeaderNavChildren(parentIndex, children) { - const container = document.getElementById(`header-nav-children-list-${parentIndex}`); - container.innerHTML = ''; - - children.forEach((child, childIndex) => { - const item = document.createElement('div'); - item.className = 'config-item'; - item.style.marginLeft = '20px'; - item.innerHTML = ` -
-

子项 ${childIndex + 1}

- -
-
-
-
- - -
-
- - -
-
- - -
-
-
- - -
-
-
-
- `; - container.appendChild(item); - }); - } - - function collectHeaderNav() { - const navs = []; - document.querySelectorAll('[data-header-nav]').forEach(input => { - const index = parseInt(input.dataset.headerNav); - const field = input.dataset.field; - if (!navs[index]) navs[index] = { children: [] }; - navs[index][field] = input.type === 'checkbox' ? input.checked : input.value; - }); - - document.querySelectorAll('[data-header-nav-child]').forEach(input => { - const [parentIndex, childIndex] = input.dataset.headerNavChild.split('.').map(Number); - const field = input.dataset.field; - if (!navs[parentIndex].children[childIndex]) navs[parentIndex].children[childIndex] = {}; - navs[parentIndex].children[childIndex][field] = input.type === 'checkbox' ? input.checked : input.value; - }); - - return navs.filter(n => n); - } - - window.addHeaderNav = function() { - const navs = collectHeaderNav(); - navs.push({ name: '', file_address: '', blank: false, children: [] }); - renderHeaderNav(navs); - }; - - window.removeHeaderNav = function(index) { - if(confirm('确定删除此导航项吗?')) { - const navs = collectHeaderNav(); - navs.splice(index, 1); - renderHeaderNav(navs); - } - }; - - window.toggleHeaderNavChildren = function(index) { - const container = document.getElementById(`header-nav-children-${index}`); - container.style.display = container.style.display === 'none' ? 'block' : 'none'; - }; - - window.addHeaderNavChild = function(parentIndex) { - const navs = collectHeaderNav(); - if (!navs[parentIndex].children) navs[parentIndex].children = []; - navs[parentIndex].children.push({ name: '', file_address: '', blank: false, icon: '', description: '' }); - renderHeaderNav(navs); - document.getElementById(`header-nav-children-${parentIndex}`).style.display = 'block'; - }; - - window.removeHeaderNavChild = function(parentIndex, childIndex) { - if(confirm('确定删除此子菜单吗?')) { - const navs = collectHeaderNav(); - navs[parentIndex].children.splice(childIndex, 1); - renderHeaderNav(navs); - } - }; - - // ========== 底部导航 ========== - function renderFooterNav(navs) { - const container = document.getElementById('footerNavList'); - container.innerHTML = ''; - - navs.forEach((col, colIndex) => { - const item = document.createElement('div'); - item.className = 'config-item'; - const hasChildren = Array.isArray(col.children) && col.children.length > 0; - - item.innerHTML = ` -
-

栏目 ${colIndex + 1}: ${col.name || '(未命名)'}

-
- - -
-
-
-
- - -
- -
- `; - container.appendChild(item); - - if (hasChildren) { - renderFooterNavChildren(colIndex, col.children); - } - }); - } - - function renderFooterNavChildren(colIndex, children) { - const container = document.getElementById(`footer-nav-children-list-${colIndex}`); - container.innerHTML = ''; - - children.forEach((link, linkIndex) => { - const item = document.createElement('div'); - item.className = 'config-item'; - item.style.marginLeft = '20px'; - item.innerHTML = ` -
-

链接 ${linkIndex + 1}

- -
-
-
-
- - -
-
- - -
-
-
- - -
-
-
-
- `; - container.appendChild(item); - }); - } - - function collectFooterNav() { - const navs = []; - document.querySelectorAll('[data-footer-nav]').forEach(input => { - const index = parseInt(input.dataset.footerNav); - if (!navs[index]) navs[index] = { children: [] }; - navs[index][input.dataset.field] = input.value; - }); - - document.querySelectorAll('[data-footer-nav-child]').forEach(input => { - const [colIndex, linkIndex] = input.dataset.footerNavChild.split('.').map(Number); - const field = input.dataset.field; - if (!navs[colIndex].children[linkIndex]) navs[colIndex].children[linkIndex] = {}; - navs[colIndex].children[linkIndex][field] = input.type === 'checkbox' ? input.checked : input.value; - }); - - return navs.filter(n => n); - } - - window.addFooterNav = function() { - const navs = collectFooterNav(); - navs.push({ name: '', children: [] }); - renderFooterNav(navs); - }; - - window.removeFooterNav = function(index) { - if(confirm('确定删除此栏目吗?')) { - const navs = collectFooterNav(); - navs.splice(index, 1); - renderFooterNav(navs); - } - }; - - window.toggleFooterNavChildren = function(index) { - const container = document.getElementById(`footer-nav-children-${index}`); - container.style.display = container.style.display === 'none' ? 'block' : 'none'; - }; - - window.addFooterNavChild = function(colIndex) { - const navs = collectFooterNav(); - if (!navs[colIndex].children) navs[colIndex].children = []; - navs[colIndex].children.push({ name: '', url: '', blank: false }); - renderFooterNav(navs); - document.getElementById(`footer-nav-children-${colIndex}`).style.display = 'block'; - }; - - window.removeFooterNavChild = function(colIndex, linkIndex) { - if(confirm('确定删除此链接吗?')) { - const navs = collectFooterNav(); - navs[colIndex].children.splice(linkIndex, 1); - renderFooterNav(navs); - } - }; - - // 文件上传 document.addEventListener('click', (e) => { if (e.target.closest('.upload-btn')) { e.preventDefault(); const btn = e.target.closest('.upload-btn'); - currentUploadTarget = btn.dataset.target || btn.dataset.targetBanner || btn.dataset.targetHonor || btn.dataset.targetSide; + currentUploadTarget = btn.dataset.target || btn.dataset.targetBanner || btn.dataset.targetHonor; document.getElementById('fileInput').click(); } }); @@ -1007,11 +481,6 @@ // 添加按钮事件 document.getElementById('addBannerBtn').addEventListener('click', addBanner); document.getElementById('addHonorBtn').addEventListener('click', addHonor); - document.getElementById('addFriendlyLinkBtn').addEventListener('click', addFriendlyLink); - document.getElementById('addSideBtn').addEventListener('click', addSide); - document.getElementById('addFeedbackTypeBtn').addEventListener('click', addFeedbackType); - document.getElementById('addHeaderNavBtn').addEventListener('click', addHeaderNav); - document.getElementById('addFooterNavBtn').addEventListener('click', addFooterNav); // JSON编辑器功能 document.getElementById('syncJsonBtn').addEventListener('click', () => { @@ -1061,4 +530,4 @@ // 初始化 loadConfig(); })(); - \ No newline at end of file +