Manager web (#227)

* update:增加前端设计图

* 前端代码优化

* update:底部信息纠正

* 增加:flyio

* update:去除org.quartz

* update:登陆功能

---------

Co-authored-by: hrz <1710360675@qq.com>
Co-authored-by: CGD <3030332422@qq.com>
This commit is contained in:
欣南科技
2025-03-07 10:01:20 +08:00
committed by GitHub
co-authored by hrz CGD
parent 0b7abfae3a
commit 6464c81e72
11 changed files with 892 additions and 116 deletions
+132
View File
@@ -0,0 +1,132 @@
import {goToPage, showDanger, showWarning} from '../utils/index'
import Constant from '../utils/constant'
import Fly from 'flyio/dist/npm/fly';
const fly = new Fly()
// 设置超时
fly.config.timeout = 30000
/**
* Request服务封装
*/
export default {
sendRequest,
reAjaxFun,
clearRequestTime
}
function sendRequest() {
return {
_sucCallback: null,
_failCallback: null,
_method: 'GET',
_data: {},
_header: {'content-type': 'application/json; charset=utf-8'},
_url: '',
'send'() {
this._header.token = localStorage.getItem(Constant.STORAGE_KEY.TOKEN)
fly.request(this._url, this._data, {
method: this._method,
headers: this._header
}).then((res) => {
const error = httpHandlerError(res, this._failCallback)
if (error) {
return
}
if (this._sucCallback) {
this._sucCallback(res)
}
}).catch((res) => {
console.log(1111, res)
httpHandlerError(res, this._failCallback)
})
return this
},
'success'(callback) {
this._sucCallback = callback
return this
},
'fail'(callback) {
this._failCallback = callback
return this
},
'url'(url) {
if (url) {
url = url.replaceAll('$', '/')
}
this._url = url
return this
},
'data'(data) {
this._data = data
return this
},
'method'(method) {
this._method = method
return this
},
'header'(header) {
this._header = header
return this
},
'showLoading'(showLoading) {
this._showLoading = showLoading
return this
},
'async'(flag) {
this.async = flag
}
}
}
/**
* Info 请求完成后返回信息
* callBack 回调函数
* errTip 自定义错误信息
*/
function httpHandlerError(info, callBack) {
/** 请求成功,退出该函数 可以根据项目需求来判断是否请求成功。这里判断的是status为200的时候是成功 */
let networkError = false
if (info.status === 200) {
if (info.data.code === 'success' || info.data.code === 0) {
return networkError
} else if (info.data.code === 401) {
goToPage(Constant.PAGE.LOGIN, true)
return true
} else {
showDanger(info.data.msg)
return true
}
}
if (callBack) {
callBack(info)
} else {
showDanger(`网络请求出现了错误【${info.status}`)
}
return true
}
let requestTime = 0
let reAjaxSec = 2
function reAjaxFun(fn) {
let nowTimeSec = new Date().getTime() / 1000
if (requestTime === 0) {
requestTime = nowTimeSec
}
let ajaxIndex = parseInt((nowTimeSec - requestTime) / reAjaxSec)
if (ajaxIndex > 10) {
showWarning('似乎无法连接服务器')
} else {
showWarning('正在连接服务器(' + ajaxIndex + ')')
}
if (fn) {
setTimeout(() => {
fn()
}, reAjaxSec * 1000)
}
}
function clearRequestTime() {
requestTime = 0
}