修改定时刷新机制

main
LX 2023-12-12 13:18:03 +08:00
parent 559cd0929e
commit b1e67ad084
2 changed files with 11 additions and 5 deletions

View File

@ -33,6 +33,7 @@ const dataHandler = (event) => {
customeText.value = event
}
onMounted(async () => {
console.log(propValue)
try {
const queryParems = { tag: propValue.base.tag }
const res = await http.get({ url: propValue.base.url, params: queryParems })
@ -45,16 +46,19 @@ onMounted(async () => {
}
})
const dataChange = (resp: any, _?: string) => {
if (!resp || !resp.data.data) {
console.log(resp)
if (!resp ||( !resp.afterData && !resp.data.data)) {
console.log("数据失败-----")
return
}
if (resp.status === 'SUCCESS') {
console.log(resp.data.data)
if(resp.afterData && resp.status === 'SUCCESS'){
console.log("数据-----afterData")
dataHandler(resp.afterData)
}else if(resp.data.data && resp.status === 'SUCCESS'){
console.log("数据-----data.data")
dataHandler(resp.data.data)
}
}
useData(props.component, dataChange)

View File

@ -21,6 +21,8 @@ class RestRequestData implements DataInstance {
public async connect(acceptor: DataAcceptor) {
const { otherConfig } = this.options || {}
if (otherConfig.isRepeat) {
const resp = await this.getRespData()
acceptor(resp)
const handler = async () => {
const resp = await this.getRespData()
acceptor(resp)