feat: 优化接口配置设计,注册的网络请求会自动注册到 vue 原型 $api 上,修改了一些旧的接口调用方式
This commit is contained in:
@@ -13,11 +13,6 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
// API
|
||||
import {
|
||||
fetch
|
||||
} from '@/api/demo.business.issues.142'
|
||||
|
||||
export default {
|
||||
data () {
|
||||
return {
|
||||
@@ -55,12 +50,13 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
// 请求表格数据
|
||||
getTableData () {
|
||||
fetch()
|
||||
.then(res => {
|
||||
this.crud.data = res.list
|
||||
})
|
||||
.catch(err => console.log(err))
|
||||
async getTableData () {
|
||||
try {
|
||||
const res = this.$api.DEMO_BUSINESS_ISSUE_142_LIST()
|
||||
this.crud.data = res.list
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
},
|
||||
// 跳转到编辑页面
|
||||
goToEditPage (name, id) {
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
import {
|
||||
detail
|
||||
} from '@api/demo.business.issues.142'
|
||||
|
||||
export default {
|
||||
props: {
|
||||
id: {
|
||||
@@ -31,7 +27,7 @@ export default {
|
||||
this.resetFormData()
|
||||
// 请求数据
|
||||
try {
|
||||
const res = await detail(id)
|
||||
const res = await this.$api.DEMO_BUSINESS_ISSUE_142_DETAIL({ id })
|
||||
const { name, address } = res
|
||||
this.form = { name, address }
|
||||
this.$message.success('getFormData')
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { businessTable1List } from '@api/demo.business.table.1'
|
||||
export default {
|
||||
// name 值和本页的 $route.name 一致才可以缓存页面
|
||||
name: 'demo-business-table-1',
|
||||
@@ -57,7 +56,7 @@ export default {
|
||||
this.$notify({
|
||||
title: '开始请求模拟表格数据'
|
||||
})
|
||||
businessTable1List({
|
||||
this.$api.DEMO_BUSINESS_TABLE_1_LIST({
|
||||
...form,
|
||||
...this.page
|
||||
})
|
||||
|
||||
@@ -10,8 +10,6 @@ export default `<template>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { businessTable1List } from '@api/demo.business.table.1'
|
||||
|
||||
export default {
|
||||
data () {
|
||||
return {
|
||||
@@ -57,7 +55,7 @@ export default {
|
||||
},
|
||||
fetchData () {
|
||||
this.loading = true
|
||||
businessTable1List({
|
||||
this.$api.DEMO_BUSINESS_TABLE_1_LIST({
|
||||
...this.pagination
|
||||
}).then(res => {
|
||||
this.data = res.list
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
import '../install'
|
||||
import doc from './doc.md'
|
||||
import code from './code.js'
|
||||
import { businessTable1List } from '@api/demo.business.table.1'
|
||||
|
||||
export default {
|
||||
data () {
|
||||
@@ -73,7 +72,7 @@ export default {
|
||||
},
|
||||
fetchData () {
|
||||
this.loading = true
|
||||
businessTable1List({
|
||||
this.$api.DEMO_BUSINESS_TABLE_1_LIST({
|
||||
...this.pagination
|
||||
}).then(res => {
|
||||
this.data = res.list
|
||||
|
||||
@@ -8,11 +8,10 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getInvalidUrl } from '@api/demo.playground.log.ajax.js'
|
||||
export default {
|
||||
methods: {
|
||||
handleClick () {
|
||||
getInvalidUrl()
|
||||
this.$api.DEMO_LOG_AJAX()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user