Ver código fonte

feat: 更新数据模型和接口,优化字段命名及结构

17846405080 1 semana atrás
pai
commit
265924fbbe
26 arquivos alterados com 217 adições e 71 exclusões
  1. 70 0
      campus_health_app/backend/src/config/database.ts
  2. 1 0
      campus_health_app/backend/src/controllers/WeightController.ts
  3. 1 0
      campus_health_app/backend/src/dto/tag.dto.ts
  4. 1 0
      campus_health_app/backend/src/dto/weight-goal.dto.ts
  5. 1 0
      campus_health_app/backend/src/dto/weight-record.dto.ts
  6. 9 6
      campus_health_app/backend/src/entities/AnomalyLog.ts
  7. 10 4
      campus_health_app/backend/src/entities/Tag.ts
  8. 6 6
      campus_health_app/backend/src/entities/User.ts
  9. 31 12
      campus_health_app/backend/src/entities/WeightGoal.ts
  10. 11 10
      campus_health_app/backend/src/entities/WeightRecord.ts
  11. 4 3
      campus_health_app/backend/src/entities/WeightRecordTag.ts
  12. 1 0
      campus_health_app/backend/src/middlewares/auth.middleware.ts
  13. 3 2
      campus_health_app/backend/src/middlewares/error.middleware.ts
  14. 1 0
      campus_health_app/backend/src/middlewares/logger.middleware.ts
  15. 2 1
      campus_health_app/backend/src/routes/index.ts
  16. 1 0
      campus_health_app/backend/src/routes/weight.routes.ts
  17. 1 0
      campus_health_app/backend/src/server.ts
  18. 1 0
      campus_health_app/backend/src/services/StatsService.ts
  19. 3 2
      campus_health_app/backend/src/services/TagService.ts
  20. 1 0
      campus_health_app/backend/src/services/WeightGoalService.ts
  21. 4 3
      campus_health_app/backend/src/services/WeightRecordService.ts
  22. 51 0
      campus_health_app/docs/weight-data-tables.md
  23. 3 3
      campus_health_app/frontend/campus-health-app/src/app/modules/school-services/school-services.component.ts
  24. 0 5
      campus_health_app/frontend/campus-health-app/src/app/modules/user-center/user-center.component.html
  25. 0 4
      campus_health_app/frontend/campus-health-app/src/app/modules/user-center/user-center.component.ts
  26. 0 10
      campus_health_app/frontend/campus-health-app/src/styles.scss

+ 70 - 0
campus_health_app/backend/src/config/database.ts

@@ -0,0 +1,70 @@
+import 'reflect-metadata';
+import { DataSource, DataSourceOptions } from 'typeorm';
+import * as dotenv from 'dotenv';
+import { User } from '../entities/User';
+import { WeightRecord } from '../entities/WeightRecord';
+import { WeightGoal } from '../entities/WeightGoal';
+import { Tag } from '../entities/Tag';
+import { WeightRecordTag } from '../entities/WeightRecordTag';
+import { AnomalyLog } from '../entities/AnomalyLog';
+
+dotenv.config();
+
+const parseBoolean = (value: string | undefined, defaultValue = false): boolean => {
+  if (value === undefined) {
+    return defaultValue;
+  }
+  return ['true', '1', 'yes'].includes(value.toLowerCase());
+};
+
+const databaseOptions: DataSourceOptions = {
+  type: (process.env.DB_TYPE as any) || 'mysql',
+  host: process.env.DB_HOST || 'localhost',
+  port: Number.parseInt(process.env.DB_PORT || '3306', 10),
+  username: process.env.DB_USERNAME || 'root',
+  password: process.env.DB_PASSWORD || '',
+  database: process.env.DB_DATABASE || 'campus_health',
+  entities: [User, WeightRecord, WeightGoal, Tag, WeightRecordTag, AnomalyLog],
+  synchronize: parseBoolean(process.env.DB_SYNCHRONIZE, false),
+  logging: parseBoolean(process.env.DB_LOGGING, false),
+  timezone: process.env.DB_TIMEZONE || '+08:00',
+  charset: process.env.DB_CHARSET || 'utf8mb4_unicode_ci'
+};
+
+export const AppDataSource = new DataSource(databaseOptions);
+
+let initializationPromise: Promise<DataSource> | null = null;
+
+export const initializeDatabase = async (): Promise<DataSource> => {
+  if (AppDataSource.isInitialized) {
+    return AppDataSource;
+  }
+
+  if (!initializationPromise) {
+    initializationPromise = AppDataSource.initialize()
+      .then(dataSource => {
+        console.log('✅ 数据库连接成功');
+        return dataSource;
+      })
+      .catch(error => {
+        initializationPromise = null;
+        console.error('❌ 数据库连接失败:', error);
+        throw error;
+      });
+  }
+
+  return initializationPromise;
+};
+
+export const closeDatabase = async (): Promise<void> => {
+  if (initializationPromise) {
+    await initializationPromise.catch(() => undefined);
+    initializationPromise = null;
+  }
+
+  if (AppDataSource.isInitialized) {
+    await AppDataSource.destroy();
+    console.log('🛑 数据库连接已关闭');
+  }
+};
+

+ 1 - 0
campus_health_app/backend/src/controllers/WeightController.ts

@@ -382,4 +382,5 @@ export class WeightController {
 
 
 
+
 

+ 1 - 0
campus_health_app/backend/src/dto/tag.dto.ts

@@ -33,4 +33,5 @@ export class CreateTagDto {
 
 
 
+
 

+ 1 - 0
campus_health_app/backend/src/dto/weight-goal.dto.ts

@@ -58,4 +58,5 @@ export class UpdateWeightGoalDto {
 
 
 
+
 

+ 1 - 0
campus_health_app/backend/src/dto/weight-record.dto.ts

@@ -129,4 +129,5 @@ export class WeightRecordQueryDto {
 
 
 
+
 

+ 9 - 6
campus_health_app/backend/src/entities/AnomalyLog.ts

@@ -29,10 +29,11 @@ export class AnomalyLog {
   @PrimaryColumn('varchar', { length: 36, comment: '日志ID(UUID)' })
   id!: string;
 
-  @Column('varchar', { length: 36, comment: '用户ID' })
+  @Column('varchar', { name: 'user_id', length: 36, comment: '用户ID' })
   userId!: string;
 
   @Column({
+    name: 'anomaly_type',
     type: 'enum',
     enum: AnomalyType,
     comment: '异常类型'
@@ -40,25 +41,26 @@ export class AnomalyLog {
   anomalyType!: AnomalyType;
 
   @Column({
+    name: 'severity',
     type: 'enum',
     enum: AnomalySeverity,
     comment: '严重程度'
   })
   severity!: AnomalySeverity;
 
-  @Column('text', { comment: '提示信息' })
+  @Column('text', { name: 'message', comment: '提示信息' })
   message!: string;
 
-  @Column('date', { comment: '检测日期' })
+  @Column('date', { name: 'detected_date', comment: '检测日期' })
   detectedDate!: string;
 
-  @Column('json', { nullable: true, comment: '相关记录ID数组' })
+  @Column('json', { name: 'related_record_ids', nullable: true, comment: '相关记录ID数组' })
   relatedRecordIds!: string[] | null;
 
-  @Column('boolean', { default: false, comment: '是否已读' })
+  @Column('boolean', { name: 'is_read', default: false, comment: '是否已读' })
   isRead!: boolean;
 
-  @CreateDateColumn({ comment: '创建时间' })
+  @CreateDateColumn({ name: 'created_at', comment: '创建时间' })
   createdAt!: Date;
 
   // 关联关系
@@ -87,4 +89,5 @@ export class AnomalyLog {
 
 
 
+
 

+ 10 - 4
campus_health_app/backend/src/entities/Tag.ts

@@ -24,13 +24,19 @@ export class Tag {
   @PrimaryColumn('varchar', { length: 36, comment: '标签ID(UUID)' })
   id!: string;
 
-  @Column('varchar', { length: 36, nullable: true, comment: '用户ID(NULL表示系统标签)' })
+  @Column('varchar', {
+    name: 'user_id',
+    length: 36,
+    nullable: true,
+    comment: '用户ID(NULL表示系统标签)'
+  })
   userId!: string | null;
 
-  @Column('varchar', { length: 50, comment: '标签名称' })
+  @Column('varchar', { name: 'tag_name', length: 50, comment: '标签名称' })
   tagName!: string;
 
   @Column({
+    name: 'tag_type',
     type: 'enum',
     enum: TagType,
     default: TagType.CUSTOM,
@@ -38,10 +44,10 @@ export class Tag {
   })
   tagType!: TagType;
 
-  @Column('varchar', { length: 7, nullable: true, comment: '颜色代码(HEX)' })
+  @Column('varchar', { name: 'color', length: 7, nullable: true, comment: '颜色代码(HEX)' })
   color!: string | null;
 
-  @CreateDateColumn({ comment: '创建时间' })
+  @CreateDateColumn({ name: 'created_at', comment: '创建时间' })
   createdAt!: Date;
 
   // 关联关系

+ 6 - 6
campus_health_app/backend/src/entities/User.ts

@@ -23,25 +23,25 @@ export class User {
   @Column('varchar', { length: 50, comment: '昵称' })
   nickname!: string;
 
-  @Column('varchar', { length: 36, nullable: true, comment: '学校ID' })
+  @Column('varchar', { name: 'school_id', length: 36, nullable: true, comment: '学校ID' })
   schoolId!: string | null;
 
   @Column('varchar', { length: 20, nullable: true, comment: '年级' })
   grade!: string | null;
 
-  @Column('boolean', { default: false, comment: '是否未满14岁' })
+  @Column('boolean', { name: 'is_under_14', default: false, comment: '是否未满14岁' })
   isUnder14!: boolean;
 
-  @Column('varchar', { length: 20, nullable: true, comment: '家长手机号' })
+  @Column('varchar', { name: 'parent_phone', length: 20, nullable: true, comment: '家长手机号' })
   parentPhone!: string | null;
 
-  @CreateDateColumn({ comment: '创建时间' })
+  @CreateDateColumn({ name: 'created_at', comment: '创建时间' })
   createdAt!: Date;
 
-  @UpdateDateColumn({ nullable: true, comment: '更新时间' })
+  @UpdateDateColumn({ name: 'updated_at', nullable: true, comment: '更新时间' })
   updatedAt!: Date | null;
 
-  @DeleteDateColumn({ nullable: true, comment: '软删除时间' })
+  @DeleteDateColumn({ name: 'deleted_at', nullable: true, comment: '软删除时间' })
   deletedAt!: Date | null;
 
   // 关联关系

+ 31 - 12
campus_health_app/backend/src/entities/WeightGoal.ts

@@ -24,31 +24,50 @@ export class WeightGoal {
   @PrimaryColumn('varchar', { length: 36, comment: '目标ID(UUID)' })
   id!: string;
 
-  @Column('varchar', { length: 36, comment: '用户ID' })
+  @Column('varchar', { name: 'user_id', length: 36, comment: '用户ID' })
   userId!: string;
 
-  @Column('decimal', { precision: 5, scale: 2, comment: '目标体重(kg)' })
+  @Column('decimal', { name: 'target_weight', precision: 5, scale: 2, comment: '目标体重(kg)' })
   targetWeight!: number;
 
-  @Column('decimal', { precision: 4, scale: 2, nullable: true, comment: '目标体脂率(%)' })
+  @Column('decimal', {
+    name: 'target_body_fat',
+    precision: 4,
+    scale: 2,
+    nullable: true,
+    comment: '目标体脂率(%)'
+  })
   targetBodyFat!: number | null;
 
-  @Column('date', { comment: '目标日期' })
+  @Column('date', { name: 'target_date', comment: '目标日期' })
   targetDate!: string;
 
-  @Column('decimal', { precision: 5, scale: 2, comment: '起始体重(kg)' })
+  @Column('decimal', { name: 'start_weight', precision: 5, scale: 2, comment: '起始体重(kg)' })
   startWeight!: number;
 
-  @Column('decimal', { precision: 4, scale: 2, nullable: true, comment: '起始体脂率(%)' })
+  @Column('decimal', {
+    name: 'start_body_fat',
+    precision: 4,
+    scale: 2,
+    nullable: true,
+    comment: '起始体脂率(%)'
+  })
   startBodyFat!: number | null;
 
-  @Column('date', { comment: '开始日期' })
+  @Column('date', { name: 'start_date', comment: '开始日期' })
   startDate!: string;
 
-  @Column('decimal', { precision: 4, scale: 2, nullable: true, comment: '每周目标减重量(kg)' })
+  @Column('decimal', {
+    name: 'weekly_target',
+    precision: 4,
+    scale: 2,
+    nullable: true,
+    comment: '每周目标减重量(kg)'
+  })
   weeklyTarget!: number | null;
 
   @Column({
+    name: 'status',
     type: 'enum',
     enum: GoalStatus,
     default: GoalStatus.ACTIVE,
@@ -56,16 +75,16 @@ export class WeightGoal {
   })
   status!: GoalStatus;
 
-  @Column('timestamp', { nullable: true, comment: '完成时间' })
+  @Column('timestamp', { name: 'completed_at', nullable: true, comment: '完成时间' })
   completedAt!: Date | null;
 
-  @CreateDateColumn({ comment: '创建时间' })
+  @CreateDateColumn({ name: 'created_at', comment: '创建时间' })
   createdAt!: Date;
 
-  @UpdateDateColumn({ nullable: true, comment: '更新时间' })
+  @UpdateDateColumn({ name: 'updated_at', nullable: true, comment: '更新时间' })
   updatedAt!: Date | null;
 
-  @DeleteDateColumn({ nullable: true, comment: '软删除时间' })
+  @DeleteDateColumn({ name: 'deleted_at', nullable: true, comment: '软删除时间' })
   deletedAt!: Date | null;
 
   // 关联关系

+ 11 - 10
campus_health_app/backend/src/entities/WeightRecord.ts

@@ -25,25 +25,26 @@ export class WeightRecord {
   @PrimaryColumn('varchar', { length: 36, comment: '记录ID(UUID)' })
   id!: string;
 
-  @Column('varchar', { length: 36, comment: '用户ID' })
+  @Column('varchar', { name: 'user_id', length: 36, comment: '用户ID' })
   userId!: string;
 
-  @Column('date', { comment: '记录日期' })
+  @Column('date', { name: 'record_date', comment: '记录日期' })
   recordDate!: string;
 
-  @Column('time', { nullable: true, comment: '测量时间' })
+  @Column('time', { name: 'measurement_time', nullable: true, comment: '测量时间' })
   measurementTime!: string | null;
 
-  @Column('decimal', { precision: 5, scale: 2, comment: '体重(kg)' })
+  @Column('decimal', { name: 'weight', precision: 5, scale: 2, comment: '体重(kg)' })
   weight!: number;
 
-  @Column('decimal', { precision: 4, scale: 2, comment: '体脂率(%)' })
+  @Column('decimal', { name: 'body_fat', precision: 4, scale: 2, comment: '体脂率(%)' })
   bodyFat!: number;
 
-  @Column('decimal', { precision: 5, scale: 2, comment: '肌肉含量(kg)' })
+  @Column('decimal', { name: 'muscle_mass', precision: 5, scale: 2, comment: '肌肉含量(kg)' })
   muscleMass!: number;
 
   @Column({
+    name: 'measurement_condition',
     type: 'enum',
     enum: MeasurementCondition,
     nullable: true,
@@ -51,16 +52,16 @@ export class WeightRecord {
   })
   measurementCondition!: MeasurementCondition | null;
 
-  @Column('text', { nullable: true, comment: '备注' })
+  @Column('text', { name: 'notes', nullable: true, comment: '备注' })
   notes!: string | null;
 
-  @CreateDateColumn({ comment: '创建时间' })
+  @CreateDateColumn({ name: 'created_at', comment: '创建时间' })
   createdAt!: Date;
 
-  @UpdateDateColumn({ nullable: true, comment: '更新时间' })
+  @UpdateDateColumn({ name: 'updated_at', nullable: true, comment: '更新时间' })
   updatedAt!: Date | null;
 
-  @DeleteDateColumn({ nullable: true, comment: '软删除时间' })
+  @DeleteDateColumn({ name: 'deleted_at', nullable: true, comment: '软删除时间' })
   deletedAt!: Date | null;
 
   // 关联关系

+ 4 - 3
campus_health_app/backend/src/entities/WeightRecordTag.ts

@@ -18,13 +18,13 @@ export class WeightRecordTag {
   @PrimaryColumn('varchar', { length: 36, comment: '关联ID(UUID)' })
   id!: string;
 
-  @Column('varchar', { length: 36, comment: '体重记录ID' })
+  @Column('varchar', { name: 'weight_record_id', length: 36, comment: '体重记录ID' })
   weightRecordId!: string;
 
-  @Column('varchar', { length: 36, comment: '标签ID' })
+  @Column('varchar', { name: 'tag_id', length: 36, comment: '标签ID' })
   tagId!: string;
 
-  @CreateDateColumn({ comment: '创建时间' })
+  @CreateDateColumn({ name: 'created_at', comment: '创建时间' })
   createdAt!: Date;
 
   // 关联关系
@@ -59,4 +59,5 @@ export class WeightRecordTag {
 
 
 
+
 

+ 1 - 0
campus_health_app/backend/src/middlewares/auth.middleware.ts

@@ -48,4 +48,5 @@ declare global {
 
 
 
+
 

+ 3 - 2
campus_health_app/backend/src/middlewares/error.middleware.ts

@@ -5,9 +5,9 @@ import { Request, Response, NextFunction } from 'express';
  */
 export const errorMiddleware = (
   err: any,
-  req: Request,
+  _req: Request,
   res: Response,
-  next: NextFunction
+  _next: NextFunction
 ): void => {
   console.error('错误:', err);
 
@@ -54,4 +54,5 @@ export const notFoundMiddleware = (
 
 
 
+
 

+ 1 - 0
campus_health_app/backend/src/middlewares/logger.middleware.ts

@@ -41,4 +41,5 @@ export const loggerMiddleware = (
 
 
 
+
 

+ 2 - 1
campus_health_app/backend/src/routes/index.ts

@@ -7,7 +7,7 @@ const router = Router();
 router.use('/weight', weightRoutes);
 
 // 健康检查路由
-router.get('/health', (req, res) => {
+router.get('/health', (_req, res) => {
   res.json({
     success: true,
     message: 'API运行正常',
@@ -35,4 +35,5 @@ export default router;
 
 
 
+
 

+ 1 - 0
campus_health_app/backend/src/routes/weight.routes.ts

@@ -74,4 +74,5 @@ export default router;
 
 
 
+
 

+ 1 - 0
campus_health_app/backend/src/server.ts

@@ -134,4 +134,5 @@ export default app;
 
 
 
+
 

+ 1 - 0
campus_health_app/backend/src/services/StatsService.ts

@@ -116,4 +116,5 @@ export class StatsService {
 
 
 
+
 

+ 3 - 2
campus_health_app/backend/src/services/TagService.ts

@@ -1,4 +1,4 @@
-import { Repository } from 'typeorm';
+import { Repository, IsNull } from 'typeorm';
 import { v4 as uuidv4 } from 'uuid';
 import { AppDataSource } from '../config/database';
 import { Tag, TagType } from '../entities/Tag';
@@ -17,7 +17,7 @@ export class TagService {
   async getTags(userId: string): Promise<Tag[]> {
     const tags = await this.tagRepository.find({
       where: [
-        { userId: null }, // 系统标签
+        { userId: IsNull() }, // 系统标签
         { userId } // 用户自定义标签
       ],
       order: { tagType: 'ASC', createdAt: 'DESC' }
@@ -90,4 +90,5 @@ export class TagService {
 
 
 
+
 

+ 1 - 0
campus_health_app/backend/src/services/WeightGoalService.ts

@@ -143,4 +143,5 @@ export class WeightGoalService {
 
 
 
+
 

+ 4 - 3
campus_health_app/backend/src/services/WeightRecordService.ts

@@ -1,7 +1,7 @@
-import { Repository, Between, In } from 'typeorm';
+import { Repository, IsNull } from 'typeorm';
 import { v4 as uuidv4 } from 'uuid';
 import { AppDataSource } from '../config/database';
-import { WeightRecord, MeasurementCondition } from '../entities/WeightRecord';
+import { WeightRecord } from '../entities/WeightRecord';
 import { WeightRecordTag } from '../entities/WeightRecordTag';
 import { Tag } from '../entities/Tag';
 import { CreateWeightRecordDto, UpdateWeightRecordDto, WeightRecordQueryDto } from '../dto/weight-record.dto';
@@ -184,7 +184,7 @@ export class WeightRecordService {
       let tag = await this.tagRepository.findOne({
         where: [
           { tagName, userId },
-          { tagName, userId: null } // 系统标签
+          { tagName, userId: IsNull() } // 系统标签
         ]
       });
 
@@ -249,4 +249,5 @@ export class WeightRecordService {
 
 
 
+
 

+ 51 - 0
campus_health_app/docs/weight-data-tables.md

@@ -0,0 +1,51 @@
+## 重量管理数据表设计
+
+为支持 `http://localhost:4200/weight` 页面在 Parse Dashboard 中展示和操作数据,需要建立以下两个数据表。表格中列出了字段名称、类型、用途以及是否必填,便于快速参考。
+
+### 表一:`WeightRecord`(体重记录)
+
+| 字段名 | 类型 | 描述 | 是否必填 |
+| --- | --- | --- | --- |
+| `objectId` | String | Parse 默认的记录 ID | 是 |
+| `date` | String |      | 是 |
+| `weight` | Number | 体重(kg) | 是 |
+| `bodyFat` | Number | 体脂率(%) | 是 |
+| `muscleMass` | Number | 肌肉含量(kg) | 是 |
+| `measurementTime` | String | 测量时间(HH:mm) | 否 |
+| `measurementCondition` | String | 测量条件:`fasting`(空腹)或 `after_meal`(餐后) | 否 |
+| `notes` | String | 备注 | 否 |
+| `tags` | Array\<String\> | 关键节点标记(如“开始运动”“目标调整”等) | 否 |
+| `createdAt` | Date | Parse 默认的创建时间戳 | 是 |
+| `updatedAt` | Date | Parse 默认的更新时间戳 | 是 |
+| `syncStatus` | String | 同步状态:`synced`(已同步)或 `pending`(待同步) | 否 |
+
+**Parse Dashboard 创建步骤**
+
+1. 在 Browser 中点击 “Create a class”。
+2. 输入 `WeightRecord` 作为类名。
+3. 按照表格添加字段及对应类型。
+
+### 表二:`WeightGoal`(体重目标)
+
+| 字段名 | 类型 | 描述 | 是否必填 |
+| --- | --- | --- | --- |
+| `objectId` | String | Parse 默认的记录 ID | 是 |
+| `targetWeight` | Number | 目标体重(kg) | 是 |
+| `targetBodyFat` | Number | 目标体脂率(%) | 否 |
+| `targetDate` | String | 目标日期(YYYY-MM-DD) | 是 |
+| `startWeight` | Number | 起始体重(kg) | 是 |
+| `startBodyFat` | Number | 起始体脂率(%) | 否 |
+| `startDate` | String | 起始日期(YYYY-MM-DD) | 是 |
+| `weeklyTarget` | Number | 每周目标减重量(kg) | 否 |
+| `createdAt` | Date | Parse 默认的创建时间戳 | 是 |
+| `updatedAt` | Date | Parse 默认的更新时间戳 | 是 |
+| `syncStatus` | String | 同步状态:`synced`(已同步)或 `pending`(待同步) | 否 |
+
+**Parse Dashboard 创建步骤**
+
+1. 在 Browser 中点击 “Create a class”。
+2. 输入 `WeightGoal` 作为类名。
+3. 按照表格添加字段及对应类型。
+
+> 建议:根据业务需要为两张表配置合适的 ACL(读写权限),以保护敏感数据。
+

+ 3 - 3
campus_health_app/frontend/campus-health-app/src/app/modules/school-services/school-services.component.ts

@@ -129,7 +129,7 @@ export class SchoolServicesComponent {
   exerciseTeams: ExerciseTeam[] = [
     {
       id: 1,
-      name: '跑团',
+      name: '破晓跑团',
       activity: '慢跑',
       time: '每周一、三、五 06:30',
       location: '田径场',
@@ -140,7 +140,7 @@ export class SchoolServicesComponent {
     },
     {
       id: 2,
-      name: '瑜伽小组',
+      name: '云舒瑜伽团',
       activity: '瑜伽',
       time: '每周二、四 18:30',
       location: '体育馆2楼',
@@ -151,7 +151,7 @@ export class SchoolServicesComponent {
     },
     {
       id: 3,
-      name: '篮球爱好者',
+      name: '逐风篮球队',
       activity: '篮球',
       time: '每周六、日 15:00',
       location: '篮球场',

+ 0 - 5
campus_health_app/frontend/campus-health-app/src/app/modules/user-center/user-center.component.html

@@ -48,11 +48,6 @@
     <!-- 系统设置选项 -->
     <div class="system-settings">
       <h3>系统设置</h3>
-      <div class="setting-item" (click)="toggleDarkMode()">
-        <span class="setting-icon">🌙</span>
-        <span class="setting-text">夜间模式</span>
-        <span class="setting-status">{{ themeService.getIsDarkMode() ? '已开启' : '已关闭' }}</span>
-      </div>
       <div class="setting-item">
         <span class="setting-icon">🔔</span>
         <span class="setting-text">消息通知</span>

+ 0 - 4
campus_health_app/frontend/campus-health-app/src/app/modules/user-center/user-center.component.ts

@@ -29,8 +29,4 @@ export class UserCenterComponent {
     this.router.navigate(['/dashboard']);
   }
 
-  // 切换夜间模式
-  toggleDarkMode(): void {
-    this.themeService.toggleTheme();
-  }
 }

+ 0 - 10
campus_health_app/frontend/campus-health-app/src/styles.scss

@@ -42,16 +42,6 @@
   --spacing-xl: 3rem;
 }
 
-/* 夜间模式变量 */
-.dark-theme {
-  --bg-primary: #121212;
-  --bg-secondary: #1e1e1e;
-  --text-primary: #ffffff;
-  --text-secondary: #b0b0b0;
-  --border-color: #333;
-  --shadow-color: rgba(0, 0, 0, 0.3);
-}
-
 /* 全局样式应用 */
 * {
   box-sizing: border-box;