-
-
Notifications
You must be signed in to change notification settings - Fork 754
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
2,943 additions
and
33 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import React from 'react' | ||
import Speaker from '@/components/Speaker' | ||
import StarRates from '@/components/StarRates' | ||
import { YoudaoResult, YoudaoResultLex, YoudaoResultRelated } from './engine' | ||
|
||
export default class DictYoudao extends React.PureComponent<{ result: YoudaoResult }> { | ||
renderLex (result: YoudaoResultLex) { | ||
return ( | ||
<> | ||
{result.title && | ||
<div className='dictYoudao-HeaderContainer'> | ||
<h1 className='dictYoudao-Title'>{result.title}</h1> | ||
<span className='dictYoudao-Pattern'>{result.pattern}</span> | ||
</div> | ||
} | ||
{(result.stars > 0 || result.prons.length > 0) && | ||
<div className='dictYoudao-HeaderContainer'> | ||
{result.stars > 0 && <StarRates className='dictYoudao-Stars' rate={result.stars} />} | ||
{result.prons.map(({ phsym, url }) => ( | ||
<React.Fragment key={url}> | ||
{phsym} <Speaker src={url} /> | ||
</React.Fragment> | ||
))} | ||
<span className='dictYoudao-Rank'>{result.rank}</span> | ||
</div> | ||
} | ||
{result.basic && | ||
<div className='dictYoudao-Basic' dangerouslySetInnerHTML={{ __html: result.basic }} /> | ||
} | ||
{result.collins && | ||
<div> | ||
<h1 className='dictYoudao-SecTitle'>《柯林斯英汉双解》</h1> | ||
<ul className='dictYoudao-Collins' dangerouslySetInnerHTML={{ __html: result.collins }} /> | ||
</div> | ||
} | ||
{result.discrimination && | ||
<div className='dictYoudao-Discrimination'> | ||
<h1 className='dictYoudao-Discrimination_Title'>词义辨析</h1> | ||
<div dangerouslySetInnerHTML={{ __html: result.discrimination }} /> | ||
</div> | ||
} | ||
{result.sentence && | ||
<div> | ||
<h1 className='dictYoudao-SecTitle'>- 权威例句 -</h1> | ||
<ol className='dictYoudao-Sentence' dangerouslySetInnerHTML={{ __html: result.sentence }} /> | ||
</div> | ||
} | ||
{result.translation && | ||
<div> | ||
<h1 className='dictYoudao-SecTitle'>- 机器翻译 -</h1> | ||
<div className='dictYoudao-Translation' dangerouslySetInnerHTML={{ __html: result.translation }} /> | ||
</div> | ||
} | ||
</> | ||
) | ||
} | ||
|
||
renderRelated (result: YoudaoResultRelated) { | ||
return ( | ||
<div className='dictYoudao-Related' dangerouslySetInnerHTML={{ __html: result.list }} /> | ||
) | ||
} | ||
|
||
render () { | ||
const { result } = this.props | ||
switch (result.type) { | ||
case 'lex': | ||
return this.renderLex(result) | ||
case 'related': | ||
return this.renderRelated(result) | ||
default: | ||
return null | ||
} | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
"name": { | ||
"en": "Youdao Dictionary & Translation", | ||
"zh_CN": "有道词典(翻译)", | ||
"zh_TW": "有道詞典(翻譯)" | ||
}, | ||
"options": { | ||
"basic": { | ||
"en": "Show basic meaning", | ||
"zh_CN": "显示简单释义", | ||
"zh_TW": "顯示簡單解釋" | ||
}, | ||
"collins": { | ||
"en": "Show Collins result", | ||
"zh_CN": "显示柯林斯双解", | ||
"zh_TW": "顯示柯林斯雙解" | ||
}, | ||
"discrimination": { | ||
"en": "Show discrimination", | ||
"zh_CN": "显示词语辨析", | ||
"zh_TW": "顯示詞語辨析" | ||
}, | ||
"sentence": { | ||
"en": "Show sentences", | ||
"zh_CN": "显示权威例句", | ||
"zh_TW": "顯示權威例句" | ||
}, | ||
"translation": { | ||
"en": "Show translation", | ||
"zh_CN": "显示有道翻译", | ||
"zh_TW": "顯示有道翻譯" | ||
}, | ||
"related": { | ||
"en": "Show related results", | ||
"zh_CN": "失败时显示备选", | ||
"zh_TW": "失敗時顯示備選" | ||
} | ||
} | ||
} |
Oops, something went wrong.