Skip to content

Commit

Permalink
feat(projects): 重构项目的TS类型架构,去除interface文件夹
Browse files Browse the repository at this point in the history
  • Loading branch information
honghuangdc committed Mar 12, 2022
1 parent 75de2b0 commit 8191490
Show file tree
Hide file tree
Showing 58 changed files with 400 additions and 461 deletions.
7 changes: 7 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ module.exports = {
ignores: ['index'],
},
],

'@typescript-eslint/ban-types': [
'error',
{
Expand All @@ -182,6 +183,12 @@ module.exports = {
},
},
],
'@typescript-eslint/no-empty-interface': [
'error',
{
allowSingleExtends: true,
},
],
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-shadow': 'error',
'@typescript-eslint/no-unused-vars': ['warn', { ignoreRestSiblings: true, varsIgnorePattern: '^_' }],
Expand Down
3 changes: 1 addition & 2 deletions src/composables/common/layout.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { computed } from 'vue';
import { useAppStore, useThemeStore } from '@/store';
import type { ThemeLayoutMode, GlobalHeaderProps } from '@/interface';

type LayoutHeaderProps = Record<ThemeLayoutMode, GlobalHeaderProps>;
type LayoutHeaderProps = Record<EnumType.ThemeLayoutMode, GlobalHeaderProps>;

export function useBasicLayout() {
const app = useAppStore();
Expand Down
7 changes: 3 additions & 4 deletions src/composables/common/router.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { useRouter } from 'vue-router';
import type { RouteLocationRaw } from 'vue-router';
import { router as globalRouter, routeName } from '@/router';
import type { LoginModuleKey } from '@/interface';

/**
* 路由跳转
Expand Down Expand Up @@ -43,8 +42,8 @@ export function useRouterPush(inSetup = true) {
* @param loginModule - 展示的登录模块
* @param redirectUrl - 重定向地址(登录成功后跳转的地址),默认undefined表示取当前地址为重定向地址
*/
function toLogin(loginModule?: LoginModuleKey, redirectUrl?: string) {
const module: LoginModuleKey = loginModule || 'pwd-login';
function toLogin(loginModule?: EnumType.LoginModuleKey, redirectUrl?: string) {
const module: EnumType.LoginModuleKey = loginModule || 'pwd-login';
const routeLocation: RouteLocationRaw = {
name: routeName('login'),
params: { module },
Expand All @@ -58,7 +57,7 @@ export function useRouterPush(inSetup = true) {
* 登录页切换其他模块
* @param module - 切换后的登录模块
*/
function toLoginModule(module: LoginModuleKey) {
function toLoginModule(module: EnumType.LoginModuleKey) {
const { query } = route.value;
routerPush({ name: routeName('login'), params: { module }, query });
}
Expand Down
6 changes: 0 additions & 6 deletions src/enum/common/system.ts → src/enum/business.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
/** 布局组件的名称 */
export enum EnumLayoutComponentName {
basic = 'basic-layout',
blank = 'blank-layout',
}

/** 登录模块 */
export enum EnumLoginModule {
'pwd-login' = '账密登录',
Expand Down
1 change: 0 additions & 1 deletion src/enum/business/index.ts

This file was deleted.

35 changes: 35 additions & 0 deletions src/enum/common.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/** http请求头的content-type类型 */
export enum EnumContentType {
json = 'application/json',
formUrlencoded = 'application/x-www-form-urlencoded',
formData = 'multipart/form-data',
}

/** 缓存的key */
export enum EnumStorageKey {
/** 主题颜色 */
'theme-color' = '__THEME_COLOR__',
/** 用户token */
'token' = '__TOKEN__',
/** 用户刷新token */
'refresh-koken' = '__REFRESH_TOKEN__',
/** 用户信息 */
'user-info' = '__USER_INFO__',
/** 多页签路由信息 */
'tab-routes' = '__TAB_ROUTES__',
}

/** 数据类型 */
export enum EnumDataType {
number = '[object Number]',
string = '[object String]',
boolean = '[object Boolean]',
null = '[object Null]',
undefined = '[object Undefined]',
object = '[object Object]',
array = '[object Array]',
date = '[object Date]',
regexp = '[object RegExp]',
set = '[object Set]',
map = '[object Map]',
}
5 changes: 0 additions & 5 deletions src/enum/common/index.ts

This file was deleted.

6 changes: 0 additions & 6 deletions src/enum/common/service.ts

This file was deleted.

12 changes: 0 additions & 12 deletions src/enum/common/storage.ts

This file was deleted.

14 changes: 0 additions & 14 deletions src/enum/common/typeof.ts

This file was deleted.

2 changes: 2 additions & 0 deletions src/enum/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export * from './common';
export * from './system';
export * from './business';
6 changes: 6 additions & 0 deletions src/enum/common/theme.ts → src/enum/system.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/** 布局组件的名称 */
export enum EnumLayoutComponentName {
basic = 'basic-layout',
blank = 'blank-layout',
}

/** 布局模式 */
export enum EnumThemeLayoutMode {
'vertical' = '左侧菜单模式',
Expand Down
26 changes: 0 additions & 26 deletions src/interface/enum.ts

This file was deleted.

5 changes: 0 additions & 5 deletions src/interface/expose.ts

This file was deleted.

5 changes: 0 additions & 5 deletions src/interface/index.ts

This file was deleted.

9 changes: 0 additions & 9 deletions src/interface/layout.ts

This file was deleted.

35 changes: 0 additions & 35 deletions src/interface/system.ts

This file was deleted.

150 changes: 0 additions & 150 deletions src/interface/theme.ts

This file was deleted.

Loading

0 comments on commit 8191490

Please sign in to comment.