mirror of
https://github.com/xfgryujk/blivechat.git
synced 2025-03-13 11:20:42 +08:00
添加通过服务器转发消息配置
This commit is contained in:
parent
6e2f3b1a0c
commit
d6897ca4b4
@ -17,6 +17,7 @@ export const DEFAULT_CONFIG = {
|
||||
blockUsers: '',
|
||||
blockMedalLevel: 0,
|
||||
|
||||
relayMessagesByServer: false,
|
||||
autoTranslate: false
|
||||
}
|
||||
|
@ -41,7 +41,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import * as config from '@/api/config'
|
||||
import * as chatConfig from '@/api/chatConfig'
|
||||
import {formatCurrency} from '@/utils'
|
||||
import ImgShadow from './ImgShadow.vue'
|
||||
import MembershipItem from './MembershipItem.vue'
|
||||
@ -59,7 +59,7 @@ export default {
|
||||
messages: Array,
|
||||
showGiftName: {
|
||||
type: Boolean,
|
||||
default: config.DEFAULT_CONFIG.showGiftName
|
||||
default: chatConfig.DEFAULT_CONFIG.showGiftName
|
||||
}
|
||||
},
|
||||
data() {
|
||||
|
@ -42,7 +42,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import * as config from '@/api/config'
|
||||
import * as chatConfig from '@/api/chatConfig'
|
||||
import Ticker from './Ticker.vue'
|
||||
import TextMessage from './TextMessage.vue'
|
||||
import MembershipItem from './MembershipItem.vue'
|
||||
@ -64,11 +64,11 @@ export default {
|
||||
css: String,
|
||||
maxNumber: {
|
||||
type: Number,
|
||||
default: config.DEFAULT_CONFIG.maxNumber
|
||||
default: chatConfig.DEFAULT_CONFIG.maxNumber
|
||||
},
|
||||
showGiftName: {
|
||||
type: Boolean,
|
||||
default: config.DEFAULT_CONFIG.showGiftName
|
||||
default: chatConfig.DEFAULT_CONFIG.showGiftName
|
||||
}
|
||||
},
|
||||
data() {
|
||||
|
@ -31,7 +31,8 @@ export default {
|
||||
blockMedalLevel: 'Block medal level lower than',
|
||||
|
||||
advanced: 'Advanced',
|
||||
autoTranslate: 'Auto translate messages to Japanese',
|
||||
relayMessagesByServer: 'Relay messages by server',
|
||||
autoTranslate: 'Auto translate messages to Japanese (requires relay messages by server)',
|
||||
|
||||
roomUrl: 'Room URL',
|
||||
copy: 'Copy',
|
||||
|
@ -31,7 +31,8 @@ export default {
|
||||
blockMedalLevel: 'ブロック勲章等級がx未満',
|
||||
|
||||
advanced: 'アドバンスド',
|
||||
autoTranslate: '自動翻訳コメントから日本語へ',
|
||||
relayMessagesByServer: 'サーバを介してメッセージを転送する',
|
||||
autoTranslate: 'コメントを日本語に翻訳する(サーバを介してメッセージを転送する必要)',
|
||||
|
||||
roomUrl: 'ルームのURL',
|
||||
copy: 'コピー',
|
||||
|
@ -31,7 +31,8 @@ export default {
|
||||
blockMedalLevel: '屏蔽当前直播间勋章等级低于',
|
||||
|
||||
advanced: '高级',
|
||||
autoTranslate: '自动翻译弹幕到日语',
|
||||
relayMessagesByServer: '通过服务器转发消息',
|
||||
autoTranslate: '自动翻译弹幕到日语(需要通过服务器转发消息)',
|
||||
|
||||
roomUrl: '房间URL',
|
||||
copy: '复制',
|
||||
|
@ -58,8 +58,11 @@
|
||||
</el-tab-pane>
|
||||
|
||||
<el-tab-pane :label="$t('home.advanced')">
|
||||
<el-form-item :label="$t('home.relayMessagesByServer')">
|
||||
<el-switch v-model="form.relayMessagesByServer"></el-switch>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('home.autoTranslate')">
|
||||
<el-switch v-model="form.autoTranslate" :disabled="!serverConfig.enableTranslate"></el-switch>
|
||||
<el-switch v-model="form.autoTranslate" :disabled="!serverConfig.enableTranslate || !form.relayMessagesByServer"></el-switch>
|
||||
</el-form-item>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
@ -83,7 +86,7 @@ import axios from 'axios'
|
||||
import download from 'downloadjs'
|
||||
|
||||
import {mergeConfig} from '@/utils'
|
||||
import * as config from '@/api/config'
|
||||
import * as chatConfig from '@/api/chatConfig'
|
||||
|
||||
export default {
|
||||
name: 'Home',
|
||||
@ -95,7 +98,7 @@ export default {
|
||||
},
|
||||
form: {
|
||||
roomId: parseInt(window.localStorage.roomId || '1'),
|
||||
...config.getLocalConfig()
|
||||
...chatConfig.getLocalConfig()
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -124,7 +127,7 @@ export default {
|
||||
watch: {
|
||||
roomUrl: _.debounce(function() {
|
||||
window.localStorage.roomId = this.form.roomId
|
||||
config.setLocalConfig(this.form)
|
||||
chatConfig.setLocalConfig(this.form)
|
||||
}, 500)
|
||||
},
|
||||
mounted() {
|
||||
@ -146,7 +149,7 @@ export default {
|
||||
document.execCommand('Copy')
|
||||
},
|
||||
exportConfig() {
|
||||
let cfg = mergeConfig(this.form, config.DEFAULT_CONFIG)
|
||||
let cfg = mergeConfig(this.form, chatConfig.DEFAULT_CONFIG)
|
||||
download(JSON.stringify(cfg, null, 2), 'blivechat.json', 'application/json')
|
||||
},
|
||||
importConfig() {
|
||||
@ -163,7 +166,7 @@ export default {
|
||||
this.$message.error(this.$t('home.failedToParseConfig') + e)
|
||||
return
|
||||
}
|
||||
cfg = mergeConfig(cfg, config.DEFAULT_CONFIG)
|
||||
cfg = mergeConfig(cfg, chatConfig.DEFAULT_CONFIG)
|
||||
this.form = {roomId: this.form.roomId, ...cfg}
|
||||
}
|
||||
reader.readAsText(input.files[0])
|
||||
|
@ -4,9 +4,9 @@
|
||||
|
||||
<script>
|
||||
import {mergeConfig, toBool, toInt} from '@/utils'
|
||||
import * as config from '@/api/config'
|
||||
import * as chatConfig from '@/api/chatConfig'
|
||||
import ChatClientDirect from '@/api/chat/ChatClientDirect'
|
||||
// import ChatClientRelay from '@/api/chat/ChatClientRelay'
|
||||
import ChatClientRelay from '@/api/chat/ChatClientRelay'
|
||||
import ChatRenderer from '@/components/ChatRenderer'
|
||||
import * as constants from '@/components/ChatRenderer/constants'
|
||||
|
||||
@ -17,7 +17,7 @@ export default {
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
config: {...config.DEFAULT_CONFIG},
|
||||
config: {...chatConfig.DEFAULT_CONFIG},
|
||||
chatClient: null
|
||||
}
|
||||
},
|
||||
@ -52,31 +52,32 @@ export default {
|
||||
cfg[i] = this.$route.query[i]
|
||||
}
|
||||
}
|
||||
cfg = mergeConfig(cfg, config.DEFAULT_CONFIG)
|
||||
cfg = mergeConfig(cfg, chatConfig.DEFAULT_CONFIG)
|
||||
|
||||
cfg.minGiftPrice = toInt(cfg.minGiftPrice, config.DEFAULT_CONFIG.minGiftPrice)
|
||||
cfg.minGiftPrice = toInt(cfg.minGiftPrice, chatConfig.DEFAULT_CONFIG.minGiftPrice)
|
||||
cfg.showDanmaku = toBool(cfg.showDanmaku)
|
||||
cfg.showGift = toBool(cfg.showGift)
|
||||
cfg.showGiftName = toBool(cfg.showGiftName)
|
||||
cfg.mergeSimilarDanmaku = toBool(cfg.mergeSimilarDanmaku)
|
||||
cfg.mergeGift = toBool(cfg.mergeGift)
|
||||
cfg.maxNumber = toInt(cfg.maxNumber, config.DEFAULT_CONFIG.maxNumber)
|
||||
cfg.maxNumber = toInt(cfg.maxNumber, chatConfig.DEFAULT_CONFIG.maxNumber)
|
||||
cfg.blockGiftDanmaku = toBool(cfg.blockGiftDanmaku)
|
||||
cfg.blockLevel = toInt(cfg.blockLevel, config.DEFAULT_CONFIG.blockLevel)
|
||||
cfg.blockLevel = toInt(cfg.blockLevel, chatConfig.DEFAULT_CONFIG.blockLevel)
|
||||
cfg.blockNewbie = toBool(cfg.blockNewbie)
|
||||
cfg.blockNotMobileVerified = toBool(cfg.blockNotMobileVerified)
|
||||
cfg.blockMedalLevel = toInt(cfg.blockMedalLevel, config.DEFAULT_CONFIG.blockMedalLevel)
|
||||
cfg.blockMedalLevel = toInt(cfg.blockMedalLevel, chatConfig.DEFAULT_CONFIG.blockMedalLevel)
|
||||
cfg.relayMessagesByServer = toBool(cfg.relayMessagesByServer)
|
||||
cfg.autoTranslate = toBool(cfg.autoTranslate)
|
||||
|
||||
this.config = cfg
|
||||
},
|
||||
initChatClient() {
|
||||
let roomId = parseInt(this.$route.params.roomId)
|
||||
// if () {
|
||||
if (!this.config.relayMessagesByServer) {
|
||||
this.chatClient = new ChatClientDirect(roomId)
|
||||
// } else {
|
||||
// this.chatClient = new ChatClientRelay(roomId, this.config.autoTranslate)
|
||||
// }
|
||||
} else {
|
||||
this.chatClient = new ChatClientRelay(roomId, this.config.autoTranslate)
|
||||
}
|
||||
this.chatClient.onAddText = this.onAddText
|
||||
this.chatClient.onAddGift = this.onAddGift
|
||||
this.chatClient.onAddMember = this.onAddMember
|
||||
|
Loading…
Reference in New Issue
Block a user