diff --git a/frontend/matrix-middle-service-web/index.html b/frontend/matrix-middle-service-web/index.html index 143557b..f6911f3 100644 --- a/frontend/matrix-middle-service-web/index.html +++ b/frontend/matrix-middle-service-web/index.html @@ -5,6 +5,13 @@ Vite + Vue + TS +
diff --git a/frontend/matrix-middle-service-web/package.json b/frontend/matrix-middle-service-web/package.json index 2ad72f7..144ab97 100644 --- a/frontend/matrix-middle-service-web/package.json +++ b/frontend/matrix-middle-service-web/package.json @@ -11,7 +11,10 @@ "build-storybook": "storybook build" }, "dependencies": { + "@amap/amap-jsapi-loader": "^1.0.1", "@quasar/extras": "^1.15.11", + "axios": "^1.3.4", + "moment": "^2.29.4", "pinia": "^2.0.30", "quasar": "^2.11.5", "vue": "^3.2.45", diff --git a/frontend/matrix-middle-service-web/src/App.vue b/frontend/matrix-middle-service-web/src/App.vue index b3e89cb..2b9c6e4 100644 --- a/frontend/matrix-middle-service-web/src/App.vue +++ b/frontend/matrix-middle-service-web/src/App.vue @@ -1,30 +1,5 @@ - - - diff --git a/frontend/matrix-middle-service-web/src/api/index.ts b/frontend/matrix-middle-service-web/src/api/index.ts new file mode 100644 index 0000000..b3eb39a --- /dev/null +++ b/frontend/matrix-middle-service-web/src/api/index.ts @@ -0,0 +1,8 @@ +import {getAxiosInstance} from "matrix-middle-service-web/src/api/utils"; + +export const http = getAxiosInstance({ + baseURL: "/api", + timeout: 30 * 1000 +}) + +export default http; diff --git a/frontend/matrix-middle-service-web/src/api/record/index.ts b/frontend/matrix-middle-service-web/src/api/record/index.ts new file mode 100644 index 0000000..f96cedb --- /dev/null +++ b/frontend/matrix-middle-service-web/src/api/record/index.ts @@ -0,0 +1,3 @@ +export const record = { + getLocationRecord: "/record/location/get" +} diff --git a/frontend/matrix-middle-service-web/src/api/utils.ts b/frontend/matrix-middle-service-web/src/api/utils.ts new file mode 100644 index 0000000..6d3c6cd --- /dev/null +++ b/frontend/matrix-middle-service-web/src/api/utils.ts @@ -0,0 +1,65 @@ +import axios, {AxiosInstance, AxiosRequestConfig, AxiosResponse, InternalAxiosRequestConfig} from "axios"; +import {useQuasar} from "quasar"; +export function getAxiosInstance(axiosRequestConfig: AxiosRequestConfig): AxiosInstance { + let instance = axios.create(axiosRequestConfig); + // 全局 请求拦截器 + instance.interceptors.request.use(async (config: InternalAxiosRequestConfig) => { + let headers = config.headers || {} + return config; + }) + // 全局 响应拦截器 + instance.interceptors.response.use(successCB, rejectCB); + return instance; +} + + +// 请求成功回调 +export function successCB(response: AxiosResponse | Promise): AxiosResponse | Promise { + function processResponse(response: AxiosResponse) { + if (response.status === 200) { // 响应成功 + if (response.data.code === 401) { + const $q = useQuasar() + $q.notify({ + position: "top", + color: 'negative', + message: "登录状态失效, 请重新登录", + icon: 'report_problem' + }) + console.log(response,response.data.msg) + } else if (response.data.code === 403) { + setTimeout(() => { + console.log(response,response.data.msg) + }, 0) + } + return response; + } else { + return Promise.reject(response); + } + } + + if (response instanceof Promise) { + let resp: AxiosResponse + return new Promise((resolve)=>{ + response.then((r: AxiosResponse) => { + resp = r; + resolve(processResponse(resp)) + }); + }) + } else { + return processResponse(response); + } +} + +// 请求失败回调 +export function rejectCB(error: any): any { + let response = error.response + if(response.status === 401){ + return response; + } else if(response.status === 403){ + setTimeout(() => { + console.log(response.data.msg) + }, 0) + return response; + } + return Promise.reject(error); +} diff --git a/frontend/matrix-middle-service-web/src/components/DateTimeSelector.vue b/frontend/matrix-middle-service-web/src/components/DateTimeSelector.vue new file mode 100644 index 0000000..cd8434a --- /dev/null +++ b/frontend/matrix-middle-service-web/src/components/DateTimeSelector.vue @@ -0,0 +1,251 @@ + + + + + diff --git a/frontend/matrix-middle-service-web/src/components/HelloWorld.vue b/frontend/matrix-middle-service-web/src/components/HelloWorld.vue index 00571f1..c7dbdd7 100644 --- a/frontend/matrix-middle-service-web/src/components/HelloWorld.vue +++ b/frontend/matrix-middle-service-web/src/components/HelloWorld.vue @@ -1,9 +1,16 @@