Skip to content

Commit

Permalink
refactor: 优化 queryForm 的 Query 类型使用
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles7c committed May 2, 2024
1 parent 05ab89d commit 5b71369
Show file tree
Hide file tree
Showing 22 changed files with 82 additions and 96 deletions.
2 changes: 1 addition & 1 deletion src/apis/monitor/online.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type * as Monitor from './type'
const BASE_URL = '/monitor/online'

/** @desc 查询在线用户列表 */
export function listOnlineUser(query: Monitor.OnlineUserQuery) {
export function listOnlineUser(query: Monitor.OnlineUserPageQuery) {
return http.get<PageRes<Monitor.OnlineUserResp[]>>(`${BASE_URL}`, query)
}

Expand Down
6 changes: 4 additions & 2 deletions src/apis/monitor/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ export interface OnlineUserResp {
createUserString: string
createTime: string
}
export interface OnlineUserQuery extends PageQuery {
export interface OnlineUserQuery {
nickname?: string
loginTime?: string
sort: Array<string>
}
export interface OnlineUserPageQuery extends OnlineUserQuery, PageQuery {}

/** 系统日志类型 */
export interface LogResp {
Expand Down Expand Up @@ -52,4 +54,4 @@ export interface LogQuery {
status?: number
sort: Array<string>
}
export interface LogPageQuery extends PageQuery, LogQuery {}
export interface LogPageQuery extends LogQuery, PageQuery {}
4 changes: 2 additions & 2 deletions src/apis/system/dict.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type * as System from './type'
const BASE_URL = '/system/dict'

/** @desc 查询字典列表 */
export function listDict(query: System.DictQuery) {
export function listDict(query: System.DictPageQuery) {
return http.get<PageRes<System.DictResp[]>>(`${BASE_URL}`, query)
}

Expand All @@ -29,7 +29,7 @@ export function deleteDict(id: string) {
}

/** @desc 查询字典项列表 */
export function listDictItem(query: System.DictItemQuery) {
export function listDictItem(query: System.DictItemPageQuery) {
return http.get<PageRes<System.DictItemResp[]>>(`${BASE_URL}/item`, query)
}

Expand Down
2 changes: 1 addition & 1 deletion src/apis/system/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type * as System from './type'
const BASE_URL = '/system/file'

/** @desc 查询文件列表 */
export function listFile(query: System.FileQuery) {
export function listFile(query: System.FilePageQuery) {
return http.get<PageRes<System.FileItem[]>>(`${BASE_URL}`, query)
}

Expand Down
2 changes: 1 addition & 1 deletion src/apis/system/notice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type * as System from './type'
const BASE_URL = '/system/notice'

/** @desc 查询公告列表 */
export function listNotice(query: System.NoticeQuery) {
export function listNotice(query: System.NoticePageQuery) {
return http.get<PageRes<System.NoticeResp[]>>(`${BASE_URL}`, query)
}

Expand Down
2 changes: 1 addition & 1 deletion src/apis/system/role.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type * as System from './type'
const BASE_URL = '/system/role'

/** @desc 查询角色列表 */
export function listRole(query: System.RoleQuery) {
export function listRole(query: System.RolePageQuery) {
return http.get<PageRes<System.RoleResp[]>>(`${BASE_URL}`, query)
}

Expand Down
2 changes: 1 addition & 1 deletion src/apis/system/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type * as System from './type'
const BASE_URL = '/system/storage'

/** @desc 查询存储列表 */
export function listStorage(query: System.StorageQuery) {
export function listStorage(query: System.StoragePageQuery) {
return http.get<PageRes<System.StorageResp[]>>(`${BASE_URL}`, query)
}

Expand Down
72 changes: 41 additions & 31 deletions src/apis/system/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export interface UserQuery {
deptId?: string
sort: Array<string>
}
export interface UserPageQuery extends PageQuery, UserQuery {}
export interface UserPageQuery extends UserQuery, PageQuery {}

/** 系统角色类型 */
export interface RoleResp {
Expand Down Expand Up @@ -62,9 +62,11 @@ export interface RoleDetailResp {
updateTime: string
disabled: boolean
}
export interface RoleQuery extends PageQuery {
export interface RoleQuery {
description?: string
sort: Array<string>
}
export interface RolePageQuery extends RoleQuery, PageQuery {}

/** 系统菜单类型 */
export interface MenuResp {
Expand Down Expand Up @@ -116,25 +118,6 @@ export interface DeptQuery {
sort: Array<string>
}

/** 系统公告类型 */
export interface NoticeResp {
id: string
title: string
content: string
status: number
type: string
effectiveTime: string
terminateTime: string
createUserString: string
createTime: string
updateUserString: string
updateTime: string
}
export interface NoticeQuery extends PageQuery {
title?: string
type?: string
}

/** 系统字典类型 */
export interface DictResp {
id: string
Expand All @@ -147,9 +130,11 @@ export interface DictResp {
updateUserString: string
updateTime: string
}
export interface DictQuery extends PageQuery {
export interface DictQuery {
description?: string
sort: Array<string>
}
export interface DictPageQuery extends DictQuery, PageQuery {}
export type DictItemResp = {
id: string
label: string
Expand All @@ -164,11 +149,34 @@ export type DictItemResp = {
updateUserString: string
updateTime: string
}
export interface DictItemQuery extends PageQuery {
export interface DictItemQuery {
description?: string
status?: number
sort: Array<string>
dictId: string
}
export interface DictItemPageQuery extends DictItemQuery, PageQuery {}

/** 系统公告类型 */
export interface NoticeResp {
id: string
title: string
content: string
status: number
type: string
effectiveTime: string
terminateTime: string
createUserString: string
createTime: string
updateUserString: string
updateTime: string
}
export interface NoticeQuery {
title?: string
type?: string
sort: Array<string>
}
export interface NoticePageQuery extends NoticeQuery, PageQuery {}

/** 系统文件类型 */
export type FileItem = {
Expand All @@ -184,18 +192,19 @@ export type FileItem = {
updateUserString: string
updateTime: string
}
export interface FileQuery extends PageQuery {
name?: string
type?: string
}
/** 文件资源统计 */
/** 文件资源统计信息 */
export interface FileStatisticsResp {
type: string
size: number
formattedSize: string
number: number
data: Array<FileStatisticsResp>
}
export interface FileQuery {
name?: string
type?: string
sort: Array<string>
}
export interface FilePageQuery extends FileQuery, PageQuery {}

/** 系统存储类型 */
export type StorageResp = {
Expand All @@ -217,10 +226,12 @@ export type StorageResp = {
updateUserString: string
updateTime: string
}
export interface StorageQuery extends PageQuery {
export interface StorageQuery {
description?: string
status?: number
sort: Array<string>
}
export interface StoragePageQuery extends StorageQuery, PageQuery {}

/** 系统参数类型 */
export interface OptionResp {
Expand All @@ -232,7 +243,6 @@ export interface OptionResp {
export interface OptionQuery {
code: Array<string>
}

/** 基础配置类型 */
export interface BasicConfigResp {
site_favicon: string
Expand Down
1 change: 0 additions & 1 deletion src/types/api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,4 @@ interface PageRes<T> {
interface PageQuery {
page: number
size: number
sort: Array<string>
}
10 changes: 5 additions & 5 deletions src/views/login/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,11 @@ const onOauth = async (source: string) => {
&-logo {
width: 100%;
height: 104px;
font-weight: 700;
font-size: 20px;
line-height: 32px;
display: flex;
padding: 0px 20px;
padding: 0 20px;
align-items: center;
justify-content: start;
background-image: url('/src/assets/images/login_h5.jpg');
Expand Down Expand Up @@ -175,10 +178,7 @@ const onOauth = async (source: string) => {
}
:deep(.arco-tabs-tab) {
color: var(--color-text-2);
margin-right: 20px;
margin-top: 0px;
margin-left: 0px;
margin-bottom: 0px;
margin: 0 20px 0 0;
}
:deep(.arco-tabs-tab-title) {
font-size: 16px;
Expand Down
7 changes: 2 additions & 5 deletions src/views/monitor/log/login/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
</template>

<script setup lang="ts">
import { exportLoginLog, listLog } from '@/apis'
import { exportLoginLog, listLog, type LogQuery } from '@/apis'
import type { TableInstanceColumns } from '@/components/GiTable/type'
import DateRangePicker from '@/components/DateRangePicker/index.vue'
import { useTable, useDownload } from '@/hooks'
Expand Down Expand Up @@ -90,15 +90,12 @@ const columns: TableInstanceColumns[] = [
{ title: '终端系统', dataIndex: 'os', ellipsis: true, tooltip: true }
]
const queryForm = reactive({
const queryForm = reactive<LogQuery>({
module: '登录',
ip: undefined,
createUserString: undefined,
createTime: [
dayjs().subtract(6, 'day').startOf('day').format('YYYY-MM-DD HH:mm:ss'),
dayjs().endOf('day').format('YYYY-MM-DD HH:mm:ss')
],
status: undefined,
sort: ['createTime,desc']
})
Expand Down
8 changes: 2 additions & 6 deletions src/views/monitor/log/operation/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
</template>

<script setup lang="ts">
import { listLog, exportOperationLog, type LogResp } from '@/apis'
import { listLog, exportOperationLog, type LogResp, type LogQuery } from '@/apis'
import OperationLogDetailDrawer from './OperationLogDetailDrawer.vue'
import type { TableInstanceColumns } from '@/components/GiTable/type'
import DateRangePicker from '@/components/DateRangePicker/index.vue'
Expand Down Expand Up @@ -102,15 +102,11 @@ const columns: TableInstanceColumns[] = [
{ title: '终端系统', dataIndex: 'os', ellipsis: true, tooltip: true }
]
const queryForm = reactive({
description: undefined,
ip: undefined,
createUserString: undefined,
const queryForm = reactive<LogQuery>({
createTime: [
dayjs().subtract(6, 'day').startOf('day').format('YYYY-MM-DD HH:mm:ss'),
dayjs().endOf('day').format('YYYY-MM-DD HH:mm:ss')
],
status: undefined,
sort: ['createTime,desc']
})
Expand Down
6 changes: 2 additions & 4 deletions src/views/monitor/online/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
</template>

<script setup lang="ts">
import { listOnlineUser, kickout } from '@/apis'
import { listOnlineUser, kickout, type OnlineUserQuery } from '@/apis'
import { Message } from '@arco-design/web-vue'
import type { TableInstanceColumns } from '@/components/GiTable/type'
import DateRangePicker from '@/components/DateRangePicker/index.vue'
Expand Down Expand Up @@ -79,9 +79,7 @@ const columns: TableInstanceColumns[] = [
}
]
const queryForm = reactive({
nickname: undefined,
loginTime: undefined,
const queryForm = reactive<OnlineUserQuery>({
sort: ['createTime,desc']
})
Expand Down
4 changes: 1 addition & 3 deletions src/views/system/dept/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,7 @@ const columns: TableInstanceColumns[] = [
}
]
const queryForm = reactive({
description: undefined,
status: undefined,
const queryForm = reactive<DeptQuery>({
sort: ['parentId,asc', 'sort,asc', 'createTime,desc']
})
Expand Down
5 changes: 2 additions & 3 deletions src/views/system/dict/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
</template>

<script setup lang="ts">
import { listDict, deleteDict, type DictResp } from '@/apis'
import { listDict, deleteDict, type DictResp, type DictQuery } from '@/apis'
import DictAddModal from './DictAddModal.vue'
import DictItemModal from '@/views/system/dict/item/index.vue'
import type { TableInstanceColumns } from '@/components/GiTable/type'
Expand Down Expand Up @@ -87,8 +87,7 @@ const columns: TableInstanceColumns[] = [
}
]
const queryForm = reactive({
description: undefined,
const queryForm = reactive<DictQuery>({
sort: ['createTime,desc']
})
Expand Down
6 changes: 2 additions & 4 deletions src/views/system/dict/item/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
</template>

<script lang="ts" setup>
import { listDictItem, deleteDictItem, type DictItemResp } from '@/apis'
import { listDictItem, deleteDictItem, type DictItemResp, type DictItemQuery } from '@/apis'
import DictItemAddModal from './DictItemAddModal.vue'
import type { TableInstanceColumns } from '@/components/GiTable/type'
import { useTable } from '@/hooks'
Expand Down Expand Up @@ -97,9 +97,7 @@ const columns: TableInstanceColumns[] = [
{ title: '操作', slotName: 'action', width: 130, align: 'center', fixed: !isMobile() ? 'right' : undefined }
]
const queryForm = reactive({
description: undefined,
status: undefined,
const queryForm = reactive<DictItemQuery>({
sort: ['createTime,desc']
})
Expand Down
Loading

0 comments on commit 5b71369

Please sign in to comment.