art: 🎨 页面全局提示
This commit is contained in:
parent
6e4eb46da6
commit
0b6c1e9000
@ -29,7 +29,7 @@ export default [
|
|||||||
dictionary: true,
|
dictionary: true,
|
||||||
sensor: true,
|
sensor: true,
|
||||||
station: true,
|
station: true,
|
||||||
material: true,
|
material: true,
|
||||||
},
|
},
|
||||||
ecmaVersion: 2020,
|
ecmaVersion: 2020,
|
||||||
parser: parserVue,
|
parser: parserVue,
|
||||||
|
@ -1,22 +1,22 @@
|
|||||||
/**
|
/**
|
||||||
* @desc 登录
|
* @desc 登录
|
||||||
*/
|
*/
|
||||||
import { defaultSuccess, defaultError, http } from '@/plugins/axios';
|
import { defaultSuccess, defaultError, http } from '@/plugins/axios'
|
||||||
import type { AxiosResponse } from 'axios';
|
import type { AxiosResponse } from 'axios'
|
||||||
export default async function (
|
export default async function (
|
||||||
/** 请求体 */
|
/** 请求体 */
|
||||||
requestBody: auth.LoginDTO,
|
requestBody: auth.LoginDTO,
|
||||||
|
|
||||||
success: (data: auth.AuthUser) => void = defaultSuccess,
|
success: (data: auth.AuthUser) => void = defaultSuccess,
|
||||||
fail: (error: { code: string; error?: string }) => void = defaultError,
|
fail: (error: { code: string; error?: string }) => void = defaultError,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
return http({
|
return http({
|
||||||
method: 'post',
|
method: 'post',
|
||||||
url: `/auth/login`,
|
url: `/auth/login`,
|
||||||
data: requestBody,
|
data: requestBody,
|
||||||
})
|
})
|
||||||
.then((data: AxiosResponse<auth.AuthUser, unknown>) => {
|
.then((data: AxiosResponse<auth.AuthUser, unknown>) => {
|
||||||
success(data.data);
|
success(data.data)
|
||||||
})
|
})
|
||||||
.catch((error: { code: string; error?: string }) => fail(error));
|
.catch((error: { code: string; error?: string }) => fail(error))
|
||||||
}
|
}
|
||||||
|
@ -1,22 +1,22 @@
|
|||||||
/**
|
/**
|
||||||
* @desc 增加/编辑物料
|
* @desc 增加/编辑物料
|
||||||
*/
|
*/
|
||||||
import { defaultSuccess, defaultError, http } from '@/plugins/axios';
|
import { defaultSuccess, defaultError, http } from '@/plugins/axios'
|
||||||
import type { AxiosResponse } from 'axios';
|
import type { AxiosResponse } from 'axios'
|
||||||
export default async function (
|
export default async function (
|
||||||
/** 请求体 */
|
/** 请求体 */
|
||||||
requestBody: material.Material,
|
requestBody: material.Material,
|
||||||
|
|
||||||
success: (data: material.Material) => void = defaultSuccess,
|
success: (data: material.Material) => void = defaultSuccess,
|
||||||
fail: (error: { code: string; error?: string }) => void = defaultError,
|
fail: (error: { code: string; error?: string }) => void = defaultError,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
return http({
|
return http({
|
||||||
method: 'put',
|
method: 'put',
|
||||||
url: `/material`,
|
url: `/material`,
|
||||||
data: requestBody,
|
data: requestBody,
|
||||||
})
|
})
|
||||||
.then((data: AxiosResponse<material.Material, unknown>) => {
|
.then((data: AxiosResponse<material.Material, unknown>) => {
|
||||||
success(data.data);
|
success(data.data)
|
||||||
})
|
})
|
||||||
.catch((error: { code: string; error?: string }) => fail(error));
|
.catch((error: { code: string; error?: string }) => fail(error))
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ import { http } from '@/settings/http'
|
|||||||
import { useUserStore } from '@/stores/user'
|
import { useUserStore } from '@/stores/user'
|
||||||
import axios, { InternalAxiosRequestConfig, type AxiosError, type AxiosResponse } from 'axios'
|
import axios, { InternalAxiosRequestConfig, type AxiosError, type AxiosResponse } from 'axios'
|
||||||
import type { App } from 'vue'
|
import type { App } from 'vue'
|
||||||
import router from '@/router'
|
import { notification } from 'ant-design-vue'
|
||||||
|
|
||||||
export interface GlobalError {
|
export interface GlobalError {
|
||||||
/** 错误码 */
|
/** 错误码 */
|
||||||
@ -24,9 +24,13 @@ export function defaultSuccess(data: unknown): void {
|
|||||||
console.log(data)
|
console.log(data)
|
||||||
}
|
}
|
||||||
export function defaultError(error: { code: string; error?: string }): void {
|
export function defaultError(error: { code: string; error?: string }): void {
|
||||||
if (error) {
|
window.console.log(error)
|
||||||
router.push({ path: '/message', query: { status: error.code, message: error.error } })
|
notification.error({
|
||||||
}
|
message: '操作异常: ',
|
||||||
|
placement: 'top',
|
||||||
|
description: error.error + '(' + error.code + ')',
|
||||||
|
duration: null,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
const config = {
|
const config = {
|
||||||
baseURL: http.prefix,
|
baseURL: http.prefix,
|
||||||
|
@ -59,7 +59,7 @@ export default defineConfig(({ mode }) => {
|
|||||||
open: true,
|
open: true,
|
||||||
proxy: {
|
proxy: {
|
||||||
'/api': {
|
'/api': {
|
||||||
// target: 'https://iot.riemann.tech/api/',
|
// target: 'https://ims.riemann.tech/api/',
|
||||||
target: 'http://127.0.0.1:8888',
|
target: 'http://127.0.0.1:8888',
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
rewrite: (path) => path.replace(/^\/api/, ''),
|
rewrite: (path) => path.replace(/^\/api/, ''),
|
||||||
|
93
vite.config.ts.timestamp-1735107646682-da78b7e5d1808.mjs
Normal file
93
vite.config.ts.timestamp-1735107646682-da78b7e5d1808.mjs
Normal file
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user