Skip to content

Commit

Permalink
feat: support split emotion cdn (#592)
Browse files Browse the repository at this point in the history
* feat: support  split emotion cdn

* feat: support split emotion cdn

---------

Co-authored-by: iMaeGoo <mail1st@qq.com>
  • Loading branch information
zYeoman and imaegoo authored Sep 11, 2023
1 parent d5fc806 commit b50d027
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
9 changes: 8 additions & 1 deletion src/client/utils/emotion.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ function initOwoEmotion (api) {
})
}

async function initOwoEmotions (apis) {
const odata = {}
const odatas = await Promise.all(apis.split(',').map((api) => initOwoEmotion(api.trim())))
Object.assign(odata, ...odatas)
return odata
}

// 格式化不规范的 OwO 数据格式
function formatOdata (odata) {
try {
Expand Down Expand Up @@ -69,6 +76,6 @@ function initMarkedOwo (odata) {
}

export {
initOwoEmotion,
initOwoEmotions,
initMarkedOwo
}
10 changes: 5 additions & 5 deletions src/client/utils/i18n/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,11 +364,11 @@ export default {
`Аватар тўлдирувчиси. Стандарт: «идентификатор». Қуйидагилардан танланг: ${defaultGravatar.join(', ')}`
],
[S.ACI + '_EMOTION_CDN']: [
'表情 CDN,默认为:https://owo.imaegoo.com/owo.json',
'表情 CDN,預設為:https://owo.imaegoo.com/owo.json',
'表情 CDN 來源,預設為:https://owo.imaegoo.com/owo.json',
'Emotion CDN. Default: https://owo.imaegoo.com/owo.json',
'Emotion CDN. Default: https://owo.imaegoo.com/owo.json'
'表情 CDN,英文逗号分隔。默认为:https://owo.imaegoo.com/owo.json',
'表情 CDN,英文逗號分隔。預設為:https://owo.imaegoo.com/owo.json',
'表情 CDN 來源,使用英文逗號分隔。預設為:https://owo.imaegoo.com/owo.json',
'Emotion CDN. Separate by comma. Default: https://owo.imaegoo.com/owo.json',
'Emotion CDN. Вергул билан ажратинг. Default: https://owo.imaegoo.com/owo.json'
],
[S.ACI + '_FORBIDDEN_WORDS']: [
'违禁词配置,包含违禁词的内容会直接标记为垃圾评论。英文逗号分隔。',
Expand Down
4 changes: 2 additions & 2 deletions src/client/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import marked from './marked'
import renderCode from './highlight'
import { isUrl, call } from './api'
import { normalizeMail, isQQ, getQQAvatar } from './avatar'
import { initOwoEmotion, initMarkedOwo } from './emotion'
import { initOwoEmotions, initMarkedOwo } from './emotion'

const isNotSet = (option) => {
return option === undefined || option === null || option === ''
Expand Down Expand Up @@ -173,7 +173,7 @@ export {
normalizeMail,
isQQ,
getQQAvatar,
initOwoEmotion,
initOwoEmotions,
initMarkedOwo,
getCommentsCountApi,
getRecentCommentsApi,
Expand Down
4 changes: 2 additions & 2 deletions src/client/view/components/TkSubmit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ import iconImage from '@fortawesome/fontawesome-free/svgs/regular/image.svg'
import Clickoutside from 'element-ui/src/utils/clickoutside'
import TkAvatar from './TkAvatar.vue'
import TkMetaInput from './TkMetaInput.vue'
import { marked, call, logger, renderLinks, renderMath, renderCode, initOwoEmotion, initMarkedOwo, t, getUrl, getHref, blobToDataURL } from '../../utils'
import { marked, call, logger, renderLinks, renderMath, renderCode, initOwoEmotions, initMarkedOwo, t, getUrl, getHref, blobToDataURL } from '../../utils'
import OwO from '../../lib/owo'
const imageTypes = [
Expand Down Expand Up @@ -132,7 +132,7 @@ export default {
},
async initOwo () {
if (this.config.SHOW_EMOTION === 'true') {
const odata = await initOwoEmotion(this.config.EMOTION_CDN || 'https://owo.imaegoo.com/owo.json')
const odata = await initOwoEmotions(this.config.EMOTION_CDN || 'https://owo.imaegoo.com/owo.json')
this.owo = new OwO({
logo: iconEmotion, // OwO button text, default: `OωO表情`
container: this.$refs.owo, // OwO container, default: `document.getElementsByClassName('OwO')[0]`
Expand Down

0 comments on commit b50d027

Please sign in to comment.