File tree Expand file tree Collapse file tree 4 files changed +66
-6
lines changed
Expand file tree Collapse file tree 4 files changed +66
-6
lines changed Original file line number Diff line number Diff line change 1919 "axios" : " ^1.12.2" ,
2020 "react" : " ^18.2.0" ,
2121 "react-dom" : " ^18.2.0" ,
22- "react-router-dom " : " ^6.30.1 " ,
23- "react-json-view-lite " : " ^2.5.0 "
22+ "react-json-view-lite " : " ^2.5.0 " ,
23+ "react-router-dom " : " ^6.30.1 "
2424 },
2525 "devDependencies" : {
2626 "@types/react" : " ^18.2.0" ,
2727 "@types/react-dom" : " ^18.2.0" ,
2828 "@vitejs/plugin-react" : " ^4.2.0" ,
29+ "axios" : " ^1.12.2" ,
2930 "typescript" : " ^5.3.0" ,
30- "vite" : " ^5.0.0"
31+ "vite" : " ^5.0.0" ,
32+ "vite-plugin-html" : " ^3.2.2"
3133 },
3234 "repository" : " git@github.com:antvis/AVA.git"
3335}
Original file line number Diff line number Diff line change @@ -2,10 +2,51 @@ import React from 'react';
22
33import ReactDOM from 'react-dom/client' ;
44
5+ import axios from 'axios' ;
6+
57import App from './App' ;
68
79import './index.css' ;
810
11+ axios . interceptors . request . use (
12+ ( config ) => {
13+ if ( config . url && config . url . includes ( 'https://api.tbox.cn/api/completion' ) ) {
14+ const originData = JSON . parse ( config . data ) ;
15+ config . headers [ 'x-webgw-version' ] = '2.0' ;
16+ config . headers [ 'x-webgw-appid' ] = '180020010001266875' ;
17+ config . headers [ 'content-type' ] = 'application/json' ;
18+ config . url = 'https://webgw-internet.alipay.com/antvservice/api/dsl' ;
19+ config . data = JSON . stringify ( {
20+ sceneName : 'tbox_agent' ,
21+ data : {
22+ appId : '202511APbBtP00568478' ,
23+ input : originData . inputs . input ,
24+ } ,
25+ } ) ;
26+ }
27+ return config ;
28+ } ,
29+ ( error ) => {
30+ return Promise . reject ( error ) ;
31+ }
32+ ) ;
33+
34+ axios . interceptors . response . use ( ( response ) => {
35+ if (
36+ response . request . responseURL &&
37+ response . request . responseURL . includes ( 'https://webgw-internet.alipay.com/antvservice/api/dsl' )
38+ ) {
39+ response . data . data = {
40+ result : [
41+ {
42+ chunk : response . data . data ,
43+ } ,
44+ ] ,
45+ } ;
46+ }
47+ return response ;
48+ } ) ;
49+
950ReactDOM . createRoot ( document . getElementById ( 'root' ) ! ) . render (
1051 < React . StrictMode >
1152 < App />
Original file line number Diff line number Diff line change 11import { defineConfig } from 'vite' ;
22import react from '@vitejs/plugin-react' ;
3+ import { createHtmlPlugin } from 'vite-plugin-html' ;
34
45// https://vitejs.dev/config/
56export default defineConfig ( {
6- plugins : [ react ( ) ] ,
7+ plugins : [
8+ react ( ) ,
9+ createHtmlPlugin ( {
10+ inject : {
11+ tags : [
12+ {
13+ tag : 'script' ,
14+ attrs : { src : 'https://gw.alipayobjects.com/os/lib/axios/1.12.2/dist/axios.min.js' } ,
15+ injectTo : 'head' ,
16+ } ,
17+ ] ,
18+ } ,
19+ } ) ,
20+ ] ,
721 server : {
822 port : 3001 ,
923 open : true ,
@@ -13,4 +27,9 @@ export default defineConfig({
1327 exclude : [ '@antv/ava' ] ,
1428 include : [ 'color-blind' , 'quantize' ] ,
1529 } ,
30+ build : {
31+ rollupOptions : {
32+ external : [ 'axios' ] ,
33+ } ,
34+ } ,
1635} ) ;
Original file line number Diff line number Diff line change @@ -7,10 +7,8 @@ if (window) {
77 ( window as any ) . reactJsonViewLite = require ( 'react-json-view-lite' ) ;
88 const axios = require ( 'axios' ) ;
99
10- /** 代理百宝箱请求 */
1110 axios . interceptors . request . use (
1211 ( config ) => {
13- // 检查请求URL是否匹配目标域名
1412 if ( config . url && config . url . includes ( 'https://api.tbox.cn/api/completion' ) ) {
1513 const originData = JSON . parse ( config . data ) ;
1614 config . headers [ 'x-webgw-version' ] = '2.0' ;
You can’t perform that action at this time.
0 commit comments