perf: 代码优化 所有的 interface 类型命名

This commit is contained in:
pany
2023-05-21 09:51:41 +08:00
parent 6cca254335
commit 05712f4adc
19 changed files with 61 additions and 61 deletions

View File

@@ -3,29 +3,29 @@ import { ref, onMounted } from "vue"
type OptionValueType = string | number
/** Select 需要的数据格式 */
interface ISelectOption {
interface SelectOption {
value: OptionValueType
label: string
disabled?: boolean
}
/** 接口响应格式 */
interface IApiData {
interface ApiData {
code: number
data: ISelectOption[]
data: SelectOption[]
message: string
}
/** 入参格式,暂时只需要传递 api 函数即可 */
interface IFetchSelectProps {
api: () => Promise<IApiData>
interface FetchSelectProps {
api: () => Promise<ApiData>
}
export function useFetchSelect(props: IFetchSelectProps) {
export function useFetchSelect(props: FetchSelectProps) {
const { api } = props
const loading = ref<boolean>(false)
const options = ref<ISelectOption[]>([])
const options = ref<SelectOption[]>([])
const value = ref<OptionValueType>("")
/** 调用接口获取数据 */

View File

@@ -5,11 +5,11 @@ const defaultOptions = {
text: "加载中..."
}
interface ILoadingInstance {
interface LoadingInstance {
close: () => void
}
interface IUseFullscreenLoading {
interface UseFullscreenLoading {
<T extends (...args: any[]) => ReturnType<T>>(fn: T, options?: LoadingOptions): (
...args: Parameters<T>
) => Promise<ReturnType<T>> | ReturnType<T>
@@ -25,8 +25,8 @@ interface IUseFullscreenLoading {
* @param options LoadingOptions
* @returns Function 一个新的函数,去执行它吧
*/
export const useFullscreenLoading: IUseFullscreenLoading = (fn, options = {}) => {
let loadingInstance: ILoadingInstance
export const useFullscreenLoading: UseFullscreenLoading = (fn, options = {}) => {
let loadingInstance: LoadingInstance
const showLoading = (options: LoadingOptions) => {
loadingInstance = ElLoading.service(options)
}

View File

@@ -1,6 +1,6 @@
import { reactive } from "vue"
interface IDefaultPaginationData {
interface DefaultPaginationData {
total: number
currentPage: number
pageSizes: number[]
@@ -8,7 +8,7 @@ interface IDefaultPaginationData {
layout: string
}
interface IPaginationData {
interface PaginationData {
total?: number
currentPage?: number
pageSizes?: number[]
@@ -17,7 +17,7 @@ interface IPaginationData {
}
/** 默认的分页参数 */
const defaultPaginationData: IDefaultPaginationData = {
const defaultPaginationData: DefaultPaginationData = {
total: 0,
currentPage: 1,
pageSizes: [10, 20, 50],
@@ -25,7 +25,7 @@ const defaultPaginationData: IDefaultPaginationData = {
layout: "total, sizes, prev, pager, next, jumper"
}
export function usePagination(initialPaginationData: IPaginationData = {}) {
export function usePagination(initialPaginationData: PaginationData = {}) {
/** 合并分页参数 */
const paginationData = reactive({ ...defaultPaginationData, ...initialPaginationData })
/** 改变当前页码 */

View File

@@ -7,13 +7,13 @@ type DefaultThemeNameType = typeof DEFAULT_THEME_NAME
/** 注册的主题名称, 其中 DefaultThemeNameType 是必填的 */
export type ThemeName = DefaultThemeNameType | "dark" | "dark-blue"
interface IThemeList {
interface ThemeList {
title: string
name: ThemeName
}
/** 主题列表 */
const themeList: IThemeList[] = [
const themeList: ThemeList[] = [
{
title: "默认",
name: DEFAULT_THEME_NAME