diff --git a/README.md b/README.md index 1912edc3e..2a05dca26 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # [Fiora](https://fiora.suisuijiang.com/) · [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/yinxin630/fiora/blob/master/LICENSE) [![author](https://img.shields.io/badge/author-%E7%A2%8E%E7%A2%8E%E9%85%B1-blue.svg)](http://suisuijiang.com) [![Node.js Version](https://img.shields.io/badge/node.js-14.16.0-blue.svg)](http://nodejs.org/download) [![Test Status](https://github.com/yinxin630/fiora/workflows/Unit%20Test/badge.svg)](https://github.com/yinxin630/fiora/actions?query=workflow%3A%22Unit+Test%22) [![Typescript Status](https://github.com/yinxin630/fiora/workflows/Typescript%20Type%20Check/badge.svg)](https://github.com/yinxin630/fiora/actions?query=workflow%3A%22Typescript+Type+Check%22) +主题修改全局搜索theme Fiora is an interesting open source chat application. It is developed based on [node.js](https://nodejs.org/), [react](https://reactjs.org/) and [socket.io](https://socket.io/) technologies diff --git a/packages/server/src/routes/system.ts b/packages/server/src/routes/system.ts index 98ff506af..f7c1cf914 100644 --- a/packages/server/src/routes/system.ts +++ b/packages/server/src/routes/system.ts @@ -62,7 +62,7 @@ export async function search(ctx: Context<{ keywords: string }>) { } /** - * 搜索表情包, 爬其它站资源 + * 搜索表情包, 爬其它站资源,搜狗表情站 * @param ctx Context */ export async function searchExpression( @@ -75,9 +75,7 @@ export async function searchExpression( const res = await axios({ method: 'get', - url: `https://pic.sogou.com/pics/json.jsp?query=${encodeURIComponent( - `${keywords} 表情`, - )}&st=5&start=0&xml_len=60&callback=callback&reqFrom=wap_result&`, + url: `https://pic.sogou.com/napi/wap/emoji/searchlist?keyword=${encodeURIComponent(`${keywords}`)}&st=5&start=0&xml_len=60&callback=callback&reqFrom=wap_result&routeName=emosearch`, headers: { accept: '*/*', 'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8,zh-TW;q=0.7', @@ -85,9 +83,7 @@ export async function searchExpression( pragma: 'no-cache', 'sec-fetch-mode': 'navigate', 'sec-fetch-site': 'same-origin', - referrer: `https://pic.sogou.com/pic/emo/searchList.jsp?statref=search_form&uID=hTHHybkSPt37C46z&spver=0&rcer=&keyword=${encodeURIComponent( - keywords, - )}`, + referrer: `https://pic.sogou.com/`, referrerPolicy: 'no-referrer-when-downgrade', 'user-agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1', @@ -95,30 +91,36 @@ export async function searchExpression( }); assert(res.status === 200, '搜索表情包失败, 请重试'); - try { - const parseDataResult = res.data.match(/callback\((.+)\)/); - const data = JSON.parse(`${parseDataResult[1]}`); - type Image = { + + + const data = res.data.data.emotions; + + type Image = { locImageLink: string; width: number; height: number; - }; - const images = data.items as Image[]; - return images - .map(({ locImageLink, width, height }) => ({ - image: locImageLink, - width, - height, - })) - .filter((image, index) => - limit === Infinity ? true : index < limit, - ); - } catch (err) { - assert(false, '搜索表情包失败, 数据解析异常'); - } - - return []; + }; + + var img_arr=[]; + + data.forEach(element=>{ + + img_arr.push({image:element.thumbSrc,width:90,height:90}); + }) + + + const images = img_arr as Image[]; + + + + + + + return images; + + + } /**