文件上传的问题
This commit is contained in:
@@ -87,9 +87,11 @@ export default {
|
|||||||
if (++i < content.length) setTimeout(() => concatenateStr(content, i, target), 50)
|
if (++i < content.length) setTimeout(() => concatenateStr(content, i, target), 50)
|
||||||
}
|
}
|
||||||
this.$debounce(() => {
|
this.$debounce(() => {
|
||||||
const {currentConversation: conversationId, app, prompt: content, latlng} = this.$data
|
const {currentConversation: conversationId, app, prompt: content, latlng, files} = this.$data
|
||||||
const message = {appType: "2", userType: 0, content, conversationId, ...app, supplementContent: latlng}
|
const {id: fileId, url: sdkFileUrl, name: fileName} = files[0] || {}
|
||||||
|
const message = {appType: "2", userType: 0, content, conversationId, ...app, supplementContent: latlng, fileId, sdkFileUrl, fileName}
|
||||||
this.history.push(message)
|
this.history.push(message)
|
||||||
|
this.$refs.uploader?.clearFiles()
|
||||||
this.loading = true
|
this.loading = true
|
||||||
this.prompt = ""
|
this.prompt = ""
|
||||||
this.http.post("/app/appaicopilotinfo/add", message).then(res => {
|
this.http.post("/app/appaicopilotinfo/add", message).then(res => {
|
||||||
@@ -190,7 +192,7 @@ export default {
|
|||||||
<div class="topBar flex">
|
<div class="topBar flex">
|
||||||
<div v-for="(btn,i) in btns" :key="i" class="btn pointer" :style="{backgroundImage: `url(${btn.icon})`}" v-text="btn.label" @click="btn.click"/>
|
<div v-for="(btn,i) in btns" :key="i" class="btn pointer" :style="{backgroundImage: `url(${btn.icon})`}" v-text="btn.label" @click="btn.click"/>
|
||||||
</div>
|
</div>
|
||||||
<ai-uploader v-model="files" :instance="http" :limit="1" show-loading fileType="file">
|
<ai-uploader ref="uploader" v-model="files" :instance="http" :limit="1" show-loading fileType="file">
|
||||||
<div slot="trigger" ref="uploadTrigger"/>
|
<div slot="trigger" ref="uploadTrigger"/>
|
||||||
</ai-uploader>
|
</ai-uploader>
|
||||||
<div class="flex end">
|
<div class="flex end">
|
||||||
@@ -202,7 +204,7 @@ export default {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</ai-drag>
|
</ai-drag>
|
||||||
<ai-locate-dialog dialogTitle="选择当前位置" v-model="locate" :ins="http" @confirm="v=>handleLocate(v)" :modal="false" :latlng="{lat:30.5395460128784,lng:114.271802902222}"/>
|
<ai-locate-dialog dialogTitle="选择当前位置" v-model="locate" :ins="http" @confirm="v=>handleLocate(v)" :modal="false"/>
|
||||||
<img class="icon" src="https://cdn.sinoecare.com/i/2024/08/22/66c6dfdc3766a.png" @click="show=!show"/>
|
<img class="icon" src="https://cdn.sinoecare.com/i/2024/08/22/66c6dfdc3766a.png" @click="show=!show"/>
|
||||||
</section>
|
</section>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -3,7 +3,10 @@
|
|||||||
<div class="chat-wrapper" v-for="item in list" :key="item.id">
|
<div class="chat-wrapper" v-for="item in list" :key="item.id">
|
||||||
<div class="chat-text" :class="{right:item.userType == '0',system:item.userType == '2'}">
|
<div class="chat-text" :class="{right:item.userType == '0',system:item.userType == '2'}">
|
||||||
<img v-if="item.userType!=2" class="avatar" :src="avatar(item)" alt=""/>
|
<img v-if="item.userType!=2" class="avatar" :src="avatar(item)" alt=""/>
|
||||||
<div class="content" v-html="markdown(item.content)"/>
|
<div style="max-width: max(calc(100% - 140px), 220px)">
|
||||||
|
<div class="content" v-html="markdown(item.content)"/>
|
||||||
|
<div class="attachments pointer el-icon-paperclip" v-if="item.fileName" v-text="item.fileName" @click="handleDownload(item)"/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</el-scrollbar>
|
</el-scrollbar>
|
||||||
@@ -45,6 +48,9 @@ export default {
|
|||||||
},
|
},
|
||||||
markdown(v) {
|
markdown(v) {
|
||||||
return this.md?.render(v) || v
|
return this.md?.render(v) || v
|
||||||
|
},
|
||||||
|
handleDownload(item) {
|
||||||
|
window.open(item.sdkFileUrl)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
@@ -100,7 +106,6 @@ export default {
|
|||||||
|
|
||||||
.content {
|
.content {
|
||||||
position: relative;
|
position: relative;
|
||||||
max-width: max(calc(100% - 140px), 220px);
|
|
||||||
padding: 8px;
|
padding: 8px;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
background: #F3F5F7;
|
background: #F3F5F7;
|
||||||
@@ -151,6 +156,23 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.attachments {
|
||||||
|
font-size: 12px;
|
||||||
|
background: #F0F0F0;
|
||||||
|
border-radius: 4px;
|
||||||
|
color: #888;
|
||||||
|
padding: 3px 6px;
|
||||||
|
width: fit-content;
|
||||||
|
margin-top: 4px;
|
||||||
|
|
||||||
|
&:hover, &:active {
|
||||||
|
color: $primaryColor;
|
||||||
|
}
|
||||||
|
&:before{
|
||||||
|
margin-right: 2px;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.avatar {
|
.avatar {
|
||||||
|
|||||||
@@ -86,7 +86,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {VueCropper} from 'vue-cropper'
|
import {VueCropper} from 'vue-cropper'
|
||||||
|
|
||||||
@@ -403,6 +402,9 @@ export default {
|
|||||||
parent.$emit.apply(parent, [eventName].concat(params));
|
parent.$emit.apply(parent, [eventName].concat(params));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
clearFiles() {
|
||||||
|
this.$refs.upload.clearFiles()
|
||||||
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user