feat: webAddress

This commit is contained in:
2026-03-16 14:11:01 +08:00
parent b82c35f8b7
commit 8eff97a3f2
7 changed files with 73 additions and 129 deletions

View File

@@ -146,7 +146,7 @@
id: messageList.value.length + 1,
text: '',
isUser: false,
sessionId: 'projectStore.state.id',
sessionId: projectStore.state.id,
loading: true,
thinking: false,
thinkingText: '',
@@ -258,7 +258,7 @@
reportsContent.value
) {
isGeneratingReport.value = false
localStorage.setItem(
sessionStorage.setItem(
'reportsContent_' + projectStore.state.id,
reportsContent.value
)
@@ -297,6 +297,7 @@
}
// if (eventName === 'webAddress') {
// console.log('webAddress111111111111111', eventName, dataLines)
// debugger
// }
if (eventName === 'tool') {
@@ -311,17 +312,17 @@
// console.log('jsonData', jsonData)
if (jsonData.webAddress) {
aiMessage.webAddress = JSON.parse(jsonData.webAddress)
contentBody += `<slot slot-name="url">123</slot>`
}
if (jsonData.title) {
emits('setTitle', jsonData.title)
}
if (hasSketch) {
console.log('sketch事件-----', jsonData);
sketchList.value.push({
[Object.keys(jsonData)[0]]: jsonData[Object.keys(jsonData)[0]]
})
MyEvent.emit('OpenSketch')
}
if (eventName === 'report') {
reportsContent.value += jsonData.report
@@ -438,10 +439,6 @@
while (i < dialogue.length) {
const item = dialogue[i]
if (item.webAddress?.length > 0) {
console.log('item.webAddress-----', item.webAddress)
debugger
}
if (item.role === 'user') {
// user 角色直接添加
result.push({
@@ -513,7 +510,7 @@
}
})
if (reportStr && session.id) {
localStorage.setItem(`reportsContent_${session.id}`, reportStr)
sessionStorage.setItem(`reportsContent_${session.id}`, reportStr)
}
// 3. 收集 sketchIDAndUrl 到 imgList

View File

@@ -40,11 +40,10 @@
<template v-slot:s-card="{ children: children, ...attrs }">
<Card :title="attrs.title" @click.native="handleClickReport" />
</template>
<template v-slot:url-card="{ children: children }">
<template v-slot:s-url="{ children: children }">
<Url :list="content.webAddress" @click.native="handleClickUrls" />
</template>
</VueMarkdown>
<!-- <Url @click.native="handleClickUrls" /> -->
<div
class="web-address flex align-center"
v-show="content.webAddress?.length > 0"

View File

@@ -50,6 +50,17 @@
<img src="@/assets/images/sketch-loading.gif" alt="loading" />
</div>
</template>
<template v-else-if="type === 'url'">
<div class="url-list flex">
<div class="url-item" v-for="item in urlList" :key="item">
<div class="url-title" @click="handleClickUrl(item)">
{{ item }}
<img src="@/assets/images/link-outer.png" class="link-outer" />
</div>
<div class="url-link">{{ item }}</div>
</div>
</div>
</template>
<div v-else class="reportBorder">
<div class="report">
<!-- <div v-if="false" class="report-content-null">
@@ -75,11 +86,6 @@
</div>
</div>
</template>
<template v-else>
<div class="url-list">
<div class="url-item" v-for="item in urlList" :key="item"></div>
</div>
</template>
</div>
</div>
</div>
@@ -99,9 +105,6 @@
import { VueMarkdown } from '@crazydos/vue-markdown'
import type { CustomAttrs } from '@crazydos/vue-markdown'
import rehypeRaw from 'rehype-raw'
import { useWebsiteTitle } from '@/utils/useWebTitle'
const { titles, loading, fetchAll } = useWebsiteTitle()
const { t } = useI18n()
const emits = defineEmits(['deleteSketch'])
@@ -111,7 +114,7 @@
const props = withDefaults(
defineProps<{
type: 'sketch' | 'report'
type: 'sketch' | 'report' | 'url'
sketchList: Array<string>
}>(),
{
@@ -138,26 +141,23 @@
const urlList = ref([])
const reportType = ref<'report' | 'urls'>('report')
const setSessionId = (id: string) => {
console.log('setSessionId-----', id)
reportType.value = 'report'
sessionId.value = id
}
const setUrls = (list: string[]) => {
console.log('setUrls-----', list)
reportType.value = 'urls'
urlList.value = [
'https://furnitureindustrynews.substack.com/p/what-2026-really-looks-like-for-furniture',
'https://furnitureindustrynews.substack.com/p/what-2026-really-looks-like-for-furniture',
'https://furnitureindustrynews.substack.com/p/what-2026-really-looks-like-for-furniture'
]
fetchAll(list)
urlList.value = list
// urlList.value = [
// 'https://furnitureindustrynews.substack.com/p/what-2026-really-looks-like-for-furniture',
// 'https://furnitureindustrynews.substack.com/p/what-2026-really-looks-like-for-furniture',
// 'https://furnitureindustrynews.substack.com/p/what-2026-really-looks-like-for-furniture'
// ]
}
watch(
() => sessionId.value,
(newVal) => {
if (newVal) {
markdownContent.value = localStorage.getItem(`reportsContent_${newVal}`)
console.log(`报告key值:reportsContent_${newVal}`, markdownContent.value)
markdownContent.value = sessionStorage.getItem(`reportsContent_${newVal}`)
}
}
)
@@ -226,6 +226,11 @@
const handleLoadingSketch = () => {
showLoading.value = true
}
const handleClickUrl = (item: string) => {
window.open(item, '_blank')
}
// watch(
// () => props.sketchList,
// (val) => {
@@ -301,6 +306,38 @@
}
}
}
.url-list {
flex: 1;
flex-wrap: wrap;
column-gap: 4rem;
row-gap: 3rem;
.url-item {
width: 24rem;
height: 28.7rem;
word-break: break-all;
background: url('@/assets/images/web-card.png') no-repeat;
background-size: 100% 100%;
padding: 5rem 1.5rem;
.url-title {
cursor: pointer;
font-family: 'Medium';
font-size: 1.6rem;
color: #232323;
padding-bottom: 0.6rem;
.link-outer {
width: 1.2rem;
height: 1.2rem;
}
}
.url-link {
font-family: 'Medium';
font-style: italic;
font-size: 1.2rem;
color: #7c7c7c;
user-select: text;
}
}
}
.reportBorder {
position: relative;
display: flex;

View File

@@ -8,7 +8,7 @@
</div>
</div>
<div class="report-card-content">
<span v-if="!isUrl">{{ content }}</span>
<span v-if="!isUrl">markdown.md</span>
<span v-else>Destination URL</span>
</div>
</div>

View File

@@ -104,16 +104,13 @@
const proJectId = computed(() => route.params.id)
const handleOpenReport = (data, isUrls = false) => {
if (isUrls) {
previewRef.value.setUrls(data)
} else {
previewRef.value.setSessionId(data)
}
previewRef.value.setSessionId(data)
previewType.value = 'report'
}
const handleOpenUrls = (data) => {
handleOpenReport(data, true)
previewRef.value.setUrls(data)
previewType.value = 'url'
}
watch(
@@ -129,6 +126,9 @@
onMounted(() => {
MyEvent.add('openReport', handleOpenReport)
MyEvent.add('openUrls', handleOpenUrls)
MyEvent.add('OpenSketch', ()=>{
previewType.value = 'sketch'
})
projectStore.clearProject()
if (proJectId.value) {
handleGetProjectInfoAndHistory()
@@ -137,6 +137,9 @@
onUnmounted(() => {
MyEvent.remove('openReport', handleOpenReport)
MyEvent.remove('openUrls', handleOpenUrls)
MyEvent.remove('OpenSketch', ()=>{
previewType.value = 'sketch'
})
})
</script>