feat: 图片上传

This commit is contained in:
2026-03-02 15:08:03 +08:00
parent 0371484984
commit e8aba28f5d
4 changed files with 61 additions and 30 deletions

View File

@@ -113,11 +113,11 @@
const handleSendMessage = async (
message: {
text: string
images: Array<{ url: string; name: string }>
images: Array<{ url: string; name: string }>,
tempImages: any[]
},
skipUserMessage = false
) => {
// console.log('Message sent:', message)
isPaused.value = false
isGenerating.value = true
params.message = message.text
@@ -128,7 +128,8 @@
messageList.value.push({
id: messageList.value.length + 1,
text: message.text,
isUser: true
isUser: true,
imageUrls:message.tempImages
})
}

View File

@@ -8,6 +8,14 @@
class="message-context"
v-show="!content.loading && !content.thinking && !content.streaming"
>
<div class="img-list flex">
<img
v-for="(item, index) in imageList"
:key="'img-' + index"
:src="item"
class="img-item"
/>
</div>
<div class="message-txt markdown-body">
<div v-html="formatMessage"></div>
</div>
@@ -51,7 +59,7 @@
</template>
<script setup lang="ts">
import { ref, onMounted, computed } from 'vue'
import { ref, onMounted, computed, watch } from 'vue'
import { useI18n } from 'vue-i18n'
import gsap from 'gsap'
import userThumb from '@/assets/images/user-thumb.jpg'
@@ -66,18 +74,22 @@
content: Object
}>()
const imageList = computed(() => {
const { imageUrls } = props.content
const list = []
if (!imageUrls || imageUrls.length === 0) return list
imageUrls.forEach((item) => {
if (typeof item === 'string') {
list.push(item)
} else if (typeof item === 'object' && item.url) {
list.push(item.url)
}
})
return list
})
const formatMessage = computed(() => {
// MARKDOWN.renderer.rules.link_open = (tokens, idx, options, env, self) => {
// const aIndex = tokens[idx].attrIndex('target')
// if (aIndex < 0) {
// tokens[idx].attrPush(['target', '_blank'])
// } else {
// tokens[idx].attrs[aIndex][1] = '_blank'
// }
// return self.renderToken(tokens, idx, options, env, self)
// }
const str = md.render(props.content.text)
// console.log('str',str)
return str
})
@@ -180,6 +192,16 @@
}
}
}
.img-list {
column-gap: 1rem;
margin-bottom: 1.4rem;
.img-item {
width: 6.8rem;
height: 6.8rem;
border: 0.1rem solid #cdcdcd;
border-radius: 1.5rem;
}
}
.generating {
font-family: 'GeneralBold';

View File

@@ -37,7 +37,6 @@
const agentRef = ref()
const sketchList = ref([])
const updateSketchList = (newVal) => {
console.log('newVal', newVal)
sketchList.value = newVal
// VersionTreeIndexRef.value.getVersionTree()
}