fixed #69
All checks were successful
CSGOWTF/csgowtf/pipeline/head This commit looks good

This commit is contained in:
2022-02-13 01:33:43 +01:00
parent 9ff510a9f6
commit 3963f6decf
2 changed files with 84 additions and 71 deletions

View File

@@ -7,7 +7,7 @@
@translated="handleTranslatedText" @translated="handleTranslatedText"
/> />
<div v-if="data.chat.length > 0" class="chat-history mt-2"> <div v-if="data.chat.length > 0" class="chat-history mt-2">
<table class="table table-borderless"> <table id="chat" :style="`max-width: ${data.clientWidth}px; width: ${data.clientWidth}px`" class="table table-borderless">
<tbody> <tbody>
<tr v-for="(m, id) in data.chat" :key="id"> <tr v-for="(m, id) in data.chat" :key="id">
<td class="td-time"> <td class="td-time">
@@ -79,23 +79,20 @@ export default {
const data = reactive({ const data = reactive({
chat: [], chat: [],
translatedText: [], translatedText: [],
originalChat: [] originalChat: [],
clientWidth: 0
}) })
const handleTranslatedText = async (e) => { const handleTranslatedText = async (e) => {
const res = await e const [res, toggle] = await e
if (res === 'original' && data.originalChat.length > 0) {
data.chat = data.originalChat
return
}
if (res === 'already translated' && data.translatedText.length > 0) {
data.chat = data.translatedText
return
}
if (res !== null) { if (res !== null) {
if (toggle === 'translated') {
data.translatedText = await setPlayer(sortChatHistory(res, true)) data.translatedText = await setPlayer(sortChatHistory(res, true))
data.chat = data.translatedText data.chat = data.translatedText
} else if (toggle === 'original') {
data.chat = data.originalChat
}
} }
} }
@@ -158,8 +155,21 @@ export default {
return arr return arr
} }
const sizeTable = () => {
if (document.documentElement.clientWidth <= 768) {
data.clientWidth = document.documentElement.clientWidth - 32
} else {
data.clientWidth = 700
}
}
window.onresize = () => {
sizeTable()
}
onMounted(() => { onMounted(() => {
getChatHistory() getChatHistory()
sizeTable()
}) })
return { return {
@@ -188,9 +198,6 @@ export default {
margin-top: .5rem; margin-top: .5rem;
} }
table {
width: 700px;
max-width: 700px;
td { td {
padding: .5rem; padding: .5rem;
} }
@@ -201,6 +208,7 @@ table {
.td-avatar { .td-avatar {
width: 30px; width: 30px;
.avatar { .avatar {
width: 20px; width: 20px;
height: 20px; height: 20px;
@@ -209,8 +217,8 @@ table {
} }
.td-name { .td-name {
width: 250px; width: 200px;
max-width: 250px; max-width: 200px;
cursor: pointer; cursor: pointer;
text-align: left; text-align: left;
white-space: nowrap; white-space: nowrap;
@@ -237,20 +245,30 @@ table {
} }
.td-message { .td-message {
width: 320px; width: 400px !important;
}
@media screen and (max-width: 768px) {
.container {
justify-content: flex-start;
align-items: flex-start;
margin-left: 1rem;
}
.td-name {
width: 120px !important;
max-width: 120px !important;
}
.td-message {
width: auto !important;
} }
} }
@media screen and (max-width: 576px) { @media screen and (max-width: 576px) {
.container {
margin-left: 0;
}
.td-avatar { .td-avatar {
display: none; display: none;
} }
.td-name {
width: 120px;
max-width: 120px;
}
.td-message {
width: auto;
}
} }
</style> </style>

View File

@@ -33,7 +33,7 @@ export default {
required: true required: true
} }
}, },
setup(props) { setup() {
const store = useStore() const store = useStore()
const data = reactive({ const data = reactive({
@@ -67,18 +67,12 @@ export default {
toggleShow() toggleShow()
if (!props.translated && toggle.value === 'translated') {
response = await GetChatHistoryTranslated(store, store.state.matchDetails.match_id) response = await GetChatHistoryTranslated(store, store.state.matchDetails.match_id)
}
if (props.translated && toggle.value === 'translated')
response = 'already translated'
if (toggle.value === 'original')
response = 'original'
if (refreshButton.classList.contains('show')) if (refreshButton.classList.contains('show'))
refreshButton.classList.remove('show') refreshButton.classList.remove('show')
return response return [response, toggle.value]
} }
const toggleShow = () => { const toggleShow = () => {
@@ -108,6 +102,7 @@ export default {
.toggle-btn { .toggle-btn {
margin: 0 auto; margin: 0 auto;
cursor: pointer; cursor: pointer;
width: 100%;
.fa { .fa {
display: none; display: none;