Skip to content
This repository was archived by the owner on Sep 7, 2026. It is now read-only.

Add the NEU campus version of the Little Cow translation option and update the translation logic - #1268

Open
SomeZeroK wants to merge 2 commits into
pot-app:masterfrom
SomeZeroK:NEUniutrans
Open

SomeZeroK wants to merge 2 commits into
pot-app:masterfrom
SomeZeroK:NEUniutrans

Conversation

@SomeZeroK

Copy link
Copy Markdown

增加了小牛翻译校园版接口,经测试可以使用。可提供apikey进行测试。
主要改动如下:

配置界面 (Config.jsx):
在小牛翻译的配置中增加了一个「NEU」校园版的开关选项。当开启此模式时,内部系统会自动拼接专属端点。

核心请求逻辑 (index.jsx):
判断到开启了 is_campus 后,将请求地址切换为 https://trans.neu.edu.cn/niutrans/textTranslation?apikey=${apikey}
处理请求体的格式:校园内部版将 apikey 直接放置在了URL Query,否则认证会有问题。

image

Copilot AI review requested due to automatic review settings May 8, 2026 14:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the existing NiuTrans translator integration by adding support for the NEU (campus) endpoint variant, including a UI toggle to switch modes and adjusted request/response handling for the campus API format.

Changes:

  • Add an is_campus config flag to enable the NEU campus version mode in the NiuTrans config UI.
  • Switch the request endpoint to https://trans.neu.edu.cn/niutrans/textTranslation when is_campus is enabled.
  • Add campus-specific response parsing to extract translated text from the NEU response structure.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/services/translate/niutrans/index.jsx Switch endpoint based on is_campus and add campus response parsing logic.
src/services/translate/niutrans/Config.jsx Add is_campus default config and a new Switch in the configuration UI.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +8 to +10
const url = is_campus
? `https://trans.neu.edu.cn/niutrans/textTranslation?apikey=${apikey}`
: `${https ? 'https' : 'http'}://api.niutrans.com/NiuTransServer/translation`;
base: 'flex flex-row-reverse justify-between w-full max-w-full',
}}
>
NEU
Comment on lines 90 to 94
NEU
</Switch>
</div>
<div className={'config-item'}>
<Switch

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot apply changes based on this feedback

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comment on lines 341 to 345
"niutrans": {
"title": "NiuTrans",
"https": "Use Https",
"is_campus": "NEU Campus Network",
"apikey": "API Key"
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants