mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-08 05:59:00 +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:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user