客户端请求增加 X-Web-Version

dev/timezone
Jimmy Liow 2 years ago
parent f8aa04245c
commit 5ed7d97f50

@ -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;

@ -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())

@ -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 }) {

@ -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})`);
},
};

Loading…
Cancel
Save