提交 4868c113 authored 作者: 朱政's avatar 朱政

feat:展开默认展开第一条,同时ai智能总结默认展示,多智库分析流式默认展示,图表图例颜色与对应领域的tag颜色相同,报告原文搜索功能开发,点击多智库分析后的报告题目跳转到对应原文

上级 8b627b15
差异被折叠。
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
"json5": "^2.2.3", "json5": "^2.2.3",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"markdown-it": "^14.1.0", "markdown-it": "^14.1.0",
"pdfjs-dist": "^5.4.449", "pdfjs-dist": "^5.5.207",
"pinia": "^3.0.4", "pinia": "^3.0.4",
"vue": "^3.4.0", "vue": "^3.4.0",
"vue-router": "^4.2.5" "vue-router": "^4.2.5"
......
...@@ -46,7 +46,10 @@ export function getThinkTankPolicyIndustryChange(params) { ...@@ -46,7 +46,10 @@ export function getThinkTankPolicyIndustryChange(params) {
params: { params: {
startDate: params.startDate, startDate: params.startDate,
endDate: params.endDate endDate: params.endDate
} },
// 无数据年份(如 2026)后端可能返回 HTTP 400/500,避免走全局错误提示
validateStatus: (status) =>
(status >= 200 && status < 300) || status === 400 || status === 500
}); });
} }
......
...@@ -160,7 +160,7 @@ ...@@ -160,7 +160,7 @@
</AnalysisBox> </AnalysisBox>
</div> </div>
<div class="box2"> <div class="box2">
<AnalysisBox title="共识观点列表" :showAllBtn="true" v-if="isBox2 || isAnalysisLoading"> <AnalysisBox title="核心观点分析" :showAllBtn="true" v-if="isBox2 || isAnalysisLoading">
<div class="box2-main"> <div class="box2-main">
<div class="empty-image" v-if="isBox2 && !isAnalysisLoading"> <div class="empty-image" v-if="isBox2 && !isAnalysisLoading">
<img src="../assets/images/empty-image.png" alt="" /> <img src="../assets/images/empty-image.png" alt="" />
...@@ -228,7 +228,11 @@ ...@@ -228,7 +228,11 @@
<div v-for="(sv, svIdx) in item.sourceViewDetails" :key="`${sv.report_id}-${sv.view_id}-${svIdx}`" <div v-for="(sv, svIdx) in item.sourceViewDetails" :key="`${sv.report_id}-${sv.view_id}-${svIdx}`"
class="source-view-detail"> class="source-view-detail">
<div class="source-view-detail-title"> <div class="source-view-detail-title">
<span class="source-view-detail-title-text">{{ getSourceViewDisplayTitle(sv, svIdx) }}</span> <span
class="source-view-detail-title-text"
:class="{ 'is-clickable-report': hasReportLinkForSourceView(sv) }"
@click.stop="handleOpenReportOriginalFromSource(sv)"
>{{ getSourceViewDisplayTitle(sv) }}</span>
<span class="source-view-detail-org" v-if="sv.thinktankName || sv.thinktankLogoUrl"> <span class="source-view-detail-org" v-if="sv.thinktankName || sv.thinktankLogoUrl">
<img v-if="sv.thinktankLogoUrl" :src="sv.thinktankLogoUrl" alt="" /> <img v-if="sv.thinktankLogoUrl" :src="sv.thinktankLogoUrl" alt="" />
<span class="source-view-detail-org-text">{{ sv.thinktankName }}</span> <span class="source-view-detail-org-text">{{ sv.thinktankName }}</span>
...@@ -274,8 +278,11 @@ ...@@ -274,8 +278,11 @@
<div v-for="(sv, svIdx) in item.sourceViewDetails" <div v-for="(sv, svIdx) in item.sourceViewDetails"
:key="`${sv.report_id}-${sv.view_id}-${svIdx}`" class="source-view-detail"> :key="`${sv.report_id}-${sv.view_id}-${svIdx}`" class="source-view-detail">
<div class="source-view-detail-title"> <div class="source-view-detail-title">
<span class="source-view-detail-title-text">{{ getSourceViewDisplayTitle(sv, svIdx) <span
}}</span> class="source-view-detail-title-text"
:class="{ 'is-clickable-report': hasReportLinkForSourceView(sv) }"
@click.stop="handleOpenReportOriginalFromSource(sv)"
>{{ getSourceViewDisplayTitle(sv) }}</span>
<span class="source-view-detail-org" v-if="sv.thinktankName || sv.thinktankLogoUrl"> <span class="source-view-detail-org" v-if="sv.thinktankName || sv.thinktankLogoUrl">
<img v-if="sv.thinktankLogoUrl" :src="sv.thinktankLogoUrl" alt="" /> <img v-if="sv.thinktankLogoUrl" :src="sv.thinktankLogoUrl" alt="" />
<span class="source-view-detail-org-text">{{ sv.thinktankName }}</span> <span class="source-view-detail-org-text">{{ sv.thinktankName }}</span>
...@@ -323,7 +330,7 @@ const sort = ref(""); ...@@ -323,7 +330,7 @@ const sort = ref("");
const searchPolicy = ref(""); const searchPolicy = ref("");
const isBox2 = ref(true) const isBox2 = ref(true)
const isAnalysisLoading = ref(false) const isAnalysisLoading = ref(false)
const isBeingAnalysisExpanded = ref(false) const isBeingAnalysisExpanded = ref(true)
const beingAnalysisContent = ref("") const beingAnalysisContent = ref("")
const beingAnalysisContentRef = ref(null) const beingAnalysisContentRef = ref(null)
const activeOpinionTab = ref('consensus') const activeOpinionTab = ref('consensus')
...@@ -435,11 +442,23 @@ const getViewpointDetailForSource = (reportId, viewId) => { ...@@ -435,11 +442,23 @@ const getViewpointDetailForSource = (reportId, viewId) => {
thinktankLogoUrl: "" thinktankLogoUrl: ""
} }
} }
/** 展开区标题:优先中文标题,否则英文;无标题则返回空串(由上游过滤) */ /** 根据 report_id 找到报告名(用于展开区标题展示) */
const getSourceViewDisplayTitle = (sv, idx) => { const getReportNameById = (reportId) => {
const zh = String(sv.titleZh ?? "").trim() const id = String(reportId ?? "")
if (!id) return ""
const list = selectedReportList.value || []
const hit = Array.isArray(list) ? list.find((r) => String(r?.id ?? "") === id) : null
return String(hit?.name ?? "").trim()
}
/** 展开区标题:显示报告名《xxx》(优先);否则回退中文标题/英文标题;无标题则返回空串(由上游过滤) */
const getSourceViewDisplayTitle = (sv) => {
const reportName = String(sv?.reportName ?? "").trim()
if (reportName) return `《${reportName}》`
const fromId = getReportNameById(sv?.report_id)
if (fromId) return `《${fromId}》`
const zh = String(sv?.titleZh ?? "").trim()
if (zh) return zh if (zh) return zh
const en = String(sv.title ?? "").trim() const en = String(sv?.title ?? "").trim()
if (en) return en if (en) return en
return "" return ""
} }
...@@ -449,6 +468,20 @@ const getSourceViewDisplayContent = (sv) => { ...@@ -449,6 +468,20 @@ const getSourceViewDisplayContent = (sv) => {
if (zh) return zh if (zh) return zh
return String(sv.content ?? "").trim() return String(sv.content ?? "").trim()
} }
/** 是否存在可跳转的报告 id(source_views 的 report_id) */
const hasReportLinkForSourceView = (sv) => Boolean(String(sv?.report_id ?? "").trim())
/** 点击报告标题:新标签打开该报告原文页 */
const handleOpenReportOriginalFromSource = (sv) => {
const id = String(sv?.report_id ?? "").trim()
if (!id) return
const route = router.resolve({
name: "ReportOriginal",
params: { id }
})
window.open(route.href, "_blank")
}
const tryParseAnswerFromStreamText = (text) => { const tryParseAnswerFromStreamText = (text) => {
const lines = String(text || "") const lines = String(text || "")
.split(/\r?\n/) .split(/\r?\n/)
...@@ -492,9 +525,11 @@ const consensusList = computed(() => { ...@@ -492,9 +525,11 @@ const consensusList = computed(() => {
const sourceViewDetails = sourceViews const sourceViewDetails = sourceViews
.map((v) => { .map((v) => {
const detail = getViewpointDetailForSource(v.report_id, v.view_id) const detail = getViewpointDetailForSource(v.report_id, v.view_id)
const reportName = getReportNameById(v.report_id)
return { return {
report_id: v.report_id, report_id: v.report_id,
view_id: v.view_id, view_id: v.view_id,
reportName,
titleZh: detail.titleZh, titleZh: detail.titleZh,
contentZh: detail.contentZh, contentZh: detail.contentZh,
title: detail.title, title: detail.title,
...@@ -504,14 +539,15 @@ const consensusList = computed(() => { ...@@ -504,14 +539,15 @@ const consensusList = computed(() => {
} }
}) })
.filter((sv) => { .filter((sv) => {
const title = getSourceViewDisplayTitle(sv, 0) const title = getSourceViewDisplayTitle(sv)
return Boolean(title) return Boolean(title)
}) })
const uniqueReportCount = new Set(sourceViewDetails.map((sv) => String(sv.report_id ?? ""))).size
const sourceViewText = sourceViews.map((v) => `report_id: ${v.report_id}, view_id: ${v.view_id}`).join(";") const sourceViewText = sourceViews.map((v) => `report_id: ${v.report_id}, view_id: ${v.view_id}`).join(";")
return { return {
id: `consensus-${index + 1}`, id: `consensus-${index + 1}`,
consensusContent: item?.consensus_content || "", consensusContent: item?.consensus_content || "",
reportCount: sourceViewDetails.length, reportCount: uniqueReportCount,
sourceViewText, sourceViewText,
sourceViewDetails sourceViewDetails
} }
...@@ -525,9 +561,11 @@ const differenceList = computed(() => { ...@@ -525,9 +561,11 @@ const differenceList = computed(() => {
const sourceViewDetails = sourceViews const sourceViewDetails = sourceViews
.map((v) => { .map((v) => {
const detail = getViewpointDetailForSource(v.report_id, v.view_id) const detail = getViewpointDetailForSource(v.report_id, v.view_id)
const reportName = getReportNameById(v.report_id)
return { return {
report_id: v.report_id, report_id: v.report_id,
view_id: v.view_id, view_id: v.view_id,
reportName,
titleZh: detail.titleZh, titleZh: detail.titleZh,
contentZh: detail.contentZh, contentZh: detail.contentZh,
title: detail.title, title: detail.title,
...@@ -537,19 +575,43 @@ const differenceList = computed(() => { ...@@ -537,19 +575,43 @@ const differenceList = computed(() => {
} }
}) })
.filter((sv) => { .filter((sv) => {
const title = getSourceViewDisplayTitle(sv, 0) const title = getSourceViewDisplayTitle(sv)
return Boolean(title) return Boolean(title)
}) })
const uniqueReportCount = new Set(sourceViewDetails.map((sv) => String(sv.report_id ?? ""))).size
const sourceViewText = sourceViews.map((v) => `report_id: ${v.report_id}, view_id: ${v.view_id}`).join(";") const sourceViewText = sourceViews.map((v) => `report_id: ${v.report_id}, view_id: ${v.view_id}`).join(";")
return { return {
id: `difference-${index + 1}`, id: `difference-${index + 1}`,
disagreementContent: item?.disagreement_content || "", disagreementContent: item?.disagreement_content || "",
reportCount: sourceViewDetails.length, reportCount: uniqueReportCount,
sourceViewText, sourceViewText,
sourceViewDetails sourceViewDetails
} }
}) })
}) })
// 默认展开:每次分析结果就绪后,共识/分歧列表第一条展开,其余关闭
watch(
consensusList,
(list) => {
if (!Array.isArray(list) || list.length === 0) return
if (openConsensusIds.value.size > 0) return
if (!list[0]?.id) return
openConsensusIds.value = new Set([list[0].id])
},
{ immediate: true }
)
watch(
differenceList,
(list) => {
if (!Array.isArray(list) || list.length === 0) return
if (openDifferencesIds.value.size > 0) return
if (!list[0]?.id) return
openDifferencesIds.value = new Set([list[0].id])
},
{ immediate: true }
)
// 近N年发布(用于 startDate) // 近N年发布(用于 startDate)
const selectedYears = ref(5); const selectedYears = ref(5);
const yearsOptions = [ const yearsOptions = [
...@@ -585,9 +647,12 @@ const handleAnalysis = async () => { ...@@ -585,9 +647,12 @@ const handleAnalysis = async () => {
if (!canProceed.value) return if (!canProceed.value) return
isBox2.value = false isBox2.value = false
isAnalysisLoading.value = true isAnalysisLoading.value = true
isBeingAnalysisExpanded.value = false isBeingAnalysisExpanded.value = true
beingAnalysisContent.value = "" beingAnalysisContent.value = ""
domainViewAnalysisRes.value = null domainViewAnalysisRes.value = null
// 默认:共识/分歧第一条展开,其余关闭(每次开始分析先清空旧展开状态)
openConsensusIds.value = new Set()
openDifferencesIds.value = new Set()
// 每次进入“开始分析”默认回到共识观点,避免上次状态残留导致内容错位 // 每次进入“开始分析”默认回到共识观点,避免上次状态残留导致内容错位
activeOpinionTab.value = 'consensus' activeOpinionTab.value = 'consensus'
await handlePostReportDomainViewAnalysis() await handlePostReportDomainViewAnalysis()
...@@ -601,6 +666,8 @@ const handleBack = () => { ...@@ -601,6 +666,8 @@ const handleBack = () => {
beingAnalysisContent.value = "" beingAnalysisContent.value = ""
// 返回选择时也重置,确保下次进入分析展示一致 // 返回选择时也重置,确保下次进入分析展示一致
activeOpinionTab.value = 'consensus' activeOpinionTab.value = 'consensus'
openConsensusIds.value = new Set()
openDifferencesIds.value = new Set()
} }
const pageSize = 10; const pageSize = 10;
const total = ref(0); const total = ref(0);
...@@ -1029,7 +1096,7 @@ onMounted(async () => { ...@@ -1029,7 +1096,7 @@ onMounted(async () => {
.being-analysis-detail-box { .being-analysis-detail-box {
width: 1063px; width: 1063px;
height: 160px; height: 260px;
background-color: rgb(246, 250, 255); background-color: rgb(246, 250, 255);
border-radius: 10px; border-radius: 10px;
...@@ -1087,7 +1154,7 @@ onMounted(async () => { ...@@ -1087,7 +1154,7 @@ onMounted(async () => {
.being-analysis-box-content { .being-analysis-box-content {
width: 983px; width: 983px;
height: 104px; height: 204px;
margin-left: 40px; margin-left: 40px;
overflow-y: auto; overflow-y: auto;
overflow-x: hidden; overflow-x: hidden;
......
...@@ -50,24 +50,24 @@ ...@@ -50,24 +50,24 @@
</div> </div>
<div class="text">{{ "查看官网" }}</div> <div class="text">{{ "查看官网" }}</div>
</div> --> </div> -->
<div class="btn"> <!-- <div class="btn">
<div class="icon"> <div class="icon">
<img src="./images/btn-icon2.png" alt="" /> <img src="./images/btn-icon2.png" alt="" />
</div> </div>
<div class="text" @click="goToOfficialWebsite()">{{ "查看官网" }}</div> <div class="text" @click="goToOfficialWebsite()">{{ "查看官网" }}</div>
</div> </div> -->
<div class="btn"> <div class="btn">
<div class="icon"> <div class="icon">
<img src="./images/btn-icon2.png" alt="" /> <img src="./images/btn-icon2.png" alt="" />
</div> </div>
<div class="text" @click="toReport()">{{ "报告原文" }}</div> <div class="text" @click="toReport()">{{ "报告原文" }}</div>
</div> </div>
<div class="btn" @click="handleDownloadDocument"> <!-- <div class="btn" @click="handleDownloadDocument">
<div class="icon"> <div class="icon">
<img src="./images/btn-icon3.png" alt="" /> <img src="./images/btn-icon3.png" alt="" />
</div> </div>
<div class="text">{{ "文档下载" }}</div> <div class="text">{{ "文档下载" }}</div>
</div> </div> -->
<div class="btn btn1" @click="handleAnalysisClick"> <div class="btn btn1" @click="handleAnalysisClick">
<div class="icon"> <div class="icon">
<img src="./images/btn-icon4.png" alt="" /> <img src="./images/btn-icon4.png" alt="" />
......
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
<!-- 多个作者:显示第一个 + 等 --> <!-- 多个作者:显示第一个 + 等 -->
<span v-else> <span v-else>
{{ reportAuthors[0].name }} {{ reportAuthors[0].name }}{{ reportAuthors.length }}
</span> </span>
</template> </template>
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
@error="() => { if (author.avatar) author.avatar = null; }" /></div> @error="() => { if (author.avatar) author.avatar = null; }" /></div>
<div class="author-text"> <div class="author-text">
<div class="author-name">{{ author.name }}</div> <div class="author-name">{{ author.name }}</div>
<div class="author-position">{{ author.job }}</div>
</div> </div>
</div> </div>
</div> </div>
...@@ -67,6 +67,10 @@ ...@@ -67,6 +67,10 @@
<div class="box5"> <div class="box5">
<AnalysisBox title="报告关键词云" :showAllBtn="true"> <AnalysisBox title="报告关键词云" :showAllBtn="true">
<div class="box5-main"> <div class="box5-main">
<template v-if="!hasBox5ChartData">
<el-empty class="box5-el-empty" description="暂无数据" :image-size="100" />
</template>
<template v-else>
<div class="box5Chart"> <div class="box5Chart">
<!-- 有数据后再挂载子组件:子组件仅在 onMounted 初始化,异步数据到达后需 v-if + key 强制重新挂载 --> <!-- 有数据后再挂载子组件:子组件仅在 onMounted 初始化,异步数据到达后需 v-if + key 强制重新挂载 -->
<WordCloudChart v-if="box5Data.length" :key="box5WordCloudKey" :data="box5Data" width="100%" <WordCloudChart v-if="box5Data.length" :key="box5WordCloudKey" :data="box5Data" width="100%"
...@@ -77,12 +81,12 @@ ...@@ -77,12 +81,12 @@
</div> </div>
<div class="ai-wrap" @mouseenter="handleSwitchAiContentShowBox5(true)"> <div class="ai-wrap" @mouseenter="handleSwitchAiContentShowBox5(true)">
<AiButton /> <AiButton />
</div> </div>
<div class="ai-content" v-if="isShowAiContentBox5" @mouseleave="handleSwitchAiContentShowBox5(false)"> <div class="ai-content" v-if="isShowAiContentBox5" @mouseleave="handleSwitchAiContentShowBox5(false)">
<AiPane :aiContent="aiContentBox5" /> <AiPane :aiContent="aiContentBox5" />
</div> </div>
</template>
</div> </div>
</AnalysisBox> </AnalysisBox>
</div> </div>
...@@ -255,7 +259,8 @@ const props = defineProps({ ...@@ -255,7 +259,8 @@ const props = defineProps({
}); });
const REPORT_ANALYSIS_TIP_BOX5 = const REPORT_ANALYSIS_TIP_BOX5 =
"智库报告关键词云,数据来源:美国兰德公司官网"; "智库报告关键词云,数据来源:美国兰德公司官网";
const isShowAiContentBox5 = ref(false); // 刷新后默认展示「报告关键词云」AI 总结
const isShowAiContentBox5 = ref(true);
const aiContentBox5 = ref(""); const aiContentBox5 = ref("");
const isBox5InterpretLoading = ref(false); const isBox5InterpretLoading = ref(false);
const handleSwitchAiContentShowBox5 = (val) => { const handleSwitchAiContentShowBox5 = (val) => {
...@@ -468,6 +473,7 @@ const box2Data = ref([ ...@@ -468,6 +473,7 @@ const box2Data = ref([
]); ]);
// 报告关键词云 // 报告关键词云
const box5Data = ref([]); const box5Data = ref([]);
const hasBox5ChartData = computed(() => Array.isArray(box5Data.value) && box5Data.value.length > 0);
/** 词云子组件不 watch 数据,每次接口成功有数据时递增 key,强制重新挂载以触发 onMounted */ /** 词云子组件不 watch 数据,每次接口成功有数据时递增 key,强制重新挂载以触发 onMounted */
const box5WordCloudKey = ref(0); const box5WordCloudKey = ref(0);
...@@ -490,6 +496,10 @@ const handleGetThinkTankReportIndustryCloud = async () => { ...@@ -490,6 +496,10 @@ const handleGetThinkTankReportIndustryCloud = async () => {
if (data.length) { if (data.length) {
box5WordCloudKey.value += 1; box5WordCloudKey.value += 1;
} }
// 刷新后默认展开 AI:数据就绪即触发解读
if (isShowAiContentBox5.value) {
fetchBox5ChartInterpretation();
}
} else { } else {
box5Data.value = []; box5Data.value = [];
} }
...@@ -582,11 +592,16 @@ const handleGetThinkTankReportViewpoint = async () => { ...@@ -582,11 +592,16 @@ const handleGetThinkTankReportViewpoint = async () => {
const res = await getThinkTankReportViewpoint(params); const res = await getThinkTankReportViewpoint(params);
console.log("核心论点", res.data); console.log("核心论点", res.data);
if (res.code === 200 && res.data) { if (res.code === 200 && res.data) {
majorOpinions.value = res.data.content || []; const nextOpinions = res.data.content || [];
majorOpinions.value = nextOpinions;
total.value = res.data.totalElements || 0; total.value = res.data.totalElements || 0;
// 重置展开状态 // 默认:第一条展开,其余关闭
expandedOpinionKeys.value = new Set(); const nextExpandedKeys = new Set();
if (Array.isArray(nextOpinions) && nextOpinions.length > 0) {
nextExpandedKeys.add(getOpinionExpandKey(nextOpinions[0], 0));
}
expandedOpinionKeys.value = nextExpandedKeys;
} }
} catch (error) { } catch (error) {
console.error("获取主要观点error", error); console.error("获取主要观点error", error);
......
...@@ -302,11 +302,46 @@ import AiButton from "@/components/base/Ai/AiButton/index.vue"; ...@@ -302,11 +302,46 @@ import AiButton from "@/components/base/Ai/AiButton/index.vue";
import AiPane from "@/components/base/Ai/AiPane/index.vue"; import AiPane from "@/components/base/Ai/AiPane/index.vue";
import TipTab from "@/views/thinkTank/TipTab/index.vue"; import TipTab from "@/views/thinkTank/TipTab/index.vue";
import defaultNewsIcon from "@/assets/icons/default-icon-news.png"; import defaultNewsIcon from "@/assets/icons/default-icon-news.png";
import AreaTag from "@/components/base/AreaTag/index.vue";
import { useRouter } from "vue-router"; import { useRouter } from "vue-router";
const router = useRouter(); const router = useRouter();
/** 与 AreaTag 一致的领域色(取 tag 的文字色) */
const AREA_TAG_COLOR_BY_NAME = {
"人工智能": "rgba(245, 34, 45, 1)", // tag1
"生物科技": "rgba(19, 168, 168, 1)", // tag2
"新一代通信网络": "rgba(5, 95, 194, 1)", // tag3
// 兼容常见写法
"通信网络": "rgba(5, 95, 194, 1)",
"量子科技": "rgba(114, 46, 209, 1)", // tag4
"新能源": "rgba(82, 196, 26, 1)", // tag5
"集成电路": "rgba(22, 119, 255, 1)", // tag6
"海洋": "rgba(15, 120, 199, 1)", // tag7
"先进制造": "rgba(250, 173, 20, 1)", // tag8
"新材料": "rgba(250, 140, 22, 1)", // tag9
"航空航天": "rgba(47, 84, 235, 1)", // tag10
"太空": "rgba(47, 84, 235, 1)", // tag11
"深海": "rgba(73, 104, 161, 1)", // tag12
"极地": "rgba(133, 165, 255, 1)", // tag13
"核": "rgba(250, 84, 28, 1)", // tag14
"其他": "rgba(82, 196, 26, 1)" // tag15
};
const AREA_TAG_FALLBACK_COLORS = [
"rgba(5, 95, 194, 1)",
"rgba(245, 34, 45, 1)",
"rgba(19, 168, 168, 1)",
"rgba(250, 140, 22, 1)",
"rgba(114, 46, 209, 1)",
"rgba(82, 196, 26, 1)",
"rgba(22, 119, 255, 1)",
"rgba(250, 84, 28, 1)",
"rgba(47, 84, 235, 1)"
];
const getAreaTagColor = (name, idx = 0) =>
AREA_TAG_COLOR_BY_NAME[name] || AREA_TAG_FALLBACK_COLORS[idx % AREA_TAG_FALLBACK_COLORS.length];
/** 与智库概览 TipTab 文案格式一致(政策追踪-美国国会) */ /** 与智库概览 TipTab 文案格式一致(政策追踪-美国国会) */
const POLICY_TRACKING_TIP_BOX1 = const POLICY_TRACKING_TIP_BOX1 =
"智库报告中政策建议的领域分布情况,数据来源:美国兰德公司官网"; "智库报告中政策建议的领域分布情况,数据来源:美国兰德公司官网";
...@@ -320,7 +355,8 @@ const POLICY_FILTER_ALL_AREA = "全部领域"; ...@@ -320,7 +355,8 @@ const POLICY_FILTER_ALL_AREA = "全部领域";
const POLICY_FILTER_ALL_TIME = "全部时间"; const POLICY_FILTER_ALL_TIME = "全部时间";
const POLICY_FILTER_ALL_DEPT = "全部部门"; const POLICY_FILTER_ALL_DEPT = "全部部门";
const isShowAiContentPolicyPt1 = ref(false); // 刷新后默认展示 3 个图表 AI 总结
const isShowAiContentPolicyPt1 = ref(true);
const aiContentPolicyPt1 = ref(""); const aiContentPolicyPt1 = ref("");
const isPolicyPt1InterpretLoading = ref(false); const isPolicyPt1InterpretLoading = ref(false);
const handleSwitchAiContentShowPolicyPt1 = (val) => { const handleSwitchAiContentShowPolicyPt1 = (val) => {
...@@ -330,7 +366,7 @@ const handleSwitchAiContentShowPolicyPt1 = (val) => { ...@@ -330,7 +366,7 @@ const handleSwitchAiContentShowPolicyPt1 = (val) => {
} }
}; };
const isShowAiContentPolicyPt2 = ref(false); const isShowAiContentPolicyPt2 = ref(true);
const aiContentPolicyPt2 = ref(""); const aiContentPolicyPt2 = ref("");
const isPolicyPt2InterpretLoading = ref(false); const isPolicyPt2InterpretLoading = ref(false);
const handleSwitchAiContentShowPolicyPt2 = (val) => { const handleSwitchAiContentShowPolicyPt2 = (val) => {
...@@ -340,7 +376,7 @@ const handleSwitchAiContentShowPolicyPt2 = (val) => { ...@@ -340,7 +376,7 @@ const handleSwitchAiContentShowPolicyPt2 = (val) => {
} }
}; };
const isShowAiContentPolicyPt3 = ref(false); const isShowAiContentPolicyPt3 = ref(true);
const aiContentPolicyPt3 = ref(""); const aiContentPolicyPt3 = ref("");
const isPolicyPt3InterpretLoading = ref(false); const isPolicyPt3InterpretLoading = ref(false);
const handleSwitchAiContentShowPolicyPt3 = (val) => { const handleSwitchAiContentShowPolicyPt3 = (val) => {
...@@ -439,16 +475,20 @@ const handleGetThinkPolicyIndustry = async () => { ...@@ -439,16 +475,20 @@ const handleGetThinkPolicyIndustry = async () => {
box1Data.value = []; box1Data.value = [];
return; return;
} }
const data = list.map(item => ({ const data = list.map((item, idx) => ({
name: item.industry, name: item.industry,
value: item.amount, value: item.amount,
percent: item.percent percent: item.percent,
color: getAreaTagColor(item.industry, idx)
})); }));
box1Data.value = data; box1Data.value = data;
/* v-if 有数据后才挂载 #box1Chart,须等 DOM 更新后再 init echarts */ /* v-if 有数据后才挂载 #box1Chart,须等 DOM 更新后再 init echarts */
await nextTick(); await nextTick();
const box1Chart = getPieChart(box1Data.value); const box1Chart = getPieChart(box1Data.value);
setChart(box1Chart, "box1Chart"); setChart(box1Chart, "box1Chart");
if (isShowAiContentPolicyPt1.value) {
fetchPolicyPtBox1ChartInterpretation();
}
} else { } else {
box1Data.value = []; box1Data.value = [];
} }
...@@ -518,6 +558,9 @@ const handleGetPolicyAdviceDeptDistribution = async () => { ...@@ -518,6 +558,9 @@ const handleGetPolicyAdviceDeptDistribution = async () => {
await nextTick(); await nextTick();
const box2Chart = getPieChart(box2Data.value); const box2Chart = getPieChart(box2Data.value);
setChart(box2Chart, "box2Chart"); setChart(box2Chart, "box2Chart");
if (isShowAiContentPolicyPt2.value) {
fetchPolicyPtBox2ChartInterpretation();
}
} else { } else {
box2Data.value = []; box2Data.value = [];
} }
...@@ -670,7 +713,8 @@ const handleGetThinkPolicyIndustryChange = async () => { ...@@ -670,7 +713,8 @@ const handleGetThinkPolicyIndustryChange = async () => {
const industryAmount = const industryAmount =
quarterData?.industryList?.find(i => i.industry === industry)?.amount || 0; quarterData?.industryList?.find(i => i.industry === industry)?.amount || 0;
return industryAmount; return industryAmount;
}) }),
color: getAreaTagColor(industry, frontendData.data.length)
}; };
frontendData.data.push(industryData); frontendData.data.push(industryData);
}); });
...@@ -680,6 +724,9 @@ const handleGetThinkPolicyIndustryChange = async () => { ...@@ -680,6 +724,9 @@ const handleGetThinkPolicyIndustryChange = async () => {
} }
box3Data.value = frontendData; box3Data.value = frontendData;
await renderBox3Chart(); await renderBox3Chart();
if (isShowAiContentPolicyPt3.value) {
fetchPolicyPtBox3ChartInterpretation();
}
} else { } else {
box3Data.value = { title: [], data: [] }; box3Data.value = { title: [], data: [] };
} }
...@@ -1255,14 +1302,14 @@ watch( ...@@ -1255,14 +1302,14 @@ watch(
} }
); );
onMounted(() => { onMounted(async () => {
handleGetThinkPolicyIndustry(); await handleGetThinkPolicyIndustry();
handleGetThinkPolicyIndustryTotal(); handleGetThinkPolicyIndustryTotal();
handleGetThinkPolicyIndustryChange(); await handleGetThinkPolicyIndustryChange();
handleGetHylyList(); handleGetHylyList();
handleGetGovAgencyList(); handleGetGovAgencyList();
handleGetThinkPolicy(); handleGetThinkPolicy();
handleGetPolicyAdviceDeptDistribution(); await handleGetPolicyAdviceDeptDistribution();
}); });
</script> </script>
...@@ -1476,7 +1523,7 @@ onMounted(() => { ...@@ -1476,7 +1523,7 @@ onMounted(() => {
width: 520px; width: 520px;
height: 372px; height: 372px;
box-sizing: border-box; box-sizing: border-box;
padding: 24px 24px 64px 24px; padding: 0px 24px 64px 24px;
position: relative; position: relative;
overflow: hidden; overflow: hidden;
...@@ -1504,7 +1551,7 @@ onMounted(() => { ...@@ -1504,7 +1551,7 @@ onMounted(() => {
flex: 1; flex: 1;
min-width: 0; min-width: 0;
width: 472px; width: 472px;
height: 284px; height: 308px;
} }
.source { .source {
......
import * as echarts from 'echarts' import * as echarts from 'echarts'
const colorList = [ // 按 AreaTag 的颜色规则映射到折线图配色(取 tag 的文字色)
const AREA_TAG_COLOR_BY_NAME = {
'人工智能': 'rgba(245, 34, 45, 1)', // tag1
'生物科技': 'rgba(19, 168, 168, 1)', // tag2
'新一代通信网络': 'rgba(5, 95, 194, 1)', // tag3
// 兼容常见写法
'通信网络': 'rgba(5, 95, 194, 1)',
'量子科技': 'rgba(114, 46, 209, 1)', // tag4
'新能源': 'rgba(82, 196, 26, 1)', // tag5
'集成电路': 'rgba(22, 119, 255, 1)', // tag6
'海洋': 'rgba(15, 120, 199, 1)', // tag7
'先进制造': 'rgba(250, 173, 20, 1)', // tag8
'新材料': 'rgba(250, 140, 22, 1)', // tag9
'航空航天': 'rgba(47, 84, 235, 1)', // tag10
'太空': 'rgba(47, 84, 235, 1)', // tag11
'深海': 'rgba(73, 104, 161, 1)', // tag12
'极地': 'rgba(133, 165, 255, 1)', // tag13
'核': 'rgba(250, 84, 28, 1)', // tag14
'其他': 'rgba(82, 196, 26, 1)' // tag15
}
const fallbackColorList = [
'rgba(5, 95, 194, 1)', 'rgba(5, 95, 194, 1)',
'rgba(245, 34, 45, 1)',
'rgba(19, 168, 168, 1)', 'rgba(19, 168, 168, 1)',
'rgba(250, 140, 22, 1)', 'rgba(250, 140, 22, 1)',
'rgba(114, 46, 209, 1)', 'rgba(114, 46, 209, 1)',
'rgba(115, 209, 61, 1)', 'rgba(82, 196, 26, 1)',
'rgba(206, 79, 81, 1)', 'rgba(22, 119, 255, 1)',
'rgba(145, 202, 255, 1)',
'rgba(95, 101, 108, 1)',
'rgba(250, 84, 28, 1)', 'rgba(250, 84, 28, 1)',
'rgba(47, 84, 235, 1)', 'rgba(47, 84, 235, 1)',
'rgba(64, 150, 255, 1)', 'rgba(133, 165, 255, 1)'
'rgba(34, 41, 52, 1)',
'rgba(173, 198, 255, 1)',
'rgba(255, 169, 64, 1)'
] ]
const parseRgba = (colorStr) => { const parseRgba = (colorStr) => {
...@@ -50,7 +67,8 @@ const getMultiLineChart = (chartInput) => { ...@@ -50,7 +67,8 @@ const getMultiLineChart = (chartInput) => {
const echartsSeries = series.map((item, index) => { const echartsSeries = series.map((item, index) => {
const baseColor = const baseColor =
item.color || item.color ||
colorList[index % colorList.length] || AREA_TAG_COLOR_BY_NAME[item.name] ||
fallbackColorList[index % fallbackColorList.length] ||
`rgba(${Math.floor(Math.random() * 256)}, ${Math.floor(Math.random() * 256)}, ${Math.floor(Math.random() * 256)}, 1)` `rgba(${Math.floor(Math.random() * 256)}, ${Math.floor(Math.random() * 256)}, ${Math.floor(Math.random() * 256)}, 1)`
const { r, g, b } = parseRgba(baseColor) const { r, g, b } = parseRgba(baseColor)
...@@ -58,9 +76,11 @@ const getMultiLineChart = (chartInput) => { ...@@ -58,9 +76,11 @@ const getMultiLineChart = (chartInput) => {
name: item.name, name: item.name,
type: 'line', type: 'line',
smooth: true, smooth: true,
lineStyle: { color: baseColor },
itemStyle: { color: baseColor },
areaStyle: { areaStyle: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [ color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{ offset: 0, color: `rgba(${r}, ${g}, ${b}, 0.3)` }, { offset: 0, color: `rgba(${r}, ${g}, ${b}, 0.1)` },
{ offset: 1, color: `rgba(${r}, ${g}, ${b}, 0)` } { offset: 1, color: `rgba(${r}, ${g}, ${b}, 0)` }
]) ])
}, },
...@@ -147,7 +167,7 @@ const getMultiLineChart = (chartInput) => { ...@@ -147,7 +167,7 @@ const getMultiLineChart = (chartInput) => {
itemHeight: 12 itemHeight: 12
} }
], ],
color: colorList, // 不使用全局 color,改为每条 series 自己定色(与 AreaTag 一致)
xAxis: [ xAxis: [
{ {
type: 'category', type: 'category',
......
const getPieChart = (data) => { const getPieChart = (data) => {
const seriesData = (Array.isArray(data) ? data : []).map((d) => {
const color = d?.color
if (!color) return d
return {
...d,
itemStyle: { ...(d.itemStyle || {}), color },
// “飞线”(labelLine)跟随领域色
labelLine: {
...(d.labelLine || {}),
lineStyle: { ...(d.labelLine?.lineStyle || {}), color }
}
}
})
let option = { let option = {
series: [ series: [
{ {
...@@ -57,7 +71,7 @@ const getPieChart = (data) => { ...@@ -57,7 +71,7 @@ const getPieChart = (data) => {
labelLinePoints: points labelLinePoints: points
}; };
}, },
data: data data: seriesData
}] }]
} }
return option return option
......
...@@ -17,12 +17,12 @@ ...@@ -17,12 +17,12 @@
<AreaTag v-for="(tag, index) in thinkTank.tags" :key="index" :tagName="tag.industryName"></AreaTag> <AreaTag v-for="(tag, index) in thinkTank.tags" :key="index" :tagName="tag.industryName"></AreaTag>
</div> </div>
</div> </div>
<div class="header-top-right"> <!-- <div class="header-top-right">
<button class="blue-btn" @click="handleOpenThinkTankSite"> <button class="blue-btn" @click="handleOpenThinkTankSite">
<img class="btn-img" src="./images/image1.png" alt="" /> <img class="btn-img" src="./images/image1.png" alt="" />
<span class="text">{{ '查看智库官网' }}</span> <span class="text">{{ '查看智库官网' }}</span>
</button> </button>
</div> </div> -->
</div> </div>
<div class="header-footer"> <div class="header-footer">
<div class="tab" :class="{ tabActive: tabActiveName === '智库动态' }" @click="switchTab('智库动态')"> <div class="tab" :class="{ tabActive: tabActiveName === '智库动态' }" @click="switchTab('智库动态')">
......
...@@ -455,7 +455,7 @@ const handleGetThinkTankFundsSource = async () => { ...@@ -455,7 +455,7 @@ const handleGetThinkTankFundsSource = async () => {
formatter(params) { formatter(params) {
const valueYi = (params.data.value || 0) / 10000 const valueYi = (params.data.value || 0) / 10000
const percent = params.percent || 0 const percent = params.percent || 0
const valueStr = `${valueYi}${percent}%` const valueStr = `${valueYi.toFixed(2)}${percent}%`
let cumulative = 0 let cumulative = 0
for (let i = 0; i < params.dataIndex; i++) cumulative += dataList[i].value || 0 for (let i = 0; i < params.dataIndex; i++) cumulative += dataList[i].value || 0
const centerAngle = 90 + ((cumulative + (params.data.value || 0) / 2) / total) * 360 const centerAngle = 90 + ((cumulative + (params.data.value || 0) / 2) / total) * 360
......
...@@ -163,8 +163,8 @@ ...@@ -163,8 +163,8 @@
</div> </div>
<DivideHeader id="position2" class="divide-header" :titleText="'资讯要闻'"></DivideHeader> <DivideHeader id="position2" class="divide-header" :titleText="'资讯要闻'"></DivideHeader>
<div class="center-center"> <div class="center-center">
<NewsList :newsList="newsList" @item-click="handleToNewsAnalysis" @more-click="handleToMoreNews" <NewsList :newsList="newsList" @item-click="item => gotoNewsDetail(item.newsId)"
img="newsImage" title="newsTitle" content="newsContent" from="from" /> @more-click="handleToMoreNews" img="newsImage" title="newsTitle" content="newsContent" from="from" />
<MessageBubble :messageList="messageList" imageUrl="personImage" @more-click="handleToSocialDetail" <MessageBubble :messageList="messageList" imageUrl="personImage" @more-click="handleToSocialDetail"
@person-click="handleClickPerson" name="personName" content="remarks" source="orgName" /> @person-click="handleClickPerson" name="personName" content="remarks" source="orgName" />
</div> </div>
...@@ -449,11 +449,13 @@ import Box1Logo from "./assets/images/box1-logo.png"; ...@@ -449,11 +449,13 @@ import Box1Logo from "./assets/images/box1-logo.png";
import { setCanvasCreator } from "echarts/core"; import { setCanvasCreator } from "echarts/core";
import { ElMessage } from "element-plus"; import { ElMessage } from "element-plus";
import { useRouter } from 'vue-router'; import { useRouter } from 'vue-router';
import { useGotoNewsDetail } from '@/router/modules/news';
const gotoNewsDetail = useGotoNewsDetail()
const containerRef = ref(null); const containerRef = ref(null);
const statCountInfo = ref([]); const statCountInfo = ref([]);
const pageSize = ref(15) const pageSize = ref(15)
const totalAllItem = ref(0) const totalAllItem = ref(0)
const isShowAiContentBox5 = ref(false); const isShowAiContentBox5 = ref(true);
const aiContentBox5 = ref(""); const aiContentBox5 = ref("");
const isBox5InterpretLoading = ref(false); const isBox5InterpretLoading = ref(false);
const handleSwitchAiContentShowBox5 = (val) => { const handleSwitchAiContentShowBox5 = (val) => {
...@@ -462,7 +464,8 @@ const handleSwitchAiContentShowBox5 = (val) => { ...@@ -462,7 +464,8 @@ const handleSwitchAiContentShowBox5 = (val) => {
fetchBox5ChartInterpretation(); fetchBox5ChartInterpretation();
} }
}; };
const isShowAiContentBox6 = ref(false); // 刷新后默认展示「领域分布情况」AI 总结
const isShowAiContentBox6 = ref(true);
const aiContentBox6 = ref(""); const aiContentBox6 = ref("");
const isBox6InterpretLoading = ref(false); const isBox6InterpretLoading = ref(false);
const handleSwitchAiContentShowBox6 = (val) => { const handleSwitchAiContentShowBox6 = (val) => {
...@@ -471,7 +474,8 @@ const handleSwitchAiContentShowBox6 = (val) => { ...@@ -471,7 +474,8 @@ const handleSwitchAiContentShowBox6 = (val) => {
fetchBox6ChartInterpretation(); fetchBox6ChartInterpretation();
} }
}; };
const isShowAiContentBox7 = ref(false); // 刷新后默认展示「智库资金流向」AI 总结
const isShowAiContentBox7 = ref(true);
const aiContentBox7 = ref(""); const aiContentBox7 = ref("");
const isBox7InterpretLoading = ref(false); const isBox7InterpretLoading = ref(false);
const handleSwitchAiContentShowBox7 = (val) => { const handleSwitchAiContentShowBox7 = (val) => {
...@@ -1004,6 +1008,10 @@ const renderBox5Chart = () => { ...@@ -1004,6 +1008,10 @@ const renderBox5Chart = () => {
const handleBox5AreaChange = () => { const handleBox5AreaChange = () => {
aiContentBox5.value = ""; aiContentBox5.value = "";
renderBox5Chart(); renderBox5Chart();
// 切换领域后,若 AI 面板已打开则重新触发流式解读
if (isShowAiContentBox5.value) {
fetchBox5ChartInterpretation();
}
}; };
const handleBox5 = async year => { const handleBox5 = async year => {
...@@ -1012,7 +1020,13 @@ const handleBox5 = async year => { ...@@ -1012,7 +1020,13 @@ const handleBox5 = async year => {
box5selectetedArea.value = "全部领域"; box5selectetedArea.value = "全部领域";
await handleGetThinkTankPolicyIndustryChange(getBox5YearDateRange(y)); await handleGetThinkTankPolicyIndustryChange(getBox5YearDateRange(y));
renderBox5Chart(); renderBox5Chart();
// 若 AI 面板已打开,让解读在首次加载时自动生成;否则仅清空缓存
if (isShowAiContentBox5.value) {
aiContentBox5.value = "";
fetchBox5ChartInterpretation();
} else {
aiContentBox5.value = ""; aiContentBox5.value = "";
}
}; };
/** 兼容 getChartAnalysis 返回对象:从 data[0] 提取「解读」文本 */ /** 兼容 getChartAnalysis 返回对象:从 data[0] 提取「解读」文本 */
...@@ -1234,14 +1248,45 @@ const box6TankList = ref([ ...@@ -1234,14 +1248,45 @@ const box6TankList = ref([
} }
]); ]);
function transformToChartFormat(data) { function transformToChartFormat(data) {
// 预设颜色池(可按需修改或扩展) // 按 AreaTag 的颜色规则映射到饼图配色(取 tag 的文字色)
const colorPalette = ["#4096FF", "#FFA39E", "#ADC6FF", "#FFC069", "#B5F5EC", "#B37FEB", "#D6E4FF", "#FF8C8C", "#87E8DE"]; const areaTagColorByName = {
"人工智能": "rgba(245, 34, 45, 1)", // tag1
"生物科技": "rgba(19, 168, 168, 1)", // tag2
"新一代通信网络": "rgba(5, 95, 194, 1)", // tag3
// 兼容常见写法
"通信网络": "rgba(5, 95, 194, 1)",
"量子科技": "rgba(114, 46, 209, 1)", // tag4
"新能源": "rgba(82, 196, 26, 1)", // tag5
"集成电路": "rgba(22, 119, 255, 1)", // tag6
"海洋": "rgba(15, 120, 199, 1)", // tag7
"先进制造": "rgba(250, 173, 20, 1)", // tag8
"新材料": "rgba(250, 140, 22, 1)", // tag9
"航空航天": "rgba(47, 84, 235, 1)", // tag10
"太空": "rgba(47, 84, 235, 1)", // tag11
"深海": "rgba(73, 104, 161, 1)", // tag12
"极地": "rgba(133, 165, 255, 1)", // tag13
"核": "rgba(250, 84, 28, 1)", // tag14
"其他": "rgba(82, 196, 26, 1)" // tag15
};
// 未命中 AreaTag 映射时的兜底色板
const fallbackColorPalette = [
"rgba(5, 95, 194, 1)",
"rgba(245, 34, 45, 1)",
"rgba(19, 168, 168, 1)",
"rgba(250, 140, 22, 1)",
"rgba(114, 46, 209, 1)",
"rgba(82, 196, 26, 1)",
"rgba(22, 119, 255, 1)",
"rgba(250, 84, 28, 1)",
"rgba(47, 84, 235, 1)"
];
const list = Array.isArray(data) ? data.slice(0, 7) : []; const list = Array.isArray(data) ? data.slice(0, 7) : [];
return list.map((item, index) => ({ return list.map((item, index) => ({
name: item.industry, name: item.industry,
value: item.amount, value: item.amount,
color: colorPalette[index % colorPalette.length] color: areaTagColorByName[item.industry] || fallbackColorPalette[index % fallbackColorPalette.length]
})); }));
} }
// 政策建议领域分布 // 政策建议领域分布
...@@ -1287,6 +1332,10 @@ const handleBox6 = async () => { ...@@ -1287,6 +1332,10 @@ const handleBox6 = async () => {
aiContentBox6.value = ""; aiContentBox6.value = "";
await handleGetThinkTankPolicyIndustry(); await handleGetThinkTankPolicyIndustry();
renderBox6Chart(); renderBox6Chart();
// 若 AI 面板已打开,让解读在首次加载时自动生成
if (isShowAiContentBox6.value) {
fetchBox6ChartInterpretation();
}
}; };
// 智库资金流向 // 智库资金流向
...@@ -1398,6 +1447,10 @@ const handleBox7 = async () => { ...@@ -1398,6 +1447,10 @@ const handleBox7 = async () => {
const links = box7Data.value?.links ?? []; const links = box7Data.value?.links ?? [];
const box7Chart = getSankeyChart(nodes, links); const box7Chart = getSankeyChart(nodes, links);
setChart(box7Chart, "box7Chart"); setChart(box7Chart, "box7Chart");
// 若 AI 面板已打开,让解读在首次加载时自动生成
if (isShowAiContentBox7.value) {
fetchBox7ChartInterpretation();
}
}; };
/** 请求 box7 智库资金流向桑基图解读(入参:{ text: JSON.stringify({ type, name, nodes, links }) }) */ /** 请求 box7 智库资金流向桑基图解读(入参:{ text: JSON.stringify({ type, name, nodes, links }) }) */
...@@ -2044,9 +2097,12 @@ onMounted(async () => { ...@@ -2044,9 +2097,12 @@ onMounted(async () => {
handleGetNewReport(); handleGetNewReport();
handleGetThinkTankRiskSignal(); handleGetThinkTankRiskSignal();
handleBox5(box5selectetedYear.value); // 先拉到图表数据,再打开 AI 面板并触发解读,避免初始为空导致“无内容”
handleBox6(); await handleBox5(box5selectetedYear.value);
handleBox7(); handleSwitchAiContentShowBox5(true);
// 先把图表数据准备好,避免用户悬浮太快触发解读但数据未就绪
await handleBox6();
await handleBox7();
handleGetHylyList(); handleGetHylyList();
handleGetThinkTankHot(getDateYearsAgo(1)); handleGetThinkTankHot(getDateYearsAgo(1));
handleGetetThinkTankReport(); handleGetetThinkTankReport();
...@@ -3424,7 +3480,7 @@ onMounted(async () => { ...@@ -3424,7 +3480,7 @@ onMounted(async () => {
width: 1063px; width: 1063px;
box-sizing: border-box; box-sizing: border-box;
position: relative; position: relative;
padding: 24px 24px 64px 24px; padding: 0px 24px 64px 24px;
&.box5-main--empty { &.box5-main--empty {
display: flex; display: flex;
...@@ -3453,7 +3509,7 @@ onMounted(async () => { ...@@ -3453,7 +3509,7 @@ onMounted(async () => {
.box5-chart-canvas { .box5-chart-canvas {
flex: 1; flex: 1;
min-width: 0; min-width: 0;
height: 324px; height: 348px;
} }
.source { .source {
......
...@@ -24,11 +24,24 @@ ...@@ -24,11 +24,24 @@
</div> </div>
<div class="main"> <div class="main">
<div class="main-header"> <div class="main-header">
<div style=" margin-top: 17px;"> <div>
智库报告原文 智库报告原文
</div> </div>
<div class="btn-box"> <div class="btn-box">
<div class="translate"> <div class="translate">
<div class="search-input-wrap" v-if="showSearchInput">
<input v-model="searchKeywordText" class="search-input" placeholder="回车查询"
@keyup.enter="handleSearchInPdf" />
<div class="search-match-count">{{ matchInfo.current }}/{{ matchInfo.total }}</div>
<button class="search-nav-btn" type="button" @click="handlePrevMatch"
:disabled="matchInfo.total === 0 || matchInfo.current <= 1">
上一个
</button>
<button class="search-nav-btn" type="button" @click="handleNextMatch"
:disabled="matchInfo.total === 0 || matchInfo.current >= matchInfo.total">
下一个
</button>
</div>
<div class="switch"> <div class="switch">
<el-switch v-model="valueSwitch" /> <el-switch v-model="valueSwitch" />
</div> </div>
...@@ -48,17 +61,24 @@ ...@@ -48,17 +61,24 @@
</div> </div>
</div> </div>
<div class="report-box"> <div class="report-box">
<pdf v-if="valueSwitch && reportUrlEnWithPage" ref="leftPdfRef" :pdfUrl="reportUrlEnWithPage" <div class="pdf-pane-wrap" v-if="valueSwitch && reportUrlEnWithPage">
class="pdf-pane" /> <pdf ref="leftPdfRef" :pdfUrl="reportUrlEnWithPage" class="pdf-pane-inner" />
<pdf v-if="reportUrlWithPage" ref="rightPdfRef" :pdfUrl="reportUrlWithPage" </div>
:class="['pdf-pane', { 'pdf-pane-full': !valueSwitch }]" /> <div class="pdf-pane-wrap" :class="{ 'is-full': !valueSwitch }" v-if="reportUrlWithPage">
<pdf
:key="`right-pdf-${valueSwitch ? 'split' : 'full'}`"
ref="rightPdfRef"
:pdfUrl="reportUrlWithPage"
class="pdf-pane-inner"
/>
</div>
</div> </div>
</div> </div>
</div> </div>
</template> </template>
<script setup> <script setup>
import { computed, ref, onMounted } from "vue"; import { computed, ref, onMounted, watch } from "vue";
import pdf from "./pdf.vue"; import pdf from "./pdf.vue";
import { import {
getThinkTankReportSummary, getThinkTankReportSummary,
...@@ -88,14 +108,59 @@ const buildPdfPageUrl = url => { ...@@ -88,14 +108,59 @@ const buildPdfPageUrl = url => {
const reportUrlWithPage = computed(() => buildPdfPageUrl(reportUrl.value)) const reportUrlWithPage = computed(() => buildPdfPageUrl(reportUrl.value))
const reportUrlEnWithPage = computed(() => buildPdfPageUrl(reportUrlEn.value)) const reportUrlEnWithPage = computed(() => buildPdfPageUrl(reportUrlEn.value))
const valueSwitch = ref(true) const valueSwitch = ref(true)
const showSearchInput = ref(false) const showSearchInput = ref(true)
const searchKeywordText = ref('') const searchKeywordText = ref('')
const leftPdfRef = ref(null) const leftPdfRef = ref(null)
const rightPdfRef = ref(null) const rightPdfRef = ref(null)
const matchInfo = ref({ current: 0, total: 0 })
const activePdfRef = ref(null)
const clearPdfSearchState = () => {
activePdfRef.value = null
matchInfo.value = { current: 0, total: 0 }
const leftPdf = leftPdfRef.value
const rightPdf = rightPdfRef.value
if (leftPdf && typeof leftPdf.clearSearch === 'function') {
leftPdf.clearSearch()
}
if (rightPdf && typeof rightPdf.clearSearch === 'function') {
rightPdf.clearSearch()
}
}
const updateMatchInfo = () => {
const pdf = activePdfRef.value
if (pdf && typeof pdf.getMatchInfo === 'function') {
matchInfo.value = pdf.getMatchInfo()
return
}
matchInfo.value = { current: 0, total: 0 }
}
watch(
() => searchKeywordText.value,
(val) => {
const keyword = String(val ?? '').trim()
if (!keyword) {
clearPdfSearchState()
}
}
)
watch(
() => valueSwitch.value,
() => {
// 切换「显示原文」会导致 PDF 重新挂载/布局变化:清空搜索与计数,回到初始状态
searchKeywordText.value = ''
clearPdfSearchState()
}
)
const handleSearchInPdf = async () => { const handleSearchInPdf = async () => {
const keyword = searchKeywordText.value?.trim() const keyword = searchKeywordText.value?.trim()
if (!keyword) return if (!keyword) return
activePdfRef.value = null
matchInfo.value = { current: 0, total: 0 }
const leftPdf = leftPdfRef.value const leftPdf = leftPdfRef.value
const rightPdf = rightPdfRef.value const rightPdf = rightPdfRef.value
let page = 0 let page = 0
...@@ -110,6 +175,8 @@ const handleSearchInPdf = async () => { ...@@ -110,6 +175,8 @@ const handleSearchInPdf = async () => {
} }
if (page && targetRef && typeof targetRef.goToPage === 'function') { if (page && targetRef && typeof targetRef.goToPage === 'function') {
targetRef.goToPage(page) targetRef.goToPage(page)
activePdfRef.value = targetRef
updateMatchInfo()
} else { } else {
try { try {
const { ElMessage } = await import('element-plus') const { ElMessage } = await import('element-plus')
...@@ -118,6 +185,20 @@ const handleSearchInPdf = async () => { ...@@ -118,6 +185,20 @@ const handleSearchInPdf = async () => {
} }
} }
const handlePrevMatch = () => {
const pdf = activePdfRef.value
if (!pdf || typeof pdf.prevMatch !== 'function') return
pdf.prevMatch()
updateMatchInfo()
}
const handleNextMatch = () => {
const pdf = activePdfRef.value
if (!pdf || typeof pdf.nextMatch !== 'function') return
pdf.nextMatch()
updateMatchInfo()
}
// 下载:中英文都下载,与政令原文页相同的 fetch → blob → a 标签触发下载 // 下载:中英文都下载,与政令原文页相同的 fetch → blob → a 标签触发下载
const downloadOnePdf = async (url, filename) => { const downloadOnePdf = async (url, filename) => {
const response = await fetch(url, { const response = await fetch(url, {
...@@ -410,11 +491,14 @@ onMounted(async () => { ...@@ -410,11 +491,14 @@ onMounted(async () => {
text-align: left; text-align: left;
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center;
overflow: visible;
.btn-box { .btn-box {
display: flex; display: flex;
align-items: center; align-items: center;
gap: 8px; gap: 8px;
flex-shrink: 0;
.translate { .translate {
display: flex; display: flex;
...@@ -422,6 +506,7 @@ onMounted(async () => { ...@@ -422,6 +506,7 @@ onMounted(async () => {
align-items: center; align-items: center;
height: 24px; height: 24px;
margin-right: 16px; margin-right: 16px;
flex-shrink: 0;
...@@ -522,6 +607,58 @@ onMounted(async () => { ...@@ -522,6 +607,58 @@ onMounted(async () => {
align-items: center; align-items: center;
gap: 8px; gap: 8px;
margin-left: 4px; margin-left: 4px;
flex-shrink: 0;
}
.search-input {
width: 160px;
height: 24px;
box-sizing: border-box;
border: 1px solid rgba(231, 243, 255, 1);
background: rgba(246, 250, 255, 1);
border-radius: 4px;
padding: 0 10px;
font-family: "Source Han Sans CN";
font-size: 14px;
line-height: 22px;
outline: none;
}
.search-match-count {
font-family: "Source Han Sans CN";
font-weight: 400;
font-size: 14px;
line-height: 22px;
min-width: 48px;
text-align: center;
flex-shrink: 0;
}
.search-nav-btn {
width: 68px;
height: 24px;
box-sizing: border-box;
border: 1px solid rgba(231, 243, 255, 1);
background: rgba(246, 250, 255, 1);
border-radius: 4px;
font-family: "Source Han Sans CN";
font-weight: 400;
font-size: 14px;
line-height: 22px;
cursor: pointer;
padding: 0;
flex-shrink: 0;
white-space: nowrap;
}
.search-nav-btn:disabled {
opacity: 0.45;
cursor: not-allowed;
} }
} }
} }
...@@ -536,13 +673,21 @@ onMounted(async () => { ...@@ -536,13 +673,21 @@ onMounted(async () => {
overflow-x: hidden; overflow-x: hidden;
} }
.pdf-pane { .pdf-pane-wrap {
width: 50%; flex: 0 0 50%;
max-width: 50%;
height: 100%; height: 100%;
min-width: 0;
} }
.pdf-pane-full { .pdf-pane-wrap.is-full {
flex: 0 0 100%;
max-width: 100%;
}
.pdf-pane-inner {
width: 100%; width: 100%;
height: 100%;
} }
} }
} }
......
...@@ -13,23 +13,40 @@ const getMultiLineChart = (data) => { ...@@ -13,23 +13,40 @@ const getMultiLineChart = (data) => {
const legendFirstLine = allNames.slice(0, legendSplitAt) const legendFirstLine = allNames.slice(0, legendSplitAt)
const legendSecondLine = allNames.slice(legendSplitAt) const legendSecondLine = allNames.slice(legendSplitAt)
// 定义配色数组 // 按 AreaTag 的颜色规则映射到折线图配色(取 tag 的文字色)
const colorList = [ const AREA_TAG_COLOR_BY_NAME = {
'rgba(5, 95, 194, 1)', // #055fc2 '人工智能': 'rgba(245, 34, 45, 1)', // tag1
'rgba(19, 168, 168, 1)', // #13a8a8 '生物科技': 'rgba(19, 168, 168, 1)', // tag2
'rgba(250, 140, 22, 1)', // #fa8c16 '新一代通信网络': 'rgba(5, 95, 194, 1)', // tag3
'rgba(114, 46, 209, 1)', // #722ed1 // 兼容后端/页面常见写法
'rgba(115, 209, 61, 1)', // #73d13d '通信网络': 'rgba(5, 95, 194, 1)',
'rgba(206, 79, 81, 1)', // #ce4f51 '量子科技': 'rgba(114, 46, 209, 1)', // tag4
'rgba(145, 202, 255, 1)', // #91caff '新能源': 'rgba(82, 196, 26, 1)', // tag5
'rgba(95, 101, 108, 1)', // #5f656c '集成电路': 'rgba(22, 119, 255, 1)', // tag6
'rgba(250, 84, 28, 1)', // #fa541c '海洋': 'rgba(15, 120, 199, 1)', // tag7
'rgba(47, 84, 235, 1)', // #2f54eb '先进制造': 'rgba(250, 173, 20, 1)', // tag8
'rgba(64, 150, 255, 1)', // #4096ff '新材料': 'rgba(250, 140, 22, 1)', // tag9
'rgba(34, 41, 52, 1)', // #222934 '航空航天': 'rgba(47, 84, 235, 1)', // tag10
'rgba(173, 198, 255, 1)', // #adc6ff '太空': 'rgba(47, 84, 235, 1)', // tag11
'rgba(255, 169, 64, 1)' // #ffa940 '深海': 'rgba(73, 104, 161, 1)', // tag12
]; '极地': 'rgba(133, 165, 255, 1)', // tag13
'核': 'rgba(250, 84, 28, 1)', // tag14
'其他': 'rgba(82, 196, 26, 1)' // tag15
}
// 兜底颜色池(未命中 AreaTag 映射时使用)
const fallbackColorList = [
'rgba(5, 95, 194, 1)',
'rgba(19, 168, 168, 1)',
'rgba(250, 140, 22, 1)',
'rgba(114, 46, 209, 1)',
'rgba(82, 196, 26, 1)',
'rgba(250, 84, 28, 1)',
'rgba(22, 119, 255, 1)',
'rgba(95, 101, 108, 1)',
'rgba(47, 84, 235, 1)',
'rgba(133, 165, 255, 1)',
]
// 解析 RGBA 颜色的辅助函数 // 解析 RGBA 颜色的辅助函数
const parseRgba = (colorStr) => { const parseRgba = (colorStr) => {
...@@ -50,19 +67,29 @@ const getMultiLineChart = (data) => { ...@@ -50,19 +67,29 @@ const getMultiLineChart = (data) => {
// 动态生成 series 配置 // 动态生成 series 配置
const echartsSeries = series.map((item, index) => { const echartsSeries = series.map((item, index) => {
// 获取当前系列的颜色(优先使用item.color,否则用预设颜色,再否则随机) // 获取当前系列的颜色(优先使用item.color,否则用预设颜色,再否则随机)
const baseColor = item.color || colorList[index % colorList.length] || `rgba(${Math.floor(Math.random() * 256)}, ${Math.floor(Math.random() * 256)}, ${Math.floor(Math.random() * 256)}, 1)`; const baseColor =
item.color ||
AREA_TAG_COLOR_BY_NAME[item.name] ||
fallbackColorList[index % fallbackColorList.length] ||
`rgba(${Math.floor(Math.random() * 256)}, ${Math.floor(Math.random() * 256)}, ${Math.floor(Math.random() * 256)}, 1)`;
const { r, g, b } = parseRgba(baseColor); const { r, g, b } = parseRgba(baseColor);
return ({ return ({
name: item.name, name: item.name,
type: 'line', type: 'line',
smooth: true, smooth: true,
lineStyle: {
color: baseColor
},
itemStyle: {
color: baseColor
},
// 新增/优化:面积填充渐变效果 // 新增/优化:面积填充渐变效果
areaStyle: { areaStyle: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [ color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{ {
offset: 0, // 顶部 offset: 0, // 顶部
color: `rgba(${r}, ${g}, ${b}, 0.3)` // 0.3 透明度 color: `rgba(${r}, ${g}, ${b}, 0.1)` // 按需求:0.1 -> 0
}, },
{ {
offset: 1, // 底部 offset: 1, // 底部
...@@ -131,7 +158,7 @@ const getMultiLineChart = (data) => { ...@@ -131,7 +158,7 @@ const getMultiLineChart = (data) => {
} }
} }
], ],
color: colorList, // 使用预设的配色数组 // 不使用全局 color,改为每条 series 自己定色(与 AreaTag 一致)
xAxis: [ xAxis: [
{ {
type: 'category', type: 'category',
......
const getPieChart = (data) => { const getPieChart = (data) => {
const seriesData = (Array.isArray(data) ? data : []).map((d) => {
const color = d?.color
if (!color) return d
return {
...d,
itemStyle: { ...(d.itemStyle || {}), color },
// “飞线”(labelLine)跟随领域色
labelLine: {
...(d.labelLine || {}),
lineStyle: { ...(d.labelLine?.lineStyle || {}), color }
}
}
})
let option = { let option = {
series: [ series: [
{ {
...@@ -61,7 +75,7 @@ const getPieChart = (data) => { ...@@ -61,7 +75,7 @@ const getPieChart = (data) => {
labelLinePoints: points labelLinePoints: points
}; };
}, },
data: data data: seriesData
}] }]
} }
return option return option
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论