Skip to content

Commit cc0e198

Browse files
author
白唯
committed
feat(tsx): 增加 tsx 测试用例以及更新 ts 版本&相关依赖
去掉了 css 检查
1 parent 11e6644 commit cc0e198

30 files changed

+100
-81
lines changed

.eslintrc.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
module.exports = {
32
root: true,
43
parserOptions: {
@@ -20,7 +19,8 @@ module.exports = {
2019
'@typescript-eslint/class-name-casing': 'off',
2120
'vue/valid-v-slot': 'off',
2221
'no-debugger': 'off',
23-
'vue/experimental-script-setup-vars': 'off'
22+
'vue/experimental-script-setup-vars': 'off',
23+
'@typescript-eslint/explicit-module-boundary-types': 'off'
2424
},
2525
extends: [
2626
'plugin:vue/vue3-essential',

global.d.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { StateType } from '@types'
1+
import { StateType } from '@/@types'
22
import { Message } from 'ant-design-vue/types/message'
33
import { Router, RouteLocationNormalizedLoaded } from 'vue-router'
44
import { Store } from 'vuex'
@@ -13,6 +13,8 @@ declare module '@vue/runtime-core' {
1313
}
1414
}
1515

16+
declare module '*.tsx'
17+
1618
declare global {
1719
interface X {
1820
name: string

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
"pre-commit": "lint-staged"
8989
},
9090
"lint-staged": {
91-
"src/**/*.{jsx,txs,ts,js,json,less,vue,md}": [
91+
"src/**/*.{jsx,txs,ts,js,json,vue,md}": [
9292
"vue-cli-service lint"
9393
]
9494
},

src/api/team.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class TeamService {
8585

8686
// 批量删除团队成员
8787
static deleteMember(list: TeamMemberType[]): Promise<HttpResponse> {
88-
const path = list.map(item => item.id).join(',')
88+
const path = list.map((item) => item.id).join(',')
8989
console.log('deletepath', path)
9090
return Axios(`/bus/teamMember/${path}`, {
9191
method: 'delete'

src/api/user.ts

-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ class UserService {
103103
method: 'post',
104104
responseType: 'json',
105105
params: {
106-
// eslint-disable-next-line @typescript-eslint/camelcase
107106
grant_type: 'refresh_token',
108107
...params
109108
}

src/components/ChangeLanguage.vue

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<a-dropdown :trigger="['click']">
33
<a
44
class="ant-dropdown-link"
5-
@click="e => e.preventDefault()"
5+
@click="(e) => e.preventDefault()"
66
:style="{ color: titleColor, fontSize: titleSize }"
77
>
88
{{ i18n.languageName }}<DownOutlined
@@ -47,9 +47,9 @@ export default defineComponent({
4747
},
4848
setup() {
4949
const { i18n } = i18nInstance
50-
const changeLanguage = e => {
50+
const changeLanguage = (e) => {
5151
const lang = e.key
52-
setLang(lang).then(result => {
52+
setLang(lang).then((result) => {
5353
if (result === lang) {
5454
message.success(
5555
`${i18n.value['Current Language:']} ${i18n.value.languageName}`

src/components/Selector.vue

+4-19
Original file line numberDiff line numberDiff line change
@@ -75,21 +75,6 @@ import { BasicUserType, RoleType, StateType } from '@/@types'
7575
import { useStore } from 'vuex'
7676
import { message } from 'ant-design-vue'
7777
78-
interface ListItem {
79-
id: number
80-
name: string
81-
avatar: string
82-
}
83-
84-
interface State {
85-
optionsUp: boolean
86-
checkAll: boolean
87-
indeterminate: boolean
88-
inAdd: boolean
89-
inSearch: boolean
90-
keyword: string
91-
}
92-
9378
export default defineComponent({
9479
name: 'Selector',
9580
components: { CloseOutlined },
@@ -218,7 +203,7 @@ export default defineComponent({
218203
219204
// 搜索选项是否被选中
220205
const isChecked = (id: number) => {
221-
return state.selectedData.filter(item => item.userId == id).length !== 0
206+
return state.selectedData.filter((item) => item.userId == id).length !== 0
222207
}
223208
224209
/**
@@ -233,7 +218,7 @@ export default defineComponent({
233218
state.selectedData = [...state.selectedData, data]
234219
} else {
235220
state.selectedData = [...state.selectedData].filter(
236-
item => item.userId !== data.userId
221+
(item) => item.userId !== data.userId
237222
)
238223
}
239224
@@ -244,15 +229,15 @@ export default defineComponent({
244229
searchRef.value.focus()
245230
246231
const deleteList = rawList
247-
.map(item => {
232+
.map((item) => {
248233
if (!find(state.selectedData, ['userId', item.userId])) {
249234
return item
250235
}
251236
})
252237
.filter((item: any) => Boolean(item))
253238
254239
const addList = state.selectedData
255-
.map(item => {
240+
.map((item) => {
256241
if (!find(rawList, ['userId', item.userId])) {
257242
return item
258243
}

src/components/Slider.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<div class="operate">
1313
<div class="icon">
1414
<IconFont type="iconleft" @click="prev" />
15-
<IconFont type="iconright" @click="next" style="margin-left:120px" />
15+
<IconFont type="iconright" @click="next" style="margin-left: 120px" />
1616
</div>
1717
</div>
1818
</div>

src/components/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export function registeGlobalComponent(
1616
app: ReturnType<typeof createApp>
1717
): void {
1818
const files = require.context('./global', true, /\.(vue|ts)$/)
19-
files.keys().forEach(key => {
19+
files.keys().forEach((key) => {
2020
const config = files(key)
2121
const name = kebabCase(key.replace(/^\.\//, '').replace(/\.\w+$/, ''))
2222
app.component(name, config.default || config)

src/i18n/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function loadAtdLocales() {
5353
true,
5454
/\.js$/
5555
)
56-
files.keys().forEach(key => {
56+
files.keys().forEach((key) => {
5757
const fileName = key.slice(2, key.lastIndexOf('.'))
5858
if (includes(TranslateTable, fileName)) {
5959
const localeKey = findKeyByValue(TranslateTable, fileName)

src/layout/AppLayout.vue

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<app-header />
66
<div id="nav">
77
<router-link to="/">Home</router-link> |
8+
<router-link to="/tsxtest">tsx页面</router-link> |
89
<router-link to="/about">About</router-link> |
910
<router-link to="/contact">Contact</router-link> |
1011
<router-link to="/tests">组件测试</router-link>

src/main.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,4 @@ loadAllPlugins(app)
2121
/** 自动注册全局组件 */
2222
registeGlobalComponent(app)
2323

24-
app
25-
.use(store)
26-
.use(router)
27-
.mount('#app')
24+
app.use(store).use(router).mount('#app')

src/plugins/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { createApp } from 'vue'
66
*/
77
export function loadAllPlugins(app: ReturnType<typeof createApp>) {
88
const files = require.context('.', true, /\.ts$/)
9-
files.keys().forEach(key => {
9+
files.keys().forEach((key) => {
1010
if (typeof files(key).default === 'function') {
1111
if (key !== './index.ts') files(key).default(app)
1212
}

src/router/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Home from '../views/Home.vue'
44
/** 自动加载其他路由模块 */
55
const files = require.context('.', true, /\.ts$/)
66
const modules: Array<RouteRecordRaw> = []
7-
files.keys().forEach(key => {
7+
files.keys().forEach((key) => {
88
if (key === './index.ts') return
99
modules.push(files(key).default)
1010
})

src/router/tsx.ts

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { RouteRecordRaw } from 'vue-router'
2+
3+
/** 关于我们页面的路由配置 */
4+
const AboutRouter: RouteRecordRaw = {
5+
path: '/tsxtest',
6+
name: 'tsxtest',
7+
component: () =>
8+
import(/* webpackChunkName: "tsxtest" */ '@/views/TsxPage.tsx')
9+
}
10+
11+
export default AboutRouter

src/shims-vue.d.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
declare module '*.vue' {
22
import { DefineComponent } from 'vue'
3-
const component: DefineComponent<{}, {}, unknown>
3+
const component: DefineComponent<
4+
Record<string, unknown>,
5+
Record<string, unknown>,
6+
unknown
7+
>
48
export default component
59
}
10+
11+
declare module '*.tsx'
12+
declare module '*.less'

src/store/modules/console/getters.ts

+8-6
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ const consoleGetter = {
55
// 获取云角色列表
66
getTeamClouldList() {
77
// 获取用户列表以及云角色列表
8-
const memberList = store.state.console.selectedTeamMemberList.map(item => {
9-
let cloudRoleList: number[] = []
10-
if (item.cloudRole) {
11-
cloudRoleList = item.cloudRole.split(',').map(id => Number(id))
8+
const memberList = store.state.console.selectedTeamMemberList.map(
9+
(item) => {
10+
let cloudRoleList: number[] = []
11+
if (item.cloudRole) {
12+
cloudRoleList = item.cloudRole.split(',').map((id) => Number(id))
13+
}
14+
return { ...item, cloudRoleList: cloudRoleList }
1215
}
13-
return { ...item, cloudRoleList: cloudRoleList }
14-
})
16+
)
1517

1618
const cloudRoleList = [...store.state.console.selectedTeamCloudRoleList]
1719

src/store/modules/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
const files = require.context('.', true, /\.ts$/)
44
const modules: any = {}
55

6-
files.keys().forEach(key => {
6+
files.keys().forEach((key) => {
77
if (key === './index.ts') return
88
const path = key.replace(/(\.\/|\.ts)/g, '')
99
const [namespace, imported] = path.split('/')

src/store/modules/user/actions.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@ const userActions = {
1010
// 刷新令牌
1111
refreshToken() {
1212
return UserService.refreshToken({
13-
// eslint-disable-next-line @typescript-eslint/camelcase
13+
// eslint-disable-next-line
1414
refresh_token: Store.state.user.token.refresh_token
15-
}).then(res => {
15+
}).then((res) => {
1616
// token过期时间
1717
const expireTime = res.data.expires_in * 1000 + new Date().getTime()
1818
setStoreState('user', 'token', { ...res.data, expireTime })
1919
})
2020
},
2121
// 获取用户信息
2222
getUserDetail() {
23-
return UserService.getUserDetail().then(res => {
23+
return UserService.getUserDetail().then((res) => {
2424
setStoreState('user', 'userDetail', res.data.data)
2525
})
2626
}

src/store/utils.ts

-6
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
import store from '@/store'
2-
import { AppStateType } from './modules/app/state'
3-
import { ConsoleStateType } from './modules/console/state'
4-
import { UserStateType } from './modules/user/state'
52

63
// 定义 state 下的 module 值
74
type ModuleNameType = 'app' | 'console' | 'user'
85

9-
// 定义 module 下的 key 值
10-
type CommitNameType = AppStateType & ConsoleStateType & UserStateType
11-
126
/**
137
* @description setStoreState -方法是一个 mutaitions 的操作
148
* @type {T} T - 你要更改的模块的类型

src/utils/common.ts

+4-7
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export function loadScript(url: string) {
7373
script.type = 'text/javascript'
7474
if (script.readyState) {
7575
//IE
76-
script.onreadystatechange = function() {
76+
script.onreadystatechange = function () {
7777
if (
7878
script.readyState == 'loaded' ||
7979
script.readyState == 'complete'
@@ -84,7 +84,7 @@ export function loadScript(url: string) {
8484
}
8585
} else {
8686
//Others: Firefox, Safari, Chrome, and Opera
87-
script.onload = function() {
87+
script.onload = function () {
8888
Promise.resolve(0)
8989
}
9090
}
@@ -351,7 +351,7 @@ export const isIphonex = () => {
351351
const { devicePixelRatio, screen } = window
352352
const { width, height } = screen
353353
return xSeriesConfig.some(
354-
item =>
354+
(item) =>
355355
item.devicePixelRatio === devicePixelRatio &&
356356
item.width === width &&
357357
item.height === height
@@ -522,10 +522,7 @@ export function createPassword(len: number) {
522522
'Z'
523523
]
524524
var special = ['-', '_', '#']
525-
var config = num
526-
.concat(english)
527-
.concat(ENGLISH)
528-
.concat(special)
525+
var config = num.concat(english).concat(ENGLISH).concat(special)
529526

530527
//先放入一个必须存在的
531528
var arr = []

src/utils/hooks/modal.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
export default function() {
1+
export default function () {
22
console.log('hahah')
33
}

src/views/About.vue

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<template>
2-
<div ref="root" class="about">
3-
about.page
4-
</div>
2+
<div ref="root" class="about">about.page</div>
53
</template>
64

75
<script lang="ts">

src/views/AboutMe.vue

+2-4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<script lang="ts">
88
import { defineComponent, ref, onMounted } from 'vue'
99
10+
// 混合 Compostion API 和 Options API 写法,不推荐在生产环境这样做
1011
const AboutMe = defineComponent({
1112
setup() {
1213
onMounted(() => {
@@ -25,10 +26,7 @@ const AboutMe = defineComponent({
2526
},
2627
methods: {
2728
caculatePageName(): string {
28-
return this.book.pageName
29-
.split('-')
30-
.reverse()
31-
.join()
29+
return this.book.pageName.split('-').reverse().join()
3230
}
3331
}
3432
})

src/views/Contact.vue

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<template>
2-
<div>
3-
contact.page
4-
</div>
2+
<div>contact.page</div>
53
</template>
64

75
<script lang="ts">

src/views/Home.vue

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<template>
2-
<div>
3-
home.page
4-
</div>
2+
<div>home.page</div>
53
</template>
64
<script lang="ts">
75
import { defineComponent } from 'vue'

0 commit comments

Comments
 (0)