Skip to content

Commit

Permalink
Refactor code and add Pinia for state management
Browse files Browse the repository at this point in the history
  • Loading branch information
zh4men9 committed Jan 23, 2025
1 parent 2860776 commit 8d0e387
Show file tree
Hide file tree
Showing 13 changed files with 988 additions and 889 deletions.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,24 @@
"echarts": "^5.6.0",
"electron-store": "^8.1.0",
"element-plus": "^2.5.6",
"pinia": "^2.1.7",
"vue": "^3.4.15",
"vue-router": "^4.2.5"
"vue-router": "^4.5.0"
},
"devDependencies": {
"@element-plus/icons-vue": "^2.3.1",
"@octokit/rest": "^21.1.0",
"@tsconfig/node18": "^18.2.4",
"@types/node": "^20.11.19",
"@types/node": "^20.17.16",
"@vitejs/plugin-vue": "^4.5.2",
"electron": "^28.2.0",
"electron-builder": "^24.9.1",
"pinia": "^2.3.1",
"typescript": "^5.3.3",
"unplugin-auto-import": "^0.17.5",
"unplugin-vue-components": "^0.26.0",
"vite": "^4.5.2",
"vite-plugin-electron": "^0.28.0",
"vite-plugin-electron-renderer": "^0.14.5",
"vue": "^3.5.13",
"vue-tsc": "^1.8.27"
},
"build": {
Expand Down
30 changes: 14 additions & 16 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

128 changes: 70 additions & 58 deletions src/renderer/assets/styles/index.css
Original file line number Diff line number Diff line change
@@ -1,85 +1,76 @@
:root {
/* 颜色变量 */
--primary-color: #409eff;
--success-color: #67c23a;
--warning-color: #e6a23c;
--danger-color: #f56c6c;
--info-color: #909399;

/* 背景颜色 */
--bg-color: #f5f7fa;
--bg-color-light: #ffffff;
--bg-color-dark: #304156;

/* 文字颜色 */
--text-color: #303133;
--text-color-light: #606266;
--text-color-lighter: #909399;

/* 边框颜色 */
--border-color: #dcdfe6;
--border-color-light: #e4e7ed;
--border-color-lighter: #ebeef5;

/* 阴影 */
--box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
}

/* 全局样式 */
@import './variables.css';

/* 重置样式 */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}

html, body {
html,
body {
height: 100%;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
font-size: 14px;
font-size: var(--text-base);
line-height: 1.5;
color: var(--text-color);
background-color: var(--bg-color);
color: var(--color-text-primary);
background-color: var(--color-bg-primary);
}

/* 滚动条样式 */
::-webkit-scrollbar {
width: 6px;
height: 6px;
width: 8px;
height: 8px;
}

::-webkit-scrollbar-track {
background: var(--bg-color-light);
background: var(--color-bg-secondary);
}

::-webkit-scrollbar-thumb {
background: var(--text-color-lighter);
border-radius: 3px;
background: var(--color-text-secondary);
border-radius: var(--radius-sm);
}

::-webkit-scrollbar-thumb:hover {
background: var(--text-color-light);
background: var(--color-text-primary);
}

/* 通用样式类 */
/* 通用工具类 */
.flex {
display: flex;
}

.flex-center {
display: flex;
.flex-col {
flex-direction: column;
}

.items-center {
align-items: center;
}

.justify-center {
justify-content: center;
}

.flex-between {
display: flex;
align-items: center;
.justify-between {
justify-content: space-between;
}

.flex-column {
display: flex;
flex-direction: column;
.gap-1 {
gap: var(--space-1);
}

.gap-2 {
gap: var(--space-2);
}

.gap-3 {
gap: var(--space-3);
}

.gap-4 {
gap: var(--space-4);
}

.text-ellipsis {
Expand All @@ -92,15 +83,36 @@ html, body {
cursor: pointer;
}

/* 间距类 */
.m-1 { margin: 0.25rem; }
.m-2 { margin: 0.5rem; }
.m-3 { margin: 1rem; }
.m-4 { margin: 1.5rem; }
.m-5 { margin: 2rem; }
.cursor-not-allowed {
cursor: not-allowed;
}

/* 动画类 */
.fade-enter-active,
.fade-leave-active {
transition: opacity var(--transition-normal);
}

.fade-enter-from,
.fade-leave-to {
opacity: 0;
}

/* 响应式工具类 */
@media (max-width: 640px) {
.hidden-sm {
display: none;
}
}

@media (max-width: 768px) {
.hidden-md {
display: none;
}
}

.p-1 { padding: 0.25rem; }
.p-2 { padding: 0.5rem; }
.p-3 { padding: 1rem; }
.p-4 { padding: 1.5rem; }
.p-5 { padding: 2rem; }
@media (max-width: 1024px) {
.hidden-lg {
display: none;
}
}
60 changes: 60 additions & 0 deletions src/renderer/assets/styles/variables.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
:root {
/* 主题颜色 */
--color-primary: #3498db;
--color-primary-dark: #2980b9;
--color-success: #2ecc71;
--color-success-dark: #27ae60;
--color-warning: #f1c40f;
--color-warning-dark: #f39c12;
--color-error: #e74c3c;
--color-error-dark: #c0392b;

/* 背景颜色 */
--color-bg-primary: #ffffff;
--color-bg-secondary: #f8f9fa;
--color-bg-tertiary: #e9ecef;

/* 文本颜色 */
--color-text-primary: #2c3e50;
--color-text-secondary: #6c757d;

/* 边框颜色 */
--color-border: #dee2e6;

/* 阴影 */
--shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
--shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
--shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);

/* 圆角 */
--radius-sm: 4px;
--radius-md: 8px;
--radius-lg: 16px;

/* 间距 */
--space-1: 0.25rem;
--space-2: 0.5rem;
--space-3: 1rem;
--space-4: 1.5rem;
--space-5: 2rem;
--space-6: 3rem;

/* 字体大小 */
--text-xs: 0.75rem;
--text-sm: 0.875rem;
--text-base: 1rem;
--text-lg: 1.125rem;
--text-xl: 1.25rem;
--text-2xl: 1.5rem;

/* 字体粗细 */
--font-normal: 400;
--font-medium: 500;
--font-semibold: 600;
--font-bold: 700;

/* 过渡动画 */
--transition-fast: 0.15s ease-in-out;
--transition-normal: 0.25s ease-in-out;
--transition-slow: 0.35s ease-in-out;
}
3 changes: 2 additions & 1 deletion src/renderer/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ import './assets/styles/index.css';

// 创建Vue应用
const app = createApp(App);
const pinia = createPinia();

// 注册 Element Plus 图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
app.component(key, component);
}

// 使用Pinia状态管理
app.use(createPinia());
app.use(pinia);

// 使用路由
app.use(router);
Expand Down
Loading

0 comments on commit 8d0e387

Please sign in to comment.