axios泛型修改

This commit is contained in:
灌糖包子 2021-10-05 15:55:13 +08:00
parent 5b29560455
commit 557f8874cb
13 changed files with 47 additions and 62 deletions

View File

@ -27,7 +27,7 @@ service.interceptors.request.use(config => {
}) })
service.interceptors.response.use(res=> { service.interceptors.response.use(res=> {
return res return res.data
}, err => { }, err => {
if (err.response.status >= 500) { if (err.response.status >= 500) {
ElMessage.error('服务器内部错误') ElMessage.error('服务器内部错误')

View File

@ -51,7 +51,6 @@
<script lang="ts"> <script lang="ts">
import { Options, Vue } from 'vue-class-component' import { Options, Vue } from 'vue-class-component'
import { ElContainer, ElHeader, ElMain, ElAside, ElDropdown, ElDropdownMenu, ElDropdownItem, ElButton, ElMenu, ElSubMenu, ElMenuItem, ElBreadcrumb, ElBreadcrumbItem } from 'element-plus' import { ElContainer, ElHeader, ElMain, ElAside, ElDropdown, ElDropdownMenu, ElDropdownItem, ElButton, ElMenu, ElSubMenu, ElMenuItem, ElBreadcrumb, ElBreadcrumbItem } from 'element-plus'
import { AxiosResponse } from 'axios'
import menus from '../config/menu' import menus from '../config/menu'
@Options({ @Options({
@ -80,7 +79,7 @@ export default class Home extends Vue{
this.$router.push('/login') this.$router.push('/login')
return return
} }
const { data } = await this.$http.post<{token: null | string}, AxiosResponse<any>>('/api/common/verifyToken', {token: localStorage.getItem('login_token')}) const data = await this.$http.post<{token: null | string}, any>('/api/common/verifyToken', {token: localStorage.getItem('login_token')})
if(data.status) { if(data.status) {
// token token // token token
this.$store.commit('login', {token: data.newToken || localStorage.getItem('login_token'), userInfo: data.userInfo}) this.$store.commit('login', {token: data.newToken || localStorage.getItem('login_token'), userInfo: data.userInfo})

View File

@ -20,7 +20,6 @@
<script lang="ts"> <script lang="ts">
import { Options, Vue } from 'vue-class-component' import { Options, Vue } from 'vue-class-component'
import { ElMessage, ElButton, ElForm, ElFormItem, ElInput, ElTooltip } from 'element-plus' import { ElMessage, ElButton, ElForm, ElFormItem, ElInput, ElTooltip } from 'element-plus'
import { AxiosResponse } from 'axios'
import { VForm } from "../types" import { VForm } from "../types"
@Options({ @Options({
@ -46,7 +45,7 @@ export default class Login extends Vue {
async login() { async login() {
(this.$refs.loginForm as VForm).validate(async (valid: boolean) => { (this.$refs.loginForm as VForm).validate(async (valid: boolean) => {
if(!valid) return if(!valid) return
const { data } = await this.$http.post<UserInfo, AxiosResponse<any>>('/api/common/login', this.userInfo) const data = await this.$http.post<UserInfo, any>('/api/common/login', this.userInfo)
if(data.token) { if(data.token) {
this.$store.commit('login', data) this.$store.commit('login', data)
this.$router.push('/') this.$router.push('/')
@ -59,7 +58,7 @@ export default class Login extends Vue {
* 访客模式 * 访客模式
*/ */
async guestLogin() { async guestLogin() {
const { data } = await this.$http.post<never, AxiosResponse<any>>('/api/common/guestLogin') const data = await this.$http.post<never, any>('/api/common/guestLogin')
if (data.status && data.data.token) { if (data.status && data.data.token) {
this.$store.commit('login', data.data) this.$store.commit('login', data.data)
this.$router.push('/') this.$router.push('/')

View File

@ -71,7 +71,6 @@ import { Options, Vue } from 'vue-class-component'
import BaseList from '../../model/baselist' import BaseList from '../../model/baselist'
import { Page } from '../../model/common.dto' import { Page } from '../../model/common.dto'
import HitokotoModel from '../../model/api/hitokoto' 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 { ElButton, ElForm, ElFormItem, ElInput, ElTable, ElTableColumn, ElPagination, ElDialog, ElSelect, ElOption, ElDatePicker, ElMessage, ElMessageBox } from 'element-plus'
import { VForm } from '../../types' import { VForm } from '../../types'
@ -89,7 +88,7 @@ export default class Hitokoto extends BaseList<HitokotoPage> {
async loadData() { async loadData() {
this.loading = true 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 = [] selectedData = []
this.loading = false this.loading = false
this.total = data.total 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) => { ((this.$refs.addForm as Vue).$refs.hitokotoForm as VForm).validate(async (valid: boolean) => {
if(!valid) return if(!valid) return
this.modalLoading = true 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.modalLoading = false
this.addModal = false this.addModal = false
ElMessage.success(data.message) ElMessage.success(data.message)
@ -114,7 +113,7 @@ export default class Hitokoto extends BaseList<HitokotoPage> {
return return
} }
ElMessageBox.confirm(`是否确认删除选中的${selectedData.length}条数据?`, '确认删除', {type: 'warning'}).then(async () => { 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) ElMessage.success(data.message)
this.loadData() this.loadData()
}).catch(() => {}) }).catch(() => {})
@ -124,7 +123,7 @@ export default class Hitokoto extends BaseList<HitokotoPage> {
} }
created() { created() {
this.loadData() 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 this.typeList = data
}) })
} }

View File

@ -115,8 +115,7 @@
import { Options } from 'vue-class-component' import { Options } from 'vue-class-component'
import BaseList from '../../model/baselist' import BaseList from '../../model/baselist'
import { Page } from '../../model/common.dto' import { Page } from '../../model/common.dto'
import { AxiosResponse } from 'axios' import { ElButton, ElForm, ElFormItem, ElInput, ElTable, ElTableColumn, ElPagination, ElDialog, ElSelect, ElOption, ElRadioGroup, ElRadio, ElDrawer, ElMessage, ElMessageBox } from 'element-plus'
import { ElButton, ElForm, ElFormItem, ElInput, ElTable, ElTableColumn, ElPagination, ElDialog, ElSelect, ElOption, ElRadioGroup, ElRadio, ElMessage, ElMessageBox } from 'element-plus'
import { MusicModel, MusicLibModel, MusicLyricModel, MusicPlayerItem } from '../../model/api/music' import { MusicModel, MusicLibModel, MusicLyricModel, MusicPlayerItem } from '../../model/api/music'
import prettyBytes from 'pretty-bytes' import prettyBytes from 'pretty-bytes'
import { VForm } from '../../types' import { VForm } from '../../types'
@ -124,7 +123,7 @@ import { VForm } from '../../types'
let selectedIds: string[] = [] let selectedIds: string[] = []
@Options({ @Options({
name: 'Music', 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> { export default class Music extends BaseList<MusicPage> {
search = new MusicPage() search = new MusicPage()
@ -151,17 +150,17 @@ export default class Music extends BaseList<MusicPage> {
private musicPlaying: boolean = false private musicPlaying: boolean = false
private musicList: MusicPlayerItem[] = [] private musicList: MusicPlayerItem[] = []
created() { created() {
this.$http.get('/api/music/listLibs').then(({data}) => { this.$http.get<never, any>('/api/music/listLibs').then(data => {
this.musicLibs = data this.musicLibs = data
this.loadData() this.loadData()
}) })
this.$http.get('/api/music/listExts').then(({data}) => { this.$http.get<never, any>('/api/music/listExts').then(({data}) => {
this.exts = data this.exts = data
}) })
} }
async loadData() { async loadData() {
this.loading = true 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 = [] selectedIds = []
this.loading = false this.loading = false
this.total = data.total this.total = data.total
@ -177,16 +176,16 @@ export default class Music extends BaseList<MusicPage> {
// //
async playMusic() { async playMusic() {
try { 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) => { this.musicList = data.map((item: MusicModel, index: number) => {
return { return {
id: index + 1, id: index + 1,
name: item.title || item.name, name: item.title || item.name,
artist: item.artist, artist: item.artist,
album: item.album, album: item.album,
url: `${this.$http.defaults.baseURL || ''}/api/common/music/get/${item._id}`, url: `/api/common/music/get/${item._id}`,
cover: `${this.$http.defaults.baseURL || ''}/api/common/music/album/${item._id}`, cover: `/api/common/music/album/${item._id}`,
lrc: item.lyric_id ? `${this.$http.defaults.baseURL || ''}/api/common/music/lyric/${item.lyric_id}` : undefined 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) { remove(row: MusicModel) {
ElMessageBox.confirm(`是否确认删除 ${row.name} `, '确认删除', {type: 'warning'}).then(async () => { 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) { if(data.status) {
ElMessage.success(data.message) ElMessage.success(data.message)
this.loadData() this.loadData()
@ -215,7 +214,7 @@ export default class Music extends BaseList<MusicPage> {
this.currentRow = row this.currentRow = row
this.modifyLyricModal = true this.modifyLyricModal = true
if (row.lyric_id) { 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 data.cloud_id = data.cloud_id ? data.cloud_id.toString() : null
this.lyricFormData = data this.lyricFormData = data
} else { } else {
@ -226,7 +225,7 @@ export default class Music extends BaseList<MusicPage> {
(this.$refs.lyricForm as VForm).validate(async (valid: boolean) => { (this.$refs.lyricForm as VForm).validate(async (valid: boolean) => {
if(!valid) return if(!valid) return
this.modalLoading = true 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.modalLoading = false
this.modifyLyricModal = false this.modifyLyricModal = false
ElMessage.success(data.message) ElMessage.success(data.message)
@ -237,7 +236,7 @@ export default class Music extends BaseList<MusicPage> {
} }
async updateMusicLib() { async updateMusicLib() {
if (!this.currentRow) return 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) ElMessage.success(data.message)
this.modifyModal = false this.modifyModal = false
} }

View File

@ -79,7 +79,6 @@
<script lang="ts"> <script lang="ts">
import { Options } from 'vue-class-component' import { Options } from 'vue-class-component'
import { ElButton, ElForm, ElFormItem, ElInput, ElTable, ElTableColumn, ElPagination, ElAlert, ElUpload, ElMessage, ElMessageBox } from 'element-plus' 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 { MsgResult, Page } from '../../model/common.dto'
import BaseList from '../../model/baselist' import BaseList from '../../model/baselist'
import PhotoWallModel from '../../model/api/photowall' import PhotoWallModel from '../../model/api/photowall'
@ -98,7 +97,7 @@ export default class PhotoWall extends BaseList<PhotoWallPage> {
isUploading: boolean = false isUploading: boolean = false
async loadData() { async loadData() {
this.loading = true 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 = [] selectedData = []
this.loading = false this.loading = false
this.total = data.total this.total = data.total
@ -141,7 +140,7 @@ export default class PhotoWall extends BaseList<PhotoWallPage> {
} }
async preview(row: PhotoWallModel) { async preview(row: PhotoWallModel) {
const previewHeight = Math.floor(row.height * (500 / row.width)) 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({ ElMessageBox({
title: '图片预览', title: '图片预览',
message: h('img', { style: `width:500px;height:${previewHeight}px;`, src: `${pictureCdn}/${row.name}` }, ''), message: h('img', { style: `width:500px;height:${previewHeight}px;`, src: `${pictureCdn}/${row.name}` }, ''),

View File

@ -80,7 +80,6 @@ import prettyBytes from 'pretty-bytes'
import { MsgResult, Page } from '../../model/common.dto' import { MsgResult, Page } from '../../model/common.dto'
import BaseList from '../../model/baselist' import BaseList from '../../model/baselist'
import { SourceImageModel, ImageLabel } from '../../model/api/source-image' import { SourceImageModel, ImageLabel } from '../../model/api/source-image'
import { AxiosResponse } from 'axios'
import { h } from 'vue' import { h } from 'vue'
let selectedData: string[] = [] let selectedData: string[] = []
@ -109,7 +108,7 @@ export default class SourceImage extends BaseList<Page> {
} }
async loadData(): Promise<void> { async loadData(): Promise<void> {
this.loading = true 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 = [] selectedData = []
this.loading = false this.loading = false
this.total = data.total 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}) await this.$http.post('/api/source-image/updateLabel', {id: this.curId, labels: newTargetKeys})
} }
created() { 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.labelList.push(...data)
this.loadData() this.loadData()
}) })

View File

@ -36,7 +36,7 @@
<el-button @click="pullArticles" size="small" >拉取文章</el-button> <el-button @click="pullArticles" size="small" >拉取文章</el-button>
<el-upload <el-upload
action="/api/system/deployBlog" action="/api/system/deployBlog"
accept=".zip" accept="application/zip"
name="blogZip" name="blogZip"
:headers="uploadHeaders" :headers="uploadHeaders"
:before-upload="beforeUpload" :before-upload="beforeUpload"
@ -115,7 +115,6 @@ import Node from 'element-plus/lib/components/tree/src/model/node'
import { Options } from 'vue-class-component' import { Options } from 'vue-class-component'
import BaseList from '../../model/baselist' import BaseList from '../../model/baselist'
import { Page, MsgResult } from '../../model/common.dto' import { Page, MsgResult } from '../../model/common.dto'
import { AxiosResponse } from 'axios'
let selectedData: string[] = [] let selectedData: string[] = []
@Options({ @Options({
@ -140,7 +139,7 @@ export default class Article extends BaseList<ArticlePage> {
isUploading: boolean = false isUploading: boolean = false
async loadData() { async loadData() {
this.loading = true this.loading = true
const { data } = await this.$http.get<ArticlePage, AxiosResponse<any>>('/api/article/list', {params:this.search}) const data = await this.$http.get<ArticlePage, any>('/api/article/list', {params:this.search})
selectedData = [] selectedData = []
this.loading = false this.loading = false
this.total = data.total this.total = data.total
@ -152,7 +151,7 @@ export default class Article extends BaseList<ArticlePage> {
return return
} }
ElMessageBox.confirm(`是否确认对选中的${selectedData.length}篇文章执行分词处理?`, '操作确认', {type: 'info'}).then(async () => { ElMessageBox.confirm(`是否确认对选中的${selectedData.length}篇文章执行分词处理?`, '操作确认', {type: 'info'}).then(async () => {
const { data } = await this.$http.put<{_ids: string[]}, AxiosResponse<any>>('/api/article/splitWord', {_ids: selectedData}) const data = await this.$http.put<{_ids: string[]}, any>('/api/article/splitWord', {_ids: selectedData})
if(data.status) { if(data.status) {
ElMessage.success(data.message) ElMessage.success(data.message)
} else { } else {
@ -162,7 +161,7 @@ export default class Article extends BaseList<ArticlePage> {
} }
pullArticles() { pullArticles() {
ElMessageBox.confirm('确认拉取全部文章?', '操作确认', {type: 'info'}).then(async () => { ElMessageBox.confirm('确认拉取全部文章?', '操作确认', {type: 'info'}).then(async () => {
const { data } = await this.$http.get<never, AxiosResponse<any>>('/api/article/pull') const data = await this.$http.get<never, any>('/api/article/pull')
if(data.status) { if(data.status) {
ElMessage.success(data.message) ElMessage.success(data.message)
this.loadData() this.loadData()
@ -196,7 +195,7 @@ export default class Article extends BaseList<ArticlePage> {
isLeaf: 'isLeaf', isLeaf: 'isLeaf',
} }
async loadTreeData(node: Node, resolve: Function) { async loadTreeData(node: Node, resolve: Function) {
const childItems: TreeNodeSource[] = (await this.$http.get('/api/article/tree', {params:{deep: node.level, parent: node.data.name}})).data const childItems: TreeNodeSource[] = await this.$http.get('/api/article/tree', {params:{deep: node.level, parent: node.data.name}})
resolve(childItems.map((childItem): TreeNodeData => { resolve(childItems.map((childItem): TreeNodeData => {
const treeNode: TreeNodeData = { const treeNode: TreeNodeData = {
name: childItem._id, name: childItem._id,
@ -215,7 +214,7 @@ export default class Article extends BaseList<ArticlePage> {
async articlePreview(node: TreeNodeData) { async articlePreview(node: TreeNodeData) {
if(!node.isLeaf) return if(!node.isLeaf) return
// markdown // markdown
const mdText = (await this.$http.get('/api/article/markdown', {params:{id: node.id}})).data const mdText = await this.$http.get<never, any>('/api/article/markdown', {params:{id: node.id}})
this.markdownPreview.show = true this.markdownPreview.show = true
const markdownHtml = new hyperdown().makeHtml(mdText) const markdownHtml = new hyperdown().makeHtml(mdText)
this.markdownPreview.content = markdownHtml.replace(/(?<=<pre><code[^>]*?>)[\s\S]*?(?=<\/code><\/pre>)/gi, content => { this.markdownPreview.content = markdownHtml.replace(/(?<=<pre><code[^>]*?>)[\s\S]*?(?=<\/code><\/pre>)/gi, content => {
@ -226,15 +225,12 @@ export default class Article extends BaseList<ArticlePage> {
} }
created() { created() {
this.loadData() this.loadData()
this.$http.get('/api/article/listCategories').then(({data}) => { this.$http.get<never, any>('/api/article/listCategories').then(data => {
this.categories = data this.categories = data
}) })
this.$http.get('/api/article/listTags').then(({data}) => { this.$http.get<never, any>('/api/article/listTags').then(data => {
this.tags = data this.tags = data
}) })
// this.loadTreeData({deep:-1, name: null}, (treeNodes: TreeNode[]) => {
// this.articleTree.push(...treeNodes)
// })
} }
} }

View File

@ -10,7 +10,6 @@
<script lang="ts"> <script lang="ts">
import * as echarts from 'echarts' import * as echarts from 'echarts'
import { Options, Vue } from 'vue-class-component' import { Options, Vue } from 'vue-class-component'
import { AxiosResponse } from 'axios'
@Options({ @Options({
name: 'Statistics' name: 'Statistics'
@ -24,7 +23,7 @@ export default class Statistics extends Vue {
this.publishDatesChartLoading = true this.publishDatesChartLoading = true
this.timelineWordsChartLoading = true this.timelineWordsChartLoading = true
const articleData = (await this.$http.get<{params:{type:string}}, AxiosResponse<any>>('/api/article/statistics', {params:{type:'normal'}})).data const articleData = await this.$http.get<{params:{type:string}}, any>('/api/article/statistics', {params:{type:'normal'}})
this.categoriesChartOption.legend.data = articleData.categories.map((item: any) => item._id) this.categoriesChartOption.legend.data = articleData.categories.map((item: any) => item._id)
this.categoriesChartOption.series.data = articleData.categories.map((item: any) => { this.categoriesChartOption.series.data = articleData.categories.map((item: any) => {
return {name: item._id, value: item.cnt} return {name: item._id, value: item.cnt}
@ -39,7 +38,7 @@ export default class Statistics extends Vue {
this.categoriesChartLoading = false this.categoriesChartLoading = false
this.publishDatesChartLoading = false this.publishDatesChartLoading = false
const timelineData = (await this.$http.get<{params:{type:string}}, AxiosResponse<any>>('/api/article/statistics', {params:{type:'timelineWords'}})).data const timelineData = await this.$http.get<{params:{type:string}}, any>('/api/article/statistics', {params:{type:'timelineWords'}})
this.timelineWordsChartOption.timeline.data = timelineData.timelineWords.map((item: any) => item._id) this.timelineWordsChartOption.timeline.data = timelineData.timelineWords.map((item: any) => item._id)
timelineData.timelineWords.forEach((item: any) => { timelineData.timelineWords.forEach((item: any) => {
this.timelineWordsChartOption.options.push({ this.timelineWordsChartOption.options.push({

View File

@ -57,7 +57,6 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import { Options, Vue } from 'vue-class-component' import { Options, Vue } from 'vue-class-component'
import { AxiosResponse } from 'axios'
import { ElButton, ElForm, ElFormItem, ElInput, ElTable, ElTableColumn, ElDialog, ElMessage, ElMessageBox } from 'element-plus' import { ElButton, ElForm, ElFormItem, ElInput, ElTable, ElTableColumn, ElDialog, ElMessage, ElMessageBox } from 'element-plus'
import moment from 'moment' import moment from 'moment'
import SystemConfigAdd from './SystemConfigAdd.vue' import SystemConfigAdd from './SystemConfigAdd.vue'
@ -88,7 +87,7 @@ export default class SystemConfig extends Vue {
} }
async loadData() { async loadData() {
this.loading = true this.loading = true
this.systemConfigData = (await this.$http.get('/api/system/config/list', {params:this.search})).data this.systemConfigData = await this.$http.get('/api/system/config/list', {params:this.search})
this.loading = false this.loading = false
} }
add() { add() {
@ -113,7 +112,7 @@ export default class SystemConfig extends Vue {
((this.$refs.addForm as Vue).$refs.configForm as VForm).validate(async (valid: boolean) => { ((this.$refs.addForm as Vue).$refs.configForm as VForm).validate(async (valid: boolean) => {
if(!valid) return if(!valid) return
this.modalLoading = true this.modalLoading = true
const { data } = await this.$http.post<SystemConfigModel, AxiosResponse<any>>('/api/system/config/save', this.formData) const data = await this.$http.post<SystemConfigModel, any>('/api/system/config/save', this.formData)
this.modalLoading = false this.modalLoading = false
this.addModal = false this.addModal = false
ElMessage.success(data.message) ElMessage.success(data.message)
@ -122,7 +121,7 @@ export default class SystemConfig extends Vue {
} }
remove(row: SystemConfigModel) { remove(row: SystemConfigModel) {
ElMessageBox.confirm(`是否确认删除 ${row.name} 配置项?`, '确认删除', {type: 'warning'}).then(async () => { ElMessageBox.confirm(`是否确认删除 ${row.name} 配置项?`, '确认删除', {type: 'warning'}).then(async () => {
const { data } = await this.$http.delete<{params: {id: string}}, AxiosResponse<any>>('/api/system/config/delete', {params: {id: row._id}}) const data = await this.$http.delete<{params: {id: string}}, any>('/api/system/config/delete', {params: {id: row._id}})
if(data.status) { if(data.status) {
ElMessage.success(data.message) ElMessage.success(data.message)
this.loadData() this.loadData()

View File

@ -23,7 +23,6 @@
import { Options, Vue } from 'vue-class-component' import { Options, Vue } from 'vue-class-component'
import { SystemConfigModel } from '../../model/system/system-config' import { SystemConfigModel } from '../../model/system/system-config'
import { ElForm, ElFormItem, ElInput, ElSwitch } from 'element-plus' import { ElForm, ElFormItem, ElInput, ElSwitch } from 'element-plus'
import { AxiosResponse } from 'axios'
@Options({ @Options({
name: 'SystemConfigAdd', name: 'SystemConfigAdd',
@ -39,7 +38,7 @@ export default class SystenConfigAdd extends Vue {
name: [ name: [
{ required: true, message: '请输入配置项名称', trigger: 'blur' }, { required: true, message: '请输入配置项名称', trigger: 'blur' },
{ validator: (rule: object, value: string, callback: Function) => { { validator: (rule: object, value: string, callback: Function) => {
this.$http.get<any, AxiosResponse<any>>('/api/system/config/exists', {params: {name: value, id: this.formData._id}}).then(({data}) => { this.$http.get<any, any>('/api/system/config/exists', {params: {name: value, id: this.formData._id}}).then(data => {
if(data.data.exists) { if(data.data.exists) {
callback(new Error('配置项名称已存在')) callback(new Error('配置项名称已存在'))
} else { } else {

View File

@ -95,7 +95,6 @@ import { Options } from 'vue-class-component'
import BaseList from '../../model/baselist' import BaseList from '../../model/baselist'
import { Page } from '../../model/common.dto' import { Page } from '../../model/common.dto'
import { SystemRoleModel } from '../../model/system/system-role' import { SystemRoleModel } from '../../model/system/system-role'
import { AxiosResponse } from 'axios'
import { ElButton, ElForm, ElFormItem, ElInput, ElTable, ElTableColumn, ElTag, ElPagination, ElDialog, ElSelect, ElOption, ElMessage, ElMessageBox } from 'element-plus' import { ElButton, ElForm, ElFormItem, ElInput, ElTable, ElTableColumn, ElTag, ElPagination, ElDialog, ElSelect, ElOption, ElMessage, ElMessageBox } from 'element-plus'
import { VForm } from '../../types' import { VForm } from '../../types'
@ -130,7 +129,7 @@ export default class SystemRole extends BaseList<SystemRolePage> {
} }
async loadData() { async loadData() {
this.loading = true this.loading = true
const { data } = await this.$http.get<{params: SystemRolePage}, AxiosResponse<any>>('/api/system/role/list', {params:this.search}) const data = await this.$http.get<{params: SystemRolePage}, any>('/api/system/role/list', {params:this.search})
this.loading = false this.loading = false
this.total = data.total this.total = data.total
this.systemRoleData = data.data this.systemRoleData = data.data
@ -181,7 +180,7 @@ export default class SystemRole extends BaseList<SystemRolePage> {
} }
remove(row: SystemRoleModel) { remove(row: SystemRoleModel) {
ElMessageBox.confirm(`是否确认删除 ${row.name} 角色?`, '确认删除', {type: 'warning'}).then(async () => { ElMessageBox.confirm(`是否确认删除 ${row.name} 角色?`, '确认删除', {type: 'warning'}).then(async () => {
const { data } = await this.$http.delete<{params: {id: string}}, AxiosResponse<any>>('/api/system/role/delete', {params: {id: row._id}}) const data = await this.$http.delete<{params: {id: string}}, any>('/api/system/role/delete', {params: {id: row._id}})
if(data.status) { if(data.status) {
ElMessage.success(data.message) ElMessage.success(data.message)
this.loadData() this.loadData()
@ -194,7 +193,7 @@ export default class SystemRole extends BaseList<SystemRolePage> {
(this.$refs.roleForm as VForm).validate(async (valid: boolean) => { (this.$refs.roleForm as VForm).validate(async (valid: boolean) => {
if(!valid) return if(!valid) return
this.modalLoading = true this.modalLoading = true
const { data } = await this.$http.post<SystemRoleModel, AxiosResponse<any>>('/api/system/role/save', this.formData) const data = await this.$http.post<SystemRoleModel, any>('/api/system/role/save', this.formData)
this.modalLoading = false this.modalLoading = false
this.addModal = false this.addModal = false
ElMessage.success(data.message) ElMessage.success(data.message)

View File

@ -75,7 +75,6 @@ import BaseList from '../../model/baselist'
import { Page } from '../../model/common.dto' import { Page } from '../../model/common.dto'
import { SystemUserModel } from '../../model/system/system-user' import { SystemUserModel } from '../../model/system/system-user'
import { SystemRoleModel } from '../../model/system/system-role' import { SystemRoleModel } from '../../model/system/system-role'
import { AxiosResponse } from 'axios'
import { ElButton, ElForm, ElFormItem, ElInput, ElTable, ElTableColumn, ElPagination, ElDialog, ElSelect, ElOption, ElMessage, ElMessageBox } from 'element-plus' import { ElButton, ElForm, ElFormItem, ElInput, ElTable, ElTableColumn, ElPagination, ElDialog, ElSelect, ElOption, ElMessage, ElMessageBox } from 'element-plus'
import { VForm } from '../../types' import { VForm } from '../../types'
@ -89,7 +88,7 @@ export default class SystemUser extends BaseList<SystemUserPage> {
username: [ username: [
{ required: true, message: '请输入用户名', trigger: 'blur' }, { required: true, message: '请输入用户名', trigger: 'blur' },
{ validator: async (rule: object, value: string, callback: Function) => { { validator: async (rule: object, value: string, callback: Function) => {
const { data } = await this.$http.get<any, AxiosResponse<any>>('/api/system/user/exists', {params: {username: value, id: this.formData._id}}) const data = await this.$http.get<any, any>('/api/system/user/exists', {params: {username: value, id: this.formData._id}})
if(data.data.exists) { if(data.data.exists) {
callback(new Error('用户名已存在')) callback(new Error('用户名已存在'))
} else { } else {
@ -119,7 +118,7 @@ export default class SystemUser extends BaseList<SystemUserPage> {
} }
async loadData() { async loadData() {
this.loading = true this.loading = true
const { data } = await this.$http.get<{params: SystemUserPage}, AxiosResponse<any>>('/api/system/user/list', {params:this.search}) const data = await this.$http.get<{params: SystemUserPage}, any>('/api/system/user/list', {params:this.search})
this.loading = false this.loading = false
this.total = data.total this.total = data.total
this.systemUserData = data.data this.systemUserData = data.data
@ -150,7 +149,7 @@ export default class SystemUser extends BaseList<SystemUserPage> {
(this.$refs.userForm as VForm).validate(async (valid: boolean) => { (this.$refs.userForm as VForm).validate(async (valid: boolean) => {
if(!valid) return if(!valid) return
this.modalLoading = true this.modalLoading = true
const { data } = await this.$http.post<SystemUserModel, AxiosResponse<any>>('/api/system/user/save', this.formData) const data = await this.$http.post<SystemUserModel, any>('/api/system/user/save', this.formData)
this.modalLoading = false this.modalLoading = false
this.addModal = false this.addModal = false
ElMessage.success(data.message) ElMessage.success(data.message)
@ -159,7 +158,7 @@ export default class SystemUser extends BaseList<SystemUserPage> {
} }
remove(row: SystemUserModel) { remove(row: SystemUserModel) {
ElMessageBox.confirm(`是否确认删除 ${row.username} 用户?`, '确认删除', {type: 'warning'}).then(async () => { ElMessageBox.confirm(`是否确认删除 ${row.username} 用户?`, '确认删除', {type: 'warning'}).then(async () => {
const { data } = await this.$http.delete<{params: {id: string}}, AxiosResponse<any>>('/api/system/user/delete', {params: {id: row._id}}) const data = await this.$http.delete<{params: {id: string}}, any>('/api/system/user/delete', {params: {id: row._id}})
if(data.status) { if(data.status) {
ElMessage.success(data.message) ElMessage.success(data.message)
this.loadData() this.loadData()
@ -170,7 +169,7 @@ export default class SystemUser extends BaseList<SystemUserPage> {
} }
created() { created() {
this.loadData() this.loadData()
this.$http.get('/api/system/role/listAll').then(({data}) => { this.$http.get<never, any>('/api/system/role/listAll').then(data => {
this.roles = data this.roles = data
}) })
} }