提交 9bd6f7eb authored 作者: 王鹏飞's avatar 王鹏飞

chore: update

上级 e8fff8e5
# VITE_API_URL_WORD = https://zijingebook.ezijing.com/file/
VITE_API_URL_WORD = https://zijingebook.ezijing.com/api
VITE_API_URL = https://zijingebook.ezijing.com/api
VITE_API_BASE_API_PREFFIX = /api
VITE_API_PREFIX = /api
# VITE_API_WEBSOCKET_URL = wss://zijingebook.ezijing.com
VITE_API_WEBSOCKET_URL = wss://zijingebook.ezijing.com/ws
VITE_API_OPENAI_URL = https://model-platform-skyagents.tiangong.cn
\ No newline at end of file
# VITE_API_URL_WORD = https://book-admin-web.ezijing.com/api
VITE_API_URL_WORD = https://zijingebook.ezijing.com/api
VITE_API_URL = https://zijingebook.ezijing.com/api
VITE_API_BASE_API_PREFFIX = /api
VITE_API_PREFIX = /api
# VITE_API_WEBSOCKET_URL = wss://zijingebook.ezijing.com
VITE_API_WEBSOCKET_URL = wss://zijingebook.ezijing.com/ws
VITE_API_OPENAI_URL = https://model-platform-skyagents.tiangong.cn
\ No newline at end of file
import axios from '@/utils/wenku'
// 文件上传前置
export function uploadPrepare(data) {
return axios.post('/api/wenku/wenchain/partner/uploadprepare', data)
}
// 生成论文大纲
export function usePaperOutline() {}
// 文档下载
export function useDownload() {}
// 文档上传
export function useUpload() {}
......@@ -13,7 +13,7 @@ import {
Form,
Modal,
message,
Image
Image,
} from 'antd'
const { RangePicker } = DatePicker
const { TextArea } = Input
......@@ -46,7 +46,7 @@ const Sensitive = () => {
const [isadd, setisadd] = useState(true)
const [word_name, setword_name] = useState('')
const [file, setFile] = useState('')
const handleEdit = obj => {
const handleEdit = (obj) => {
setid(obj.id)
form.setFieldsValue(obj)
setisadd(false)
......@@ -59,7 +59,7 @@ const Sensitive = () => {
setData(list)
setLoading(false)
}
const changeWord = ev => {
const changeWord = (ev) => {
let val = ev.target.value
setword_name(val)
if (val == '') {
......@@ -69,7 +69,7 @@ const Sensitive = () => {
const handleFilter = async () => {
init({ word_name })
}
const submitForm = async obj => {
const submitForm = async (obj) => {
console.log('点解了编辑的提交表单')
let bool
if (isadd) {
......@@ -77,7 +77,7 @@ const Sensitive = () => {
} else {
bool = await editWords({
...obj,
id
id,
})
}
bool && init()
......@@ -106,7 +106,7 @@ const Sensitive = () => {
}
setFile(file)
return false
}
},
}
const [importRes, setimportRes] = useState(false)
const [importMsg, setimportMsg] = useState(false)
......@@ -129,7 +129,7 @@ const Sensitive = () => {
}
// 下载模板
const handleDownload = async () => {
window.open(import.meta.env.VITE_API_URL_WORD + '/敏感词导入示例.xlsx')
window.open(import.meta.env.VITE_API_URL + '/敏感词导入示例.xlsx')
}
useEffect(() => {
if (!showModal) {
......@@ -146,19 +146,19 @@ const Sensitive = () => {
title: 'ID',
key: 'id',
dataIndex: 'id',
align: 'center'
align: 'center',
},
{
title: '敏感词',
key: 'word_name',
dataIndex: 'word_name',
align: 'center'
align: 'center',
},
{
title: '创建时间',
key: 'create_time',
dataIndex: 'create_time',
align: 'center'
align: 'center',
},
{
title: '操作',
......@@ -183,8 +183,8 @@ const Sensitive = () => {
</Button>
</Space>
)
}
}
},
},
]
return (
<div className="classify">
......@@ -210,7 +210,7 @@ const Sensitive = () => {
display: 'inline-block',
width: '11px',
height: '10px',
pointerEvents: 'none'
pointerEvents: 'none',
}}>
<Image src={reset} />
</span>
......@@ -226,7 +226,7 @@ const Sensitive = () => {
display: 'inline-block',
width: '13px',
height: '12px',
pointerEvents: 'none'
pointerEvents: 'none',
}}>
<Image src={filter} />
</span>
......@@ -234,7 +234,7 @@ const Sensitive = () => {
ghost
onClick={() => {
setPage(1)
Object.values(filterObj).some(item => item) ? init(filterObj) : init()
Object.values(filterObj).some((item) => item) ? init(filterObj) : init()
}}>
筛选
</Button>
......@@ -247,12 +247,12 @@ const Sensitive = () => {
display: 'inline-block',
width: '10px',
height: '12px',
pointerEvents: 'none'
pointerEvents: 'none',
}}>
<Image src={reload} />
</span>
}
onClick={() => (Object.values(filterObj).some(item => item) ? init(filterObj) : init())}>
onClick={() => (Object.values(filterObj).some((item) => item) ? init(filterObj) : init())}>
刷新
</Button>
</Space>
......@@ -269,7 +269,7 @@ const Sensitive = () => {
display: 'inline-block',
width: '11px',
height: '12px',
pointerEvents: 'none'
pointerEvents: 'none',
}}>
<Image src={imports} />
</span>
......@@ -290,7 +290,7 @@ const Sensitive = () => {
display: 'inline-block',
width: '13px',
height: '12px',
pointerEvents: 'none'
pointerEvents: 'none',
}}>
<Image src={Add} />
</span>
......@@ -389,7 +389,7 @@ const Sensitive = () => {
key="err"
ghost
onClick={() => {
window.open(import.meta.env.VITE_API_URL_WORD + '/敏感词导入失败.xlsx')
window.open(import.meta.env.VITE_API_URL + '/敏感词导入失败.xlsx')
}}>
下载导入失败的数据
</Button>
......@@ -401,7 +401,7 @@ const Sensitive = () => {
setUploadModal(false)
}}>
完成
</Button>
</Button>,
]}
/>
)}
......
......@@ -21,7 +21,7 @@ function showLoginModal() {
onOk() {
localStorage.removeItem('kiwi.gpt.token')
location.href = '/login'
}
},
})
}
......@@ -31,14 +31,14 @@ function alphabeticalSort(a, b) {
}
const httpRequest = axios.create({
// baseURL: import.meta.env.VITE_API_BASE_API_PREFFIX,
// baseURL: import.meta.env.VITE_API_PREFIX,
// timeout: 60000,
withCredentials: true
withCredentials: true,
})
// 请求拦截器
httpRequest.interceptors.request.use(
config => {
(config) => {
const token = getToken()
// 应用设置
const appId = 'TzEU5jPk2tu80266'
......@@ -51,7 +51,7 @@ httpRequest.interceptors.request.use(
appSecret,
timestamp,
token,
url: config.url
url: config.url,
}
const signStr = qs.stringify(signData, { sort: alphabeticalSort })
......@@ -64,7 +64,7 @@ httpRequest.interceptors.request.use(
AppId: appId,
AppSecret: appSecret,
Timestamp: timestamp,
Sign: sign
Sign: sign,
}
config.headers = { ...config.headers, ...defaultHeaders }
......@@ -75,14 +75,14 @@ httpRequest.interceptors.request.use(
return config
},
error => {
(error) => {
return Promise.reject(error)
}
)
// 响应拦截器
httpRequest.interceptors.response.use(
response => {
(response) => {
const { data } = response
if (data.code === 401 || data.code === 403) {
if (location.pathname !== '/login') {
......@@ -96,7 +96,7 @@ httpRequest.interceptors.response.use(
}
return data
},
error => {
(error) => {
if (error.response) {
const { status, data = {} } = error.response
if (status === 401 || status === 403) {
......
......@@ -150,8 +150,8 @@ export const findParentsExpanded = (treeData, targetKey = 'id') => {
export const treeRouterData = (source, id = 'menuId', parentId = 'pid', children = 'children') => {
const cloneData = JSON.parse(JSON.stringify(source))
if (source.length === 0) return source
return cloneData.filter(father => {
const branchArr = cloneData.filter(child => parseFloat(father[id]) === parseFloat(child[parentId]))
return cloneData.filter((father) => {
const branchArr = cloneData.filter((child) => parseFloat(father[id]) === parseFloat(child[parentId]))
father[children] = branchArr.length > 0 ? branchArr : null
return father[parentId] === 0
......@@ -162,13 +162,13 @@ export const treeRouterData = (source, id = 'menuId', parentId = 'pid', children
export function convertToAntdTreeData(data, target = 'label') {
const antdTreeData = []
const convertNode = node => {
const convertNode = (node) => {
const antdTreeNode = {
...node,
title: node[target],
key: node.id,
select: false,
edit: false
edit: false,
}
if (node.children && node.children.length > 0) {
......@@ -261,7 +261,7 @@ export const findAllParents = (tree, key, value, parents = []) => {
export const findAllChildren = (tree, key, value) => {
for (const node of tree) {
const currentKey = node[key]
const currentChildren = (node.children || []).map(child => child[key])
const currentChildren = (node.children || []).map((child) => child[key])
if (currentKey === value) {
return currentChildren
......@@ -275,11 +275,11 @@ export const findAllChildren = (tree, key, value) => {
}
// 将树形结构转为一维数组
export const treeDataToArray = source => {
export const treeDataToArray = (source) => {
const res = []
// 第二种方式
source.length &&
source.forEach(item => {
source.forEach((item) => {
res.push(item)
item.children && res.push(...treeDataToArray(item.children))
})
......@@ -306,7 +306,7 @@ export const getStyleValue = (elem, styleKey) => {
}
// 根据id 查找树中的节点内容
export const findFirstNotHasChildren = tree => {
export const findFirstNotHasChildren = (tree) => {
if (tree.length > 0) {
if (tree[0].children && tree[0].children.length > 0) {
return findFirstNotHasChildren(tree[0].children)
......@@ -321,7 +321,7 @@ export const findParentLevelOne = (data, key = 'id', value) => {
for (let i = 0; i < data.length; i++) {
const item = data[i]
if (item.children) {
const child = item.children.find(c => c[key] === value)
const child = item.children.find((c) => c[key] === value)
if (child) {
// 找到目标子元素,返回其父元素
return item
......@@ -340,11 +340,11 @@ export const findParentLevelOne = (data, key = 'id', value) => {
// 找所在位置
export const findTreeToIndex = (data, key, value) => {
let index = data.findIndex(item => item[key] === value)
let index = data.findIndex((item) => item[key] === value)
return index > -1 ? index : -1
}
export const hexToRgb = hex => {
export const hexToRgb = (hex) => {
// 移除前缀#符号
let hexTemp = hex.replace(/^\s*#|\s*$/g, '')
......@@ -361,7 +361,7 @@ export const hexToRgb = hex => {
? {
r: parseInt(rgb[1], 16),
g: parseInt(rgb[2], 16),
b: parseInt(rgb[3], 16)
b: parseInt(rgb[3], 16),
}
: null
}
......@@ -420,8 +420,8 @@ export const clacTopicText = (type, radio, checkbox, judge, fill, textarea) => {
}
export const downloadFile = (res = '') => {
window.open(import.meta.env.VITE_API_URL_WORD + '/' + res)
window.open(import.meta.env.VITE_API_URL + '/' + res)
}
// 延时函数
export const sleep = time => new Promise(resolve => setTimeout(resolve, time))
export const sleep = (time) => new Promise((resolve) => setTimeout(resolve, time))
......@@ -18,8 +18,8 @@ let pending = [] // 存储每个ajax请求的取消函数和ajax标识
let CancelToken = Axios.CancelToken
// 取消请求 方法
// 取消请求 方法
let cancelPending = config => {
pending.forEach(item => {
let cancelPending = (config) => {
pending.forEach((item) => {
item.cancel() // 取消请求
})
pending = [] // 清空数组
......@@ -28,8 +28,8 @@ let cancelPending = config => {
// Axios.defaults.withCredentials = true; // 默认为false 表示跨域请求时是否需要使用凭证
const axios = Axios.create({
baseURL: import.meta.env.VITE_API_BASE_API_PREFFIX,
timeout: 999999
baseURL: import.meta.env.VITE_API_PREFIX,
timeout: 999999,
})
function getToken() {
......@@ -37,7 +37,7 @@ function getToken() {
}
// 请求拦截器
axios.interceptors.request.use(
config => {
(config) => {
// 登录流程控制中,根据本地是否存在token判断用户的登录情况
// 但是即使token存在,也有可能token是过期的,所以在每次的请求头中携带token
// 后台根据携带的token判断用户的登录情况,并返回给我们对应的状态码
......@@ -68,7 +68,7 @@ axios.interceptors.request.use(
if (config.url.indexOf('.tiangong.cn') > -1) {
s = config.url
} else {
s = import.meta.env.VITE_API_URL_WORD + config.url
s = import.meta.env.VITE_API_URL + config.url
s = s.replace('/api', '')
}
signData.url = decodeURIComponent(s)
......@@ -105,7 +105,7 @@ axios.interceptors.request.use(
} */
// 在请求拦截器中,为每个请求创建一个取消令牌,并将其添加到pending数组
config.cancelToken = new CancelToken(cancel => {
config.cancelToken = new CancelToken((cancel) => {
pending.push({ url: config.url, cancel })
})
......@@ -116,7 +116,7 @@ axios.interceptors.request.use(
return config
},
error => {
(error) => {
Promise.reject(error)
}
)
......@@ -139,7 +139,7 @@ axios.interceptors.response.use(
onOk() {
localStorage.removeItem('kiwi.gpt.token')
window.location.pathname = '/login'
}
},
})
cancelPending(response.config) // 取消后续请求
return Promise.reject(response)
......@@ -147,7 +147,7 @@ axios.interceptors.response.use(
}
return response
},
error => {
(error) => {
const { response = {}, config = {} } = error
console.error('我要的response', response, error)
const status = get(response, 'status', 0)
......@@ -164,7 +164,7 @@ axios.interceptors.response.use(
onOk() {
localStorage.removeItem('kiwi.gpt.token')
window.location.href = '/login'
}
},
})
}
break
......@@ -179,27 +179,27 @@ axios.interceptors.response.use(
onOk() {
localStorage.removeItem('kiwi.gpt.token')
window.location.href = '/login'
}
},
})
}
break
case 404:
notification.error({
message: 'Error: 404 Not Found',
description: `url: ${urlPath}, The requested URL was not found on the server.`
description: `url: ${urlPath}, The requested URL was not found on the server.`,
})
break
case 500:
notification.error({
message: 'Error: 500',
description: `url: ${urlPath}`
description: `url: ${urlPath}`,
})
break
default:
if (status) {
notification.error({
message: `Error: ${status}`,
description: `url: ${urlPath}`
description: `url: ${urlPath}`,
})
}
}
......
import axios from './request';
import { get } from 'lodash-es';
import { message } from 'antd';
import axios from './request'
import { get } from 'lodash-es'
import { message } from 'antd'
// 统一上传
const uploadFiles = async (obj) => {
export const uploadFiles = async (obj) => {
try {
const res = await axios.post('/common/OssUpload/uploadFiles', obj, {
headers: {
'Content-Type': 'multipart/form-data',
},
});
const code = get(res, 'data.code', 0);
const data = get(res, 'data.data', []);
const msg = get(res, 'data.message', '数据获取失败!');
})
const code = get(res, 'data.code', 0)
const data = get(res, 'data.data', [])
const msg = get(res, 'data.message', '数据获取失败!')
if (code === 200) {
message.success(msg);
return data;
message.success(msg)
return data
} else {
message.error(msg);
return false;
message.error(msg)
return false
}
} catch (error) {
return false;
return false
}
};
export { uploadFiles };
}
import axios from 'axios'
import md5 from 'js-md5'
import { fetchEventSource } from '@fortaine/fetch-event-source'
export const PartnerID = '8980934e767f5acfa1c7cd92'
export const PartnerKey = 'N64IJm!e#iAWsac'
export const generateHeaders = () => {
const TS = Date.now()
return {
'Content-Type': 'application/json',
PartnerID,
TS,
Version: '1.0.1',
Authorization: md5(`${PartnerID}+${PartnerKey}+${TS}`),
}
}
const httpRequest = axios.create({
withCredentials: true,
})
// 请求拦截器
httpRequest.interceptors.request.use((config) => {
config.headers = { ...config.headers, ...generateHeaders() }
return config
})
export default httpRequest
export async function fetchEventSourceFn(url, options) {
const messages = []
const defaultOptions = {
method: 'POST',
headers: generateHeaders(),
onmessage(res) {
const message = JSON.parse(res.data)
messages.push(message)
},
}
return await fetchEventSource(url, { ...defaultOptions, ...options }).then(() => messages)
}
......@@ -14,28 +14,28 @@ export default defineConfig(({ mode }) => {
host: 'dev.ezijing.com',
proxy: {
'/api': {
target: env.VITE_API_URL_WORD,
target: env.VITE_API_URL,
changeOrigin: true,
rewrite: path => path.replace(/^\/api/, '') // 将请求路径中的“/api”前缀替换为空字符串
rewrite: (path) => path.replace(/^\/api/, ''), // 将请求路径中的“/api”前缀替换为空字符串
},
'/openapi': {
target: env.VITE_API_OPENAI_URL,
'/api/wenku': {
target: 'https://wenchain.baidu.com',
changeOrigin: true,
rewrite: path => path.replace(/^\/openapi/, '/openapi') // 将请求路径中的“/api”前缀替换为空字符串
}
}
rewrite: (path) => path.replace(/^\/api\/wenku/, '/'), // 将请求路径中的“/api”前缀替换为空字符串
},
},
},
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
'@': fileURLToPath(new URL('./src', import.meta.url)),
},
},
css: {
preprocessorOptions: {
less: {
javascriptEnabled: true
}
}
}
javascriptEnabled: true,
},
},
},
}
})
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论