feat(admin): 短信配置独立页+短信宝支持;后台顶部面包屑导航优化
This commit is contained in:
1 parent
c275cc3b5e
commit
e38e18fbe7
8 files changed
+3909
-2470
No files matched your search
File diff suppressed because it is too large.
Load diff
+1105
-1101
File diff suppressed because it is too large.
Load diff
@@ -28,6 +28,7 @@ const AdminDashboard = React.lazy(() => import('@/pages/admin/Dashboard'));
|
|||||||
const AdminUsers = React.lazy(() => import('@/pages/admin/Users'));
|
const AdminUsers = React.lazy(() => import('@/pages/admin/Users'));
|
||||||
const AdminModels = React.lazy(() => import('@/pages/admin/Models'));
|
const AdminModels = React.lazy(() => import('@/pages/admin/Models'));
|
||||||
const AdminSiteSettings = React.lazy(() => import('@/pages/admin/SiteSettings'));
|
const AdminSiteSettings = React.lazy(() => import('@/pages/admin/SiteSettings'));
|
||||||
|
const AdminSmsConfig = React.lazy(() => import('@/pages/admin/SmsConfig'));
|
||||||
const AdminPayment = React.lazy(() => import('@/pages/admin/Payment'));
|
const AdminPayment = React.lazy(() => import('@/pages/admin/Payment'));
|
||||||
const AdminServices = React.lazy(() => import('@/pages/admin/Services'));
|
const AdminServices = React.lazy(() => import('@/pages/admin/Services'));
|
||||||
const AdminMembership = React.lazy(() => import('@/pages/admin/Membership'));
|
const AdminMembership = React.lazy(() => import('@/pages/admin/Membership'));
|
||||||
@@ -130,6 +131,7 @@ const App: React.FC = () => {
|
|||||||
<Route path="users" element={<AdminUsers />} />
|
<Route path="users" element={<AdminUsers />} />
|
||||||
<Route path="models" element={<AdminModels />} />
|
<Route path="models" element={<AdminModels />} />
|
||||||
<Route path="settings" element={<AdminSiteSettings />} />
|
<Route path="settings" element={<AdminSiteSettings />} />
|
||||||
|
<Route path="sms" element={<AdminSmsConfig />} />
|
||||||
<Route path="payment" element={<AdminPayment />} />
|
<Route path="payment" element={<AdminPayment />} />
|
||||||
<Route path="services" element={<AdminServices />} />
|
<Route path="services" element={<AdminServices />} />
|
||||||
<Route path="membership" element={<AdminMembership />} />
|
<Route path="membership" element={<AdminMembership />} />
|
||||||
|
|||||||
+1019
-13
File diff suppressed because it is too large.
Load diff
@@ -1,394 +1,502 @@
|
|||||||
/* ===== Admin Layout ===== */
|
/* ===== Admin Layout ===== */
|
||||||
.admin-layout {
|
.admin-layout {
|
||||||
display: flex;
|
display: flex;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
background: #F1F3F7;
|
background: #F1F3F7;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Admin Sidebar */
|
/* Admin Sidebar */
|
||||||
.admin-sidebar {
|
.admin-sidebar {
|
||||||
width: var(--admin-sidebar-width);
|
width: var(--admin-sidebar-width);
|
||||||
min-width: var(--admin-sidebar-width);
|
min-width: var(--admin-sidebar-width);
|
||||||
background: #1A1A2E;
|
background: #1A1A2E;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
transition: width var(--transition-slow), min-width var(--transition-slow);
|
transition: width var(--transition-slow), min-width var(--transition-slow);
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
z-index: var(--z-sticky);
|
z-index: var(--z-sticky);
|
||||||
}
|
}
|
||||||
|
|
||||||
.admin-sidebar.collapsed {
|
.admin-sidebar.collapsed {
|
||||||
width: var(--sidebar-collapsed);
|
width: var(--sidebar-collapsed);
|
||||||
min-width: var(--sidebar-collapsed);
|
min-width: var(--sidebar-collapsed);
|
||||||
}
|
}
|
||||||
|
|
||||||
.admin-sidebar-header {
|
.admin-sidebar-header {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
padding: var(--space-lg);
|
padding: var(--space-lg);
|
||||||
height: var(--header-height);
|
height: var(--header-height);
|
||||||
border-bottom: 1px solid rgba(255,255,255,0.06);
|
border-bottom: 1px solid rgba(255,255,255,0.06);
|
||||||
}
|
}
|
||||||
|
|
||||||
.admin-brand {
|
.admin-brand {
|
||||||
color: #E0E2F0 !important;
|
color: #E0E2F0 !important;
|
||||||
font-size: var(--text-base) !important;
|
font-size: var(--text-base) !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.admin-sidebar .collapse-btn {
|
.admin-sidebar .collapse-btn {
|
||||||
color: rgba(255,255,255,0.4);
|
color: rgba(255,255,255,0.4);
|
||||||
}
|
}
|
||||||
.admin-sidebar .collapse-btn:hover {
|
.admin-sidebar .collapse-btn:hover {
|
||||||
background: rgba(255,255,255,0.08);
|
background: rgba(255,255,255,0.08);
|
||||||
color: rgba(255,255,255,0.8);
|
color: rgba(255,255,255,0.8);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Admin Nav */
|
/* Admin Nav */
|
||||||
.admin-nav {
|
.admin-nav {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
padding: var(--space-sm);
|
padding: var(--space-sm);
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 2px;
|
gap: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.admin-nav-item {
|
.admin-nav-item {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: var(--space-md);
|
gap: var(--space-md);
|
||||||
padding: var(--space-md) var(--space-md);
|
padding: var(--space-md) var(--space-md);
|
||||||
border-radius: var(--radius-md);
|
border-radius: var(--radius-md);
|
||||||
color: rgba(255,255,255,0.55);
|
color: rgba(255,255,255,0.55);
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
font-size: var(--text-sm);
|
font-size: var(--text-sm);
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
transition: all var(--transition-fast);
|
transition: all var(--transition-fast);
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
.admin-nav-item:hover {
|
.admin-nav-item:hover {
|
||||||
background: rgba(255,255,255,0.06);
|
background: rgba(255,255,255,0.06);
|
||||||
color: rgba(255,255,255,0.85);
|
color: rgba(255,255,255,0.85);
|
||||||
}
|
}
|
||||||
|
|
||||||
.admin-nav-item.active {
|
.admin-nav-item.active {
|
||||||
background: rgba(107, 99, 255, 0.2);
|
background: rgba(107, 99, 255, 0.2);
|
||||||
color: #8B8DFF;
|
color: #8B8DFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
.admin-sidebar-footer {
|
.admin-sidebar-footer {
|
||||||
padding: var(--space-sm);
|
padding: var(--space-sm);
|
||||||
border-top: 1px solid rgba(255,255,255,0.06);
|
border-top: 1px solid rgba(255,255,255,0.06);
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 2px;
|
gap: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.logout-btn {
|
.logout-btn {
|
||||||
color: rgba(255,255,255,0.35) !important;
|
color: rgba(255,255,255,0.35) !important;
|
||||||
}
|
}
|
||||||
.logout-btn:hover {
|
.logout-btn:hover {
|
||||||
color: #FF6B6B !important;
|
color: #FF6B6B !important;
|
||||||
background: rgba(255,107,107,0.1) !important;
|
background: rgba(255,107,107,0.1) !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Admin Main */
|
/* Admin Main */
|
||||||
.admin-main {
|
.admin-main {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.admin-topbar {
|
.admin-topbar {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
height: var(--header-height);
|
height: var(--header-height);
|
||||||
padding: 0 var(--space-2xl);
|
padding: 0 var(--space-2xl);
|
||||||
background: #FFFFFF;
|
background: #FFFFFF;
|
||||||
border-bottom: 1px solid var(--color-border);
|
border-bottom: 1px solid var(--color-border);
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.admin-topbar-left {
|
.admin-topbar-left {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.admin-welcome {
|
.admin-welcome {
|
||||||
font-size: var(--text-sm);
|
font-size: var(--text-sm);
|
||||||
color: var(--color-text-secondary);
|
color: var(--color-text-secondary);
|
||||||
}
|
}
|
||||||
|
|
||||||
.admin-topbar-right {
|
.admin-topbar-right {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: var(--space-lg);
|
gap: var(--space-lg);
|
||||||
}
|
}
|
||||||
|
|
||||||
.admin-user-tag {
|
.admin-user-tag {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: var(--space-sm);
|
gap: var(--space-sm);
|
||||||
font-size: var(--text-sm);
|
font-size: var(--text-sm);
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
color: var(--color-text-primary);
|
color: var(--color-text-primary);
|
||||||
}
|
}
|
||||||
|
|
||||||
.admin-topbar-action {
|
.admin-topbar-action {
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 6px;
|
gap: 6px;
|
||||||
padding: 6px 14px;
|
padding: 6px 14px;
|
||||||
border-radius: var(--radius-md);
|
border-radius: var(--radius-md);
|
||||||
border: 1px solid var(--color-border);
|
border: 1px solid var(--color-border);
|
||||||
background: var(--color-bg-primary);
|
background: var(--color-bg-primary);
|
||||||
color: var(--color-accent);
|
color: var(--color-accent);
|
||||||
font-size: var(--text-sm);
|
font-size: var(--text-sm);
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
transition: all var(--transition-fast);
|
transition: all var(--transition-fast);
|
||||||
}
|
}
|
||||||
|
|
||||||
.admin-topbar-action:hover {
|
.admin-topbar-action:hover {
|
||||||
background: var(--color-accent);
|
background: var(--color-accent);
|
||||||
color: #FFFFFF;
|
color: #FFFFFF;
|
||||||
border-color: var(--color-accent);
|
border-color: var(--color-accent);
|
||||||
}
|
}
|
||||||
|
|
||||||
.admin-avatar {
|
.admin-avatar {
|
||||||
background: #1A1A2E !important;
|
background: #1A1A2E !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Admin Content Area */
|
/* Admin Content Area */
|
||||||
.admin-content {
|
.admin-content {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
padding: var(--space-2xl);
|
padding: var(--space-2xl);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Admin Common Components */
|
/* Admin Common Components */
|
||||||
.admin-page-title {
|
.admin-page-title {
|
||||||
font-size: var(--text-xl);
|
font-size: var(--text-xl);
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
color: var(--color-text-primary);
|
color: var(--color-text-primary);
|
||||||
margin-bottom: var(--space-2xl);
|
margin-bottom: var(--space-2xl);
|
||||||
}
|
}
|
||||||
|
|
||||||
.admin-card {
|
.admin-card {
|
||||||
background: #FFFFFF;
|
background: #FFFFFF;
|
||||||
border-radius: var(--radius-xl);
|
border-radius: var(--radius-xl);
|
||||||
border: 1px solid var(--color-border);
|
border: 1px solid var(--color-border);
|
||||||
padding: var(--space-2xl);
|
padding: var(--space-2xl);
|
||||||
margin-bottom: var(--space-xl);
|
margin-bottom: var(--space-xl);
|
||||||
}
|
}
|
||||||
|
|
||||||
.admin-card-header {
|
.admin-card-header {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
margin-bottom: var(--space-xl);
|
margin-bottom: var(--space-xl);
|
||||||
}
|
}
|
||||||
|
|
||||||
.admin-card-title {
|
.admin-card-title {
|
||||||
font-size: var(--text-lg);
|
font-size: var(--text-lg);
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
color: var(--color-text-primary);
|
color: var(--color-text-primary);
|
||||||
}
|
}
|
||||||
|
|
||||||
.admin-table {
|
.admin-table {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
border-collapse: collapse;
|
border-collapse: collapse;
|
||||||
}
|
}
|
||||||
|
|
||||||
.admin-table th {
|
.admin-table th {
|
||||||
text-align: left;
|
text-align: left;
|
||||||
padding: var(--space-md) var(--space-lg);
|
padding: var(--space-md) var(--space-lg);
|
||||||
font-size: var(--text-xs);
|
font-size: var(--text-xs);
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
color: var(--color-text-tertiary);
|
color: var(--color-text-tertiary);
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
letter-spacing: 0.05em;
|
letter-spacing: 0.05em;
|
||||||
border-bottom: 1px solid var(--color-border);
|
border-bottom: 1px solid var(--color-border);
|
||||||
background: var(--color-bg-tertiary);
|
background: var(--color-bg-tertiary);
|
||||||
}
|
}
|
||||||
|
|
||||||
.admin-table td {
|
.admin-table td {
|
||||||
padding: var(--space-md) var(--space-lg);
|
padding: var(--space-md) var(--space-lg);
|
||||||
font-size: var(--text-sm);
|
font-size: var(--text-sm);
|
||||||
color: var(--color-text-primary);
|
color: var(--color-text-primary);
|
||||||
border-bottom: 1px solid var(--color-border-light);
|
border-bottom: 1px solid var(--color-border-light);
|
||||||
}
|
}
|
||||||
|
|
||||||
.admin-table tr:hover td {
|
.admin-table tr:hover td {
|
||||||
background: var(--color-bg-hover);
|
background: var(--color-bg-hover);
|
||||||
}
|
}
|
||||||
|
|
||||||
.admin-badge {
|
.admin-badge {
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding: 2px 10px;
|
padding: 2px 10px;
|
||||||
border-radius: var(--radius-full);
|
border-radius: var(--radius-full);
|
||||||
font-size: var(--text-xs);
|
font-size: var(--text-xs);
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.badge-success { background: var(--color-success-light); color: var(--color-success); }
|
.badge-success { background: var(--color-success-light); color: var(--color-success); }
|
||||||
.badge-warning { background: var(--color-warning-light); color: var(--color-warning); }
|
.badge-warning { background: var(--color-warning-light); color: var(--color-warning); }
|
||||||
.badge-error { background: var(--color-error-light); color: var(--color-error); }
|
.badge-error { background: var(--color-error-light); color: var(--color-error); }
|
||||||
.badge-info { background: var(--color-info-light); color: var(--color-info); }
|
.badge-info { background: var(--color-info-light); color: var(--color-info); }
|
||||||
.badge-neutral { background: var(--color-bg-tertiary); color: var(--color-text-secondary); }
|
.badge-neutral { background: var(--color-bg-tertiary); color: var(--color-text-secondary); }
|
||||||
|
|
||||||
.admin-btn {
|
.admin-btn {
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: var(--space-sm);
|
gap: var(--space-sm);
|
||||||
padding: var(--space-sm) var(--space-lg);
|
padding: var(--space-sm) var(--space-lg);
|
||||||
border-radius: var(--radius-md);
|
border-radius: var(--radius-md);
|
||||||
font-size: var(--text-sm);
|
font-size: var(--text-sm);
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
transition: all var(--transition-fast);
|
transition: all var(--transition-fast);
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.admin-btn-primary {
|
.admin-btn-primary {
|
||||||
background: var(--color-accent);
|
background: var(--color-accent);
|
||||||
color: #FFFFFF;
|
color: #FFFFFF;
|
||||||
}
|
}
|
||||||
.admin-btn-primary:hover {
|
.admin-btn-primary:hover {
|
||||||
background: var(--color-accent-hover);
|
background: var(--color-accent-hover);
|
||||||
}
|
}
|
||||||
|
|
||||||
.admin-btn-outline {
|
.admin-btn-outline {
|
||||||
background: transparent;
|
background: transparent;
|
||||||
border: 1px solid var(--color-border);
|
border: 1px solid var(--color-border);
|
||||||
color: var(--color-text-primary);
|
color: var(--color-text-primary);
|
||||||
}
|
}
|
||||||
.admin-btn-outline:hover {
|
.admin-btn-outline:hover {
|
||||||
background: var(--color-bg-hover);
|
background: var(--color-bg-hover);
|
||||||
border-color: var(--color-border-hover);
|
border-color: var(--color-border-hover);
|
||||||
}
|
}
|
||||||
|
|
||||||
.admin-btn-danger {
|
.admin-btn-danger {
|
||||||
background: transparent;
|
background: transparent;
|
||||||
border: 1px solid var(--color-error);
|
border: 1px solid var(--color-error);
|
||||||
color: var(--color-error);
|
color: var(--color-error);
|
||||||
}
|
}
|
||||||
.admin-btn-danger:hover {
|
.admin-btn-danger:hover {
|
||||||
background: var(--color-error-light);
|
background: var(--color-error-light);
|
||||||
}
|
}
|
||||||
|
|
||||||
.admin-btn-sm {
|
.admin-btn-sm {
|
||||||
padding: 3px 10px;
|
padding: 3px 10px;
|
||||||
font-size: var(--text-xs);
|
font-size: var(--text-xs);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Admin Stats */
|
/* Admin Stats */
|
||||||
.admin-stats {
|
.admin-stats {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
||||||
gap: var(--space-lg);
|
gap: var(--space-lg);
|
||||||
margin-bottom: var(--space-2xl);
|
margin-bottom: var(--space-2xl);
|
||||||
}
|
}
|
||||||
|
|
||||||
.admin-stat-card {
|
.admin-stat-card {
|
||||||
background: #FFFFFF;
|
background: #FFFFFF;
|
||||||
border-radius: var(--radius-xl);
|
border-radius: var(--radius-xl);
|
||||||
border: 1px solid var(--color-border);
|
border: 1px solid var(--color-border);
|
||||||
padding: var(--space-xl);
|
padding: var(--space-xl);
|
||||||
}
|
}
|
||||||
|
|
||||||
.admin-stat-label {
|
.admin-stat-label {
|
||||||
font-size: var(--text-xs);
|
font-size: var(--text-xs);
|
||||||
color: var(--color-text-tertiary);
|
color: var(--color-text-tertiary);
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
margin-bottom: var(--space-sm);
|
margin-bottom: var(--space-sm);
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
letter-spacing: 0.05em;
|
letter-spacing: 0.05em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.admin-stat-value {
|
.admin-stat-value {
|
||||||
font-size: var(--text-2xl);
|
font-size: var(--text-2xl);
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
color: var(--color-text-primary);
|
color: var(--color-text-primary);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Admin Form */
|
/* Admin Form */
|
||||||
.admin-form-group {
|
.admin-form-group {
|
||||||
margin-bottom: var(--space-xl);
|
margin-bottom: var(--space-xl);
|
||||||
}
|
}
|
||||||
|
|
||||||
.admin-form-label {
|
.admin-form-label {
|
||||||
display: block;
|
display: block;
|
||||||
font-size: var(--text-sm);
|
font-size: var(--text-sm);
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
color: var(--color-text-primary);
|
color: var(--color-text-primary);
|
||||||
margin-bottom: var(--space-sm);
|
margin-bottom: var(--space-sm);
|
||||||
}
|
}
|
||||||
|
|
||||||
.admin-form-input {
|
.admin-form-input {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding: var(--space-md) var(--space-lg);
|
padding: var(--space-md) var(--space-lg);
|
||||||
border: 1px solid var(--color-border);
|
border: 1px solid var(--color-border);
|
||||||
border-radius: var(--radius-md);
|
border-radius: var(--radius-md);
|
||||||
font-size: var(--text-sm);
|
font-size: var(--text-sm);
|
||||||
color: var(--color-text-primary);
|
color: var(--color-text-primary);
|
||||||
background: #FFFFFF;
|
background: #FFFFFF;
|
||||||
transition: border-color var(--transition-fast);
|
transition: border-color var(--transition-fast);
|
||||||
outline: none;
|
outline: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.admin-form-input:focus {
|
.admin-form-input:focus {
|
||||||
border-color: var(--color-accent);
|
border-color: var(--color-accent);
|
||||||
box-shadow: 0 0 0 3px var(--color-accent-light);
|
box-shadow: 0 0 0 3px var(--color-accent-light);
|
||||||
}
|
}
|
||||||
|
|
||||||
.admin-form-input::placeholder {
|
.admin-form-input::placeholder {
|
||||||
color: var(--color-text-disabled);
|
color: var(--color-text-disabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
.admin-form-textarea {
|
.admin-form-textarea {
|
||||||
min-height: 100px;
|
min-height: 100px;
|
||||||
resize: vertical;
|
resize: vertical;
|
||||||
}
|
}
|
||||||
|
|
||||||
.admin-form-row {
|
.admin-form-row {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(2, 1fr);
|
grid-template-columns: repeat(2, 1fr);
|
||||||
gap: var(--space-lg);
|
gap: var(--space-lg);
|
||||||
}
|
}
|
||||||
|
|
||||||
.admin-form-actions {
|
.admin-form-actions {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: var(--space-md);
|
gap: var(--space-md);
|
||||||
padding-top: var(--space-lg);
|
padding-top: var(--space-lg);
|
||||||
border-top: 1px solid var(--color-border-light);
|
border-top: 1px solid var(--color-border-light);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Version info in sidebar */
|
/* Version info in sidebar */
|
||||||
.admin-version-info {
|
.admin-version-info {
|
||||||
padding: var(--space-sm) var(--space-md);
|
padding: var(--space-sm) var(--space-md);
|
||||||
font-size: var(--text-xs);
|
font-size: var(--text-xs);
|
||||||
color: rgba(255,255,255,0.25);
|
color: rgba(255,255,255,0.25);
|
||||||
text-align: center;
|
text-align: center;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
border-top: 1px solid rgba(255,255,255,0.04);
|
border-top: 1px solid rgba(255,255,255,0.04);
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 768px) {
|
@media (max-width: 768px) {
|
||||||
.admin-content {
|
.admin-content {
|
||||||
padding: var(--space-lg);
|
padding: var(--space-lg);
|
||||||
}
|
}
|
||||||
.admin-form-row {
|
.admin-form-row {
|
||||||
grid-template-columns: 1fr;
|
grid-template-columns: 1fr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* ===== 页面头部与提示组件(短信配置等页复用) ===== */
|
||||||
|
.admin-page-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-end;
|
||||||
|
justify-content: space-between;
|
||||||
|
margin-bottom: var(--space-xl);
|
||||||
|
gap: var(--space-lg);
|
||||||
|
}
|
||||||
|
.admin-page-subtitle {
|
||||||
|
margin: 6px 0 0;
|
||||||
|
font-size: var(--text-sm);
|
||||||
|
color: var(--color-text-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-alert {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: var(--space-sm);
|
||||||
|
padding: var(--space-md) var(--space-lg);
|
||||||
|
border-radius: var(--radius-md);
|
||||||
|
font-size: var(--text-sm);
|
||||||
|
margin-bottom: var(--space-lg);
|
||||||
|
border: 1px solid transparent;
|
||||||
|
line-height: 1.5;
|
||||||
|
}
|
||||||
|
.admin-alert-success {
|
||||||
|
background: var(--color-success-light);
|
||||||
|
border-color: var(--color-success);
|
||||||
|
color: var(--color-success);
|
||||||
|
}
|
||||||
|
.admin-alert-error {
|
||||||
|
background: var(--color-error-light);
|
||||||
|
border-color: var(--color-error);
|
||||||
|
color: var(--color-error);
|
||||||
|
}
|
||||||
|
.admin-alert-info {
|
||||||
|
background: var(--color-info-light);
|
||||||
|
border-color: var(--color-info);
|
||||||
|
color: var(--color-info);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-form-hint {
|
||||||
|
margin-top: var(--space-md);
|
||||||
|
font-size: var(--text-xs);
|
||||||
|
color: var(--color-text-tertiary);
|
||||||
|
line-height: 1.6;
|
||||||
|
}
|
||||||
|
.admin-form-hint code {
|
||||||
|
background: var(--color-bg-tertiary);
|
||||||
|
padding: 1px 6px;
|
||||||
|
border-radius: var(--radius-sm);
|
||||||
|
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
|
||||||
|
font-size: var(--text-xs);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-tips {
|
||||||
|
margin: 0;
|
||||||
|
padding-left: var(--space-xl);
|
||||||
|
color: var(--color-text-secondary);
|
||||||
|
font-size: var(--text-sm);
|
||||||
|
line-height: 1.9;
|
||||||
|
}
|
||||||
|
.admin-tips li {
|
||||||
|
margin-bottom: var(--space-xs);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* ===== 顶部栏与面包屑 ===== */
|
||||||
|
.admin-topbar {
|
||||||
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
z-index: 20;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
height: 56px;
|
||||||
|
margin: calc(-1 * var(--space-2xl)) calc(-1 * var(--space-2xl)) var(--space-2xl);
|
||||||
|
padding: 0 var(--space-2xl);
|
||||||
|
background: rgba(255, 255, 255, 0.82);
|
||||||
|
backdrop-filter: blur(10px);
|
||||||
|
-webkit-backdrop-filter: blur(10px);
|
||||||
|
border-bottom: 1px solid var(--color-border);
|
||||||
|
}
|
||||||
|
.admin-breadcrumb {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: var(--space-sm);
|
||||||
|
font-size: var(--text-sm);
|
||||||
|
}
|
||||||
|
.crumb-root { color: var(--color-text-tertiary); }
|
||||||
|
.crumb-sep { color: var(--color-text-disabled); }
|
||||||
|
.crumb-group { color: var(--color-text-secondary); }
|
||||||
|
.crumb-current { color: var(--color-text-primary); font-weight: 600; }
|
||||||
|
.admin-topbar-user {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: var(--space-sm);
|
||||||
|
font-size: var(--text-sm);
|
||||||
|
color: var(--color-text-secondary);
|
||||||
|
}
|
||||||
|
.admin-user-avatar.sm {
|
||||||
|
width: 28px;
|
||||||
|
height: 28px;
|
||||||
|
font-size: var(--text-xs);
|
||||||
|
}
|
||||||
|
.admin-topbar-username { font-weight: 600; color: var(--color-text-primary); }
|
||||||
@@ -73,6 +73,7 @@ const adminNavGroups: NavGroup[] = [
|
|||||||
icon: 'settings',
|
icon: 'settings',
|
||||||
items: [
|
items: [
|
||||||
{ path: '/admin/settings', icon: 'settings', label: '网站设置' },
|
{ path: '/admin/settings', icon: 'settings', label: '网站设置' },
|
||||||
|
{ path: '/admin/sms', icon: 'sms', label: '短信配置' },
|
||||||
{ path: '/admin/logs', icon: 'logs', label: '日志与风控' },
|
{ path: '/admin/logs', icon: 'logs', label: '日志与风控' },
|
||||||
{ path: '/admin/im-bots', icon: 'imbot', label: 'IM 机器人' },
|
{ path: '/admin/im-bots', icon: 'imbot', label: 'IM 机器人' },
|
||||||
{ path: '/admin/privacy', icon: 'privacy', label: '隐私与本地代理' },
|
{ path: '/admin/privacy', icon: 'privacy', label: '隐私与本地代理' },
|
||||||
@@ -123,12 +124,26 @@ const adminIconPaths: Record<string, JSX.Element> = {
|
|||||||
apps: <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round"><rect x="3" y="3" width="7" height="7" rx="1"/><rect x="14" y="3" width="7" height="7" rx="1"/><rect x="3" y="14" width="7" height="7" rx="1"/><rect x="14" y="14" width="7" height="7" rx="1"/></svg>,
|
apps: <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round"><rect x="3" y="3" width="7" height="7" rx="1"/><rect x="14" y="3" width="7" height="7" rx="1"/><rect x="3" y="14" width="7" height="7" rx="1"/><rect x="14" y="14" width="7" height="7" rx="1"/></svg>,
|
||||||
assets: <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round"><path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"/><polyline points="3.27 6.96 12 12.01 20.73 6.96"/><line x1="12" y1="22.08" x2="12" y2="12"/></svg>,
|
assets: <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round"><path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"/><polyline points="3.27 6.96 12 12.01 20.73 6.96"/><line x1="12" y1="22.08" x2="12" y2="12"/></svg>,
|
||||||
chevron: <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><polyline points="6 9 12 15 18 9"/></svg>,
|
chevron: <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><polyline points="6 9 12 15 18 9"/></svg>,
|
||||||
|
sms: <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg>,
|
||||||
};
|
};
|
||||||
|
|
||||||
const AdminLayout: React.FC = () => {
|
const AdminLayout: React.FC = () => {
|
||||||
const { user, logout } = useAuth();
|
const { user, logout } = useAuth();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
|
const navCrumb = (() => {
|
||||||
|
for (const g of adminNavGroups) {
|
||||||
|
for (const it of g.items) {
|
||||||
|
const match = it.exact
|
||||||
|
? location.pathname === it.path
|
||||||
|
: location.pathname === it.path || location.pathname.startsWith(it.path + '/');
|
||||||
|
if (match) return { group: g.title, label: it.label };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return { group: '', label: '' };
|
||||||
|
})();
|
||||||
|
const navGroup = navCrumb.group;
|
||||||
|
const navLabel = navCrumb.label;
|
||||||
|
|
||||||
// Default: all groups collapsed. Auto-expand the group containing the active route.
|
// Default: all groups collapsed. Auto-expand the group containing the active route.
|
||||||
const [expandedGroups, setExpandedGroups] = useState<Set<string>>(() => {
|
const [expandedGroups, setExpandedGroups] = useState<Set<string>>(() => {
|
||||||
@@ -227,6 +242,17 @@ const AdminLayout: React.FC = () => {
|
|||||||
</div>
|
</div>
|
||||||
</aside>
|
</aside>
|
||||||
<main className="admin-content">
|
<main className="admin-content">
|
||||||
|
<header className="admin-topbar">
|
||||||
|
<nav className="admin-breadcrumb" aria-label="breadcrumb">
|
||||||
|
<span className="crumb-root">管理控制台</span>
|
||||||
|
{navGroup && (<><span className="crumb-sep">/</span><span className="crumb-group">{navGroup}</span></>)}
|
||||||
|
{navLabel && (<><span className="crumb-sep">/</span><span className="crumb-current">{navLabel}</span></>)}
|
||||||
|
</nav>
|
||||||
|
<div className="admin-topbar-user">
|
||||||
|
<div className="admin-user-avatar sm">{user?.username?.[0]?.toUpperCase() || 'A'}</div>
|
||||||
|
<span className="admin-topbar-username">{user?.username || 'admin'}</span>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
<Outlet />
|
<Outlet />
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,454 +1,379 @@
|
|||||||
import React, { useState, useEffect } from 'react';
|
import React, { useState, useEffect } from 'react';
|
||||||
import { adminAPI } from '@/api';
|
import { adminAPI } from '@/api';
|
||||||
|
|
||||||
const SVGIcon: React.FC<{ children: React.ReactNode; size?: number }> = ({ children, size = 16 }) => (
|
const SVGIcon: React.FC<{ children: React.ReactNode; size?: number }> = ({ children, size = 16 }) => (
|
||||||
<svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
|
<svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
|
||||||
{children}
|
{children}
|
||||||
</svg>
|
</svg>
|
||||||
);
|
);
|
||||||
|
|
||||||
const SiteSettings: React.FC = () => {
|
const SiteSettings: React.FC = () => {
|
||||||
const [brand, setBrand] = useState<Record<string, string>>({
|
const [brand, setBrand] = useState<Record<string, string>>({
|
||||||
logo: '', siteName: '', announcement: '', icpNumber: '', contactPhone: '',
|
logo: '', siteName: '', announcement: '', icpNumber: '', contactPhone: '',
|
||||||
});
|
});
|
||||||
const [mail, setMail] = useState({
|
const [mail, setMail] = useState({
|
||||||
smtp_host: '', smtp_port: 587, username: '', password: '', from_address: '', use_tls: true,
|
smtp_host: '', smtp_port: 587, username: '', password: '', from_address: '', use_tls: true,
|
||||||
});
|
});
|
||||||
const [sms, setSms] = useState({
|
const [savedMsg, setSavedMsg] = useState<string | null>(null);
|
||||||
provider: '', api_key: '', api_secret: '', sign_name: '', template_code: '',
|
const [loading, setLoading] = useState(true);
|
||||||
});
|
const [testResult, setTestResult] = useState<string | null>(null);
|
||||||
const [savedMsg, setSavedMsg] = useState<string | null>(null);
|
const [showEmailTest, setShowEmailTest] = useState(false);
|
||||||
const [loading, setLoading] = useState(true);
|
const [emailTestTo, setEmailTestTo] = useState('');
|
||||||
const [testResult, setTestResult] = useState<string | null>(null);
|
const [emailTestSubject, setEmailTestSubject] = useState('');
|
||||||
const [showEmailTest, setShowEmailTest] = useState(false);
|
const [emailTestBody, setEmailTestBody] = useState('');
|
||||||
const [emailTestTo, setEmailTestTo] = useState('');
|
const [emailGenerating, setEmailGenerating] = useState(false);
|
||||||
const [emailTestSubject, setEmailTestSubject] = useState('');
|
|
||||||
const [emailTestBody, setEmailTestBody] = useState('');
|
// AI生成测试邮件内容
|
||||||
const [emailGenerating, setEmailGenerating] = useState(false);
|
const handleAIGenerateContent = async () => {
|
||||||
|
setEmailGenerating(true);
|
||||||
// AI生成测试邮件内容
|
try {
|
||||||
const handleAIGenerateContent = async () => {
|
const res = await adminAPI.generateEmailContent('测试邮件');
|
||||||
setEmailGenerating(true);
|
const data = (res as any).data || res;
|
||||||
try {
|
setEmailTestSubject(data.subject || '');
|
||||||
const res = await adminAPI.generateEmailContent('测试邮件');
|
setEmailTestBody(data.body || '');
|
||||||
const data = (res as any).data || res;
|
} catch (e) {
|
||||||
setEmailTestSubject(data.subject || '');
|
// 降级:使用客户端预设内容
|
||||||
setEmailTestBody(data.body || '');
|
const subjects = [
|
||||||
} catch (e) {
|
'【测试】AIFlow邮件服务配置验证',
|
||||||
// 降级:使用客户端预设内容
|
'AIFlow平台 - 邮件投递测试',
|
||||||
const subjects = [
|
'测试邮件:您的SMTP服务已就绪',
|
||||||
'【测试】AIFlow邮件服务配置验证',
|
];
|
||||||
'AIFlow平台 - 邮件投递测试',
|
const bodies = [
|
||||||
'测试邮件:您的SMTP服务已就绪',
|
'您好!\n\n这是一封来自 AIFlow 智能自动化平台的测试邮件。\n\n如果您收到此邮件,说明SMTP邮件服务已配置成功。\n\n此致\nAIFlow 平台团队',
|
||||||
];
|
'Hi,\n\nThis is a test email from AIFlow Platform.\n\nIf you received this, the SMTP service works fine.\n\nBest regards,\nAIFlow Team',
|
||||||
const bodies = [
|
'【系统通知】\n邮件服务连通性测试通过。\n\n发件服务器配置正确。\n\n—— AIFlow',
|
||||||
'您好!\n\n这是一封来自 AIFlow 智能自动化平台的测试邮件。\n\n如果您收到此邮件,说明SMTP邮件服务已配置成功。\n\n此致\nAIFlow 平台团队',
|
];
|
||||||
'Hi,\n\nThis is a test email from AIFlow Platform.\n\nIf you received this, the SMTP service works fine.\n\nBest regards,\nAIFlow Team',
|
setEmailTestSubject(subjects[Math.floor(Math.random() * subjects.length)]);
|
||||||
'【系统通知】\n邮件服务连通性测试通过。\n\n发件服务器配置正确。\n\n—— AIFlow',
|
setEmailTestBody(bodies[Math.floor(Math.random() * bodies.length)]);
|
||||||
];
|
} finally {
|
||||||
setEmailTestSubject(subjects[Math.floor(Math.random() * subjects.length)]);
|
setEmailGenerating(false);
|
||||||
setEmailTestBody(bodies[Math.floor(Math.random() * bodies.length)]);
|
}
|
||||||
} finally {
|
};
|
||||||
setEmailGenerating(false);
|
|
||||||
}
|
// 加载真实配置
|
||||||
};
|
useEffect(() => {
|
||||||
|
async function loadConfig() {
|
||||||
// 加载真实配置
|
try {
|
||||||
useEffect(() => {
|
const [siteRes, emailRes, smsRes] = await Promise.all([
|
||||||
async function loadConfig() {
|
adminAPI.getSiteSettings(),
|
||||||
try {
|
adminAPI.getEmailConfig(),
|
||||||
const [siteRes, emailRes, smsRes] = await Promise.all([
|
adminAPI.getSmsConfig(),
|
||||||
adminAPI.getSiteSettings(),
|
]);
|
||||||
adminAPI.getEmailConfig(),
|
if (siteRes?.data) {
|
||||||
adminAPI.getSmsConfig(),
|
setBrand({
|
||||||
]);
|
logo: siteRes.data.logo || '',
|
||||||
if (siteRes?.data) {
|
siteName: siteRes.data.site_name || siteRes.data.siteName || '',
|
||||||
setBrand({
|
announcement: siteRes.data.announcement || '',
|
||||||
logo: siteRes.data.logo || '',
|
icpNumber: siteRes.data.icp_number || siteRes.data.icpNumber || '',
|
||||||
siteName: siteRes.data.site_name || siteRes.data.siteName || '',
|
contactPhone: siteRes.data.contact_phone || siteRes.data.contactPhone || '',
|
||||||
announcement: siteRes.data.announcement || '',
|
});
|
||||||
icpNumber: siteRes.data.icp_number || siteRes.data.icpNumber || '',
|
}
|
||||||
contactPhone: siteRes.data.contact_phone || siteRes.data.contactPhone || '',
|
if (emailRes?.data) {
|
||||||
});
|
setMail({
|
||||||
}
|
smtp_host: emailRes.data.smtp_host || '',
|
||||||
if (emailRes?.data) {
|
smtp_port: emailRes.data.smtp_port || 587,
|
||||||
setMail({
|
username: emailRes.data.username || '',
|
||||||
smtp_host: emailRes.data.smtp_host || '',
|
password: emailRes.data.password || '',
|
||||||
smtp_port: emailRes.data.smtp_port || 587,
|
from_address: emailRes.data.from_address || '',
|
||||||
username: emailRes.data.username || '',
|
use_tls: emailRes.data.use_tls !== false,
|
||||||
password: emailRes.data.password || '',
|
});
|
||||||
from_address: emailRes.data.from_address || '',
|
}
|
||||||
use_tls: emailRes.data.use_tls !== false,
|
if (smsRes?.data) {
|
||||||
});
|
setSms({
|
||||||
}
|
provider: smsRes.data.provider || '',
|
||||||
if (smsRes?.data) {
|
api_key: smsRes.data.api_key || '',
|
||||||
setSms({
|
api_secret: smsRes.data.api_secret || '',
|
||||||
provider: smsRes.data.provider || '',
|
sign_name: smsRes.data.sign_name || '',
|
||||||
api_key: smsRes.data.api_key || '',
|
template_code: smsRes.data.template_code || '',
|
||||||
api_secret: smsRes.data.api_secret || '',
|
});
|
||||||
sign_name: smsRes.data.sign_name || '',
|
}
|
||||||
template_code: smsRes.data.template_code || '',
|
} catch (e) {
|
||||||
});
|
console.error('加载配置失败:', e);
|
||||||
}
|
} finally {
|
||||||
} catch (e) {
|
setLoading(false);
|
||||||
console.error('加载配置失败:', e);
|
}
|
||||||
} finally {
|
}
|
||||||
setLoading(false);
|
loadConfig();
|
||||||
}
|
}, []);
|
||||||
}
|
|
||||||
loadConfig();
|
const showSaved = (block: string) => {
|
||||||
}, []);
|
setSavedMsg(block + ' 保存成功');
|
||||||
|
setTimeout(() => setSavedMsg(null), 2000);
|
||||||
const showSaved = (block: string) => {
|
};
|
||||||
setSavedMsg(block + ' 保存成功');
|
|
||||||
setTimeout(() => setSavedMsg(null), 2000);
|
const showTestResult = (result: string) => {
|
||||||
};
|
setTestResult(result);
|
||||||
|
setTimeout(() => setTestResult(null), 5000);
|
||||||
const showTestResult = (result: string) => {
|
};
|
||||||
setTestResult(result);
|
|
||||||
setTimeout(() => setTestResult(null), 5000);
|
// 保存品牌设置
|
||||||
};
|
const saveSiteSettings = async () => {
|
||||||
|
try {
|
||||||
// 保存品牌设置
|
await adminAPI.updateSiteSettings({
|
||||||
const saveSiteSettings = async () => {
|
logo: brand.logo,
|
||||||
try {
|
site_name: brand.siteName,
|
||||||
await adminAPI.updateSiteSettings({
|
announcement: brand.announcement,
|
||||||
logo: brand.logo,
|
icp_number: brand.icpNumber,
|
||||||
site_name: brand.siteName,
|
contact_phone: brand.contactPhone,
|
||||||
announcement: brand.announcement,
|
});
|
||||||
icp_number: brand.icpNumber,
|
showSaved('品牌设置');
|
||||||
contact_phone: brand.contactPhone,
|
} catch (e: any) {
|
||||||
});
|
alert('保存失败: ' + (e.detail || e.message));
|
||||||
showSaved('品牌设置');
|
}
|
||||||
} catch (e: any) {
|
};
|
||||||
alert('保存失败: ' + (e.detail || e.message));
|
|
||||||
}
|
// 保存邮件配置
|
||||||
};
|
const saveEmailConfig = async () => {
|
||||||
|
try {
|
||||||
// 保存邮件配置
|
await adminAPI.updateEmailConfig({
|
||||||
const saveEmailConfig = async () => {
|
smtp_host: mail.smtp_host,
|
||||||
try {
|
smtp_port: mail.smtp_port,
|
||||||
await adminAPI.updateEmailConfig({
|
username: mail.username,
|
||||||
smtp_host: mail.smtp_host,
|
password: mail.password,
|
||||||
smtp_port: mail.smtp_port,
|
from_address: mail.from_address,
|
||||||
username: mail.username,
|
use_tls: mail.use_tls,
|
||||||
password: mail.password,
|
});
|
||||||
from_address: mail.from_address,
|
showSaved('邮件配置');
|
||||||
use_tls: mail.use_tls,
|
} catch (e: any) {
|
||||||
});
|
alert('保存失败: ' + (e.detail || e.message));
|
||||||
showSaved('邮件配置');
|
}
|
||||||
} catch (e: any) {
|
};
|
||||||
alert('保存失败: ' + (e.detail || e.message));
|
|
||||||
}
|
// 保存短信配置
|
||||||
};
|
// 发送测试邮件 - 先保存配置再发送
|
||||||
|
const sendTestEmail = async () => {
|
||||||
// 保存短信配置
|
if (!emailTestTo.trim()) {
|
||||||
const saveSmsConfig = async () => {
|
showTestResult('请输入收件邮箱地址');
|
||||||
try {
|
return;
|
||||||
await adminAPI.updateSmsConfig({
|
}
|
||||||
provider: sms.provider,
|
try {
|
||||||
api_key: sms.api_key,
|
// 测试前先保存邮件配置到数据库,确保使用最新配置
|
||||||
api_secret: sms.api_secret,
|
await adminAPI.updateEmailConfig({
|
||||||
sign_name: sms.sign_name,
|
smtp_host: mail.smtp_host,
|
||||||
template_code: sms.template_code,
|
smtp_port: mail.smtp_port,
|
||||||
});
|
username: mail.username,
|
||||||
showSaved('短信配置');
|
password: mail.password,
|
||||||
} catch (e: any) {
|
from_address: mail.from_address,
|
||||||
alert('保存失败: ' + (e.detail || e.message));
|
use_tls: mail.use_tls,
|
||||||
}
|
});
|
||||||
};
|
const res = await adminAPI.testEmail({
|
||||||
|
test_to: emailTestTo.trim(),
|
||||||
// 发送测试邮件 - 先保存配置再发送
|
test_subject: emailTestSubject || undefined,
|
||||||
const sendTestEmail = async () => {
|
test_body: emailTestBody || undefined,
|
||||||
if (!emailTestTo.trim()) {
|
});
|
||||||
showTestResult('请输入收件邮箱地址');
|
showTestResult('测试邮件已发送至 ' + emailTestTo + ': ' + ((res as any)?.message || 'OK'));
|
||||||
return;
|
setShowEmailTest(false);
|
||||||
}
|
} catch (e: any) {
|
||||||
try {
|
showTestResult('测试邮件发送失败: ' + (e.detail || e.message));
|
||||||
// 测试前先保存邮件配置到数据库,确保使用最新配置
|
}
|
||||||
await adminAPI.updateEmailConfig({
|
};
|
||||||
smtp_host: mail.smtp_host,
|
|
||||||
smtp_port: mail.smtp_port,
|
const openEmailTest = () => {
|
||||||
username: mail.username,
|
setEmailTestTo('');
|
||||||
password: mail.password,
|
setEmailTestSubject('');
|
||||||
from_address: mail.from_address,
|
setEmailTestBody('');
|
||||||
use_tls: mail.use_tls,
|
setShowEmailTest(true);
|
||||||
});
|
};
|
||||||
const res = await adminAPI.testEmail({
|
|
||||||
test_to: emailTestTo.trim(),
|
if (loading) {
|
||||||
test_subject: emailTestSubject || undefined,
|
return <div style={{ padding: 40, textAlign: 'center' }}>加载中...</div>;
|
||||||
test_body: emailTestBody || undefined,
|
}
|
||||||
});
|
|
||||||
showTestResult('测试邮件已发送至 ' + emailTestTo + ': ' + ((res as any)?.message || 'OK'));
|
return (
|
||||||
setShowEmailTest(false);
|
<div style={{ animation: 'fadeIn var(--transition-normal)' }}>
|
||||||
} catch (e: any) {
|
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', marginBottom: 'var(--space-2xl)' }}>
|
||||||
showTestResult('测试邮件发送失败: ' + (e.detail || e.message));
|
<h1 className="admin-page-title" style={{ marginBottom: 0 }}>网站基础设置</h1>
|
||||||
}
|
{savedMsg && (
|
||||||
};
|
<span className="admin-badge badge-success" style={{ padding: '6px 14px', fontSize: 'var(--text-sm)' }}>
|
||||||
|
<SVGIcon><polyline points="20 6 9 17 4 12"/></SVGIcon>
|
||||||
const openEmailTest = () => {
|
{' '}{savedMsg}
|
||||||
setEmailTestTo('');
|
</span>
|
||||||
setEmailTestSubject('');
|
)}
|
||||||
setEmailTestBody('');
|
</div>
|
||||||
setShowEmailTest(true);
|
|
||||||
};
|
{/* Brand Settings */}
|
||||||
|
<div className="admin-card">
|
||||||
// 发送测试短信
|
<div className="admin-card-header">
|
||||||
const sendTestSms = async () => {
|
<h3 className="admin-card-title">
|
||||||
try {
|
<SVGIcon size={18}><rect x="3" y="3" width="7" height="7" rx="1"/><rect x="14" y="3" width="7" height="7" rx="1"/><rect x="3" y="14" width="7" height="7" rx="1"/><rect x="14" y="14" width="7" height="7" rx="1"/></SVGIcon>
|
||||||
const res = await adminAPI.testSms();
|
{' '}品牌设置
|
||||||
showTestResult('测试短信发送成功: ' + (res?.message || 'OK'));
|
</h3>
|
||||||
} catch (e: any) {
|
</div>
|
||||||
showTestResult('测试短信发送失败: ' + (e.detail || e.message));
|
|
||||||
}
|
<div className="admin-form-row">
|
||||||
};
|
<div className="admin-form-group">
|
||||||
|
<label className="admin-form-label">LOGO URL</label>
|
||||||
if (loading) {
|
<input className="admin-form-input" value={brand.logo} onChange={e => setBrand({ ...brand, logo: e.target.value })} />
|
||||||
return <div style={{ padding: 40, textAlign: 'center' }}>加载中...</div>;
|
</div>
|
||||||
}
|
<div className="admin-form-group">
|
||||||
|
<label className="admin-form-label">网站名称</label>
|
||||||
return (
|
<input className="admin-form-input" value={brand.siteName} onChange={e => setBrand({ ...brand, siteName: e.target.value })} />
|
||||||
<div style={{ animation: 'fadeIn var(--transition-normal)' }}>
|
</div>
|
||||||
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', marginBottom: 'var(--space-2xl)' }}>
|
</div>
|
||||||
<h1 className="admin-page-title" style={{ marginBottom: 0 }}>网站基础设置</h1>
|
|
||||||
{savedMsg && (
|
<div className="admin-form-group">
|
||||||
<span className="admin-badge badge-success" style={{ padding: '6px 14px', fontSize: 'var(--text-sm)' }}>
|
<label className="admin-form-label">首页公告</label>
|
||||||
<SVGIcon><polyline points="20 6 9 17 4 12"/></SVGIcon>
|
<textarea
|
||||||
{' '}{savedMsg}
|
className="admin-form-input admin-form-textarea"
|
||||||
</span>
|
value={brand.announcement}
|
||||||
)}
|
onChange={e => setBrand({ ...brand, announcement: e.target.value })}
|
||||||
</div>
|
style={{ minHeight: 60 }}
|
||||||
|
/>
|
||||||
{/* Brand Settings */}
|
</div>
|
||||||
<div className="admin-card">
|
|
||||||
<div className="admin-card-header">
|
<div className="admin-form-row">
|
||||||
<h3 className="admin-card-title">
|
<div className="admin-form-group">
|
||||||
<SVGIcon size={18}><rect x="3" y="3" width="7" height="7" rx="1"/><rect x="14" y="3" width="7" height="7" rx="1"/><rect x="3" y="14" width="7" height="7" rx="1"/><rect x="14" y="14" width="7" height="7" rx="1"/></SVGIcon>
|
<label className="admin-form-label">备案号</label>
|
||||||
{' '}品牌设置
|
<input className="admin-form-input" value={brand.icpNumber} onChange={e => setBrand({ ...brand, icpNumber: e.target.value })} />
|
||||||
</h3>
|
</div>
|
||||||
</div>
|
<div className="admin-form-group">
|
||||||
|
<label className="admin-form-label">客服联系方式</label>
|
||||||
<div className="admin-form-row">
|
<input className="admin-form-input" value={brand.contactPhone} onChange={e => setBrand({ ...brand, contactPhone: e.target.value })} />
|
||||||
<div className="admin-form-group">
|
</div>
|
||||||
<label className="admin-form-label">LOGO URL</label>
|
</div>
|
||||||
<input className="admin-form-input" value={brand.logo} onChange={e => setBrand({ ...brand, logo: e.target.value })} />
|
|
||||||
</div>
|
<div className="admin-form-actions">
|
||||||
<div className="admin-form-group">
|
<button className="admin-btn admin-btn-primary" onClick={saveSiteSettings}>
|
||||||
<label className="admin-form-label">网站名称</label>
|
<SVGIcon><path d="M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"/><polyline points="17 21 17 13 7 13 7 21"/><polyline points="7 3 7 8 15 8"/></SVGIcon>
|
||||||
<input className="admin-form-input" value={brand.siteName} onChange={e => setBrand({ ...brand, siteName: e.target.value })} />
|
保存设置
|
||||||
</div>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<div className="admin-form-group">
|
|
||||||
<label className="admin-form-label">首页公告</label>
|
{/* Mail Config */}
|
||||||
<textarea
|
<div className="admin-card">
|
||||||
className="admin-form-input admin-form-textarea"
|
<div className="admin-card-header">
|
||||||
value={brand.announcement}
|
<h3 className="admin-card-title">
|
||||||
onChange={e => setBrand({ ...brand, announcement: e.target.value })}
|
<SVGIcon size={18}><path d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"/><polyline points="22,6 12,13 2,6"/></SVGIcon>
|
||||||
style={{ minHeight: 60 }}
|
{' '}邮件配置
|
||||||
/>
|
</h3>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="admin-form-row">
|
<div className="admin-form-row">
|
||||||
<div className="admin-form-group">
|
<div className="admin-form-group">
|
||||||
<label className="admin-form-label">备案号</label>
|
<label className="admin-form-label">SMTP服务器</label>
|
||||||
<input className="admin-form-input" value={brand.icpNumber} onChange={e => setBrand({ ...brand, icpNumber: e.target.value })} />
|
<input className="admin-form-input" value={mail.smtp_host} onChange={e => setMail({ ...mail, smtp_host: e.target.value })} />
|
||||||
</div>
|
</div>
|
||||||
<div className="admin-form-group">
|
<div className="admin-form-group">
|
||||||
<label className="admin-form-label">客服联系方式</label>
|
<label className="admin-form-label">端口</label>
|
||||||
<input className="admin-form-input" value={brand.contactPhone} onChange={e => setBrand({ ...brand, contactPhone: e.target.value })} />
|
<input className="admin-form-input" type="number" value={mail.smtp_port} onChange={e => setMail({ ...mail, smtp_port: Number(e.target.value) })} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="admin-form-actions">
|
<div className="admin-form-row">
|
||||||
<button className="admin-btn admin-btn-primary" onClick={saveSiteSettings}>
|
<div className="admin-form-group">
|
||||||
<SVGIcon><path d="M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"/><polyline points="17 21 17 13 7 13 7 21"/><polyline points="7 3 7 8 15 8"/></SVGIcon>
|
<label className="admin-form-label">用户名</label>
|
||||||
保存设置
|
<input className="admin-form-input" value={mail.username} onChange={e => setMail({ ...mail, username: e.target.value })} />
|
||||||
</button>
|
</div>
|
||||||
</div>
|
<div className="admin-form-group">
|
||||||
</div>
|
<label className="admin-form-label">密码</label>
|
||||||
|
<input className="admin-form-input" type="password" value={mail.password} onChange={e => setMail({ ...mail, password: e.target.value })} />
|
||||||
{/* Mail Config */}
|
</div>
|
||||||
<div className="admin-card">
|
</div>
|
||||||
<div className="admin-card-header">
|
|
||||||
<h3 className="admin-card-title">
|
<div className="admin-form-group" style={{ maxWidth: '50%' }}>
|
||||||
<SVGIcon size={18}><path d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"/><polyline points="22,6 12,13 2,6"/></SVGIcon>
|
<label className="admin-form-label">发件地址</label>
|
||||||
{' '}邮件配置
|
<input className="admin-form-input" value={mail.from_address} onChange={e => setMail({ ...mail, from_address: e.target.value })} />
|
||||||
</h3>
|
</div>
|
||||||
</div>
|
|
||||||
|
<div className="admin-form-actions">
|
||||||
<div className="admin-form-row">
|
<button className="admin-btn admin-btn-primary" onClick={saveEmailConfig}>
|
||||||
<div className="admin-form-group">
|
<SVGIcon><path d="M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"/><polyline points="17 21 17 13 7 13 7 21"/><polyline points="7 3 7 8 15 8"/></SVGIcon>
|
||||||
<label className="admin-form-label">SMTP服务器</label>
|
保存设置
|
||||||
<input className="admin-form-input" value={mail.smtp_host} onChange={e => setMail({ ...mail, smtp_host: e.target.value })} />
|
</button>
|
||||||
</div>
|
<button className="admin-btn admin-btn-outline" onClick={openEmailTest}>
|
||||||
<div className="admin-form-group">
|
<SVGIcon><line x1="22" y1="2" x2="11" y2="13"/><polygon points="22 2 15 22 11 13 2 9 22 2"/></SVGIcon>
|
||||||
<label className="admin-form-label">端口</label>
|
发送测试邮件
|
||||||
<input className="admin-form-input" type="number" value={mail.smtp_port} onChange={e => setMail({ ...mail, smtp_port: Number(e.target.value) })} />
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="admin-form-row">
|
{/* SMS Config */}
|
||||||
<div className="admin-form-group">
|
{/* Email Test Modal */}
|
||||||
<label className="admin-form-label">用户名</label>
|
{showEmailTest && (
|
||||||
<input className="admin-form-input" value={mail.username} onChange={e => setMail({ ...mail, username: e.target.value })} />
|
<div style={{
|
||||||
</div>
|
position: 'fixed', top: 0, left: 0, right: 0, bottom: 0,
|
||||||
<div className="admin-form-group">
|
background: 'rgba(0,0,0,0.4)', zIndex: 'var(--z-modal)',
|
||||||
<label className="admin-form-label">密码</label>
|
display: 'flex', alignItems: 'center', justifyContent: 'center',
|
||||||
<input className="admin-form-input" type="password" value={mail.password} onChange={e => setMail({ ...mail, password: e.target.value })} />
|
}} onClick={() => setShowEmailTest(false)}>
|
||||||
</div>
|
<div style={{
|
||||||
</div>
|
background: '#fff', borderRadius: 'var(--radius-2xl)', width: 520, maxHeight: '90vh', overflow: 'auto',
|
||||||
|
padding: 'var(--space-3xl)', boxShadow: 'var(--shadow-xl)',
|
||||||
<div className="admin-form-group" style={{ maxWidth: '50%' }}>
|
}} onClick={e => e.stopPropagation()}>
|
||||||
<label className="admin-form-label">发件地址</label>
|
<h3 style={{ fontSize: 'var(--text-lg)', fontWeight: 700, marginBottom: 'var(--space-2xl)' }}>
|
||||||
<input className="admin-form-input" value={mail.from_address} onChange={e => setMail({ ...mail, from_address: e.target.value })} />
|
<SVGIcon size={20}><path d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"/><polyline points="22,6 12,13 2,6"/></SVGIcon>
|
||||||
</div>
|
{' '}发送测试邮件
|
||||||
|
</h3>
|
||||||
<div className="admin-form-actions">
|
<div className="admin-form-group">
|
||||||
<button className="admin-btn admin-btn-primary" onClick={saveEmailConfig}>
|
<label className="admin-form-label">收件邮箱 <span style={{ color: 'var(--color-error)' }}>*</span></label>
|
||||||
<SVGIcon><path d="M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"/><polyline points="17 21 17 13 7 13 7 21"/><polyline points="7 3 7 8 15 8"/></SVGIcon>
|
<input
|
||||||
保存设置
|
className="admin-form-input"
|
||||||
</button>
|
type="email"
|
||||||
<button className="admin-btn admin-btn-outline" onClick={openEmailTest}>
|
value={emailTestTo}
|
||||||
<SVGIcon><line x1="22" y1="2" x2="11" y2="13"/><polygon points="22 2 15 22 11 13 2 9 22 2"/></SVGIcon>
|
onChange={e => setEmailTestTo(e.target.value)}
|
||||||
发送测试邮件
|
placeholder="例如: admin@example.com"
|
||||||
</button>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div className="admin-form-group">
|
||||||
|
<label className="admin-form-label">邮件主题</label>
|
||||||
{/* SMS Config */}
|
<input
|
||||||
<div className="admin-card">
|
className="admin-form-input"
|
||||||
<div className="admin-card-header">
|
value={emailTestSubject}
|
||||||
<h3 className="admin-card-title">
|
onChange={e => setEmailTestSubject(e.target.value)}
|
||||||
<SVGIcon size={18}><rect x="5" y="2" width="14" height="20" rx="2"/><line x1="12" y1="18" x2="12.01" y2="18"/></SVGIcon>
|
placeholder="测试邮件标题"
|
||||||
{' '}短信配置
|
/>
|
||||||
</h3>
|
</div>
|
||||||
</div>
|
<div className="admin-form-group">
|
||||||
|
<label className="admin-form-label">邮件内容</label>
|
||||||
<div className="admin-form-row">
|
<textarea
|
||||||
<div className="admin-form-group">
|
className="admin-form-input admin-form-textarea"
|
||||||
<label className="admin-form-label">短信服务商</label>
|
value={emailTestBody}
|
||||||
<select className="admin-form-input" value={sms.provider} onChange={e => setSms({ ...sms, provider: e.target.value })}>
|
onChange={e => setEmailTestBody(e.target.value)}
|
||||||
<option value="">请选择</option>
|
style={{ minHeight: 120 }}
|
||||||
<option value="阿里云短信">阿里云短信</option>
|
placeholder="测试邮件内容..."
|
||||||
<option value="腾讯云短信">腾讯云短信</option>
|
/>
|
||||||
<option value="华为云短信">华为云短信</option>
|
</div>
|
||||||
</select>
|
<div style={{ display: 'flex', gap: 'var(--space-sm)', justifyContent: 'space-between', marginBottom: 'var(--space-lg)' }}>
|
||||||
</div>
|
<button
|
||||||
<div className="admin-form-group">
|
className="admin-btn admin-btn-outline admin-btn-sm"
|
||||||
<label className="admin-form-label">短信签名</label>
|
onClick={handleAIGenerateContent}
|
||||||
<input className="admin-form-input" value={sms.sign_name} onChange={e => setSms({ ...sms, sign_name: e.target.value })} />
|
disabled={emailGenerating}
|
||||||
</div>
|
style={{ display: 'inline-flex', alignItems: 'center', gap: 4 }}
|
||||||
</div>
|
>
|
||||||
|
<SVGIcon size={12}><polyline points="22 12 18 12 15 21 9 3 6 12 2 12"/></SVGIcon>
|
||||||
<div className="admin-form-row">
|
{emailGenerating ? '生成中...' : 'AI生成测试内容'}
|
||||||
<div className="admin-form-group">
|
</button>
|
||||||
<label className="admin-form-label">API Key</label>
|
</div>
|
||||||
<input className="admin-form-input" value={sms.api_key} onChange={e => setSms({ ...sms, api_key: e.target.value })} />
|
<div className="admin-form-actions">
|
||||||
</div>
|
<button
|
||||||
<div className="admin-form-group">
|
className="admin-btn admin-btn-primary"
|
||||||
<label className="admin-form-label">API Secret</label>
|
onClick={sendTestEmail}
|
||||||
<input className="admin-form-input" type="password" value={sms.api_secret} onChange={e => setSms({ ...sms, api_secret: e.target.value })} />
|
disabled={!emailTestTo.trim()}
|
||||||
</div>
|
>
|
||||||
</div>
|
<SVGIcon><line x1="22" y1="2" x2="11" y2="13"/><polygon points="22 2 15 22 11 13 2 9 22 2"/></SVGIcon>
|
||||||
|
发送测试邮件
|
||||||
<div className="admin-form-actions">
|
</button>
|
||||||
<button className="admin-btn admin-btn-primary" onClick={saveSmsConfig}>
|
<button className="admin-btn admin-btn-outline" onClick={() => setShowEmailTest(false)}>
|
||||||
<SVGIcon><path d="M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"/><polyline points="17 21 17 13 7 13 7 21"/><polyline points="7 3 7 8 15 8"/></SVGIcon>
|
取消
|
||||||
保存设置
|
</button>
|
||||||
</button>
|
</div>
|
||||||
<button className="admin-btn admin-btn-outline" onClick={sendTestSms}>
|
</div>
|
||||||
<SVGIcon><line x1="22" y1="2" x2="11" y2="13"/><polygon points="22 2 15 22 11 13 2 9 22 2"/></SVGIcon>
|
</div>
|
||||||
发送测试短信
|
)}
|
||||||
</button>
|
|
||||||
</div>
|
{/* Test Result Toast */}
|
||||||
</div>
|
{testResult && (
|
||||||
|
<div style={{
|
||||||
{/* Email Test Modal */}
|
position: 'fixed', bottom: 24, right: 24, padding: '12px 20px',
|
||||||
{showEmailTest && (
|
background: testResult.includes('失败') ? 'var(--color-error)' : 'var(--color-success)',
|
||||||
<div style={{
|
color: '#fff', borderRadius: 8, boxShadow: '0 4px 12px rgba(0,0,0,0.15)',
|
||||||
position: 'fixed', top: 0, left: 0, right: 0, bottom: 0,
|
zIndex: 9999, fontSize: 'var(--text-sm)',
|
||||||
background: 'rgba(0,0,0,0.4)', zIndex: 'var(--z-modal)',
|
}}>
|
||||||
display: 'flex', alignItems: 'center', justifyContent: 'center',
|
{testResult}
|
||||||
}} onClick={() => setShowEmailTest(false)}>
|
</div>
|
||||||
<div style={{
|
)}
|
||||||
background: '#fff', borderRadius: 'var(--radius-2xl)', width: 520, maxHeight: '90vh', overflow: 'auto',
|
</div>
|
||||||
padding: 'var(--space-3xl)', boxShadow: 'var(--shadow-xl)',
|
);
|
||||||
}} onClick={e => e.stopPropagation()}>
|
};
|
||||||
<h3 style={{ fontSize: 'var(--text-lg)', fontWeight: 700, marginBottom: 'var(--space-2xl)' }}>
|
|
||||||
<SVGIcon size={20}><path d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"/><polyline points="22,6 12,13 2,6"/></SVGIcon>
|
export default SiteSettings;
|
||||||
{' '}发送测试邮件
|
|
||||||
</h3>
|
|
||||||
<div className="admin-form-group">
|
|
||||||
<label className="admin-form-label">收件邮箱 <span style={{ color: 'var(--color-error)' }}>*</span></label>
|
|
||||||
<input
|
|
||||||
className="admin-form-input"
|
|
||||||
type="email"
|
|
||||||
value={emailTestTo}
|
|
||||||
onChange={e => setEmailTestTo(e.target.value)}
|
|
||||||
placeholder="例如: admin@example.com"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div className="admin-form-group">
|
|
||||||
<label className="admin-form-label">邮件主题</label>
|
|
||||||
<input
|
|
||||||
className="admin-form-input"
|
|
||||||
value={emailTestSubject}
|
|
||||||
onChange={e => setEmailTestSubject(e.target.value)}
|
|
||||||
placeholder="测试邮件标题"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div className="admin-form-group">
|
|
||||||
<label className="admin-form-label">邮件内容</label>
|
|
||||||
<textarea
|
|
||||||
className="admin-form-input admin-form-textarea"
|
|
||||||
value={emailTestBody}
|
|
||||||
onChange={e => setEmailTestBody(e.target.value)}
|
|
||||||
style={{ minHeight: 120 }}
|
|
||||||
placeholder="测试邮件内容..."
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div style={{ display: 'flex', gap: 'var(--space-sm)', justifyContent: 'space-between', marginBottom: 'var(--space-lg)' }}>
|
|
||||||
<button
|
|
||||||
className="admin-btn admin-btn-outline admin-btn-sm"
|
|
||||||
onClick={handleAIGenerateContent}
|
|
||||||
disabled={emailGenerating}
|
|
||||||
style={{ display: 'inline-flex', alignItems: 'center', gap: 4 }}
|
|
||||||
>
|
|
||||||
<SVGIcon size={12}><polyline points="22 12 18 12 15 21 9 3 6 12 2 12"/></SVGIcon>
|
|
||||||
{emailGenerating ? '生成中...' : 'AI生成测试内容'}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<div className="admin-form-actions">
|
|
||||||
<button
|
|
||||||
className="admin-btn admin-btn-primary"
|
|
||||||
onClick={sendTestEmail}
|
|
||||||
disabled={!emailTestTo.trim()}
|
|
||||||
>
|
|
||||||
<SVGIcon><line x1="22" y1="2" x2="11" y2="13"/><polygon points="22 2 15 22 11 13 2 9 22 2"/></SVGIcon>
|
|
||||||
发送测试邮件
|
|
||||||
</button>
|
|
||||||
<button className="admin-btn admin-btn-outline" onClick={() => setShowEmailTest(false)}>
|
|
||||||
取消
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* Test Result Toast */}
|
|
||||||
{testResult && (
|
|
||||||
<div style={{
|
|
||||||
position: 'fixed', bottom: 24, right: 24, padding: '12px 20px',
|
|
||||||
background: testResult.includes('失败') ? 'var(--color-error)' : 'var(--color-success)',
|
|
||||||
color: '#fff', borderRadius: 8, boxShadow: '0 4px 12px rgba(0,0,0,0.15)',
|
|
||||||
zIndex: 9999, fontSize: 'var(--text-sm)',
|
|
||||||
}}>
|
|
||||||
{testResult}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default SiteSettings;
|
|
||||||
@@ -0,0 +1,252 @@
|
|||||||
|
import React, { useState, useEffect } from 'react';
|
||||||
|
import { adminAPI } from '@/api';
|
||||||
|
|
||||||
|
const SVGIcon: React.FC<{ children: React.ReactNode; size?: number }> = ({ children, size = 16 }) => (
|
||||||
|
<svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
|
||||||
|
{children}
|
||||||
|
</svg>
|
||||||
|
);
|
||||||
|
|
||||||
|
const SmsConfig: React.FC = () => {
|
||||||
|
const [cfg, setCfg] = useState<Record<string, string>>({
|
||||||
|
provider: '',
|
||||||
|
api_key: '',
|
||||||
|
api_secret: '',
|
||||||
|
sign_name: '',
|
||||||
|
template_code: '',
|
||||||
|
username: '',
|
||||||
|
password: '',
|
||||||
|
goods_id: '',
|
||||||
|
});
|
||||||
|
const [loading, setLoading] = useState(true);
|
||||||
|
const [saving, setSaving] = useState(false);
|
||||||
|
const [testing, setTesting] = useState(false);
|
||||||
|
const [querying, setQuerying] = useState(false);
|
||||||
|
const [savedMsg, setSavedMsg] = useState<string | null>(null);
|
||||||
|
const [testResult, setTestResult] = useState<{ ok: boolean; msg: string } | null>(null);
|
||||||
|
const [balance, setBalance] = useState<{ sent: number; remain: number } | null>(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
(async () => {
|
||||||
|
try {
|
||||||
|
const res = await adminAPI.getSmsConfig();
|
||||||
|
const data = (res as any)?.data ?? res;
|
||||||
|
setCfg({
|
||||||
|
provider: data.provider || '',
|
||||||
|
api_key: data.api_key || '',
|
||||||
|
api_secret: data.api_secret || '',
|
||||||
|
sign_name: data.sign_name || '',
|
||||||
|
template_code: data.template_code || '',
|
||||||
|
username: data.username || '',
|
||||||
|
password: data.password || '',
|
||||||
|
goods_id: data.goods_id || '',
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
// ignore
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const update = (patch: Partial<Record<string, string>>) =>
|
||||||
|
setCfg((prev) => ({ ...prev, ...patch }));
|
||||||
|
|
||||||
|
const save = async () => {
|
||||||
|
setSaving(true);
|
||||||
|
setSavedMsg(null);
|
||||||
|
setTestResult(null);
|
||||||
|
try {
|
||||||
|
await adminAPI.updateSmsConfig({
|
||||||
|
provider: cfg.provider,
|
||||||
|
api_key: cfg.api_key,
|
||||||
|
api_secret: cfg.api_secret,
|
||||||
|
sign_name: cfg.sign_name,
|
||||||
|
template_code: cfg.template_code,
|
||||||
|
username: cfg.username,
|
||||||
|
password: cfg.password,
|
||||||
|
goods_id: cfg.goods_id,
|
||||||
|
});
|
||||||
|
setSavedMsg('短信配置已保存');
|
||||||
|
} catch (e: any) {
|
||||||
|
setSavedMsg('保存失败:' + (e?.response?.data?.detail || e?.message || '未知错误'));
|
||||||
|
} finally {
|
||||||
|
setSaving(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const sendTest = async () => {
|
||||||
|
setTesting(true);
|
||||||
|
setTestResult(null);
|
||||||
|
setSavedMsg(null);
|
||||||
|
try {
|
||||||
|
const res = await adminAPI.testSms();
|
||||||
|
const data = (res as any)?.data ?? res;
|
||||||
|
setTestResult({ ok: true, msg: data?.message || '测试短信已发送' });
|
||||||
|
} catch (e: any) {
|
||||||
|
setTestResult({ ok: false, msg: e?.response?.data?.detail || e?.message || '发送失败' });
|
||||||
|
} finally {
|
||||||
|
setTesting(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const queryBalance = async () => {
|
||||||
|
setQuerying(true);
|
||||||
|
setBalance(null);
|
||||||
|
setTestResult(null);
|
||||||
|
try {
|
||||||
|
const res = await adminAPI.getSmsBalance();
|
||||||
|
const data = (res as any)?.data ?? res;
|
||||||
|
setBalance({ sent: data?.sent ?? 0, remain: data?.remain ?? 0 });
|
||||||
|
} catch (e: any) {
|
||||||
|
setTestResult({ ok: false, msg: e?.response?.data?.detail || e?.message || '查询余额失败' });
|
||||||
|
} finally {
|
||||||
|
setQuerying(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const isSmsBao = cfg.provider === '短信宝';
|
||||||
|
|
||||||
|
if (loading) {
|
||||||
|
return <div className="admin-page"><div className="admin-page-title">短信配置</div><p style={{ color: 'var(--color-text-secondary)' }}>加载中…</p></div>;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="admin-page">
|
||||||
|
<div className="admin-page-header">
|
||||||
|
<div>
|
||||||
|
<h2 className="admin-page-title">短信配置</h2>
|
||||||
|
<p className="admin-page-subtitle">配置短信服务商,用于验证码、通知类短信的发送</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{savedMsg && (
|
||||||
|
<div className={`admin-alert ${savedMsg.startsWith('保存失败') ? 'admin-alert-error' : 'admin-alert-success'}`}>
|
||||||
|
{savedMsg}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{testResult && (
|
||||||
|
<div className={`admin-alert ${testResult.ok ? 'admin-alert-success' : 'admin-alert-error'}`}>
|
||||||
|
{testResult.msg}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{balance && (
|
||||||
|
<div className="admin-alert admin-alert-info">
|
||||||
|
短信宝账户:已发送 <b>{balance.sent}</b> 条,剩余 <b>{balance.remain}</b> 条
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<div className="admin-card">
|
||||||
|
<div className="admin-card-header">
|
||||||
|
<h3 className="admin-card-title">
|
||||||
|
<SVGIcon size={18}>
|
||||||
|
<rect x="5" y="2" width="14" height="20" rx="2" />
|
||||||
|
<line x1="12" y1="18" x2="12.01" y2="18" />
|
||||||
|
</SVGIcon>
|
||||||
|
{' '}服务商与账号
|
||||||
|
</h3>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="admin-form-row">
|
||||||
|
<div className="admin-form-group">
|
||||||
|
<label className="admin-form-label">短信服务商</label>
|
||||||
|
<select className="admin-form-input" value={cfg.provider} onChange={(e) => update({ provider: e.target.value })}>
|
||||||
|
<option value="">请选择</option>
|
||||||
|
<option value="阿里云短信">阿里云短信</option>
|
||||||
|
<option value="腾讯云短信">腾讯云短信</option>
|
||||||
|
<option value="华为云短信">华为云短信</option>
|
||||||
|
<option value="短信宝">短信宝</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div className="admin-form-group">
|
||||||
|
<label className="admin-form-label">短信签名</label>
|
||||||
|
<input
|
||||||
|
className="admin-form-input"
|
||||||
|
placeholder={isSmsBao ? '如:七虎AI(发送时自动包裹【】)' : '如:七虎AI'}
|
||||||
|
value={cfg.sign_name}
|
||||||
|
onChange={(e) => update({ sign_name: e.target.value })}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{isSmsBao ? (
|
||||||
|
<>
|
||||||
|
<div className="admin-form-row">
|
||||||
|
<div className="admin-form-group">
|
||||||
|
<label className="admin-form-label">用户名 (u)</label>
|
||||||
|
<input className="admin-form-input" value={cfg.username} onChange={(e) => update({ username: e.target.value })} placeholder="短信宝登录用户名" />
|
||||||
|
</div>
|
||||||
|
<div className="admin-form-group">
|
||||||
|
<label className="admin-form-label">密码 (p)</label>
|
||||||
|
<input className="admin-form-input" type="password" value={cfg.password} onChange={(e) => update({ password: e.target.value })} placeholder="短信宝登录密码(发送时自动 MD5)" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="admin-form-row">
|
||||||
|
<div className="admin-form-group" style={{ maxWidth: 360 }}>
|
||||||
|
<label className="admin-form-label">专属通道产品 ID (g) <span style={{ color: 'var(--color-text-muted)' }}>选填</span></label>
|
||||||
|
<input className="admin-form-input" value={cfg.goods_id} onChange={(e) => update({ goods_id: e.target.value })} placeholder="留空使用默认通用产品" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="admin-form-hint">
|
||||||
|
短信宝发送接口:<code>api.smsbao.com/sms</code>,密码以登录密码的 MD5(32位) 提交,短信内容需包含签名 <code>【签名】</code>。
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<div className="admin-form-row">
|
||||||
|
<div className="admin-form-group">
|
||||||
|
<label className="admin-form-label">API Key</label>
|
||||||
|
<input className="admin-form-input" value={cfg.api_key} onChange={(e) => update({ api_key: e.target.value })} placeholder={cfg.provider === '阿里云短信' ? 'AccessKey ID' : 'API Key'} />
|
||||||
|
</div>
|
||||||
|
<div className="admin-form-group">
|
||||||
|
<label className="admin-form-label">API Secret</label>
|
||||||
|
<input className="admin-form-input" type="password" value={cfg.api_secret} onChange={(e) => update({ api_secret: e.target.value })} placeholder={cfg.provider === '阿里云短信' ? 'AccessKey Secret' : 'API Secret'} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{cfg.provider === '阿里云短信' && (
|
||||||
|
<div className="admin-form-row">
|
||||||
|
<div className="admin-form-group" style={{ maxWidth: 360 }}>
|
||||||
|
<label className="admin-form-label">模板 Code <span style={{ color: 'var(--color-text-muted)' }}>选填</span></label>
|
||||||
|
<input className="admin-form-input" value={cfg.template_code} onChange={(e) => update({ template_code: e.target.value })} placeholder="如 SMS_00000001" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<div className="admin-form-actions">
|
||||||
|
<button className="admin-btn admin-btn-primary" onClick={save} disabled={saving}>
|
||||||
|
<SVGIcon><path d="M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z" /><polyline points="17 21 17 13 7 13 7 21" /><polyline points="7 3 7 8 15 8" /></SVGIcon>
|
||||||
|
{saving ? '保存中…' : '保存设置'}
|
||||||
|
</button>
|
||||||
|
<button className="admin-btn admin-btn-outline" onClick={sendTest} disabled={testing}>
|
||||||
|
<SVGIcon><line x1="22" y1="2" x2="11" y2="13" /><polygon points="22 2 15 22 11 13 2 9 2 2" /></SVGIcon>
|
||||||
|
{testing ? '发送中…' : '发送测试短信'}
|
||||||
|
</button>
|
||||||
|
{isSmsBao && (
|
||||||
|
<button className="admin-btn admin-btn-outline" onClick={queryBalance} disabled={querying}>
|
||||||
|
<SVGIcon><line x1="12" y1="1" x2="12" y2="23" /><path d="M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6" /></SVGIcon>
|
||||||
|
{querying ? '查询中…' : '查询余额'}
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="admin-card">
|
||||||
|
<div className="admin-card-header">
|
||||||
|
<h3 className="admin-card-title">
|
||||||
|
<SVGIcon size={18}><circle cx="12" cy="12" r="10" /><line x1="12" y1="16" x2="12" y2="12" /><line x1="12" y1="8" x2="12.01" y2="8" /></SVGIcon>
|
||||||
|
{' '}说明
|
||||||
|
</h3>
|
||||||
|
</div>
|
||||||
|
<ul className="admin-tips">
|
||||||
|
<li>测试短信将发送至<strong>当前管理员账号绑定的手机号</strong>,请先在用户管理中完善手机号。</li>
|
||||||
|
<li>阿里云、腾讯云、华为云使用平台统一的短信网关;短信宝为独立通道,支持余额查询。</li>
|
||||||
|
<li>短信内容须符合运营商规范,包含签名与退订提示,避免触发敏感词拦截。</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default SmsConfig;
|
||||||
Reference in new issue
Block a user