Skip to content

Commit

Permalink
feat: make badge gray when not same room
Browse files Browse the repository at this point in the history
  • Loading branch information
ddiu8081 committed Sep 24, 2022
1 parent 64d29c9 commit 5df4f88
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"@temir/core": "^0.0.20",
"@temir/link": "^0.0.20",
"@temir/tab": "^0.0.20",
"blive-message-listener": "^0.1.6",
"blive-message-listener": "^0.1.8",
"dayjs": "^1.11.5",
"ohmyfetch": "^0.4.19",
"vue": "^3.2.39",
Expand Down
45 changes: 36 additions & 9 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions src/components/DanmuMsgCom.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script setup lang="ts">
import { computed } from 'vue'
import { TBox, TText } from '@temir/core'
import type { DanmuMsg } from 'blive-message-listener'
import { addSpace, getUserNameColor } from '../utils/format'
Expand All @@ -7,6 +8,13 @@ const { msg } = defineProps<{
msg: DanmuMsg
}>()
const badgeColor = computed(() => {
if (msg.user.badge?.anchor.is_same_room) {
return msg.user.badge.color
}
return '#666666'
})
</script>

<template>
Expand All @@ -15,8 +23,8 @@ const { msg } = defineProps<{
<TBox :flex-shrink="0">
<TBox>
<TBox v-if="msg.user.badge && msg.user.badge.active" :margin-right="1">
<TText :background-color="msg.user.badge.color" :flex-shrink="0">{{ addSpace(msg.user.badge.name) }}</TText>
<TText :color="msg.user.badge.color" background-color="#ffffff">{{ addSpace(msg.user.badge.level.toString()) }}</TText>
<TText :background-color="badgeColor" :flex-shrink="0">{{ addSpace(msg.user.badge.name) }}</TText>
<TText :color="badgeColor" background-color="#ffffff">{{ addSpace(msg.user.badge.level.toString()) }}</TText>
</TBox>
</TBox>
<TText background-color="blue">{{ msg.user.identity?.rank ? ` 榜${msg.user.identity.rank} ` : '' }}</TText>
Expand Down
11 changes: 11 additions & 0 deletions src/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,20 @@ import { startListen, type MsgHandler } from 'blive-message-listener'
const handler: MsgHandler = {
onIncomeDanmu: (msg) => {
console.dir(msg, { depth: null });
console.log(msg.body.user.uname + ' : ' + msg.body.content);
console.log()
},
onIncomeSuperChat: (msg) => {
console.dir(msg, { depth: null });
},
onAttentionChange: (msg) => {
console.log('attention', msg.body.attention)
},
onWatchedChange: (msg) => {
console.log('watched', msg.body.text_small)
},
onGift: (msg) => {
console.dir(msg, { depth: null });
}
}

Expand Down

0 comments on commit 5df4f88

Please sign in to comment.