未登录点击讨论区弹出登录框

This commit is contained in:
A1300399510
2025-02-14 17:41:17 +08:00
parent a890fed5e1
commit 8a0c66d839
11 changed files with 84 additions and 65 deletions

View File

@@ -7,7 +7,7 @@
<div class="input-box">
<div class="top flexflex">
<img class="avatar" v-if="user.avatar" :src="user.avatar" />
<textarea class="input-textarea flex1" maxlength="500" v-model="inputTextarea" @input="autoResize" @paste="handleInputPaste" placeholder="说说你的看法…"></textarea>
<textarea class="input-textarea flex1" maxlength="500" v-model="inputTextarea" @focus="inputFocus" @input="autoResize" @paste="handleInputPaste" placeholder="说说你的看法…"></textarea>
</div>
<div class="picture-box" v-if="picture.url">
<div class="picture">
@@ -73,7 +73,7 @@
<div class="input-box" v-if="item['childState']">
<img class="cross" @click="closeAnswerCommentsChild(index)" src="/img/cross-icon.png" />
<div class="top flexflex">
<textarea class="input-textarea flex1" maxlength="500" placeholder="说说你的看法…" v-model="item['commentInput']" @input="autoResize" @paste="handleInputPaste($event, index)"></textarea>
<textarea class="input-textarea flex1" maxlength="500" placeholder="说说你的看法…" v-model="item['commentInput']" @focus="inputFocus" @input="autoResize" @paste="handleInputPaste($event, index)"></textarea>
</div>
<div class="picture-box" v-if="item.picture?.url">
<div class="picture">
@@ -144,7 +144,7 @@
<div class="input-box" v-if="ite['childState']">
<img class="cross" @click="closeAnswerCommentsChild(index)" src="/img/cross-icon.png" />
<div class="top flexflex">
<textarea class="input-textarea flex1" maxlength="500" v-model="ite['commentInput']" :placeholder="'回复“' + (ite['nickname'] || '匿名用户') + '”:'" @input="autoResize" @paste="handleInputPaste($event, index, i)"></textarea>
<textarea class="input-textarea flex1" maxlength="500" v-model="ite['commentInput']" :placeholder="'回复“' + (ite['nickname'] || '匿名用户') + '”:'" @focus="inputFocus" @input="autoResize" @paste="handleInputPaste($event, index, i)"></textarea>
</div>
<div class="picture-box" v-if="ite.picture?.url">
<div class="picture">
@@ -182,7 +182,6 @@
</div>
</template>
<script setup>
const props = defineProps({
token: String,
})
@@ -190,7 +189,7 @@ const props = defineProps({
onMounted(() => {
// getComment()
})
const emit = defineEmits();
const emit = defineEmits()
const $ajax = inject("$ajax")
const $ajaxGET = inject("$ajaxGET")
@@ -309,6 +308,10 @@ watch(
const maxSize = 20 * 1024 * 1024 // 20MB
const handleFileUpload = (event, index, i) => {
if (isNeedLogin.value) {
goLogin()
return
}
closeEmoji()
const file = event.target.files[0] // 获取选择的文件
@@ -352,6 +355,10 @@ const emojiData = ["😀", "😁", "😆", "😅", "😂", "😉", "😍", "🥰
// 打开 Emoji
const openEmoji = (index, i) => {
if (isNeedLogin.value) {
goLogin()
return
}
if (i != undefined) commentList.value[index].child[i]["emojiState"] = true
else if (index != undefined) commentList.value[index]["emojiState"] = true
else {
@@ -403,6 +410,11 @@ const autoResize = e => {
}
const handleInputPaste = (event, index, ii) => {
if (isNeedLogin.value) {
goLogin()
return
}
const items = event.clipboardData.items // 获取粘贴的内容
for (let i = 0; i < items.length; i++) {
@@ -523,7 +535,7 @@ const submitAnswerComments = (index, i) => {
commentTotalCount.value = data.count || 0
emit('updateAnswers', data.count)
emit("updateAnswers", data.count)
// targetAnswerList[index]["commentnum"] = data["count"]
@@ -635,5 +647,12 @@ const closeUserInfo = (index, i) => {
if (i != undefined) commentList.value[index].child[i]["avatarState"] = false
else if (index != undefined) commentList.value[index]["avatarState"] = false
}
const inputFocus = () => {
if (isNeedLogin.value) {
goLogin()
return
}
}
</script>
<style scoped></style>