Skip to content

Commit

Permalink
refactor(format): 重构多个组件和服务的代码结构
Browse files Browse the repository at this point in the history
  • Loading branch information
Encaik committed Sep 27, 2024
1 parent 6f6a752 commit 91f64ef
Show file tree
Hide file tree
Showing 20 changed files with 34 additions and 47 deletions.
8 changes: 3 additions & 5 deletions src/app/components/bag-item-view/bag-item-view.component.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import { CommonModule } from '@angular/common';
import { Component, inject, Input } from '@angular/core';
import { LogType, LogLevel, EventType, ItemEventOperate, EventRes, BagItem, getItemLevelClass, ItemLevelMap, ItemMap } from '@models';
import { BackpackService, EventService, LogService } from '@services';
import { getItemSpan } from '@utils/html';
import { NzButtonModule } from 'ng-zorro-antd/button';
import { NzCardModule } from 'ng-zorro-antd/card';
import { NzMessageModule, NzMessageService } from 'ng-zorro-antd/message';
import { NzPopoverModule } from 'ng-zorro-antd/popover';

import { LogType, LogLevel, EventType, ItemEventOperate, EventRes } from '@models';
import { BagItem, getItemLevelClass, ItemLevelMap, ItemMap } from '@models';
import { BackpackService, EventService, LogService } from '@services';
import { getItemSpan } from '@utils/html';
import { of, switchMap } from 'rxjs';

@Component({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { NzModalRefMock } from '@utils/test';
import { NzModalRef } from 'ng-zorro-antd/modal';

import { NzModalRefMock } from '@utils/test';
import { BattleModalComponent } from './battle-modal.component';

describe('BattleModalComponent', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/app/components/battle-modal/battle-modal.component.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { CommonModule } from '@angular/common';
import { Component, inject, Input, OnInit } from '@angular/core';
import { BattleCharacter, BattleStatusInfo } from '@models';
import { EnvService } from '@services';
import { NzButtonModule } from 'ng-zorro-antd/button';
import { NzDescriptionsModule } from 'ng-zorro-antd/descriptions';
import { NzModalRef } from 'ng-zorro-antd/modal';
import { NzSpaceModule } from 'ng-zorro-antd/space';
import { BehaviorSubject, from, map, mergeMap, Subscription, timer } from 'rxjs';

import { BattleCharacter, BattleStatusInfo } from '@models';
import { EnvService } from '@services';
import { ProgressViewComponent } from '../progress-view/progress-view.component';

@Component({
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/init-modal/init-modal.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { NzModalRefMock } from '@utils/test';
import { NzModalRef } from 'ng-zorro-antd/modal';

import { NzModalRefMock } from '@utils/test';
import { InitModalComponent } from './init-modal.component';

describe('InitModalComponent', () => {
Expand Down
6 changes: 3 additions & 3 deletions src/app/components/init-modal/init-modal.component.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { CommonModule, KeyValuePipe } from '@angular/common';
import { Component, inject, OnInit } from '@angular/core';
import { Env, InitCharacter } from '@models';
import { EnvService } from '@services';
import { Generate } from '@utils/generate';
import { NzDescriptionsModule } from 'ng-zorro-antd/descriptions';
import { NzModalRef } from 'ng-zorro-antd/modal';
import { NzStepsModule } from 'ng-zorro-antd/steps';
import { NzTagModule } from 'ng-zorro-antd/tag';

import { Env, InitCharacter } from '@models';
import { EnvService } from '@services';
import { Generate } from '@utils/generate';
import { LevelMapViewComponent } from '../level-map-view/level-map-view.component';

@Component({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { CommonModule } from '@angular/common';
import { ChangeDetectionStrategy, Component, Input, OnInit } from '@angular/core';
import { NzCardModule } from 'ng-zorro-antd/card';

import { getItemLevelClass, Item, ItemLevelMap, ItemMap, RewardPool } from '@models';
import { NzCardModule } from 'ng-zorro-antd/card';

@Component({
selector: 'app-reward-item-view',
Expand Down
5 changes: 2 additions & 3 deletions src/app/layouts/character/character.component.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { Component, inject, OnInit } from '@angular/core';
import { ProgressViewComponent } from '@components/progress-view/progress-view.component';
import { CharacterService, EnvService, TimeTickService } from '@services';
import { NzDescriptionsModule } from 'ng-zorro-antd/descriptions';
import { NzProgressModule } from 'ng-zorro-antd/progress';
import { NzTagModule } from 'ng-zorro-antd/tag';
import { NzTypographyModule } from 'ng-zorro-antd/typography';

import { ProgressViewComponent } from '@components/progress-view/progress-view.component';
import { CharacterService, EnvService, TimeTickService } from '@services';

@Component({
selector: 'app-character',
standalone: true,
Expand Down
7 changes: 3 additions & 4 deletions src/app/layouts/header/header.component.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { KeyValuePipe } from '@angular/common';
import { Component, inject } from '@angular/core';
import { LevelMapViewComponent } from '@components/level-map-view/level-map-view.component';
import { TimeFormatPipe } from '@pipes/time-format.pipe';
import { EnvService, CharacterService, TimeTickService, RuntimeService } from '@services';
import { NzButtonModule } from 'ng-zorro-antd/button';
import { NzDescriptionsModule } from 'ng-zorro-antd/descriptions';
import { NzGridModule } from 'ng-zorro-antd/grid';
import { NzTagModule } from 'ng-zorro-antd/tag';

import { LevelMapViewComponent } from '@components/level-map-view/level-map-view.component';
import { TimeFormatPipe } from '@pipes/time-format.pipe';
import { EnvService, CharacterService, TimeTickService, RuntimeService } from '@services';

@Component({
selector: 'app-header',
standalone: true,
Expand Down
5 changes: 2 additions & 3 deletions src/app/layouts/sider/components/log/log.component.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { Component, ElementRef, inject, ViewChild, OnInit } from '@angular/core';
import { NzTimelineModule } from 'ng-zorro-antd/timeline';
import { NzTypographyModule } from 'ng-zorro-antd/typography';

import { LogTypeMap } from '@models';
import { LogService } from '@services';
import { NzTimelineModule } from 'ng-zorro-antd/timeline';
import { NzTypographyModule } from 'ng-zorro-antd/typography';

@Component({
selector: 'app-log',
Expand Down
5 changes: 2 additions & 3 deletions src/app/layouts/sider/components/task/task.component.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { Component, inject, OnInit } from '@angular/core';
import { Task, ItemMap } from '@models';
import { BackpackService, TaskService } from '@services';
import { NzButtonModule } from 'ng-zorro-antd/button';
import { NzEmptyModule } from 'ng-zorro-antd/empty';
import { NzTypographyModule } from 'ng-zorro-antd/typography';

import { Task, ItemMap } from '@models';
import { BackpackService, TaskService } from '@services';

@Component({
selector: 'app-task',
standalone: true,
Expand Down
7 changes: 3 additions & 4 deletions src/app/pages/challenge/challenge.component.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { Component, inject } from '@angular/core';
import { Router } from '@angular/router';
import { NzButtonModule } from 'ng-zorro-antd/button';
import { NzCardModule } from 'ng-zorro-antd/card';
import { NzTagModule } from 'ng-zorro-antd/tag';

import { RewardItemViewComponent } from '@components/reward-item-view/reward-item-view.component';
import { Challenge, RewardPoolMap } from '@models';
import { EnvService } from '@services';
import { NzButtonModule } from 'ng-zorro-antd/button';
import { NzCardModule } from 'ng-zorro-antd/card';
import { NzTagModule } from 'ng-zorro-antd/tag';

@Component({
selector: 'app-challenge',
Expand Down
5 changes: 2 additions & 3 deletions src/app/pages/home/components/backpack/backpack.component.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { Component, inject } from '@angular/core';
import { NzTabsModule } from 'ng-zorro-antd/tabs';
import { NzTypographyModule } from 'ng-zorro-antd/typography';

import { BagItemViewComponent } from '@components/bag-item-view/bag-item-view.component';
import { BagItem, ItemTypeMap, ItemTypeValueMap } from '@models';
import { BackpackService } from '@services';
import { NzTabsModule } from 'ng-zorro-antd/tabs';
import { NzTypographyModule } from 'ng-zorro-antd/typography';

@Component({
selector: 'app-backpack',
Expand Down
6 changes: 3 additions & 3 deletions src/app/pages/home/home.component.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Component, inject, OnInit } from '@angular/core';
import { LogType, LogLevel, BattleCharacter, CharacterEventOperate, EventType, EventRes } from '@models';
import { CharacterService, LogService, RuntimeService, BattleService, EnvService, BackpackService, EventService } from '@services';
import { Generate } from '@utils/generate';
import { NzButtonModule } from 'ng-zorro-antd/button';
import { NzDividerModule } from 'ng-zorro-antd/divider';
import { NzModalModule } from 'ng-zorro-antd/modal';
import { NzTypographyModule } from 'ng-zorro-antd/typography';

import { LogType, LogLevel, BattleCharacter, CharacterEventOperate, EventType, EventRes } from '@models';
import { Generate } from '@utils/generate';
import { BackpackComponent } from './components/backpack/backpack.component';
import { CharacterService, LogService, RuntimeService, BattleService, EnvService, BackpackService, EventService } from '@services';

@Component({
selector: 'app-home',
Expand Down
5 changes: 2 additions & 3 deletions src/app/pages/shop/shop.component.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { Component, inject, OnInit } from '@angular/core';
import { NzEmptyModule } from 'ng-zorro-antd/empty';
import { NzTypographyModule } from 'ng-zorro-antd/typography';

import { BagItemViewComponent } from '@components/bag-item-view/bag-item-view.component';
import { BagItem, ItemMap } from '@models';
import { TimeTickService } from '@services';
import { NzEmptyModule } from 'ng-zorro-antd/empty';
import { NzTypographyModule } from 'ng-zorro-antd/typography';

@Component({
selector: 'app-shop',
Expand Down
3 changes: 1 addition & 2 deletions src/app/pages/statistics/statistics.component.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { Component, inject } from '@angular/core';
import { StatisticsService } from '@storages/statistics.service';
import { NzDescriptionsModule } from 'ng-zorro-antd/descriptions';
import { NzTypographyModule } from 'ng-zorro-antd/typography';

import { StatisticsService } from '@storages/statistics.service';

@Component({
selector: 'app-statistics',
standalone: true,
Expand Down
1 change: 0 additions & 1 deletion src/app/pages/universe/universe.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Component, inject, OnInit } from '@angular/core';
import { Graph } from '@antv/g6';

import { EnvService } from '@services';

@Component({
Expand Down
1 change: 0 additions & 1 deletion src/app/services/backpack.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { inject, Injectable } from '@angular/core';

import {
Effect,
EffectType,
Expand Down
2 changes: 1 addition & 1 deletion src/app/services/battle.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { TestBed } from '@angular/core/testing';
import { NzModalService } from 'ng-zorro-antd/modal';

import { BattleService } from './battle.service';
import { NzModalService } from 'ng-zorro-antd/modal';

describe('BattleService', () => {
let service: BattleService;
Expand Down
2 changes: 1 addition & 1 deletion src/app/services/character.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { inject, Injectable } from '@angular/core';
import { delay, Observable, of } from 'rxjs';

import { BaseInfo, Character, LogLevel, LogType, SkillInfo, StatusInfo, LevelInfo, AttrInfo } from '../models';
import { CharacterEventOperate, Event, EventRes } from '../models/event.model';
Expand All @@ -7,7 +8,6 @@ import { EnvService } from './env.service';
import { LogService } from './log.service';
import { RuntimeService } from './runtime.service';
import { TimeTickService } from './time-tick.service';
import { delay, Observable, of } from 'rxjs';

@Injectable({
providedIn: 'root'
Expand Down
2 changes: 1 addition & 1 deletion src/app/services/event.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { inject, Injectable } from '@angular/core';
import { Observable, of, Subject } from 'rxjs';

import { Event, EventRes, EventType } from '../models/event.model';
import { BackpackService } from './backpack.service';
import { CharacterService } from './character.service';
import { TaskService } from './task.service';
import { BackpackService } from './backpack.service';

@Injectable({
providedIn: 'root'
Expand Down

1 comment on commit 91f64ef

@vercel
Copy link

@vercel vercel bot commented on 91f64ef Sep 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

wanjie – ./

wanjie.vercel.app
wanjie-git-main-encaiks-projects.vercel.app
wanjie-encaiks-projects.vercel.app

Please sign in to comment.