From 5ed7d97f50b233afcee0b7680675add2190219e3 Mon Sep 17 00:00:00 2001 From: Jimmy Liow Date: Mon, 29 Apr 2024 09:29:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=A2=E6=88=B7=E7=AB=AF=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20X-Web-Version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/config.js | 2 ++ src/utils/request.js | 30 +++++++++++++++++++++++------- src/views/orders/Follow.jsx | 6 ++---- vite.config.js | 1 - 4 files changed, 27 insertions(+), 12 deletions(-) diff --git a/src/config.js b/src/config.js index 19ac676..d6418da 100644 --- a/src/config.js +++ b/src/config.js @@ -8,3 +8,5 @@ export const DATE_FORMAT = 'YYYY-MM-DD'; export const OSS_URL_CN = 'https://haina-sale-system.oss-cn-shenzhen.aliyuncs.com/WAMedia/'; export const OSS_URL_AP = 'https://hiana-crm.oss-ap-southeast-1.aliyuncs.com/WAMedia/'; export const OSS_URL = OSS_URL_AP; + +export const WEB_VERSION = process.env.NODE_ENV === 'production' ? `__BUILD_VERSION__` : process.env.NODE_ENV; diff --git a/src/utils/request.js b/src/utils/request.js index 7de1c15..ba4cd84 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -1,3 +1,6 @@ + +import { WEB_VERSION } from '@/config' + function checkStatus(response) { if (response.status >= 200 && response.status < 300) { return response @@ -12,8 +15,12 @@ function checkStatus(response) { } export function fetchText(url) { - return fetch(url) - .then(checkStatus) + return fetch(url, { + method: 'GET', + headers: { + 'X-Web-Version': WEB_VERSION + } + }).then(checkStatus) .then(response => response.text()) .catch(error => { throw error @@ -23,8 +30,12 @@ export function fetchText(url) { export function fetchJSON(url, data) { const params = data ? new URLSearchParams(data).toString() : ''; const ifp = url.includes('?') ? '&' : '?'; - return fetch(`${url}${ifp}${params}`) - .then(checkStatus) + return fetch(`${url}${ifp}${params}`, { + method: 'GET', + headers: { + 'X-Web-Version': WEB_VERSION + } + }).then(checkStatus) .then(response => response.json()) .catch(error => { throw error; @@ -34,7 +45,10 @@ export function fetchJSON(url, data) { export function postForm(url, data) { return fetch(url, { method: 'POST', - body: data + body: data, + headers: { + 'X-Web-Version': WEB_VERSION + } }).then(checkStatus) .then(response => response.json()) .catch(error => { @@ -47,7 +61,8 @@ export function postJSON(url, obj) { method: 'POST', body: JSON.stringify(obj), headers: { - 'Content-type': 'application/json; charset=UTF-8' + 'Content-type': 'application/json; charset=UTF-8', + 'X-Web-Version': WEB_VERSION } }).then(checkStatus) .then(response => response.json()) @@ -61,7 +76,8 @@ export function postStream(url, obj) { method: 'POST', body: JSON.stringify(obj), headers: { - 'Content-type': 'application/octet-stream' + 'Content-type': 'application/octet-stream', + 'X-Web-Version': WEB_VERSION } }).then(checkStatus) .then(response => response.json()) diff --git a/src/views/orders/Follow.jsx b/src/views/orders/Follow.jsx index d715e67..45bd68f 100644 --- a/src/views/orders/Follow.jsx +++ b/src/views/orders/Follow.jsx @@ -3,15 +3,14 @@ import useAuthStore from '@/stores/AuthStore' import useFormStore from '@/stores/FormStore' import { useOrderStore, OrderLabelDefaultOptions, OrderStatusDefaultOptions, RemindStateDefaultOptions } from '@/stores/OrderStore' import { copy, isNotEmpty, isEmpty } from '@/utils/commons' -import { InfoCircleTwoTone, MailTwoTone, MessageTwoTone, PhoneTwoTone, WhatsAppOutlined } from '@ant-design/icons' +import { WhatsAppOutlined } from '@ant-design/icons' import { App, Badge, Button, Col, DatePicker, Empty, Flex, Form, Input, - Radio, Row, Typography, - Select, Space, Switch, Table, + Radio, Row, Select, Space, Switch, Table, Tabs, Divider, Tag, Tooltip } from 'antd' @@ -21,7 +20,6 @@ import { Link } from 'react-router-dom' import { useShallow } from 'zustand/react/shallow' const { RangePicker } = DatePicker -const { Title } = Typography const AdvanceSearchForm = memo(function noName({ initialValues, onSubmit }) { diff --git a/vite.config.js b/vite.config.js index a941e50..d3aeb52 100644 --- a/vite.config.js +++ b/vite.config.js @@ -10,7 +10,6 @@ const today = new dayjs().format('YYYY-MM-DD HH:mm:ss') const buildDatePlugin = () => { return { transformIndexHtml(html) { - const dataString = new Date().toISOString(); return html.replace(/%BUILD_VERSION%/, `${packageJson.version}(${today})`); }, };