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