From 123fb3f1cc3a4128c059636d104bdacc9929f8ea Mon Sep 17 00:00:00 2001 From: guoapeng Date: Sat, 7 Jun 2025 15:18:22 +0800 Subject: [PATCH] fix: Update version to V0.0.4 --- package.json | 2 +- src/components/craft/AddCraft/index.vue | 2 +- src/libs/http(1).ts | 92 +++++++++++++++++++++++++++++++++ src/libs/http.ts | 92 --------------------------------- src/libs/utils.ts | 1 + src/views/home/index.vue | 65 +++++++++++------------ 6 files changed, 128 insertions(+), 126 deletions(-) create mode 100644 src/libs/http(1).ts diff --git a/package.json b/package.json index b3945ea..c0d03a4 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "separate-gold-web", "type": "module", - "version": "0.0.3", + "version": "0.0.4", "description": "", "author": "", "license": "ISC", diff --git a/src/components/craft/AddCraft/index.vue b/src/components/craft/AddCraft/index.vue index 30f165b..bf3989a 100644 --- a/src/components/craft/AddCraft/index.vue +++ b/src/components/craft/AddCraft/index.vue @@ -58,7 +58,7 @@ const okHandle = async () => { step.params.time = (step.params.minutes || 0) * 60 + (step.params.seconds || 0) || undefined } } - step.params.description = `${index}.` + step.params.description = `${index + 1}.` switch (step.method) { case 'clean': step.params.description += `针头高度${step.params.height}mm, 加${step.params.volume}ml水清洗${step.params.cycle}次` diff --git a/src/libs/http(1).ts b/src/libs/http(1).ts new file mode 100644 index 0000000..42dc3a1 --- /dev/null +++ b/src/libs/http(1).ts @@ -0,0 +1,92 @@ +import axios from 'axios' +import { FtMessage } from 'libs/message' +import { getToken } from 'libs/token' +import { HEADER_TOKEN_KEY } from '@/libs/constant' + +const http = axios.create({ + baseURL: import.meta.env.FT_API_BASE, + timeout: 1000 * 60, +}) + +// 请求拦截器 +http.interceptors.request.use( + (config) => { + if (getToken()) { + config.headers![HEADER_TOKEN_KEY] = getToken() + } + return config + }, + (error: any) => { + return Promise.reject(error) + }, +) + +// 响应拦截器 +http.interceptors.response.use( + (response) => { + if ( + response.status === 200 + && response.data.code !== '0' + ) { + // 返回错误拦截 + FtMessage.error(response.data.msg) + return Promise.reject(response) + } + else if ( + response.config.url?.includes('/files/download') + || response.config.url?.includes('downloadStream') + ) { + return response.data + } + else if (response.data instanceof Blob) { + return response.data + } + return response.data.data // 返回数据体 + }, + (error: any) => { + console.log(error) + if (error.response && error.response.status === 401) { + FtMessage.error('账号权限过期') + // TODO 登出 + } + else { + if (error.message.includes('timeout')) { + FtMessage.error('请求超时') + } + else if (error.message.includes('Network')) { + FtMessage.error('网络连接错误') + } + else { + FtMessage.error('接口请求失败') + } + error.response = { + data: { + res: false, + }, + } + return Promise.reject(error.response) + } + }, +) + +// 封装 GET 请求 +export function get(url: string, params?: any): Promise { + return http.get(url, { params }) +} + +// 封装 POST 请求 +export function post(url: string, data?: any): Promise { + return http.post(url, data) +} + +// 封装 PUT 请求 +export function put(url: string, data?: any): Promise { + return http.put(url, data) +} + +// 封装 DELETE 请求 +export function del(url: string, params?: any): Promise { + return http.delete(url, { params }) +} + +export default http diff --git a/src/libs/http.ts b/src/libs/http.ts index 42dc3a1..e69de29 100644 --- a/src/libs/http.ts +++ b/src/libs/http.ts @@ -1,92 +0,0 @@ -import axios from 'axios' -import { FtMessage } from 'libs/message' -import { getToken } from 'libs/token' -import { HEADER_TOKEN_KEY } from '@/libs/constant' - -const http = axios.create({ - baseURL: import.meta.env.FT_API_BASE, - timeout: 1000 * 60, -}) - -// 请求拦截器 -http.interceptors.request.use( - (config) => { - if (getToken()) { - config.headers![HEADER_TOKEN_KEY] = getToken() - } - return config - }, - (error: any) => { - return Promise.reject(error) - }, -) - -// 响应拦截器 -http.interceptors.response.use( - (response) => { - if ( - response.status === 200 - && response.data.code !== '0' - ) { - // 返回错误拦截 - FtMessage.error(response.data.msg) - return Promise.reject(response) - } - else if ( - response.config.url?.includes('/files/download') - || response.config.url?.includes('downloadStream') - ) { - return response.data - } - else if (response.data instanceof Blob) { - return response.data - } - return response.data.data // 返回数据体 - }, - (error: any) => { - console.log(error) - if (error.response && error.response.status === 401) { - FtMessage.error('账号权限过期') - // TODO 登出 - } - else { - if (error.message.includes('timeout')) { - FtMessage.error('请求超时') - } - else if (error.message.includes('Network')) { - FtMessage.error('网络连接错误') - } - else { - FtMessage.error('接口请求失败') - } - error.response = { - data: { - res: false, - }, - } - return Promise.reject(error.response) - } - }, -) - -// 封装 GET 请求 -export function get(url: string, params?: any): Promise { - return http.get(url, { params }) -} - -// 封装 POST 请求 -export function post(url: string, data?: any): Promise { - return http.post(url, data) -} - -// 封装 PUT 请求 -export function put(url: string, data?: any): Promise { - return http.put(url, data) -} - -// 封装 DELETE 请求 -export function del(url: string, params?: any): Promise { - return http.delete(url, { params }) -} - -export default http diff --git a/src/libs/utils.ts b/src/libs/utils.ts index a940326..c4cd46b 100644 --- a/src/libs/utils.ts +++ b/src/libs/utils.ts @@ -57,6 +57,7 @@ export const cmdNameMap = { liquid_motor_disable: '失能加液臂电机', door_enable: '使能门电机', door_disable: '失能门电机', + out_tray: '取出托盘', } diff --git a/src/views/home/index.vue b/src/views/home/index.vue index ccbcde1..5663bbf 100644 --- a/src/views/home/index.vue +++ b/src/views/home/index.vue @@ -1,5 +1,5 @@ @@ -204,7 +205,7 @@ const checkCraftVisible = ref(false) 放入托盘 - + 取出托盘 @@ -311,34 +312,34 @@ const checkCraftVisible = ref(false)