mirror of
https://github.com/Cccc-owo/CheckInApp.git
synced 2026-06-17 14:06:28 +00:00
feat: improve error handling and code quality
后端改进: - 添加统一异常处理系统 (exceptions.py, response.py) - 实现自定义异常类 (ValidationError, AuthorizationError, ResourceNotFoundError, BusinessLogicError) - 配置全局异常处理器,统一 API 错误响应格式 - 迁移业务逻辑错误到自定义异常 (users.py, auth.py) - 添加 SQL LIKE 通配符转义,防止通配符滥用 - 使用 EmailStr 进行邮箱格式验证 - 移除敏感字段暴露 (jwt_sub) 前端改进: - 配置 ESLint 9 (flat config) 和 Prettier - 修复所有 ESLint 错误和警告 - 移除未使用的变量和导入 - 为组件添加 PropTypes 默认值 - 统一代码格式和风格
This commit is contained in:
+17
-16
@@ -5,37 +5,37 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { onMounted, computed } from 'vue'
|
||||
import { ConfigProvider as AConfigProvider } from 'ant-design-vue'
|
||||
import zhCN from 'ant-design-vue/es/locale/zh_CN'
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
import getAntdTheme from './antd-theme'
|
||||
import { useTheme, initTheme, watchSystemTheme } from '@/composables/useTheme'
|
||||
import { onMounted, computed } from 'vue';
|
||||
import { ConfigProvider as AConfigProvider } from 'ant-design-vue';
|
||||
import zhCN from 'ant-design-vue/es/locale/zh_CN';
|
||||
import { useAuthStore } from '@/stores/auth';
|
||||
import getAntdTheme from './antd-theme';
|
||||
import { useTheme, initTheme, watchSystemTheme } from '@/composables/useTheme';
|
||||
|
||||
const authStore = useAuthStore()
|
||||
const authStore = useAuthStore();
|
||||
|
||||
// 初始化主题(全局)
|
||||
initTheme()
|
||||
watchSystemTheme()
|
||||
initTheme();
|
||||
watchSystemTheme();
|
||||
|
||||
// 使用主题
|
||||
const { isDark } = useTheme()
|
||||
const { isDark } = useTheme();
|
||||
|
||||
// 动态生成 Ant Design 主题
|
||||
const antdTheme = computed(() => getAntdTheme(isDark.value))
|
||||
const antdTheme = computed(() => getAntdTheme(isDark.value));
|
||||
|
||||
// 应用启动时验证 Token
|
||||
onMounted(async () => {
|
||||
if (authStore.isAuthenticated) {
|
||||
try {
|
||||
await authStore.fetchCurrentUser()
|
||||
await authStore.fetchCurrentUser();
|
||||
} catch (error) {
|
||||
console.error('验证用户信息失败:', error)
|
||||
console.error('验证用户信息失败:', error);
|
||||
// Token 可能已过期,清除认证状态
|
||||
authStore.clearAuth()
|
||||
authStore.clearAuth();
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
</script>
|
||||
|
||||
<style>
|
||||
@@ -58,7 +58,8 @@ body {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
min-height: 100vh;
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB',
|
||||
font-family:
|
||||
-apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB',
|
||||
'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
|
||||
Reference in New Issue
Block a user