Skip to content

Commit

Permalink
Merge pull request #26 from HammCn/hamm
Browse files Browse the repository at this point in the history
release(v3.0.0): 发布了v3.0.0版本
  • Loading branch information
HammCn authored Nov 28, 2024
2 parents 2df39aa + e2eb5ae commit b6ec3dc
Show file tree
Hide file tree
Showing 71 changed files with 969 additions and 813 deletions.
4 changes: 2 additions & 2 deletions App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
</template>
<script lang="ts" setup>
import { onMounted, ref, watch } from 'vue'
import { AirConfig } from './config/AirConfig'
import { AirAlert } from './feedback/AirAlert'
import { AirStore } from './store/AirStore'
import { AirRouter } from './helper/AirRouter'
const isLoading = ref(true)
Expand All @@ -47,7 +47,7 @@ onMounted(() => {
})
const airpowerInit = () => {
if (!AirConfig.router) {
if (!AirRouter.router) {
AirAlert.error('请在main.ts中配置 AirConfig.router', '请先配置')
}
}
Expand Down
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
# AirPower4T 版本发布日志

## v3.0.1

### 🎉 Features:

### 🐞 Bug fixes:

## v3.0.0

### 🎉 Features:

- feat(Field): 提供了一个全新的 `@Field` 装饰器

### 🐞 Bug fixes:

- refactor(type): 将 ClassConstructor 类型迁移至 AirType
- refactor(component): 重构工具栏组件中的 API 地址处理逻辑
- refactor(Service): 重构成功提示逻辑
- docs(payload): 优化 Payload组件脚本标签属性顺序
- perf(component): 优化脱敏逻辑
- refactor(Dialog): 优化对话框组件的样式和功能
- refactor(ToolBar): 优化日期选择器的代码结构和配置
- refactor(Table): 优化 Table组件代码结构
- refactor(upload): 将 exts 属性重命名为 extensions
- refactor(selector): 重构选择器组件

## v2.4.3

### 🎉 Features:
Expand Down
42 changes: 18 additions & 24 deletions base/AirAbstractEntityService.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { AirAlert } from '../feedback/AirAlert'
import { AirNotification } from '../feedback/AirNotification'
import { AirClassTransformer } from '../helper/AirClassTransformer'
import { IValidateRule } from '../interface/IValidateRule'
import { AirValidator } from '../helper/AirValidator'
import { ClassConstructor } from '../type/ClassConstructor'
import { AirEntity } from '../base/AirEntity'
import { AirRequest } from '../model/AirRequest'
import { AirResponsePage } from '../model/AirResponsePage'
import { IJson } from '../interface/IJson'
import { AirAbstractService } from './AirAbstractService'
import { ClassConstructor } from '../type/AirType'
import AirEvent from '../event/AirEvent'
import { AirEventType } from '../event/AirEventType'

/**
* # 实体 `API` 服务超类
Expand Down Expand Up @@ -136,10 +136,9 @@ export abstract class AirAbstractEntityService<E extends AirEntity> extends AirA
async add(data: E, message?: string, title = '添加成功', apiUrl = this.urlForAdd): Promise<number> {
const json = await this.api(apiUrl)
.post(data)
if (message) {
AirNotification.success(message, title)
}
return AirClassTransformer.parse(json, this.entityClass).id
const saved = AirClassTransformer.parse(json, this.entityClass)
AirEvent.emit(AirEventType.ADD_SUCCESS, title, message, saved)
return saved.id
}

/**
Expand All @@ -152,9 +151,7 @@ export abstract class AirAbstractEntityService<E extends AirEntity> extends AirA
async update(data: E, message?: string, title = '修改成功', apiUrl = this.urlForUpdate): Promise<void> {
await this.api(apiUrl)
.post(data)
if (message) {
AirNotification.success(message, title)
}
AirEvent.emit(AirEventType.UPDATE_SUCCESS, title, message, data)
}

/**
Expand All @@ -181,15 +178,14 @@ export abstract class AirAbstractEntityService<E extends AirEntity> extends AirA
* @param apiUrl `可选` 自定义请求URL
*/
async delete(id: number, message?: string, title = '删除成功', apiUrl = this.urlForDelete): Promise<void> {
const instance = this.newEntityInstance(id)
try {
await this.api(apiUrl)
.callbackError()
.post(this.newEntityInstance(id))
if (message) {
AirNotification.success(message, title)
}
.post(instance)
AirEvent.emit(AirEventType.DELETE_SUCCESS, title, message, instance)
} catch (err) {
await AirAlert.error((err as Error).message, '删除失败')
AirEvent.emit(AirEventType.DELETE_FAIL, '删除失败', (err as Error).message, instance)
}
}

Expand All @@ -201,15 +197,14 @@ export abstract class AirAbstractEntityService<E extends AirEntity> extends AirA
* @param apiUrl `可选` 自定义请求URL
*/
async disable(id: number, message?: string, title = '禁用成功', apiUrl = this.urlForDisable): Promise<void> {
const instance = this.newEntityInstance(id)
try {
await this.api(apiUrl)
.callbackError()
.post(this.newEntityInstance(id))
if (message) {
AirNotification.success(message, title)
}
.post(instance)
AirEvent.emit(AirEventType.DISABLE_SUCCESS, title, message, instance)
} catch (err) {
await AirAlert.error((err as Error).message, '禁用失败')
AirEvent.emit(AirEventType.ENABLE_FAIL, '禁用失败', (err as Error).message, instance)
}
}

Expand All @@ -221,15 +216,14 @@ export abstract class AirAbstractEntityService<E extends AirEntity> extends AirA
* @param apiUrl `可选` 自定义请求URL
*/
async enable(id: number, message?: string, title = '启用成功', apiUrl = this.urlForEnable): Promise<void> {
const instance = this.newEntityInstance(id)
try {
await this.api(apiUrl)
.callbackError()
.post(this.newEntityInstance(id))
if (message) {
AirNotification.success(message, title)
}
AirEvent.emit(AirEventType.ENABLE_SUCCESS, title, message, instance)
} catch (err) {
await AirAlert.error((err as Error).message, '启用失败')
AirEvent.emit(AirEventType.ENABLE_FAIL, '启用失败', (err as Error).message, instance)
}
}

Expand Down
2 changes: 1 addition & 1 deletion base/AirAbstractService.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Ref } from 'vue'
import { AirHttp } from '../helper/AirHttp'
import { AirModel } from '../base/AirModel'
import { ClassConstructor } from '../type/ClassConstructor'
import { ClassConstructor } from '../type/AirType'

/**
* # `API` 服务超类
Expand Down
18 changes: 12 additions & 6 deletions base/AirEntity.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Dictionary, Field, Type } from '../decorator/Custom'
import { AirModel } from './AirModel'
import { Table } from '../decorator/TableField'
import { AirDisableDictionary } from '../model/AirDisableDictionary'
import { AirConstant } from '../config/AirConstant'
import { Field } from '../decorator/Field'

/**
* # 实体超类
Expand All @@ -12,22 +12,28 @@ export class AirEntity extends AirModel {
/**
* ## 主键 `ID`
*/
@Type(Number)
@Field('ID') id!: number
@Field({
label: 'ID',
type: Number,
})
id!: number

/**
* ## 是否禁用
*/
@Type(Boolean)
@Dictionary(AirDisableDictionary)
@Table({
showColor: true,
width: 80,
orderNumber: -100,
forceShow: true,
removed: true,
})
@Field('禁用') isDisabled!: boolean
@Field({
label: '是否禁用',
type: Boolean,
dictionary: AirDisableDictionary,
})
isDisabled!: boolean

/**
* ## 实例化一个实体
Expand Down
5 changes: 3 additions & 2 deletions base/AirEnum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import { AirConstant } from '../config/AirConstant'
import { AirColor } from '../enum/AirColor'
import { IDictionary } from '../interface/IDictionary'
import { AirDictionaryArray } from '../model/extend/AirDictionaryArray'
import { AirAny, AirColorString, AirEnumKey } from '../type/AirType'
import { ClassConstructor } from '../type/ClassConstructor'
import {
AirAny, AirColorString, AirEnumKey, ClassConstructor,
} from '../type/AirType'

/**
* # 枚举基类
Expand Down
Loading

0 comments on commit b6ec3dc

Please sign in to comment.