mirror of
https://github.com/dqzboy/Docker-Proxy.git
synced 2026-01-12 16:25:42 +08:00
feat: optimize document management UI and error handling
This commit is contained in:
@@ -60,7 +60,7 @@ class DocumentationServiceDB {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (!document) {
|
if (!document) {
|
||||||
throw new Error(`文档 ${docId} 不存在`);
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -365,7 +365,7 @@
|
|||||||
|
|
||||||
async function loadDocument(id) {
|
async function loadDocument(id) {
|
||||||
try {
|
try {
|
||||||
const response = await fetch(`/api/documents/${id}`, {
|
const response = await fetch(`/api/documentation/documents/${id}`, {
|
||||||
credentials: 'same-origin'
|
credentials: 'same-origin'
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -426,7 +426,7 @@
|
|||||||
document.getElementById('loadingOverlay').style.display = 'flex';
|
document.getElementById('loadingOverlay').style.display = 'flex';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const url = currentDocId ? `/api/documents/${currentDocId}` : '/api/documents';
|
const url = currentDocId ? `/api/documentation/documents/${currentDocId}` : '/api/documentation/documents';
|
||||||
const method = currentDocId ? 'PUT' : 'POST';
|
const method = currentDocId ? 'PUT' : 'POST';
|
||||||
|
|
||||||
const response = await fetch(url, {
|
const response = await fetch(url, {
|
||||||
|
|||||||
@@ -815,14 +815,12 @@
|
|||||||
|
|
||||||
// 根据标签数量判断是否显示警告
|
// 根据标签数量判断是否显示警告
|
||||||
let warningMessage = '';
|
let warningMessage = '';
|
||||||
let loadAllBtnDisabled = false;
|
|
||||||
|
|
||||||
if (tagCount > 1000) {
|
if (tagCount > 1000) {
|
||||||
warningMessage = `<div class="tag-count-warning">
|
warningMessage = `<div class="tag-count-warning">
|
||||||
<i class="fas fa-exclamation-triangle"></i>
|
<i class="fas fa-exclamation-triangle"></i>
|
||||||
<p>该镜像包含 <strong>${tagCount}</strong> 个标签,加载全部可能会很慢。建议使用分页浏览或利用搜索功能查找特定标签。</p>
|
<p>该镜像包含 <strong>${tagCount}</strong> 个标签,加载全部可能会很慢。建议使用分页浏览或利用搜索功能查找特定标签。</p>
|
||||||
</div>`;
|
</div>`;
|
||||||
loadAllBtnDisabled = true;
|
|
||||||
} else if (tagCount > 500) {
|
} else if (tagCount > 500) {
|
||||||
warningMessage = `<div class="tag-count-warning moderate">
|
warningMessage = `<div class="tag-count-warning moderate">
|
||||||
<i class="fas fa-info-circle"></i>
|
<i class="fas fa-info-circle"></i>
|
||||||
@@ -851,7 +849,7 @@
|
|||||||
<div class="tag-search-container">
|
<div class="tag-search-container">
|
||||||
<input type="text" id="tagSearchInput" placeholder="搜索TAG..." onkeyup="filterTags()">
|
<input type="text" id="tagSearchInput" placeholder="搜索TAG..." onkeyup="filterTags()">
|
||||||
</div>
|
</div>
|
||||||
<button id="loadAllTagsBtn" class="load-all-btn" onclick="loadAllTags()" ${loadAllBtnDisabled ? 'disabled' : ''}>
|
<button id="loadAllTagsBtn" class="load-all-btn" onclick="loadAllTags()">
|
||||||
<i class="fas fa-cloud-download-alt"></i> 加载全部TAG
|
<i class="fas fa-cloud-download-alt"></i> 加载全部TAG
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -1530,12 +1528,6 @@
|
|||||||
|
|
||||||
// 显示指定的文档
|
// 显示指定的文档
|
||||||
function showDocument(index) {
|
function showDocument(index) {
|
||||||
// 清理之前的返回顶部按钮
|
|
||||||
const existingBackToTopBtn = document.querySelector('.back-to-top-btn');
|
|
||||||
if (existingBackToTopBtn) {
|
|
||||||
existingBackToTopBtn.remove();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!window.documentationData || !Array.isArray(window.documentationData)) {
|
if (!window.documentationData || !Array.isArray(window.documentationData)) {
|
||||||
console.error('文档数据不可用');
|
console.error('文档数据不可用');
|
||||||
return;
|
return;
|
||||||
@@ -1793,42 +1785,26 @@
|
|||||||
}
|
}
|
||||||
container.appendChild(docMetaDiv);
|
container.appendChild(docMetaDiv);
|
||||||
|
|
||||||
// 添加返回顶部按钮(如果内容很长)
|
// 添加返回顶部按钮
|
||||||
if (docContentDiv.scrollHeight > 1000) {
|
let backToTopBtn = document.querySelector('.back-to-top-btn');
|
||||||
const backToTopBtn = document.createElement('button');
|
if (!backToTopBtn) {
|
||||||
|
backToTopBtn = document.createElement('button');
|
||||||
backToTopBtn.className = 'back-to-top-btn';
|
backToTopBtn.className = 'back-to-top-btn';
|
||||||
backToTopBtn.innerHTML = '<i class="fas fa-arrow-up"></i>';
|
backToTopBtn.innerHTML = '<i class="fas fa-arrow-up"></i>';
|
||||||
backToTopBtn.style.cssText = `
|
backToTopBtn.title = '返回顶部';
|
||||||
position: fixed;
|
|
||||||
bottom: 2rem;
|
|
||||||
right: 2rem;
|
|
||||||
width: 3rem;
|
|
||||||
height: 3rem;
|
|
||||||
border-radius: 50%;
|
|
||||||
background: var(--primary-color);
|
|
||||||
color: white;
|
|
||||||
border: none;
|
|
||||||
cursor: pointer;
|
|
||||||
box-shadow: 0 4px 12px rgba(61, 124, 244, 0.3);
|
|
||||||
z-index: 1000;
|
|
||||||
opacity: 0.8;
|
|
||||||
transition: all 0.3s ease;
|
|
||||||
`;
|
|
||||||
backToTopBtn.onclick = () => {
|
backToTopBtn.onclick = () => {
|
||||||
container.scrollIntoView({ behavior: 'smooth' });
|
window.scrollTo({ top: 0, behavior: 'smooth' });
|
||||||
};
|
|
||||||
backToTopBtn.onmouseenter = () => {
|
|
||||||
backToTopBtn.style.opacity = '1';
|
|
||||||
backToTopBtn.style.transform = 'scale(1.1)';
|
|
||||||
};
|
|
||||||
backToTopBtn.onmouseleave = () => {
|
|
||||||
backToTopBtn.style.opacity = '0.8';
|
|
||||||
backToTopBtn.style.transform = 'scale(1)';
|
|
||||||
};
|
};
|
||||||
document.body.appendChild(backToTopBtn);
|
document.body.appendChild(backToTopBtn);
|
||||||
|
|
||||||
// 当切换文档时清理按钮
|
// 监听滚动事件
|
||||||
container.setAttribute('data-back-to-top', 'true');
|
window.addEventListener('scroll', () => {
|
||||||
|
if (window.scrollY > 300) {
|
||||||
|
backToTopBtn.classList.add('visible');
|
||||||
|
} else {
|
||||||
|
backToTopBtn.classList.remove('visible');
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -432,7 +432,13 @@ function refreshStoppedContainers() {
|
|||||||
tbody.innerHTML = '';
|
tbody.innerHTML = '';
|
||||||
|
|
||||||
if (containers.length === 0) {
|
if (containers.length === 0) {
|
||||||
tbody.innerHTML = '<tr><td colspan="4" style="text-align: center;">没有已停止的容器</td></tr>';
|
tbody.innerHTML = `
|
||||||
|
<tr>
|
||||||
|
<td colspan="4" class="stopped-containers-empty">
|
||||||
|
<i class="fas fa-check-circle"></i>
|
||||||
|
<p>所有容器运行正常,没有已停止的容器</p>
|
||||||
|
</td>
|
||||||
|
</tr>`;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -444,10 +450,10 @@ function refreshStoppedContainers() {
|
|||||||
|
|
||||||
const row = `
|
const row = `
|
||||||
<tr>
|
<tr>
|
||||||
<td>${container.id}</td>
|
<td><code class="container-id-cell">${container.id}</code></td>
|
||||||
<td>${container.name}</td>
|
<td><span class="container-name-cell">${container.name}</span></td>
|
||||||
<td>${container.image ? container.image : '未知'}</td>
|
<td><span class="container-image-cell">${container.image ? container.image : '未知'}</span></td>
|
||||||
<td>${container.status}</td>
|
<td><span class="container-status-badge stopped"><i class="fas fa-stop-circle"></i> ${container.status}</span></td>
|
||||||
</tr>
|
</tr>
|
||||||
`;
|
`;
|
||||||
tbody.innerHTML += row;
|
tbody.innerHTML += row;
|
||||||
@@ -455,8 +461,13 @@ function refreshStoppedContainers() {
|
|||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.error('获取已停止容器列表失败:', error);
|
console.error('获取已停止容器列表失败:', error);
|
||||||
document.getElementById('stoppedContainersBody').innerHTML =
|
document.getElementById('stoppedContainersBody').innerHTML = `
|
||||||
'<tr><td colspan="4" style="text-align: center; color: red;">获取已停止容器列表失败</td></tr>';
|
<tr>
|
||||||
|
<td colspan="4" class="table-empty-state">
|
||||||
|
<i class="fas fa-exclamation-triangle"></i>
|
||||||
|
<p>获取容器列表失败,请检查 Docker 服务状态</p>
|
||||||
|
</td>
|
||||||
|
</tr>`;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,10 +39,10 @@ const documentManager = {
|
|||||||
// 设置表头内容 (包含 ID 列)
|
// 设置表头内容 (包含 ID 列)
|
||||||
thead.innerHTML = `
|
thead.innerHTML = `
|
||||||
<tr>
|
<tr>
|
||||||
<th style="width: 5%">#</th>
|
<th style="width: 6%">#</th>
|
||||||
<th style="width: 25%">标题</th>
|
<th style="width: 28%">文档标题</th>
|
||||||
<th style="width: 20%">创建时间</th>
|
<th style="width: 18%">创建时间</th>
|
||||||
<th style="width: 20%">更新时间</th>
|
<th style="width: 18%">更新时间</th>
|
||||||
<th style="width: 10%">状态</th>
|
<th style="width: 10%">状态</th>
|
||||||
<th style="width: 20%">操作</th>
|
<th style="width: 20%">操作</th>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -187,7 +187,13 @@ const documentManager = {
|
|||||||
tbody.innerHTML = '';
|
tbody.innerHTML = '';
|
||||||
|
|
||||||
if (documents.length === 0) {
|
if (documents.length === 0) {
|
||||||
tbody.innerHTML = '<tr><td colspan="6" style="text-align: center;">没有找到文档</td></tr>';
|
tbody.innerHTML = `
|
||||||
|
<tr>
|
||||||
|
<td colspan="6" class="table-empty-state">
|
||||||
|
<i class="fas fa-file-alt"></i>
|
||||||
|
<p>暂无文档,点击"新建文档"开始创建</p>
|
||||||
|
</td>
|
||||||
|
</tr>`;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -239,21 +245,21 @@ const documentManager = {
|
|||||||
// console.warn(`解析文档时间失败:`, error, doc);
|
// console.warn(`解析文档时间失败:`, error, doc);
|
||||||
}
|
}
|
||||||
|
|
||||||
const statusClasses = doc.published ? 'status-badge status-running' : 'status-badge status-stopped';
|
const statusClasses = doc.published ? 'doc-status-badge published' : 'doc-status-badge draft';
|
||||||
const statusText = doc.published ? '已发布' : '未发布';
|
const statusText = doc.published ? '已发布' : '草稿';
|
||||||
|
|
||||||
const row = document.createElement('tr');
|
const row = document.createElement('tr');
|
||||||
row.innerHTML = `
|
row.innerHTML = `
|
||||||
<td>${index + 1}</td>
|
<td><span class="table-row-num">${index + 1}</span></td>
|
||||||
<td>${doc.title || '无标题文档'}</td>
|
<td><span class="doc-title-display">${doc.title || '无标题文档'}</span></td>
|
||||||
<td>${createdAt}</td>
|
<td><span class="doc-date">${createdAt}</span></td>
|
||||||
<td>${updatedAt}</td>
|
<td><span class="doc-date">${updatedAt}</span></td>
|
||||||
<td><span class="${statusClasses}">${statusText}</span></td>
|
<td><span class="${statusClasses}">${statusText}</span></td>
|
||||||
<td class="action-buttons">
|
<td class="action-buttons">
|
||||||
<button class="action-btn edit-btn" title="编辑文档" onclick="documentManager.editDocument('${doc.id}')">
|
<button class="action-btn edit-btn" title="编辑文档" onclick="documentManager.editDocument('${doc.id}')">
|
||||||
<i class="fas fa-edit"></i>
|
<i class="fas fa-edit"></i>
|
||||||
</button>
|
</button>
|
||||||
<button class="action-btn ${doc.published ? 'unpublish-btn' : 'publish-btn'}"
|
<button class="action-btn ${doc.published ? 'view-btn' : 'publish-btn'}"
|
||||||
title="${doc.published ? '取消发布' : '发布文档'}"
|
title="${doc.published ? '取消发布' : '发布文档'}"
|
||||||
onclick="documentManager.togglePublish('${doc.id}')">
|
onclick="documentManager.togglePublish('${doc.id}')">
|
||||||
<i class="fas ${doc.published ? 'fa-toggle-off' : 'fa-toggle-on'}"></i>
|
<i class="fas ${doc.published ? 'fa-toggle-off' : 'fa-toggle-on'}"></i>
|
||||||
|
|||||||
@@ -24,11 +24,11 @@ const menuManager = {
|
|||||||
const thead = menuTable.querySelector('thead') || document.createElement('thead');
|
const thead = menuTable.querySelector('thead') || document.createElement('thead');
|
||||||
thead.innerHTML = `
|
thead.innerHTML = `
|
||||||
<tr>
|
<tr>
|
||||||
<th style="width: 5%">#</th>
|
<th style="width: 6%">#</th>
|
||||||
<th style="width: 25%">文本 (Text)</th>
|
<th style="width: 22%">菜单文本</th>
|
||||||
<th style="width: 40%">链接 (Link)</th>
|
<th style="width: 38%">链接地址</th>
|
||||||
<th style="width: 10%">新标签页 (New Tab)</th>
|
<th style="width: 12%">新标签页</th>
|
||||||
<th style="width: 20%">操作</th>
|
<th style="width: 22%">操作</th>
|
||||||
</tr>
|
</tr>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
@@ -84,7 +84,24 @@ const menuManager = {
|
|||||||
|
|
||||||
if (!Array.isArray(configMenuItems)) {
|
if (!Array.isArray(configMenuItems)) {
|
||||||
// console.error("configMenuItems 不是一个数组:", configMenuItems);
|
// console.error("configMenuItems 不是一个数组:", configMenuItems);
|
||||||
menuTableBody.innerHTML = '<tr><td colspan="5" style="text-align: center; color: #ff4d4f;">菜单数据格式错误</td></tr>';
|
menuTableBody.innerHTML = `
|
||||||
|
<tr>
|
||||||
|
<td colspan="5" class="table-empty-state">
|
||||||
|
<i class="fas fa-exclamation-triangle"></i>
|
||||||
|
<p>菜单数据格式错误</p>
|
||||||
|
</td>
|
||||||
|
</tr>`;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (configMenuItems.length === 0) {
|
||||||
|
menuTableBody.innerHTML = `
|
||||||
|
<tr>
|
||||||
|
<td colspan="5" class="table-empty-state">
|
||||||
|
<i class="fas fa-list-ul"></i>
|
||||||
|
<p>暂无菜单项,点击"添加菜单项"开始创建</p>
|
||||||
|
</td>
|
||||||
|
</tr>`;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,10 +109,10 @@ const menuManager = {
|
|||||||
const row = document.createElement('tr');
|
const row = document.createElement('tr');
|
||||||
// 使用 index 作为临时 ID 进行操作
|
// 使用 index 作为临时 ID 进行操作
|
||||||
row.innerHTML = `
|
row.innerHTML = `
|
||||||
<td>${index + 1}</td>
|
<td><span class="table-row-num">${index + 1}</span></td>
|
||||||
<td>${item.text || ''}</td>
|
<td><span class="menu-text-display">${item.text || ''}</span></td>
|
||||||
<td>${item.link || ''}</td>
|
<td><code class="menu-link-display">${item.link || ''}</code></td>
|
||||||
<td>${item.newTab ? '是' : '否'}</td>
|
<td><span class="menu-newtab-badge ${item.newTab ? 'yes' : 'no'}">${item.newTab ? '是' : '否'}</span></td>
|
||||||
<td class="action-buttons">
|
<td class="action-buttons">
|
||||||
<button class="action-btn edit-btn" title="编辑菜单" onclick="menuManager.editMenuItem(${index})">
|
<button class="action-btn edit-btn" title="编辑菜单" onclick="menuManager.editMenuItem(${index})">
|
||||||
<i class="fas fa-edit"></i>
|
<i class="fas fa-edit"></i>
|
||||||
@@ -114,6 +131,12 @@ const menuManager = {
|
|||||||
const menuTableBody = document.getElementById('menuTableBody');
|
const menuTableBody = document.getElementById('menuTableBody');
|
||||||
if (!menuTableBody) return;
|
if (!menuTableBody) return;
|
||||||
|
|
||||||
|
// 移除空状态行(如果存在)
|
||||||
|
const emptyState = menuTableBody.querySelector('.table-empty-state');
|
||||||
|
if (emptyState) {
|
||||||
|
emptyState.closest('tr').remove();
|
||||||
|
}
|
||||||
|
|
||||||
// 如果已存在新行,则不重复添加
|
// 如果已存在新行,则不重复添加
|
||||||
if (document.getElementById('new-menu-item-row')) {
|
if (document.getElementById('new-menu-item-row')) {
|
||||||
document.getElementById('new-text').focus();
|
document.getElementById('new-text').focus();
|
||||||
@@ -207,248 +230,324 @@ const menuManager = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Swal.fire({
|
Swal.fire({
|
||||||
title: '<div class="edit-title"><i class="fas fa-edit"></i> 编辑菜单项</div>',
|
title: '',
|
||||||
html: `
|
html: `
|
||||||
<div class="edit-menu-form">
|
<div class="swal-edit-container">
|
||||||
<div class="form-group">
|
<div class="swal-edit-header">
|
||||||
<label for="edit-text">
|
<div class="swal-edit-icon">
|
||||||
<i class="fas fa-font"></i> 菜单文本
|
<i class="fas fa-edit"></i>
|
||||||
</label>
|
|
||||||
<div class="input-wrapper">
|
|
||||||
<input type="text" id="edit-text" class="modern-input" value="${item.text || ''}" placeholder="请输入菜单文本">
|
|
||||||
<span class="input-icon"><i class="fas fa-heading"></i></span>
|
|
||||||
</div>
|
</div>
|
||||||
<small class="form-hint">菜单项显示的文本,保持简洁明了</small>
|
<h2 class="swal-edit-title">编辑菜单项</h2>
|
||||||
|
<p class="swal-edit-subtitle">修改菜单显示文本和链接配置</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="swal-edit-form">
|
||||||
<label for="edit-link">
|
<div class="swal-form-group">
|
||||||
<i class="fas fa-link"></i> 链接地址
|
<label for="edit-text" class="swal-form-label">
|
||||||
</label>
|
<i class="fas fa-font"></i> 菜单文本
|
||||||
<div class="input-wrapper">
|
</label>
|
||||||
<input type="text" id="edit-link" class="modern-input" value="${item.link || ''}" placeholder="请输入链接地址">
|
<div class="swal-input-wrapper">
|
||||||
<span class="input-icon"><i class="fas fa-globe"></i></span>
|
<input type="text" id="edit-text" class="swal-modern-input" value="${item.text || ''}" placeholder="输入菜单显示文本">
|
||||||
|
</div>
|
||||||
|
<p class="swal-form-hint">用户在导航中看到的文字</p>
|
||||||
</div>
|
</div>
|
||||||
<small class="form-hint">完整URL路径(例如: https://example.com)或相对路径(例如: /docs)</small>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group toggle-switch">
|
<div class="swal-form-group">
|
||||||
<label for="edit-newTab" class="toggle-label-text">
|
<label for="edit-link" class="swal-form-label">
|
||||||
<i class="fas fa-external-link-alt"></i> 在新标签页打开
|
<i class="fas fa-link"></i> 链接地址
|
||||||
</label>
|
</label>
|
||||||
<div class="toggle-switch-container">
|
<div class="swal-input-wrapper">
|
||||||
<input type="checkbox" id="edit-newTab" class="toggle-input" ${item.newTab ? 'checked' : ''}>
|
<input type="text" id="edit-link" class="swal-modern-input" value="${item.link || ''}" placeholder="https://example.com 或 /page">
|
||||||
<label for="edit-newTab" class="toggle-label"></label>
|
</div>
|
||||||
<span class="toggle-status">${item.newTab ? '是' : '否'}</span>
|
<p class="swal-form-hint">点击菜单后跳转的URL</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-preview">
|
<div class="swal-form-group swal-toggle-group">
|
||||||
<div class="preview-title"><i class="fas fa-eye"></i> 预览</div>
|
<div class="swal-toggle-left">
|
||||||
<div class="preview-content">
|
<label class="swal-form-label">
|
||||||
<a href="${item.link || '#'}" class="preview-link" target="${item.newTab ? '_blank' : '_self'}">
|
<i class="fas fa-external-link-alt"></i> 新标签页打开
|
||||||
<span class="preview-text">${item.text || '菜单项'}</span>
|
</label>
|
||||||
${item.newTab ? '<i class="fas fa-external-link-alt preview-icon"></i>' : ''}
|
<p class="swal-form-hint">是否在新窗口中打开链接</p>
|
||||||
</a>
|
</div>
|
||||||
|
<div class="swal-toggle-right">
|
||||||
|
<label class="swal-toggle-switch">
|
||||||
|
<input type="checkbox" id="edit-newTab" ${item.newTab ? 'checked' : ''}>
|
||||||
|
<span class="swal-toggle-slider"></span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="swal-preview-box">
|
||||||
|
<div class="swal-preview-label">
|
||||||
|
<i class="fas fa-eye"></i> 效果预览
|
||||||
|
</div>
|
||||||
|
<div class="swal-preview-content">
|
||||||
|
<a href="javascript:void(0)" class="swal-preview-link" id="preview-link-el">
|
||||||
|
<span id="preview-text-el">${item.text || '菜单项'}</span>
|
||||||
|
<i class="fas fa-external-link-alt swal-preview-external" id="preview-external-icon" style="${item.newTab ? '' : 'display:none'}"></i>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<style>
|
<style>
|
||||||
.edit-title {
|
.swal2-popup.swal2-modal {
|
||||||
|
border-radius: 20px !important;
|
||||||
|
padding: 0 !important;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
.swal-edit-container {
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
.swal-edit-header {
|
||||||
|
background: linear-gradient(135deg, #3d7cfa 0%, #6366f1 100%);
|
||||||
|
padding: 2rem 2rem 1.75rem;
|
||||||
|
text-align: center;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
.swal-edit-icon {
|
||||||
|
width: 56px;
|
||||||
|
height: 56px;
|
||||||
|
background: rgba(255,255,255,0.2);
|
||||||
|
border-radius: 16px;
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
backdrop-filter: blur(10px);
|
||||||
|
}
|
||||||
|
.swal-edit-icon i {
|
||||||
font-size: 1.5rem;
|
font-size: 1.5rem;
|
||||||
color: #3085d6;
|
color: white;
|
||||||
margin-bottom: 10px;
|
|
||||||
}
|
}
|
||||||
.edit-menu-form {
|
.swal-edit-title {
|
||||||
text-align: left;
|
color: white;
|
||||||
padding: 0 15px;
|
font-size: 1.4rem;
|
||||||
|
font-weight: 700;
|
||||||
|
margin: 0 0 0.35rem 0;
|
||||||
}
|
}
|
||||||
.form-group {
|
.swal-edit-subtitle {
|
||||||
margin-bottom: 20px;
|
color: rgba(255,255,255,0.85);
|
||||||
position: relative;
|
font-size: 0.9rem;
|
||||||
|
margin: 0;
|
||||||
|
font-weight: 400;
|
||||||
}
|
}
|
||||||
.form-group label {
|
.swal-edit-form {
|
||||||
display: block;
|
padding: 1.75rem 2rem 1.5rem;
|
||||||
margin-bottom: 8px;
|
}
|
||||||
|
.swal-form-group {
|
||||||
|
margin-bottom: 1.35rem;
|
||||||
|
}
|
||||||
|
.swal-form-label {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.5rem;
|
||||||
|
font-size: 0.9rem;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
color: #444;
|
color: #334155;
|
||||||
font-size: 0.95rem;
|
margin-bottom: 0.6rem;
|
||||||
}
|
}
|
||||||
.input-wrapper {
|
.swal-form-label i {
|
||||||
|
color: #3d7cfa;
|
||||||
|
font-size: 0.85rem;
|
||||||
|
}
|
||||||
|
.swal-input-wrapper {
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
.modern-input {
|
.swal-modern-input {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding: 12px 40px 12px 15px;
|
padding: 0.85rem 1rem;
|
||||||
border: 1px solid #ddd;
|
border: 2px solid #e2e8f0;
|
||||||
border-radius: 8px;
|
border-radius: 12px;
|
||||||
font-size: 1rem;
|
font-size: 0.95rem;
|
||||||
transition: all 0.3s ease;
|
transition: all 0.25s ease;
|
||||||
box-shadow: 0 2px 5px rgba(0,0,0,0.05);
|
background: #f8fafc;
|
||||||
|
color: #1e293b;
|
||||||
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
.modern-input:focus {
|
.swal-modern-input::placeholder {
|
||||||
border-color: #3085d6;
|
color: #94a3b8;
|
||||||
box-shadow: 0 0 0 3px rgba(48, 133, 214, 0.2);
|
}
|
||||||
|
.swal-modern-input:focus {
|
||||||
|
border-color: #3d7cfa;
|
||||||
|
background: white;
|
||||||
|
box-shadow: 0 0 0 4px rgba(61, 124, 250, 0.12);
|
||||||
outline: none;
|
outline: none;
|
||||||
}
|
}
|
||||||
.input-icon {
|
.swal-form-hint {
|
||||||
position: absolute;
|
font-size: 0.78rem;
|
||||||
right: 12px;
|
color: #94a3b8;
|
||||||
top: 50%;
|
margin: 0.4rem 0 0 0;
|
||||||
transform: translateY(-50%);
|
|
||||||
color: #aaa;
|
|
||||||
}
|
}
|
||||||
.form-hint {
|
.swal-toggle-group {
|
||||||
display: block;
|
|
||||||
font-size: 0.8rem;
|
|
||||||
color: #888;
|
|
||||||
margin-top: 5px;
|
|
||||||
font-style: italic;
|
|
||||||
}
|
|
||||||
.toggle-switch {
|
|
||||||
display: flex;
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
background: linear-gradient(135deg, #f1f5f9, #f8fafc);
|
||||||
padding: 5px 0;
|
padding: 1rem 1.25rem;
|
||||||
|
border-radius: 12px;
|
||||||
|
border: 1px solid #e2e8f0;
|
||||||
}
|
}
|
||||||
.toggle-label-text {
|
.swal-toggle-left {
|
||||||
margin-bottom: 0 !important;
|
flex: 1;
|
||||||
}
|
}
|
||||||
.toggle-switch-container {
|
.swal-toggle-left .swal-form-label {
|
||||||
display: flex;
|
margin-bottom: 0.25rem;
|
||||||
align-items: center;
|
|
||||||
}
|
}
|
||||||
.toggle-input {
|
.swal-toggle-left .swal-form-hint {
|
||||||
display: none;
|
margin: 0;
|
||||||
}
|
}
|
||||||
.toggle-label {
|
.swal-toggle-switch {
|
||||||
display: block;
|
|
||||||
width: 52px;
|
|
||||||
height: 26px;
|
|
||||||
background: #e6e6e6;
|
|
||||||
border-radius: 13px;
|
|
||||||
position: relative;
|
position: relative;
|
||||||
cursor: pointer;
|
display: inline-block;
|
||||||
transition: background 0.3s ease;
|
width: 52px;
|
||||||
box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
|
height: 28px;
|
||||||
}
|
}
|
||||||
.toggle-label:after {
|
.swal-toggle-switch input {
|
||||||
content: '';
|
opacity: 0;
|
||||||
|
width: 0;
|
||||||
|
height: 0;
|
||||||
|
}
|
||||||
|
.swal-toggle-slider {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 3px;
|
cursor: pointer;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
background: #cbd5e1;
|
||||||
|
transition: 0.3s;
|
||||||
|
border-radius: 28px;
|
||||||
|
}
|
||||||
|
.swal-toggle-slider:before {
|
||||||
|
position: absolute;
|
||||||
|
content: "";
|
||||||
|
height: 22px;
|
||||||
|
width: 22px;
|
||||||
left: 3px;
|
left: 3px;
|
||||||
width: 20px;
|
bottom: 3px;
|
||||||
height: 20px;
|
|
||||||
background: white;
|
background: white;
|
||||||
|
transition: 0.3s;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
transition: transform 0.3s ease, box-shadow 0.3s ease;
|
box-shadow: 0 2px 6px rgba(0,0,0,0.15);
|
||||||
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
|
|
||||||
}
|
}
|
||||||
.toggle-input:checked + .toggle-label {
|
.swal-toggle-switch input:checked + .swal-toggle-slider {
|
||||||
background: #3085d6;
|
background: linear-gradient(135deg, #10b981, #34d399);
|
||||||
}
|
}
|
||||||
.toggle-input:checked + .toggle-label:after {
|
.swal-toggle-switch input:checked + .swal-toggle-slider:before {
|
||||||
transform: translateX(26px);
|
transform: translateX(24px);
|
||||||
}
|
}
|
||||||
.toggle-status {
|
.swal-preview-box {
|
||||||
margin-left: 10px;
|
margin-top: 1.5rem;
|
||||||
font-size: 0.9rem;
|
border: 2px dashed #e2e8f0;
|
||||||
color: #666;
|
border-radius: 12px;
|
||||||
min-width: 20px;
|
padding: 1rem;
|
||||||
|
background: linear-gradient(135deg, #fafbfc, #f5f7fa);
|
||||||
}
|
}
|
||||||
.form-preview {
|
.swal-preview-label {
|
||||||
margin-top: 25px;
|
|
||||||
border: 1px dashed #ccc;
|
|
||||||
border-radius: 8px;
|
|
||||||
padding: 15px;
|
|
||||||
background-color: #f9f9f9;
|
|
||||||
}
|
|
||||||
.preview-title {
|
|
||||||
font-size: 0.9rem;
|
|
||||||
color: #666;
|
|
||||||
margin-bottom: 10px;
|
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
color: #94a3b8;
|
||||||
|
margin-bottom: 0.75rem;
|
||||||
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
.preview-content {
|
.swal-preview-label i {
|
||||||
|
margin-right: 0.35rem;
|
||||||
|
}
|
||||||
|
.swal-preview-content {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
padding: 10px;
|
padding: 0.75rem;
|
||||||
background: white;
|
background: white;
|
||||||
border-radius: 6px;
|
border-radius: 8px;
|
||||||
box-shadow: 0 2px 4px rgba(0,0,0,0.05);
|
box-shadow: 0 2px 8px rgba(0,0,0,0.04);
|
||||||
}
|
}
|
||||||
.preview-link {
|
.swal-preview-link {
|
||||||
display: flex;
|
display: inline-flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
color: #3085d6;
|
gap: 0.4rem;
|
||||||
|
color: #3d7cfa;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
font-weight: 500;
|
font-weight: 600;
|
||||||
padding: 5px 10px;
|
font-size: 1rem;
|
||||||
border-radius: 4px;
|
padding: 0.5rem 1rem;
|
||||||
transition: background 0.2s ease;
|
border-radius: 8px;
|
||||||
|
transition: all 0.2s ease;
|
||||||
}
|
}
|
||||||
.preview-link:hover {
|
.swal-preview-link:hover {
|
||||||
background: #f0f7ff;
|
background: rgba(61, 124, 250, 0.08);
|
||||||
}
|
}
|
||||||
.preview-text {
|
.swal-preview-external {
|
||||||
margin-right: 5px;
|
font-size: 0.75rem;
|
||||||
}
|
|
||||||
.preview-icon {
|
|
||||||
font-size: 0.8rem;
|
|
||||||
opacity: 0.7;
|
opacity: 0.7;
|
||||||
}
|
}
|
||||||
|
.swal2-actions {
|
||||||
|
padding: 0 2rem 1.75rem !important;
|
||||||
|
gap: 0.75rem !important;
|
||||||
|
margin: 0 !important;
|
||||||
|
}
|
||||||
|
.swal2-confirm {
|
||||||
|
background: linear-gradient(135deg, #3d7cfa, #6366f1) !important;
|
||||||
|
border-radius: 10px !important;
|
||||||
|
padding: 0.75rem 1.5rem !important;
|
||||||
|
font-weight: 600 !important;
|
||||||
|
font-size: 0.95rem !important;
|
||||||
|
box-shadow: 0 4px 14px rgba(61, 124, 250, 0.35) !important;
|
||||||
|
border: none !important;
|
||||||
|
}
|
||||||
|
.swal2-confirm:hover {
|
||||||
|
transform: translateY(-2px);
|
||||||
|
box-shadow: 0 6px 20px rgba(61, 124, 250, 0.45) !important;
|
||||||
|
}
|
||||||
|
.swal2-cancel {
|
||||||
|
background: #f1f5f9 !important;
|
||||||
|
color: #64748b !important;
|
||||||
|
border-radius: 10px !important;
|
||||||
|
padding: 0.75rem 1.5rem !important;
|
||||||
|
font-weight: 600 !important;
|
||||||
|
font-size: 0.95rem !important;
|
||||||
|
border: none !important;
|
||||||
|
}
|
||||||
|
.swal2-cancel:hover {
|
||||||
|
background: #e2e8f0 !important;
|
||||||
|
}
|
||||||
|
.swal2-validation-message {
|
||||||
|
background: #fef2f2 !important;
|
||||||
|
color: #dc2626 !important;
|
||||||
|
border-radius: 8px !important;
|
||||||
|
margin: 0 2rem 1rem !important;
|
||||||
|
padding: 0.75rem 1rem !important;
|
||||||
|
font-size: 0.9rem !important;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
`,
|
`,
|
||||||
showCancelButton: true,
|
showCancelButton: true,
|
||||||
confirmButtonText: '<i class="fas fa-save"></i> 保存',
|
confirmButtonText: '<i class="fas fa-check"></i> 保存更改',
|
||||||
cancelButtonText: '<i class="fas fa-times"></i> 取消',
|
cancelButtonText: '取消',
|
||||||
confirmButtonColor: '#3085d6',
|
width: '480px',
|
||||||
cancelButtonColor: '#6c757d',
|
|
||||||
width: '550px',
|
|
||||||
focusConfirm: false,
|
focusConfirm: false,
|
||||||
customClass: {
|
showClass: {
|
||||||
container: 'menu-edit-container',
|
popup: 'animate__animated animate__fadeInUp animate__faster'
|
||||||
popup: 'menu-edit-popup',
|
},
|
||||||
title: 'menu-edit-title',
|
hideClass: {
|
||||||
confirmButton: 'menu-edit-confirm',
|
popup: 'animate__animated animate__fadeOutDown animate__faster'
|
||||||
cancelButton: 'menu-edit-cancel'
|
|
||||||
},
|
},
|
||||||
didOpen: () => {
|
didOpen: () => {
|
||||||
// 添加输入监听,更新预览
|
// 添加输入监听,更新预览
|
||||||
const textInput = document.getElementById('edit-text');
|
const textInput = document.getElementById('edit-text');
|
||||||
const linkInput = document.getElementById('edit-link');
|
const linkInput = document.getElementById('edit-link');
|
||||||
const newTabToggle = document.getElementById('edit-newTab');
|
const newTabToggle = document.getElementById('edit-newTab');
|
||||||
const toggleStatus = document.querySelector('.toggle-status');
|
const previewTextEl = document.getElementById('preview-text-el');
|
||||||
const previewText = document.querySelector('.preview-text');
|
const previewExternalIcon = document.getElementById('preview-external-icon');
|
||||||
const previewLink = document.querySelector('.preview-link');
|
|
||||||
const previewIcon = document.querySelector('.preview-icon') || document.createElement('i');
|
|
||||||
|
|
||||||
if (!previewIcon.classList.contains('fas')) {
|
|
||||||
previewIcon.className = 'fas fa-external-link-alt preview-icon';
|
|
||||||
}
|
|
||||||
|
|
||||||
const updatePreview = () => {
|
const updatePreview = () => {
|
||||||
previewText.textContent = textInput.value || '菜单项';
|
previewTextEl.textContent = textInput.value || '菜单项';
|
||||||
previewLink.href = linkInput.value || '#';
|
previewExternalIcon.style.display = newTabToggle.checked ? '' : 'none';
|
||||||
previewLink.target = newTabToggle.checked ? '_blank' : '_self';
|
|
||||||
|
|
||||||
if (newTabToggle.checked) {
|
|
||||||
if (!previewLink.contains(previewIcon)) {
|
|
||||||
previewLink.appendChild(previewIcon);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (previewLink.contains(previewIcon)) {
|
|
||||||
previewLink.removeChild(previewIcon);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
textInput.addEventListener('input', updatePreview);
|
textInput.addEventListener('input', updatePreview);
|
||||||
linkInput.addEventListener('input', updatePreview);
|
linkInput.addEventListener('input', updatePreview);
|
||||||
newTabToggle.addEventListener('change', () => {
|
newTabToggle.addEventListener('change', updatePreview);
|
||||||
toggleStatus.textContent = newTabToggle.checked ? '是' : '否';
|
|
||||||
updatePreview();
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
preConfirm: () => {
|
preConfirm: () => {
|
||||||
const text = document.getElementById('edit-text').value.trim();
|
const text = document.getElementById('edit-text').value.trim();
|
||||||
@@ -456,12 +555,12 @@ const menuManager = {
|
|||||||
const newTab = document.getElementById('edit-newTab').checked;
|
const newTab = document.getElementById('edit-newTab').checked;
|
||||||
|
|
||||||
if (!text) {
|
if (!text) {
|
||||||
Swal.showValidationMessage('<i class="fas fa-exclamation-circle"></i> 菜单文本不能为空');
|
Swal.showValidationMessage('菜单文本不能为空');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!link) {
|
if (!link) {
|
||||||
Swal.showValidationMessage('<i class="fas fa-exclamation-circle"></i> 链接地址不能为空');
|
Swal.showValidationMessage('链接地址不能为空');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user