Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mr-julyedu
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
baiguangyao
mr-julyedu
Commits
586ac3f4
Commit
586ac3f4
authored
Apr 05, 2025
by
liuxinlin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 修改搜索接口
parent
c7d8c077
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
131 additions
and
22 deletions
+131
-22
.env.development
+2
-2
config/proxy.js
+44
-0
public/api.js
+7
-6
scripts/start.js
+3
-2
src/components/search/search-result.js
+53
-12
src/components/search/search-result.scss
+13
-0
src/utils/http.ts
+9
-0
No files found.
.env.development
View file @
586ac3f4
HOST=
m.julyedu.com
PORT=
8
0
HOST=
localhost
PORT=
300
0
config/proxy.js
0 → 100644
View file @
586ac3f4
module
.
exports
=
{
"/homeApi"
:
{
target
:
"https://fast.julyedu.com"
,
changeOrigin
:
true
,
secure
:
false
,
pathRewrite
:
{
"^/homeApi"
:
""
},
},
"/baseApi"
:
{
target
:
"https://api.julyedu.com"
,
changeOrigin
:
true
,
secure
:
false
,
pathRewrite
:
{
"^/baseApi"
:
""
},
},
"/searchApi"
:
{
target
:
"https://search.julyedu.com"
,
changeOrigin
:
true
,
secure
:
false
,
pathRewrite
:
{
"^/searchApi"
:
""
},
},
"/passportApi"
:
{
target
:
"https://passport.julyedu.com"
,
changeOrigin
:
true
,
secure
:
false
,
pathRewrite
:
{
"^/passportApi"
:
""
},
},
"/record"
:
{
target
:
"https://record.julyedu.com"
,
changeOrigin
:
true
,
secure
:
false
,
pathRewrite
:
{
"^/record"
:
""
},
},
"/mApi"
:
{
target
:
"https://m.julyedu.com"
,
changeOrigin
:
true
,
secure
:
false
,
pathRewrite
:
{
"^/mApi"
:
""
},
},
"/ai-search"
:
{
target
:
"https://ai-search.julyedu.com"
,
changeOrigin
:
true
,
secure
:
false
,
pathRewrite
:
{
"^/ai-search"
:
""
},
},
}
public/api.js
View file @
586ac3f4
var
API
=
{
'www'
:
'http://www-test.julyedu.com'
,
'home'
:
'http
s://fast.julyedu.com
'
,
'search-api'
:
'http://
search-test.julyedu.com
'
,
'passport-api'
:
'http://
passport-test.julyedu.com
'
,
'base-api'
:
'http
s://api.julyedu.com
'
,
'record'
:
'
record.julyedu.com:8001
'
,
'home'
:
'http
://localhost:3000/homeApi
'
,
'search-api'
:
'http://
localhost:3000/searchApi
'
,
'passport-api'
:
'http://
localhost:3000/passportApi
'
,
'base-api'
:
'http
://localhost:3000/baseApi
'
,
'record'
:
'
http://localhost:3000/record
'
,
'process-api'
:
'ws:process-test.julyedu.com:9502'
,
'm'
:
'http://m-test.julyedu.com'
,
'm'
:
'http://localhost:3000/mApi'
,
'ai-search'
:
'http://localhost:3000/ai-search'
,
}
scripts/start.js
View file @
586ac3f4
...
...
@@ -31,6 +31,7 @@ const openBrowser = require("react-dev-utils/openBrowser")
const
paths
=
require
(
"../config/paths"
)
const
configFactory
=
require
(
"../config/webpack.config"
)
const
createDevServerConfig
=
require
(
"../config/webpackDevServer.config"
)
const
proxy
=
require
(
"../config/proxy.js"
)
const
useYarn
=
fs
.
existsSync
(
paths
.
yarnLockFile
)
const
isInteractive
=
process
.
stdout
.
isTTY
...
...
@@ -97,8 +98,8 @@ checkBrowsers(paths.appPath, isInteractive)
webpack
,
})
// Load proxy config
const
proxy
Setting
=
require
(
paths
.
appPackageJson
).
proxy
const
proxyConfig
=
prepareProxy
(
proxySetting
,
paths
.
appPublic
)
const
proxy
Config
=
proxy
//
const proxyConfig = prepareProxy(proxySetting, paths.appPublic)
// Serve webpack assets generated by the compiler over a web server.
const
serverConfig
=
createDevServerConfig
(
proxyConfig
,
...
...
src/components/search/search-result.js
View file @
586ac3f4
import
React
,
{
PureComponent
}
from
"react"
import
SearchHeader
from
"./searchHead"
import
VList
from
"src/common/VList"
import
{
http
,
getParam
}
from
"src/utils"
import
{
getParam
}
from
"src/utils"
import
{
aiSearchInstance
}
from
"src/utils/http"
import
"./search-result.scss"
import
Recommendation
from
"./recommendation"
import
throttle
from
"lodash/throttle"
...
...
@@ -47,15 +48,35 @@ class SearchResult extends PureComponent {
}
getCourses
=
(
word
)
=>
{
http
.
get
(
`
${
API
[
"search-api"
]}
/search/
${
word
}
?type=v2-course&page=1`
)
aiSearchInstance
.
post
(
`
${
API
[
"ai-search"
]}
/aisearch/v1/fusion`
,
{
search_params
:
{
query
:
word
,
es_fragment_size
:
200
,
es_number_of_fragments
:
3
,
es_size
:
40
,
es_slop
:
1
,
milvus_limit
:
40
,
timeout
:
5
,
},
},
{
headers
:
{
"Content-Type"
:
"application/json"
,
},
}
)
.
then
((
res
)
=>
{
const
data
=
res
.
data
console
.
log
(
"data: "
,
data
)
const
{
response
,
status_code
}
=
data
if
(
data
.
errno
===
0
)
{
if
(
status_code
===
20
0
)
{
this
.
setState
({
courseList
:
data
.
data
.
info
[
"search_data"
].
cour
se
,
resultCount
:
data
.
data
.
info
[
"search_data"
].
num
,
courseList
:
respon
se
,
resultCount
:
response
.
length
,
})
}
})
...
...
@@ -164,15 +185,35 @@ class SearchResult extends PureComponent {
className
=
"title text-overflow-2"
dangerouslySetInnerHTML
=
{{
__html
:
item
.
highlight
?.
course_title
?.
length
>
0
?
item
.
highlight
.
course_title
[
0
]
item
.
highlight
?.
[
"course_title.pinyin"
]
?.
length
>
0
?
item
.
highlight
[
"course_title.pinyin"
]
[
0
]
:
item
.
course_title
,
}}
><
/p
>
<
p
className
=
"des text-overflow-1"
>
{
item
.
simpledescription
}
<
/p
>
<
Bottom
item
=
{
item
}
/
>
{
/* <p
className="des text-overflow-1"
dangerouslySetInnerHTML={{
__html:
item.highlight?.["course_stage.pinyin"]?.length > 0
? item.highlight["course_stage.pinyin"][0]
: "",
}}
></p> */
}
<
p
className
=
"des text-overflow-1"
dangerouslySetInnerHTML
=
{{
__html
:
item
.
highlight
?.[
"course_lesson.pinyin"
]?.
length
>
0
?
item
.
highlight
[
"course_lesson.pinyin"
][
0
]
:
""
,
}}
><
/p
>
<
div
className
=
"course_tags text-overflow-1"
>
{
item
.
course_tags
.
map
((
tag
,
index
)
=>
(
<
span
key
=
{
index
}
>
{
tag
}
<
/span
>
))}
<
/div
>
{
/* <Bottom item={item} /> */
}
<
/div
>
)
const
status
=
...
...
src/components/search/search-result.scss
View file @
586ac3f4
...
...
@@ -55,6 +55,19 @@
margin-top
:
10px
;
}
.course_tags
{
margin-top
:
10px
;
font-size
:
$font_12
;
color
:
#777
;
span
{
display
:
inline-block
;
margin-right
:
5px
;
padding
:
2px
5px
;
background-color
:
#f0f0f0
;
border-radius
:
4px
;
}
}
.price
{
color
:
$red
;
font-size
:
$font_16
;
...
...
src/utils/http.ts
View file @
586ac3f4
...
...
@@ -12,4 +12,13 @@ const instance = axios.create({
HTTP_PLAT
:
5
,
},
})
export
const
aiSearchInstance
=
axios
.
create
({
headers
:
{
HTTP_PLAT_FORM
:
5
,
HTTP_PLAT
:
5
,
},
withCredentials
:
true
,
})
export
default
instance
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment