Skip to content

Commit

Permalink
fix(proxy): 本地代理问题
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxtuneLee committed Nov 13, 2022
1 parent 50e8104 commit 550ca83
Show file tree
Hide file tree
Showing 11 changed files with 189 additions and 7 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/node_modules
/build
/dist
/src/setupProxy.ts
7 changes: 6 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,10 @@
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"cSpell.words": ["antd"]
"cSpell.words": [
"antd"
],
"githubPullRequests.ignoredPullRequestBranches": [
"master"
]
}
Empty file removed niema.txt
Empty file.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"name": "approval-system",
"version": "0.1.0",
"private": true,
"proxy": "http://81.68.225.220:8080/",
"dependencies": {
"@ant-design/icons": "^4.7.0",
"@craco/craco": "^6.4.3",
Expand All @@ -20,6 +19,7 @@
"craco": "^0.0.3",
"craco-less": "^2.0.0",
"form-render": "^1.13.12",
"http-proxy-middleware": "^2.0.6",
"inquirer": "^8.2.4",
"react": "^18.1.0",
"react-dom": "^18.1.0",
Expand Down
3 changes: 1 addition & 2 deletions src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ import { message, notification } from 'antd'
import axios from 'axios'
import { Location, useNavigate } from 'react-router-dom'

const baseUrl = process.env.NODE_ENV === 'development' ? '' : '/api'
const baseUrl = process.env.NODE_ENV === 'development' ? '/api' : '/api'

export const apis = axios.create({
timeout: 10000,
baseURL: baseUrl,
})

Expand Down
5 changes: 3 additions & 2 deletions src/pages/registerDetail/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ function RegisterDetail() {
maxParti: 1,
isTeam: true,
})
const [canSubmit, setCanSubmit] = useState(false)
const { id } = useParams()
const [teamInfo, setTeamInfo] = useState<{
teamName: string
Expand Down Expand Up @@ -51,7 +52,7 @@ function RegisterDetail() {
duration: 50,
})
getCompetitionSignInfo(Number(id)).then((res) => {
console.log(res)
// console.log(res)
if (!res.data.data.isTeam) {
setCompetitionInfo({
maxParti: 1,
Expand Down Expand Up @@ -90,7 +91,7 @@ function RegisterDetail() {
}
})
getWorkInfo(Number(id)).then((res) => {
console.log(res)
// console.log(res)
setWorkData(res.data.data)
if (res.data.errMsg === '您还未上传作品') {
notification.warning({
Expand Down
58 changes: 58 additions & 0 deletions src/pages/workDetail/schema_example1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"type": "object",
"labelWidth": 120,
"properties": {
"是否为STITP项目": {
"enum": ["", ""],
"type": "string",
"title": "是否为STITP项目",
"widget": "radio",
"required": true,
"enumNames": ["", ""],
"order": 1
},
"申报书": {
"type": "string",
"widget": "customUpload",
"title": "申报书",
"required": true,
"props": { "inputName": "申报书", "accept": ".pdf" },
"order": 2
},
"研究报告": {
"type": "string",
"widget": "customUpload",
"title": "研究报告",
"required": true,
"props": { "inputName": "研究报告", "accept": ".pdf" },
"order": 3
},
"作品简介书": {
"type": "string",
"widget": "customUpload",
"title": "作品简介书",
"required": true,
"props": { "inputName": "作品简介书", "accept": ".pdf" },
"order": 4
},
"作品名称": { "type": "string", "props": {}, "title": "作品名称", "required": true, "order": 5 },
"作品类别": {
"enum": ["自然科学类学术论文", "哲学社会科学类社会调查报告和学术论文", "科技发明制作A类", "科技发明制作B类"],
"type": "string",
"title": "作品类别",
"widget": "select",
"required": true,
"enumNames": ["自然科学类学术论文", "哲学社会科学类社会调查报告和学术论文", "科技发明制作A类", "科技发明制作B类"],
"order": 6
},
"作品简介": {
"type": "string",
"props": {},
"title": "作品简介",
"format": "textarea",
"required": true,
"order": 7
}
},
"displayType": "column"
}
86 changes: 86 additions & 0 deletions src/pages/workDetail/schema_example2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
{
"type": "object",
"labelWidth": 120,
"properties": {
"作品名称": {
"title": "作品名称",
"type": "string",
"required": true,
"props": {},
"order": 1
},
"作品类型": {
"title": "作品类型",
"type": "string",
"enum": ["活动策划书", "项目企划书", "数字媒体作品"],
"enumNames": ["活动策划书", "项目企划书", "数字媒体作品"],
"widget": "radio",
"required": true,
"order": 2
},
"活动策划书": {
"title": "活动策划书",
"type": "string",
"widget": "customUpload",
"displayType": "column",
"description": "限制word文档",
"props": {
"inputName": "活动策划书",
"accept": ".doc,.docx,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document"
},
"order": 3
},
"项目企划书": {
"title": "项目企划书",
"type": "string",
"widget": "customUpload",
"displayType": "column",
"description": "限制word文档",
"props": {
"inputName": "项目企划书",
"accept": ".doc,.docx,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document"
},
"order": 4
},
"项目企划书现有成果资料附录": {
"title": "项目企划书现有成果资料附录",
"type": "string",
"widget": "customUpload",
"displayType": "column",
"description": "限制压缩包",
"props": { "inputName": "项目企划书现有成果资料附录", "accept": ".zip,.rar" },
"order": 5
},
"数字媒体作品": {
"title": "数字媒体作品",
"type": "string",
"widget": "customUpload",
"displayType": "column",
"description": "限制压缩包",
"props": { "inputName": "数字媒体作品", "accept": ".zip,.rar" },
"order": 6
},
"数字媒体作品说明书": {
"title": "数字媒体作品说明书",
"type": "string",
"widget": "customUpload",
"displayType": "column",
"description": "限制word文档",
"props": {
"inputName": "数字媒体作品说明书",
"accept": ".doc,.docx,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document"
},
"order": 7
},
"数字媒体作品参考资料": {
"title": "数字媒体作品参考资料",
"type": "string",
"widget": "customUpload",
"displayType": "column",
"description": "限制压缩包",
"props": { "inputName": "数字媒体作品参考资料", "accept": ".zip,.rar" },
"order": 8
}
},
"displayType": "column"
}
15 changes: 15 additions & 0 deletions src/setupProxy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const { createProxyMiddleware } = require('http-proxy-middleware')

module.exports = function (app) {
console.log('work')
app.use(
'/api',
createProxyMiddleware({
target: 'https://approve.sast.fun/api',
changeOrigin: true,
pathRewrite: {
'^/api': '',
},
}),
)
}
15 changes: 15 additions & 0 deletions src/setupProxy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const { createProxyMiddleware } = require('http-proxy-middleware')

module.exports = function (app) {
console.log('work')
app.use(
'/api',
createProxyMiddleware({
target: 'https://approve.sast.fun/api',
changeOrigin: true,
pathRewrite: {
'^/api': '',
},
}),
)
}
4 changes: 3 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6432,7 +6432,7 @@ http-proxy-agent@^4.0.1:
agent-base "6"
debug "4"

http-proxy-middleware@^2.0.3:
http-proxy-middleware@^2.0.3, http-proxy-middleware@^2.0.6:
version "2.0.6"
resolved "https://registry.yarnpkg.com/http-proxy-middleware/-/http-proxy-middleware-2.0.6.tgz#e1a4dd6979572c7ab5a4e4b55095d1f32a74963f"
integrity sha512-ya/UeJ6HVBYxrgYotAZo1KvPWlgB48kUJLDePFeneHsVujFaW5WNj2NgWCAE//B1Dl02BIfYlpNgBy8Kf8Rjmw==
Expand Down Expand Up @@ -11786,8 +11786,10 @@ watchpack@^1.7.4:
resolved "https://registry.npmmirror.com/watchpack/-/watchpack-1.7.5.tgz#1267e6c55e0b9b5be44c2023aed5437a2c26c453"
integrity sha512-9P3MWk6SrKjHsGkLT2KHXdQ/9SNkyoJbabxnKOoJepsvJjJG8uYTR3yTPxPQvNDI3w4Nz1xnE0TLHK4RIVe/MQ==
dependencies:
chokidar "^3.4.1"
graceful-fs "^4.1.2"
neo-async "^2.5.0"
watchpack-chokidar2 "^2.0.1"
optionalDependencies:
chokidar "^3.4.1"
watchpack-chokidar2 "^2.0.1"
Expand Down

0 comments on commit 550ca83

Please sign in to comment.