Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support split emotion cdn #592

Merged
merged 3 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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