feat: initialize new React application structure with TypeScript, ESLint, and Prettier configurations, while removing legacy files and adding new components and pages for enhanced functionality

This commit is contained in:
Supra4E8C
2025-12-07 11:32:31 +08:00
parent 8e4132200d
commit 450964fb1a
144 changed files with 14223 additions and 21647 deletions

546
src/styles/components.scss Normal file
View File

@@ -0,0 +1,546 @@
@import './variables.scss';
.btn {
display: inline-flex;
align-items: center;
justify-content: center;
gap: $spacing-sm;
border: 1px solid transparent;
border-radius: $radius-md;
padding: 10px 14px;
font-weight: 600;
cursor: pointer;
transition: all $transition-fast;
background-color: var(--bg-secondary);
color: var(--text-primary);
&.btn-primary {
background-color: var(--primary-color);
color: #fff;
border-color: var(--primary-color);
&:hover {
background-color: var(--primary-hover);
border-color: var(--primary-hover);
}
}
&.btn-secondary {
background-color: var(--bg-tertiary);
border-color: var(--border-color);
color: var(--text-primary);
&:hover {
border-color: var(--border-hover);
}
}
&.btn-ghost {
background: transparent;
border-color: transparent;
color: var(--text-secondary);
&:hover {
color: var(--text-primary);
background: var(--bg-secondary);
}
}
&.btn-danger {
background-color: $error-color;
border-color: $error-color;
color: #fff;
&:hover {
background-color: darken($error-color, 5%);
}
}
&.btn-full {
width: 100%;
}
&.btn-sm {
padding: 8px 10px;
font-size: 14px;
}
&:disabled {
opacity: 0.6;
cursor: not-allowed;
}
}
.input,
textarea {
width: 100%;
border: 1px solid var(--border-color);
border-radius: $radius-md;
padding: 10px 12px;
background-color: var(--bg-primary);
color: var(--text-primary);
transition: border-color $transition-fast, box-shadow $transition-fast;
&:focus {
outline: none;
border-color: var(--primary-color);
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}
}
.form-group {
display: flex;
flex-direction: column;
gap: $spacing-xs;
margin-bottom: $spacing-md;
label {
font-weight: 600;
color: var(--text-primary);
}
.hint {
color: var(--text-secondary);
font-size: 13px;
}
}
.card {
background-color: var(--bg-primary);
border: 1px solid var(--border-color);
border-radius: $radius-lg;
box-shadow: var(--shadow);
padding: $spacing-lg;
}
.card-header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: $spacing-md;
.title {
font-size: 18px;
font-weight: 700;
color: var(--text-primary);
}
}
.status-badge {
display: inline-flex;
align-items: center;
gap: 6px;
padding: 4px 10px;
border-radius: $radius-full;
font-size: 13px;
border: 1px solid var(--border-color);
&.success {
color: $success-color;
border-color: rgba(16, 185, 129, 0.35);
background: rgba(16, 185, 129, 0.08);
}
&.warning {
color: $warning-color;
border-color: rgba(245, 158, 11, 0.35);
background: rgba(245, 158, 11, 0.08);
}
&.error {
color: $error-color;
border-color: rgba(239, 68, 68, 0.35);
background: rgba(239, 68, 68, 0.08);
}
&.muted {
color: var(--text-secondary);
}
}
.notification-container {
position: fixed;
top: $spacing-lg;
right: $spacing-lg;
display: flex;
flex-direction: column;
gap: $spacing-sm;
z-index: $z-notification;
max-width: 360px;
}
.notification {
padding: $spacing-md;
border-radius: $radius-md;
box-shadow: var(--shadow);
border: 1px solid var(--border-color);
background: var(--bg-primary);
color: var(--text-primary);
display: flex;
justify-content: space-between;
align-items: center;
gap: $spacing-sm;
&.success {
border-color: rgba(16, 185, 129, 0.4);
}
&.warning {
border-color: rgba(245, 158, 11, 0.4);
}
&.error {
border-color: rgba(239, 68, 68, 0.4);
}
.message {
flex: 1;
font-weight: 500;
}
.close-btn {
background: transparent;
border: none;
color: var(--text-secondary);
cursor: pointer;
}
}
.switch {
position: relative;
display: inline-flex;
align-items: center;
gap: $spacing-sm;
cursor: pointer;
input {
width: 0;
height: 0;
opacity: 0;
position: absolute;
}
.track {
width: 44px;
height: 24px;
background: var(--border-color);
border-radius: $radius-full;
position: relative;
transition: background $transition-fast;
}
.thumb {
position: absolute;
top: 3px;
left: 3px;
width: 18px;
height: 18px;
background: #fff;
border-radius: $radius-full;
box-shadow: $shadow-sm;
transition: transform $transition-fast;
}
input:checked + .track {
background: var(--primary-color);
}
input:checked + .track .thumb {
transform: translateX(20px);
}
.label {
color: var(--text-primary);
font-weight: 600;
}
}
.pill {
padding: 4px 10px;
border-radius: $radius-full;
background: var(--bg-secondary);
color: var(--text-secondary);
border: 1px solid var(--border-color);
font-size: 12px;
}
.loading-spinner {
border: 3px solid rgba(255, 255, 255, 0.2);
border-top-color: #fff;
border-radius: 50%;
width: 16px;
height: 16px;
animation: spin 0.8s linear infinite;
}
@keyframes spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
.modal-overlay {
position: fixed;
inset: 0;
background: rgba(0, 0, 0, 0.35);
display: flex;
align-items: center;
justify-content: center;
z-index: $z-modal;
padding: $spacing-lg;
}
.modal {
background: var(--bg-primary);
border-radius: $radius-lg;
border: 1px solid var(--border-color);
box-shadow: $shadow-lg;
max-height: 90vh;
overflow: hidden;
display: flex;
flex-direction: column;
}
.modal-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: $spacing-md $spacing-lg;
border-bottom: 1px solid var(--border-color);
.modal-title {
font-weight: 700;
font-size: 18px;
color: var(--text-primary);
}
.modal-close {
background: transparent;
border: none;
color: var(--text-secondary);
font-size: 20px;
cursor: pointer;
padding: 4px;
}
}
.modal-body {
padding: $spacing-lg;
overflow: auto;
max-height: 65vh;
}
.modal-footer {
padding: $spacing-md $spacing-lg;
border-top: 1px solid var(--border-color);
display: flex;
justify-content: flex-end;
gap: $spacing-sm;
background: var(--bg-primary);
}
.empty-state {
border: 1px dashed var(--border-color);
border-radius: $radius-lg;
padding: $spacing-lg;
background: var(--bg-secondary);
display: flex;
justify-content: space-between;
gap: $spacing-md;
align-items: center;
.empty-content {
display: flex;
align-items: center;
gap: $spacing-md;
}
.empty-icon {
width: 42px;
height: 42px;
border-radius: $radius-full;
border: 2px solid var(--border-color);
display: grid;
place-items: center;
color: var(--text-secondary);
}
.empty-title {
font-weight: 700;
color: var(--text-primary);
}
.empty-desc {
color: var(--text-secondary);
margin-top: 4px;
}
}
.header-input-list {
display: flex;
flex-direction: column;
gap: $spacing-sm;
.header-input-row {
display: grid;
grid-template-columns: 1fr auto 1fr auto;
align-items: center;
gap: $spacing-sm;
}
.header-separator {
color: var(--text-secondary);
text-align: center;
}
.align-start {
width: fit-content;
}
}
.item-list {
display: flex;
flex-direction: column;
gap: $spacing-sm;
}
.item-row {
border: 1px solid var(--border-color);
border-radius: $radius-md;
padding: $spacing-md;
background: var(--bg-primary);
display: flex;
align-items: center;
justify-content: space-between;
gap: $spacing-md;
flex-wrap: wrap;
.item-meta {
display: flex;
flex-direction: column;
gap: 6px;
}
.item-title {
font-weight: 700;
color: var(--text-primary);
}
.item-subtitle {
color: var(--text-secondary);
font-family: ui-monospace, SFMono-Regular, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New',
monospace;
word-break: break-all;
}
.item-actions {
display: flex;
gap: $spacing-sm;
}
}
.error-box {
background: rgba(239, 68, 68, 0.1);
border: 1px solid rgba(239, 68, 68, 0.4);
border-radius: $radius-md;
padding: $spacing-sm $spacing-md;
color: $error-color;
}
.stack {
display: flex;
flex-direction: column;
gap: $spacing-lg;
}
.filters {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
gap: $spacing-md;
margin-bottom: $spacing-md;
.filter-item {
display: flex;
flex-direction: column;
gap: $spacing-xs;
}
}
.table {
display: flex;
flex-direction: column;
border: 1px solid var(--border-color);
border-radius: $radius-md;
overflow: hidden;
.table-header,
.table-row {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
gap: $spacing-sm;
padding: $spacing-sm $spacing-md;
align-items: center;
}
.table-header {
background: var(--bg-secondary);
font-weight: 700;
color: var(--text-primary);
}
.table-row {
border-top: 1px solid var(--border-color);
}
.cell {
display: flex;
align-items: center;
gap: $spacing-sm;
flex-wrap: wrap;
}
}
.pagination {
display: flex;
align-items: center;
gap: $spacing-sm;
margin-top: $spacing-md;
}
.stat-card {
border: 1px solid var(--border-color);
border-radius: $radius-md;
padding: $spacing-md;
background: var(--bg-primary);
display: flex;
flex-direction: column;
gap: $spacing-xs;
.stat-label {
color: var(--text-secondary);
font-size: 14px;
}
.stat-value {
font-weight: 800;
color: var(--text-primary);
font-size: 18px;
}
}
.log-viewer {
background: var(--bg-secondary);
border: 1px solid var(--border-color);
border-radius: $radius-md;
padding: $spacing-md;
max-height: 520px;
overflow: auto;
white-space: pre-wrap;
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
color: var(--text-primary);
}
.hint {
color: var(--text-secondary);
}

70
src/styles/global.scss Normal file
View File

@@ -0,0 +1,70 @@
/**
* 全局样式
*/
@import './variables.scss';
@import './mixins.scss';
@import './reset.scss';
@import './themes.scss';
@import './components.scss';
@import './layout.scss';
body {
background-color: var(--bg-secondary);
color: var(--text-primary);
transition: background-color $transition-normal, color $transition-normal;
}
// 滚动条样式
::-webkit-scrollbar {
width: 8px;
height: 8px;
}
::-webkit-scrollbar-track {
background: var(--bg-secondary);
}
::-webkit-scrollbar-thumb {
background: var(--border-color);
border-radius: $radius-full;
&:hover {
background: var(--border-hover);
}
}
// 通用工具类
.container {
width: 100%;
max-width: 1280px;
margin: 0 auto;
padding: 0 $spacing-md;
}
.flex-center {
@include flex-center;
}
.text-ellipsis {
@include text-ellipsis;
}
// 通用过渡
.fade-enter {
opacity: 0;
}
.fade-enter-active {
opacity: 1;
transition: opacity $transition-normal;
}
.fade-exit {
opacity: 1;
}
.fade-exit-active {
opacity: 0;
transition: opacity $transition-normal;
}

212
src/styles/layout.scss Normal file
View File

@@ -0,0 +1,212 @@
@import './variables.scss';
.app-shell {
display: flex;
min-height: 100vh;
background: var(--bg-secondary);
color: var(--text-primary);
}
.sidebar {
width: 240px;
background: var(--bg-primary);
border-right: 1px solid var(--border-color);
padding: $spacing-lg $spacing-md;
display: flex;
flex-direction: column;
gap: $spacing-lg;
transition: transform $transition-normal;
.brand {
font-weight: 800;
font-size: 18px;
color: var(--text-primary);
}
.nav-section {
display: flex;
flex-direction: column;
gap: $spacing-sm;
}
.nav-item {
padding: 10px 12px;
border-radius: $radius-md;
color: var(--text-primary);
font-weight: 600;
display: flex;
align-items: center;
gap: $spacing-sm;
cursor: pointer;
transition: background $transition-fast, color $transition-fast;
&:hover {
background: var(--bg-secondary);
}
&.active {
background: rgba(59, 130, 246, 0.12);
color: var(--primary-color);
border: 1px solid rgba(59, 130, 246, 0.3);
}
}
@media (max-width: $breakpoint-mobile) {
position: fixed;
z-index: $z-dropdown;
left: 0;
top: 0;
bottom: 0;
transform: translateX(-100%);
box-shadow: $shadow-lg;
&.open {
transform: translateX(0);
}
}
}
.content {
flex: 1;
display: flex;
flex-direction: column;
min-width: 0;
}
.main-header {
display: flex;
align-items: center;
justify-content: space-between;
gap: $spacing-md;
padding: $spacing-md $spacing-lg;
background: var(--bg-primary);
border-bottom: 1px solid var(--border-color);
position: sticky;
top: 0;
z-index: 5;
.left {
display: flex;
align-items: center;
gap: $spacing-sm;
}
.connection {
display: flex;
align-items: center;
gap: $spacing-sm;
color: var(--text-secondary);
.base {
font-weight: 600;
color: var(--text-primary);
}
}
}
.main-content {
flex: 1;
padding: $spacing-lg;
display: flex;
flex-direction: column;
gap: $spacing-lg;
}
.footer {
padding: $spacing-md $spacing-lg;
border-top: 1px solid var(--border-color);
background: var(--bg-primary);
display: flex;
justify-content: space-between;
align-items: center;
color: var(--text-secondary);
font-size: 14px;
flex-wrap: wrap;
gap: $spacing-sm;
}
.login-page {
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
background: var(--bg-secondary);
padding: $spacing-lg;
.login-card {
width: 100%;
max-width: 520px;
background: var(--bg-primary);
border: 1px solid var(--border-color);
border-radius: $radius-lg;
box-shadow: var(--shadow-lg);
padding: $spacing-xl;
display: flex;
flex-direction: column;
gap: $spacing-lg;
}
.login-header {
display: flex;
flex-direction: column;
gap: $spacing-sm;
.title {
font-size: 22px;
font-weight: 800;
color: var(--text-primary);
}
.subtitle {
color: var(--text-secondary);
}
}
.connection-box {
background: var(--bg-secondary);
border: 1px dashed var(--border-color);
border-radius: $radius-md;
padding: $spacing-md;
display: flex;
flex-direction: column;
gap: $spacing-xs;
.label {
color: var(--text-secondary);
font-size: 14px;
}
.value {
font-weight: 700;
color: var(--text-primary);
}
}
.toggle-advanced {
display: flex;
justify-content: flex-start;
align-items: center;
gap: $spacing-xs;
color: var(--text-secondary);
cursor: pointer;
}
.error-box {
background: rgba(239, 68, 68, 0.1);
border: 1px solid rgba(239, 68, 68, 0.4);
border-radius: $radius-md;
padding: $spacing-sm $spacing-md;
color: $error-color;
}
}
.grid {
display: grid;
gap: $spacing-lg;
}
@media (min-width: $breakpoint-tablet) {
.grid.cols-2 {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
}

61
src/styles/mixins.scss Normal file
View File

@@ -0,0 +1,61 @@
/**
* SCSS 混入
*/
// 响应式断点
@mixin mobile {
@media (max-width: #{$breakpoint-mobile}) {
@content;
}
}
@mixin tablet {
@media (min-width: #{$breakpoint-mobile + 1}) and (max-width: #{$breakpoint-tablet}) {
@content;
}
}
@mixin desktop {
@media (min-width: #{$breakpoint-tablet + 1}) {
@content;
}
}
// Flexbox 居中
@mixin flex-center {
display: flex;
align-items: center;
justify-content: center;
}
// 文本截断
@mixin text-ellipsis {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
// 多行文本截断
@mixin text-ellipsis-multiline($lines: 2) {
display: -webkit-box;
-webkit-line-clamp: $lines;
-webkit-box-orient: vertical;
overflow: hidden;
}
// 按钮重置
@mixin button-reset {
border: none;
background: none;
padding: 0;
margin: 0;
cursor: pointer;
font: inherit;
color: inherit;
outline: none;
&:focus {
outline: 2px solid $primary-color;
outline-offset: 2px;
}
}

47
src/styles/reset.scss Normal file
View File

@@ -0,0 +1,47 @@
/**
* CSS Reset
*/
*,
*::before,
*::after {
box-sizing: border-box;
margin: 0;
padding: 0;
}
html,
body {
height: 100%;
width: 100%;
}
body {
margin: 0;
font-family: $font-family;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
line-height: 1.5;
}
#root {
height: 100%;
width: 100%;
}
button,
input,
textarea,
select {
font: inherit;
}
a {
color: inherit;
text-decoration: none;
}
ul,
ol {
list-style: none;
}

55
src/styles/themes.scss Normal file
View File

@@ -0,0 +1,55 @@
/**
* 主题样式
*/
// 浅色主题(默认)
:root {
--bg-primary: #ffffff;
--bg-secondary: #f3f4f6;
--bg-tertiary: #e5e7eb;
--text-primary: #1f2937;
--text-secondary: #6b7280;
--text-tertiary: #9ca3af;
--border-color: #e5e7eb;
--border-hover: #d1d5db;
--primary-color: #3b82f6;
--primary-hover: #2563eb;
--primary-active: #1d4ed8;
--success-color: #10b981;
--warning-color: #f59e0b;
--error-color: #ef4444;
--info-color: #3b82f6;
--shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
--shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}
// 深色主题
[data-theme='dark'] {
--bg-primary: #1f2937;
--bg-secondary: #111827;
--bg-tertiary: #374151;
--text-primary: #f9fafb;
--text-secondary: #d1d5db;
--text-tertiary: #9ca3af;
--border-color: #374151;
--border-hover: #4b5563;
--primary-color: #3b82f6;
--primary-hover: #60a5fa;
--primary-active: #93c5fd;
--success-color: #10b981;
--warning-color: #f59e0b;
--error-color: #ef4444;
--info-color: #3b82f6;
--shadow: 0 1px 3px 0 rgb(0 0 0 / 0.3);
--shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.3);
}

62
src/styles/variables.scss Normal file
View File

@@ -0,0 +1,62 @@
/**
* SCSS 变量定义
*/
// 颜色
$primary-color: #3b82f6;
$success-color: #10b981;
$warning-color: #f59e0b;
$error-color: #ef4444;
$info-color: #3b82f6;
// 灰阶
$gray-50: #f9fafb;
$gray-100: #f3f4f6;
$gray-200: #e5e7eb;
$gray-300: #d1d5db;
$gray-400: #9ca3af;
$gray-500: #6b7280;
$gray-600: #4b5563;
$gray-700: #374151;
$gray-800: #1f2937;
$gray-900: #111827;
// 间距
$spacing-xs: 4px;
$spacing-sm: 8px;
$spacing-md: 16px;
$spacing-lg: 24px;
$spacing-xl: 32px;
$spacing-2xl: 48px;
// 圆角
$radius-sm: 4px;
$radius-md: 8px;
$radius-lg: 12px;
$radius-full: 9999px;
// 阴影
$shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
$shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
$shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
// 过渡
$transition-fast: 150ms ease;
$transition-normal: 300ms ease;
$transition-slow: 500ms ease;
// 断点
$breakpoint-mobile: 768px;
$breakpoint-tablet: 1024px;
$breakpoint-desktop: 1280px;
// Z-index
$z-dropdown: 1000;
$z-modal: 2000;
$z-notification: 3000;
// 字体
$font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell',
'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
$font-mono: 'Courier New', Courier, monospace;