mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-08 22:19:40 +08:00
refactor(middleware): replace opencc with simplecc-wasm (#7111)
* refactor: replace opencc with simplecc-wasm * docs: simplecc-wasm docs change * new yarn.lock
This commit is contained in:
@@ -78,7 +78,7 @@ Eg: <https://rsshub.app/pnas/latest?scihub=1>
|
||||
|
||||
## Conversion between Traditional and Simplified Chinese
|
||||
|
||||
- opencc: s2t (Simplified Chinese to Traditional Chinese)、t2s (Traditional Chinese to Simplified Chinese), other optional values refer to [OpenCC - Configurations](https://github.com/BYVoid/OpenCC#configurations-%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6)
|
||||
- opencc: s2t (Simplified Chinese to Traditional Chinese)、t2s (Traditional Chinese to Simplified Chinese), other optional values refer to [simplecc-wasm - Configurations](https://github.com/fengkx/simplecc-wasm#%E9%85%8D%E7%BD%AE-configurations)
|
||||
|
||||
Eg: <https://rsshub.app/dcard/posts/popular?opencc=t2s>
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ Telegram 即时预览模式需要在官网制作页面处理模板,请前往[
|
||||
|
||||
## 中文简繁体转换
|
||||
|
||||
- opencc: s2t 简体转繁体、t2s 繁体转简体,其它可选值见 [OpenCC - Configurations](https://github.com/BYVoid/OpenCC#configurations-%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6)
|
||||
- opencc: s2t 简体转繁体、t2s 繁体转简体,其它可选值见 [simple-wasm - Configurations](https://github.com/fengkx/simplecc-wasm#%E9%85%8D%E7%BD%AE-configurations)
|
||||
|
||||
举例: <https://rsshub.app/dcard/posts/popular?opencc=t2s>
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const entities = require('entities');
|
||||
const mercury_parser = require('@postlight/mercury-parser');
|
||||
const cheerio = require('cheerio');
|
||||
const OpenCC = require('opencc');
|
||||
const { simplecc } = require('simplecc-wasm');
|
||||
const got = require('@/utils/got');
|
||||
const config = require('@/config').value;
|
||||
|
||||
@@ -231,12 +231,10 @@ module.exports = async (ctx, next) => {
|
||||
|
||||
// opencc
|
||||
if (ctx.query.opencc) {
|
||||
const converter = new OpenCC(`${ctx.query.opencc}.json`);
|
||||
const tasks = ctx.state.data.item.map(async (item) => {
|
||||
item.title = await converter.convertPromise(item.title);
|
||||
item.description = await converter.convertPromise(item.description);
|
||||
ctx.state.data.item.forEach((item) => {
|
||||
item.title = simplecc(item.title, ctx.query.opencc);
|
||||
item.description = simplecc(item.description, ctx.query.opencc);
|
||||
});
|
||||
await Promise.all(tasks);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,7 +102,6 @@
|
||||
"mailparser": "3.1.0",
|
||||
"markdown-it": "12.0.4",
|
||||
"module-alias": "2.2.2",
|
||||
"opencc": "1.1.2",
|
||||
"parse-torrent": "9.1.3",
|
||||
"pidusage": "2.0.21",
|
||||
"plist": "3.0.1",
|
||||
@@ -111,6 +110,7 @@
|
||||
"require-all": "3.0.0",
|
||||
"rss-parser": "3.10.0",
|
||||
"showdown": "1.9.1",
|
||||
"simplecc-wasm": "0.1.1",
|
||||
"socks-proxy-agent": "5.0.0",
|
||||
"string-similarity": "^4.0.3",
|
||||
"tiny-async-pool": "1.2.0",
|
||||
|
||||
13
yarn.lock
13
yarn.lock
@@ -9441,14 +9441,6 @@ only@~0.0.2:
|
||||
resolved "https://registry.yarnpkg.com/only/-/only-0.0.2.tgz#2afde84d03e50b9a8edc444e30610a70295edfb4"
|
||||
integrity sha1-Kv3oTQPlC5qO3EROMGEKcCle37Q=
|
||||
|
||||
opencc@1.1.2:
|
||||
version "1.1.2"
|
||||
resolved "https://registry.yarnpkg.com/opencc/-/opencc-1.1.2.tgz#63e611d946873cc8d4351118ba620349f08ec028"
|
||||
integrity sha512-xsuoBDM5O3Qt+ctLcI97a5A/Ta+js3pa0cPodz05cQqAB27D95Sq8S+WRPZYdlShzw0xav1d+rKuaUdGksMB6Q==
|
||||
dependencies:
|
||||
nan "^2.14.2"
|
||||
node-pre-gyp "^0.14.0"
|
||||
|
||||
opencollective-postinstall@^2.0.2:
|
||||
version "2.0.2"
|
||||
resolved "https://registry.yarnpkg.com/opencollective-postinstall/-/opencollective-postinstall-2.0.2.tgz#5657f1bede69b6e33a45939b061eb53d3c6c3a89"
|
||||
@@ -11530,6 +11522,11 @@ simple-swizzle@^0.2.2:
|
||||
dependencies:
|
||||
is-arrayish "^0.3.1"
|
||||
|
||||
simplecc-wasm@0.1.1:
|
||||
version "0.1.1"
|
||||
resolved "https://registry.yarnpkg.com/simplecc-wasm/-/simplecc-wasm-0.1.1.tgz#62f64f3cb561974c73be549595874a5e562ac1ff"
|
||||
integrity sha512-ywhXmfcvsyf0fGzP9Mhxe9i079ed4C9/OSpVkgszmNUuFcHjuN8/O/ftisg308EmgQ1H3+ULigupoz+wZoe4nA==
|
||||
|
||||
sisteransi@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/sisteransi/-/sisteransi-1.0.0.tgz#77d9622ff909080f1c19e5f4a1df0c1b0a27b88c"
|
||||
|
||||
Reference in New Issue
Block a user