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
Open
Add the NEU campus version of the Little Cow translation option and update the translation logic#1268SomeZeroK wants to merge 2 commits into
SomeZeroK wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
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_campusconfig flag to enable the NEU campus version mode in the NiuTrans config UI. - Switch the request endpoint to
https://trans.neu.edu.cn/niutrans/textTranslationwhenis_campusis 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 |
Comment on lines
341
to
345
| "niutrans": { | ||
| "title": "NiuTrans", | ||
| "https": "Use Https", | ||
| "is_campus": "NEU Campus Network", | ||
| "apikey": "API Key" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
增加了小牛翻译校园版接口,经测试可以使用。可提供apikey进行测试。
主要改动如下:
配置界面 (Config.jsx):
在小牛翻译的配置中增加了一个「NEU」校园版的开关选项。当开启此模式时,内部系统会自动拼接专属端点。
核心请求逻辑 (index.jsx):
判断到开启了 is_campus 后,将请求地址切换为 https://trans.neu.edu.cn/niutrans/textTranslation?apikey=${apikey}
处理请求体的格式:校园内部版将 apikey 直接放置在了URL Query,否则认证会有问题。