Migrate to TypeScript

This commit is contained in:
Pig Fang 2019-03-17 23:39:48 +08:00
parent 83c1806d2b
commit cfe419d41c
4 changed files with 26 additions and 13 deletions

View File

@ -153,7 +153,9 @@
"rules": {
"no-undef": 0,
"no-unused-vars": 0,
"no-invalid-this": 0
"no-invalid-this": 0,
"indent": 0,
"@typescript-eslint/indent": [2, 2, { "SwitchCase": 1 }]
}
}
]

View File

@ -1,7 +1,11 @@
import Vue from 'vue'
import toastr from 'toastr'
import { swal } from '../../js/notify'
export default {
export default Vue.extend<{
name: string,
tid: number
}, { addClosetItem(): Promise<void> }, {}>({
methods: {
async addClosetItem() {
const { dismiss, value } = await swal({
@ -10,7 +14,7 @@ export default {
inputValue: this.name,
input: 'text',
showCancelButton: true,
inputValidator: val => !val && this.$t('skinlib.emptyItemName'),
inputValidator: val => (!val && this.$t('skinlib.emptyItemName')) || null,
})
if (dismiss) {
return
@ -24,8 +28,8 @@ export default {
swal({ type: 'success', text: msg })
this.$emit('like-toggled', true)
} else {
toastr.warning(msg)
toastr.warning(msg!)
}
},
},
}
})

View File

@ -1,7 +1,11 @@
import Vue from 'vue'
import toastr from 'toastr'
import { swal } from '../../js/notify'
export default {
export default Vue.extend<{
name: string,
tid: number
}, { removeClosetItem(): Promise<void> }, {}>({
methods: {
async removeClosetItem() {
const { dismiss } = await swal({
@ -21,8 +25,8 @@ export default {
this.$emit('item-removed')
swal({ type: 'success', text: msg })
} else {
toastr.warning(msg)
toastr.warning(msg!)
}
},
},
}
})

View File

@ -1,7 +1,10 @@
import Vue from 'vue'
import toastr from 'toastr'
import { swal } from '../../js/notify'
export default {
export default Vue.extend<{
tid: number
}, { setAsAvatar(): Promise<void> }, {}>({
methods: {
async setAsAvatar() {
const { dismiss } = await swal({
@ -19,13 +22,13 @@ export default {
{ tid: this.tid }
)
if (errno === 0) {
toastr.success(msg)
toastr.success(msg!)
Array.from(document.querySelectorAll('[alt="User Image"]'))
Array.from(document.querySelectorAll<HTMLImageElement>('[alt="User Image"]'))
.forEach(el => (el.src += `?${new Date().getTime()}`))
} else {
toastr.warning(msg)
toastr.warning(msg!)
}
},
},
}
})