axios泛型修改
This commit is contained in:
@@ -71,7 +71,6 @@ import { Options, Vue } from 'vue-class-component'
|
||||
import BaseList from '../../model/baselist'
|
||||
import { Page } from '../../model/common.dto'
|
||||
import HitokotoModel from '../../model/api/hitokoto'
|
||||
import { AxiosResponse } from 'axios'
|
||||
import { ElButton, ElForm, ElFormItem, ElInput, ElTable, ElTableColumn, ElPagination, ElDialog, ElSelect, ElOption, ElDatePicker, ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { VForm } from '../../types'
|
||||
|
||||
@@ -89,7 +88,7 @@ export default class Hitokoto extends BaseList<HitokotoPage> {
|
||||
|
||||
async loadData() {
|
||||
this.loading = true
|
||||
const { data } = await this.$http.get<HitokotoPage, AxiosResponse<any>>('/api/hitokoto/list', {params:this.search})
|
||||
const data = await this.$http.get<HitokotoPage, any>('/api/hitokoto/list', {params:this.search})
|
||||
selectedData = []
|
||||
this.loading = false
|
||||
this.total = data.total
|
||||
@@ -99,7 +98,7 @@ export default class Hitokoto extends BaseList<HitokotoPage> {
|
||||
((this.$refs.addForm as Vue).$refs.hitokotoForm as VForm).validate(async (valid: boolean) => {
|
||||
if(!valid) return
|
||||
this.modalLoading = true
|
||||
const { data } = await this.$http.post<any, AxiosResponse<any>>('/api/hitokoto/save', this.formData)
|
||||
const data = await this.$http.post<any, any>('/api/hitokoto/save', this.formData)
|
||||
this.modalLoading = false
|
||||
this.addModal = false
|
||||
ElMessage.success(data.message)
|
||||
@@ -114,7 +113,7 @@ export default class Hitokoto extends BaseList<HitokotoPage> {
|
||||
return
|
||||
}
|
||||
ElMessageBox.confirm(`是否确认删除选中的${selectedData.length}条数据?`, '确认删除', {type: 'warning'}).then(async () => {
|
||||
const { data } = await this.$http.delete<any, AxiosResponse<any>>('/api/hitokoto/delete', {params:{_ids: selectedData}})
|
||||
const data = await this.$http.delete<any, any>('/api/hitokoto/delete', {params:{_ids: selectedData}})
|
||||
ElMessage.success(data.message)
|
||||
this.loadData()
|
||||
}).catch(() => {})
|
||||
@@ -124,7 +123,7 @@ export default class Hitokoto extends BaseList<HitokotoPage> {
|
||||
}
|
||||
created() {
|
||||
this.loadData()
|
||||
this.$http.get('/api/common/config/hitokoto_type').then(({data}) => {
|
||||
this.$http.get<never, any>('/api/common/config/hitokoto_type').then(data => {
|
||||
this.typeList = data
|
||||
})
|
||||
}
|
||||
|
||||
+13
-14
@@ -115,8 +115,7 @@
|
||||
import { Options } from 'vue-class-component'
|
||||
import BaseList from '../../model/baselist'
|
||||
import { Page } from '../../model/common.dto'
|
||||
import { AxiosResponse } from 'axios'
|
||||
import { ElButton, ElForm, ElFormItem, ElInput, ElTable, ElTableColumn, ElPagination, ElDialog, ElSelect, ElOption, ElRadioGroup, ElRadio, ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { ElButton, ElForm, ElFormItem, ElInput, ElTable, ElTableColumn, ElPagination, ElDialog, ElSelect, ElOption, ElRadioGroup, ElRadio, ElDrawer, ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { MusicModel, MusicLibModel, MusicLyricModel, MusicPlayerItem } from '../../model/api/music'
|
||||
import prettyBytes from 'pretty-bytes'
|
||||
import { VForm } from '../../types'
|
||||
@@ -124,7 +123,7 @@ import { VForm } from '../../types'
|
||||
let selectedIds: string[] = []
|
||||
@Options({
|
||||
name: 'Music',
|
||||
components: { ElButton, ElForm, ElFormItem, ElInput, ElTable, ElTableColumn, ElPagination, ElDialog, ElSelect, ElOption, ElRadioGroup, ElRadio }
|
||||
components: { ElButton, ElForm, ElFormItem, ElInput, ElTable, ElTableColumn, ElPagination, ElDialog, ElSelect, ElOption, ElRadioGroup, ElRadio, ElDrawer }
|
||||
})
|
||||
export default class Music extends BaseList<MusicPage> {
|
||||
search = new MusicPage()
|
||||
@@ -151,17 +150,17 @@ export default class Music extends BaseList<MusicPage> {
|
||||
private musicPlaying: boolean = false
|
||||
private musicList: MusicPlayerItem[] = []
|
||||
created() {
|
||||
this.$http.get('/api/music/listLibs').then(({data}) => {
|
||||
this.$http.get<never, any>('/api/music/listLibs').then(data => {
|
||||
this.musicLibs = data
|
||||
this.loadData()
|
||||
})
|
||||
this.$http.get('/api/music/listExts').then(({data}) => {
|
||||
this.$http.get<never, any>('/api/music/listExts').then(({data}) => {
|
||||
this.exts = data
|
||||
})
|
||||
}
|
||||
async loadData() {
|
||||
this.loading = true
|
||||
const { data } = await this.$http.get<MusicPage, AxiosResponse<any>>('/api/music/list', {params: this.search})
|
||||
const data = await this.$http.get<MusicPage, any>('/api/music/list', {params: this.search})
|
||||
selectedIds = []
|
||||
this.loading = false
|
||||
this.total = data.total
|
||||
@@ -177,16 +176,16 @@ export default class Music extends BaseList<MusicPage> {
|
||||
// 根据当前搜索条件播放音乐
|
||||
async playMusic() {
|
||||
try {
|
||||
const { data } = await this.$http.get<any, AxiosResponse<any>>('/api/music/list/all', {params: selectedIds.length ? {ids: selectedIds} : this.search})
|
||||
const data = await this.$http.get<any, any>('/api/music/list/all', {params: selectedIds.length ? {ids: selectedIds} : this.search})
|
||||
this.musicList = data.map((item: MusicModel, index: number) => {
|
||||
return {
|
||||
id: index + 1,
|
||||
name: item.title || item.name,
|
||||
artist: item.artist,
|
||||
album: item.album,
|
||||
url: `${this.$http.defaults.baseURL || ''}/api/common/music/get/${item._id}`,
|
||||
cover: `${this.$http.defaults.baseURL || ''}/api/common/music/album/${item._id}`,
|
||||
lrc: item.lyric_id ? `${this.$http.defaults.baseURL || ''}/api/common/music/lyric/${item.lyric_id}` : undefined
|
||||
url: `/api/common/music/get/${item._id}`,
|
||||
cover: `/api/common/music/album/${item._id}`,
|
||||
lrc: item.lyric_id ? `/api/common/music/lyric/${item.lyric_id}` : undefined
|
||||
}
|
||||
})
|
||||
// 删除原本可能存在的播放器配置(包含播放地址 时间进度等信息)
|
||||
@@ -202,7 +201,7 @@ export default class Music extends BaseList<MusicPage> {
|
||||
}
|
||||
remove(row: MusicModel) {
|
||||
ElMessageBox.confirm(`是否确认删除 ${row.name} ?`, '确认删除', {type: 'warning'}).then(async () => {
|
||||
const { data } = await this.$http.delete<{params: {id: string}}, AxiosResponse<any>>('/api/music/delete', {params: {id: row._id}})
|
||||
const data = await this.$http.delete<{params: {id: string}}, any>('/api/music/delete', {params: {id: row._id}})
|
||||
if(data.status) {
|
||||
ElMessage.success(data.message)
|
||||
this.loadData()
|
||||
@@ -215,7 +214,7 @@ export default class Music extends BaseList<MusicPage> {
|
||||
this.currentRow = row
|
||||
this.modifyLyricModal = true
|
||||
if (row.lyric_id) {
|
||||
const { data } = (await this.$http.get<any, AxiosResponse<any>>('/api/music/lyric/get', {params: {lyricId: row.lyric_id}}))
|
||||
const data = (await this.$http.get<any, any>('/api/music/lyric/get', {params: {lyricId: row.lyric_id}}))
|
||||
data.cloud_id = data.cloud_id ? data.cloud_id.toString() : null
|
||||
this.lyricFormData = data
|
||||
} else {
|
||||
@@ -226,7 +225,7 @@ export default class Music extends BaseList<MusicPage> {
|
||||
(this.$refs.lyricForm as VForm).validate(async (valid: boolean) => {
|
||||
if(!valid) return
|
||||
this.modalLoading = true
|
||||
const { data } = await this.$http.post<MusicLyricModel, AxiosResponse<any>>(`/api/music/lyric/save?musicId=${this.currentRow ? this.currentRow._id : ''}`, this.lyricFormData)
|
||||
const data = await this.$http.post<MusicLyricModel, any>(`/api/music/lyric/save?musicId=${this.currentRow ? this.currentRow._id : ''}`, this.lyricFormData)
|
||||
this.modalLoading = false
|
||||
this.modifyLyricModal = false
|
||||
ElMessage.success(data.message)
|
||||
@@ -237,7 +236,7 @@ export default class Music extends BaseList<MusicPage> {
|
||||
}
|
||||
async updateMusicLib() {
|
||||
if (!this.currentRow) return
|
||||
const { data } = await this.$http.post<any, AxiosResponse<any>>('/api/music/updateLib', {id: this.currentRow._id, libId: this.currentRow.lib_id})
|
||||
const data = await this.$http.post<any, any>('/api/music/updateLib', {id: this.currentRow._id, libId: this.currentRow.lib_id})
|
||||
ElMessage.success(data.message)
|
||||
this.modifyModal = false
|
||||
}
|
||||
|
||||
@@ -79,7 +79,6 @@
|
||||
<script lang="ts">
|
||||
import { Options } from 'vue-class-component'
|
||||
import { ElButton, ElForm, ElFormItem, ElInput, ElTable, ElTableColumn, ElPagination, ElAlert, ElUpload, ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { AxiosResponse } from 'axios'
|
||||
import { MsgResult, Page } from '../../model/common.dto'
|
||||
import BaseList from '../../model/baselist'
|
||||
import PhotoWallModel from '../../model/api/photowall'
|
||||
@@ -98,7 +97,7 @@ export default class PhotoWall extends BaseList<PhotoWallPage> {
|
||||
isUploading: boolean = false
|
||||
async loadData() {
|
||||
this.loading = true
|
||||
const { data } = await this.$http.get<PhotoWallPage, AxiosResponse<any>>('/api/photowall/list', {params:this.search})
|
||||
const data = await this.$http.get<PhotoWallPage, any>('/api/photowall/list', {params:this.search})
|
||||
selectedData = []
|
||||
this.loading = false
|
||||
this.total = data.total
|
||||
@@ -141,7 +140,7 @@ export default class PhotoWall extends BaseList<PhotoWallPage> {
|
||||
}
|
||||
async preview(row: PhotoWallModel) {
|
||||
const previewHeight = Math.floor(row.height * (500 / row.width))
|
||||
const pictureCdn = (await this.$http.get('/api/common/config/picture_cdn')).data
|
||||
const pictureCdn = await this.$http.get('/api/common/config/picture_cdn')
|
||||
ElMessageBox({
|
||||
title: '图片预览',
|
||||
message: h('img', { style: `width:500px;height:${previewHeight}px;`, src: `${pictureCdn}/${row.name}` }, ''),
|
||||
|
||||
@@ -80,7 +80,6 @@ import prettyBytes from 'pretty-bytes'
|
||||
import { MsgResult, Page } from '../../model/common.dto'
|
||||
import BaseList from '../../model/baselist'
|
||||
import { SourceImageModel, ImageLabel } from '../../model/api/source-image'
|
||||
import { AxiosResponse } from 'axios'
|
||||
import { h } from 'vue'
|
||||
|
||||
let selectedData: string[] = []
|
||||
@@ -109,7 +108,7 @@ export default class SourceImage extends BaseList<Page> {
|
||||
}
|
||||
async loadData(): Promise<void> {
|
||||
this.loading = true
|
||||
const { data } = await this.$http.get<Page, AxiosResponse<any>>('/api/source-image/list', {params:this.search})
|
||||
const data = await this.$http.get<Page, any>('/api/source-image/list', {params:this.search})
|
||||
selectedData = []
|
||||
this.loading = false
|
||||
this.total = data.total
|
||||
@@ -171,7 +170,7 @@ export default class SourceImage extends BaseList<Page> {
|
||||
await this.$http.post('/api/source-image/updateLabel', {id: this.curId, labels: newTargetKeys})
|
||||
}
|
||||
created() {
|
||||
this.$http.get<never, AxiosResponse<any>>('/api/common/config/image_label').then(({data}) => {
|
||||
this.$http.get<never, any>('/api/common/config/image_label').then(data => {
|
||||
this.labelList.push(...data)
|
||||
this.loadData()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user