aegon-gen 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +12 -0
- package/src/App.vue +3 -0
- package/src/api/index.ts +19 -0
- package/src/api/modules/gen-ai/gen-entry/index.ts +30 -0
- package/src/api/modules/gen-ai/model-manager/index.ts +42 -0
- package/src/api/modules/gen-ai/model-manager/mockApi.ts +33 -0
- package/src/api/modules/index.ts +98 -0
- package/src/api/modules/user/index.ts +4 -0
- package/src/api/request.ts +102 -0
- package/src/assets/sample-access-icon.png +0 -0
- package/src/assets/sample-pie-chart.png +0 -0
- package/src/assets/vue.svg +1 -0
- package/src/components/CapsuleScrollbar.vue +93 -0
- package/src/components/Export/ExcelExport.vue +592 -0
- package/src/components/Export/ExcelExport2.vue +494 -0
- package/src/components/Export/ExcelExport3.vue +342 -0
- package/src/components/Export/ExcelExport4.vue +665 -0
- package/src/components/Export/excelExport.js +547 -0
- package/src/components/Export/excelExport.ts +551 -0
- package/src/components/GEN-AI/index.vue +142 -0
- package/src/components/GEN-AI/index1.vue +456 -0
- package/src/components/GEN-AI/index10.vue +5 -0
- package/src/components/GEN-AI/index2.vue +568 -0
- package/src/components/GEN-AI/index3.vue +623 -0
- package/src/components/GEN-AI/index4.vue +629 -0
- package/src/components/GEN-AI/index5.vue +578 -0
- package/src/components/GEN-AI/index6.vue +656 -0
- package/src/components/GEN-AI/index7.vue +717 -0
- package/src/components/GEN-AI/index8.vue +405 -0
- package/src/components/GEN-AI/index9.vue +1065 -0
- package/src/components/GEN-AI/types.ts +12 -0
- package/src/components/GEN-AI/utils.ts +42 -0
- package/src/components/HelloWorld.vue +41 -0
- package/src/components/PageCard.vue +7 -0
- package/src/components/PageHeader.vue +32 -0
- package/src/components/backup/index5 copy.vue +556 -0
- package/src/components/backup/index5.vue +620 -0
- package/src/components/backup/index9 copy.vue +1029 -0
- package/src/components/backup/index9-pro.vue +1065 -0
- package/src/components/backup/index9.vue +1057 -0
- package/src/components/el-date-picker.vue +64 -0
- package/src/directives/btnLoading.ts +427 -0
- package/src/directives/debounce copy.ts +670 -0
- package/src/directives/debounce.ts +98 -0
- package/src/directives/index.ts +25 -0
- package/src/layouts/MainLayout.vue +101 -0
- package/src/main.ts +85 -0
- package/src/router/index.ts +76 -0
- package/src/router/menus.ts +28 -0
- package/src/style.css +79 -0
- package/src/styles/_variables.scss +24 -0
- package/src/styles/app-button.css +26 -0
- package/src/styles/element-overrides.css +23 -0
- package/src/styles/global.css +44 -0
- package/src/styles/index.scss +1 -0
- package/src/styles/page-card.css +21 -0
- package/src/styles/variables.css +26 -0
- package/src/test/mock.ts +101 -0
- package/src/test/test1.vue +402 -0
- package/src/test/test2.vue +1689 -0
- package/src/types/gen-ai/gen-entry/index.ts +17 -0
- package/src/types/gen-ai/model-manager/index.ts +19 -0
- package/src/utils/docxExport.ts +1610 -0
- package/src/utils/gen-ai-navigation.ts +37 -0
- package/src/utils/gen-ai-scroll.ts +455 -0
- package/src/utils/openDataLoaderWordExport.ts +33 -0
- package/src/utils/pageScrollbar.ts +115 -0
- package/src/utils/randomTranscode.ts +87 -0
- package/src/utils/reportPdfExport.ts +44 -0
- package/src/views/AdminCenter/index.vue +817 -0
- package/src/views/Blank.vue +68 -0
- package/src/views/Home.vue +29 -0
- package/src/views/ReportCenter/index.vue +1380 -0
- package/src/views/TemplateCenter/Knowledge.ts +83 -0
- package/src/views/TemplateCenter/data.d.ts +10 -0
- package/src/views/TemplateCenter/index.vue +1205 -0
- package/src/views/TemplateCenter/service.ts +69 -0
- package/src/views/gen-ai/components/RecentReportsTable.vue +193 -0
- package/src/views/gen-ai/gen-entry/index.vue +309 -0
- package/src/views/gen-ai/gen-entry/mockData.ts +160 -0
- package/src/views/gen-ai/management-center/index.vue +53 -0
- package/src/views/gen-ai/model-manager/ChapterTitleScroll.vue +275 -0
- package/src/views/gen-ai/model-manager/index.vue +1205 -0
- package/src/views/gen-ai/model-manager/mockData.ts +122 -0
- package/src/views/gen-ai/report-center/index.vue +158 -0
- package/src/vite-env.d.ts +38 -0
|
@@ -0,0 +1,568 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="flex h-screen bg-[#F3F4F6] text-[#333]">
|
|
3
|
+
<main class="flex-1 overflow-y-auto p-12">
|
|
4
|
+
<div
|
|
5
|
+
class="max-w-5xl mx-auto bg-white shadow-sm border border-gray-100 rounded-sm p-10 min-h-screen relative"
|
|
6
|
+
id="report-container"
|
|
7
|
+
>
|
|
8
|
+
<!-- 导出按钮 -->
|
|
9
|
+
<div class="absolute top-6 right-8 flex gap-4 no-print">
|
|
10
|
+
<el-button
|
|
11
|
+
@click="exportToPDF('report-container', '图文报告_房地产整合')"
|
|
12
|
+
size="small"
|
|
13
|
+
plain
|
|
14
|
+
type="danger"
|
|
15
|
+
>
|
|
16
|
+
匯出為PDF
|
|
17
|
+
</el-button>
|
|
18
|
+
<el-button
|
|
19
|
+
@click="exportToWord('report-container', '图文报告_房地产整合')"
|
|
20
|
+
size="small"
|
|
21
|
+
plain
|
|
22
|
+
type="danger"
|
|
23
|
+
>
|
|
24
|
+
匯出為Word
|
|
25
|
+
</el-button>
|
|
26
|
+
</div>
|
|
27
|
+
|
|
28
|
+
<div class="prose prose-slate max-w-none">
|
|
29
|
+
<div class="font-bold flex items-center mb-5 text-lg border-t pt-6">
|
|
30
|
+
正文:
|
|
31
|
+
<Edit3Icon :size="18" class="ml-2 text-[#C54E5E] cursor-pointer" />
|
|
32
|
+
</div>
|
|
33
|
+
|
|
34
|
+
<!-- 动态内容容器 -->
|
|
35
|
+
<div class="content-wrapper space-y-4">
|
|
36
|
+
<template v-for="(item, idx) in displaySequence" :key="idx">
|
|
37
|
+
<!-- 文本段落:带打字机效果 -->
|
|
38
|
+
<div
|
|
39
|
+
v-if="item.type === 'text'"
|
|
40
|
+
ref="textRefs"
|
|
41
|
+
:data-idx="idx"
|
|
42
|
+
class="text-paragraph"
|
|
43
|
+
>
|
|
44
|
+
{{ renderedTexts[idx] || "" }}
|
|
45
|
+
</div>
|
|
46
|
+
<!-- 一次性渲染的组件 -->
|
|
47
|
+
<component
|
|
48
|
+
v-else-if="item.type === 'component'"
|
|
49
|
+
:is="item.component"
|
|
50
|
+
class="my-4"
|
|
51
|
+
/>
|
|
52
|
+
</template>
|
|
53
|
+
</div>
|
|
54
|
+
|
|
55
|
+
<!-- 打字光标 -->
|
|
56
|
+
<span
|
|
57
|
+
v-if="isTypingActive"
|
|
58
|
+
class="inline-block w-[2px] h-[18px] bg-[#C54E5E] animate-pulse ml-1 align-middle"
|
|
59
|
+
></span>
|
|
60
|
+
</div>
|
|
61
|
+
</div>
|
|
62
|
+
</main>
|
|
63
|
+
|
|
64
|
+
<aside class="w-80 bg-white border-l border-gray-200 p-6 no-print">
|
|
65
|
+
<h3 class="font-bold text-gray-700 mb-6">生成報告設置</h3>
|
|
66
|
+
<p class="text-sm text-gray-500">✨ ECharts 折柱图 + 打字机效果</p>
|
|
67
|
+
<p class="text-xs text-gray-400 mt-2">
|
|
68
|
+
包含:带状态表格 / 按钮组 / 图标集 / ECharts混合图表<br />
|
|
69
|
+
房地产报告全文 + 逐字打字效果
|
|
70
|
+
</p>
|
|
71
|
+
<el-button @click="restartDemo" type="danger" plain class="w-full mt-6">
|
|
72
|
+
重新播放
|
|
73
|
+
</el-button>
|
|
74
|
+
<div class="mt-6 text-xs text-gray-400 border-t pt-4">
|
|
75
|
+
💡 提示:<br />
|
|
76
|
+
• 表格行按状态高亮<br />
|
|
77
|
+
• ECharts 图表支持缩放/保存/切换类型<br />
|
|
78
|
+
• 图标已一次性展示
|
|
79
|
+
</div>
|
|
80
|
+
</aside>
|
|
81
|
+
</div>
|
|
82
|
+
</template>
|
|
83
|
+
|
|
84
|
+
<script setup lang="ts">
|
|
85
|
+
import {
|
|
86
|
+
ref,
|
|
87
|
+
onMounted,
|
|
88
|
+
onUnmounted,
|
|
89
|
+
defineComponent,
|
|
90
|
+
h,
|
|
91
|
+
markRaw,
|
|
92
|
+
type Component,
|
|
93
|
+
nextTick,
|
|
94
|
+
} from "vue";
|
|
95
|
+
import { Edit3Icon } from "lucide-vue-next";
|
|
96
|
+
import { ElButton, ElTable, ElTableColumn, ElIcon } from "element-plus";
|
|
97
|
+
import { Platform, Eleme, DeleteFilled, Delete } from "@element-plus/icons-vue";
|
|
98
|
+
import * as echarts from "echarts";
|
|
99
|
+
import html2canvas from "html2canvas";
|
|
100
|
+
import jsPDF from "jspdf";
|
|
101
|
+
import { saveAs } from "file-saver";
|
|
102
|
+
|
|
103
|
+
const exportToPDF = async (containerId: string, filename: string) => {
|
|
104
|
+
const element = document.getElementById(containerId);
|
|
105
|
+
if (!element) {
|
|
106
|
+
console.error("Container not found");
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
try {
|
|
111
|
+
// 显示加载提示(可选)
|
|
112
|
+
const loadingEl = document.createElement("div");
|
|
113
|
+
loadingEl.innerText = "正在生成PDF,请稍候...";
|
|
114
|
+
loadingEl.style.position = "fixed";
|
|
115
|
+
loadingEl.style.top = "50%";
|
|
116
|
+
loadingEl.style.left = "50%";
|
|
117
|
+
loadingEl.style.transform = "translate(-50%, -50%)";
|
|
118
|
+
loadingEl.style.backgroundColor = "rgba(0,0,0,0.7)";
|
|
119
|
+
loadingEl.style.color = "white";
|
|
120
|
+
loadingEl.style.padding = "10px 20px";
|
|
121
|
+
loadingEl.style.borderRadius = "8px";
|
|
122
|
+
loadingEl.style.zIndex = "9999";
|
|
123
|
+
document.body.appendChild(loadingEl);
|
|
124
|
+
|
|
125
|
+
const canvas = await html2canvas(element, {
|
|
126
|
+
scale: 2, // 提高清晰度
|
|
127
|
+
useCORS: true,
|
|
128
|
+
logging: false,
|
|
129
|
+
});
|
|
130
|
+
const imgData = canvas.toDataURL("image/png");
|
|
131
|
+
const pdf = new jsPDF("p", "mm", "a4");
|
|
132
|
+
const imgWidth = 210; // A4宽度 mm
|
|
133
|
+
const pageHeight = 297;
|
|
134
|
+
const imgHeight = (canvas.height * imgWidth) / canvas.width;
|
|
135
|
+
let heightLeft = imgHeight;
|
|
136
|
+
let position = 0;
|
|
137
|
+
|
|
138
|
+
pdf.addImage(imgData, "PNG", 0, position, imgWidth, imgHeight);
|
|
139
|
+
heightLeft -= pageHeight;
|
|
140
|
+
|
|
141
|
+
while (heightLeft > 0) {
|
|
142
|
+
position = heightLeft - imgHeight;
|
|
143
|
+
pdf.addPage();
|
|
144
|
+
pdf.addImage(imgData, "PNG", 0, position, imgWidth, imgHeight);
|
|
145
|
+
heightLeft -= pageHeight;
|
|
146
|
+
}
|
|
147
|
+
pdf.save(`${filename}.pdf`);
|
|
148
|
+
document.body.removeChild(loadingEl);
|
|
149
|
+
} catch (error) {
|
|
150
|
+
console.error("PDF导出失败:", error);
|
|
151
|
+
alert("PDF导出失败,请重试");
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
// 导出 Word(将 HTML 内容保存为 .doc 文件)
|
|
156
|
+
const exportToWord = (containerId: string, filename: string) => {
|
|
157
|
+
const element = document.getElementById(containerId);
|
|
158
|
+
if (!element) {
|
|
159
|
+
console.error("Container not found");
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// 克隆容器,避免影响原页面
|
|
164
|
+
const cloneElement = element.cloneNode(true) as HTMLElement;
|
|
165
|
+
// 移除克隆中的按钮和交互元素(避免导出按钮再次出现)
|
|
166
|
+
const noPrintElements = cloneElement.querySelectorAll(".no-print");
|
|
167
|
+
noPrintElements.forEach((el) => el.remove());
|
|
168
|
+
|
|
169
|
+
// 获取样式(内联样式可能丢失,简单复制主要样式)
|
|
170
|
+
const styles = document.querySelectorAll('style, link[rel="stylesheet"]');
|
|
171
|
+
let styleHtml = "";
|
|
172
|
+
styles.forEach((style) => {
|
|
173
|
+
if (style.tagName === "STYLE") {
|
|
174
|
+
styleHtml += (style as HTMLStyleElement).innerHTML;
|
|
175
|
+
} else if (style.tagName === "LINK") {
|
|
176
|
+
// 外部样式表无法直接嵌入,忽略或可手动添加
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
const docHtml = `
|
|
181
|
+
<!DOCTYPE html>
|
|
182
|
+
<html>
|
|
183
|
+
<head>
|
|
184
|
+
<meta charset="UTF-8">
|
|
185
|
+
<title>${filename}</title>
|
|
186
|
+
<style>
|
|
187
|
+
/* 基础重置 */
|
|
188
|
+
body {
|
|
189
|
+
font-family: 'Segoe UI', 'Roboto', 'Noto Sans', sans-serif;
|
|
190
|
+
padding: 20px;
|
|
191
|
+
margin: 0 auto;
|
|
192
|
+
max-width: 1000px;
|
|
193
|
+
}
|
|
194
|
+
/* 确保表格样式 */
|
|
195
|
+
.el-table {
|
|
196
|
+
width: 100%;
|
|
197
|
+
border-collapse: collapse;
|
|
198
|
+
}
|
|
199
|
+
.el-table th, .el-table td {
|
|
200
|
+
border: 1px solid #ddd;
|
|
201
|
+
padding: 8px;
|
|
202
|
+
}
|
|
203
|
+
${styleHtml}
|
|
204
|
+
</style>
|
|
205
|
+
</head>
|
|
206
|
+
<body>
|
|
207
|
+
${cloneElement.outerHTML}
|
|
208
|
+
</body>
|
|
209
|
+
</html>
|
|
210
|
+
`;
|
|
211
|
+
|
|
212
|
+
const blob = new Blob([docHtml], { type: "application/msword" });
|
|
213
|
+
saveAs(blob, `${filename}.doc`);
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
// ---------- 报告文本 ----------
|
|
217
|
+
const rawReport = `2024年香港房地產市場整體呈現「價跌量穩、租金偏強、商業不振」的分化局面,全年各類物業價格普遍下調,但成交及租賃需求在政策放寬和人口流入支持下較前兩年有所改善。住宅方面,撤銷所有樓市「辣招」、放寬按揭成數及利率見頂後回落,帶動一手主導的成交回升,但無礙樓價全年再跌約中個百分比,反映經濟及供應壓力仍然主導價格走勢。
|
|
218
|
+
|
|
219
|
+
在住宅市場,本年特點包括:
|
|
220
|
+
一、銷售量回升、價格續調:2024年在全面撤辣及按揭寬鬆後,全年住宅買賣宗數按年錄得逾兩成增長,但全年樓價仍錄得約6%至7%的跌幅,延續過去兩年的調整趨勢。
|
|
221
|
+
二、供應顯著增加:私樓落成量約2.4萬個單位,較2023年大幅增加約七成,主要為中小型單位,為後市價格帶來持續壓力。
|
|
222
|
+
三、租金走勢優於樓價:在人口及人才計劃帶動下,住宅租金全年錄得中低個位升幅,租金指數距歷史高位僅約數個百分點,令小型單位的平均回報率升至近十多年高位水平。
|
|
223
|
+
|
|
224
|
+
在非住宅方面,2024年為商廈及舖位市場的「谷底年」,寫字樓空置率創逾十年新高,商業成交金額及宗數均跌至有紀錄以來低位。`;
|
|
225
|
+
|
|
226
|
+
const rawParagraphs = rawReport
|
|
227
|
+
.split(/\n\s*\n/)
|
|
228
|
+
.filter((p) => p.trim().length > 0);
|
|
229
|
+
const [para1 = "", para2 = "", para3 = ""] = rawParagraphs;
|
|
230
|
+
|
|
231
|
+
// ---------- 组件定义(使用 markRaw 避免响应式)----------
|
|
232
|
+
// 带状态表格
|
|
233
|
+
const ElStatusTable = markRaw(
|
|
234
|
+
defineComponent({
|
|
235
|
+
name: "ElStatusTable",
|
|
236
|
+
setup() {
|
|
237
|
+
const tableData = [
|
|
238
|
+
{
|
|
239
|
+
date: "2016-05-02",
|
|
240
|
+
name: "王小虎",
|
|
241
|
+
address: "上海市普陀区金沙江路1518弄",
|
|
242
|
+
status: "success",
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
date: "2016-05-04",
|
|
246
|
+
name: "王小虎",
|
|
247
|
+
address: "上海市普陀区金沙江路1518弄",
|
|
248
|
+
status: "info",
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
date: "2016-05-01",
|
|
252
|
+
name: "王小虎",
|
|
253
|
+
address: "上海市普陀区金沙江路1518弄",
|
|
254
|
+
status: "warning",
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
date: "2016-05-03",
|
|
258
|
+
name: "王小虎",
|
|
259
|
+
address: "上海市普陀区金沙江路1518弄",
|
|
260
|
+
status: "danger",
|
|
261
|
+
},
|
|
262
|
+
];
|
|
263
|
+
const rowClassName = ({ row }: { row: any }) => {
|
|
264
|
+
if (row.status === "success") return "success-row";
|
|
265
|
+
if (row.status === "info") return "info-row";
|
|
266
|
+
if (row.status === "warning") return "warning-row";
|
|
267
|
+
if (row.status === "danger") return "danger-row";
|
|
268
|
+
return "";
|
|
269
|
+
};
|
|
270
|
+
return () =>
|
|
271
|
+
h(
|
|
272
|
+
ElTable,
|
|
273
|
+
{
|
|
274
|
+
data: tableData,
|
|
275
|
+
style: { width: "100%" },
|
|
276
|
+
rowClassName,
|
|
277
|
+
border: true,
|
|
278
|
+
},
|
|
279
|
+
() => [
|
|
280
|
+
h(ElTableColumn, { prop: "date", label: "日期", width: "120" }),
|
|
281
|
+
h(ElTableColumn, { prop: "name", label: "姓名", width: "100" }),
|
|
282
|
+
h(ElTableColumn, { prop: "address", label: "地址" }),
|
|
283
|
+
h(
|
|
284
|
+
ElTableColumn,
|
|
285
|
+
{ label: "状态", width: "100" },
|
|
286
|
+
{
|
|
287
|
+
default: ({ row }: any) => {
|
|
288
|
+
let type: "success" | "info" | "warning" | "danger" = "success";
|
|
289
|
+
if (row.status === "info") type = "info";
|
|
290
|
+
if (row.status === "warning") type = "warning";
|
|
291
|
+
if (row.status === "danger") type = "danger";
|
|
292
|
+
return h(
|
|
293
|
+
ElButton,
|
|
294
|
+
{ size: "small", type, plain: true },
|
|
295
|
+
() => row.status
|
|
296
|
+
);
|
|
297
|
+
},
|
|
298
|
+
}
|
|
299
|
+
),
|
|
300
|
+
]
|
|
301
|
+
);
|
|
302
|
+
},
|
|
303
|
+
})
|
|
304
|
+
);
|
|
305
|
+
|
|
306
|
+
// 按钮组
|
|
307
|
+
const ButtonGroup = markRaw(
|
|
308
|
+
defineComponent({
|
|
309
|
+
setup() {
|
|
310
|
+
return () =>
|
|
311
|
+
h("div", { class: "flex flex-wrap gap-3 my-2" }, [
|
|
312
|
+
h(ElButton, { type: "primary" }, () => "主要按钮"),
|
|
313
|
+
h(ElButton, { type: "success" }, () => "成功按钮"),
|
|
314
|
+
h(ElButton, { type: "info" }, () => "信息按钮"),
|
|
315
|
+
h(ElButton, { type: "warning" }, () => "警告按钮"),
|
|
316
|
+
h(ElButton, { type: "danger" }, () => "危险按钮"),
|
|
317
|
+
h(ElButton, {}, () => "默认按钮"),
|
|
318
|
+
h(ElButton, { round: true }, () => "圆角按钮"),
|
|
319
|
+
]);
|
|
320
|
+
},
|
|
321
|
+
})
|
|
322
|
+
);
|
|
323
|
+
|
|
324
|
+
// 图标展示
|
|
325
|
+
const IconShowcase = markRaw(
|
|
326
|
+
defineComponent({
|
|
327
|
+
setup() {
|
|
328
|
+
return () =>
|
|
329
|
+
h(
|
|
330
|
+
"div",
|
|
331
|
+
{ class: "flex gap-4 items-center py-3 border-y border-gray-100" },
|
|
332
|
+
[
|
|
333
|
+
h(ElIcon, { size: 24, color: "#409EFF" }, () => h(Platform)),
|
|
334
|
+
h(ElIcon, { size: 24, color: "#67C23A" }, () => h(Eleme)),
|
|
335
|
+
h(ElIcon, { size: 24, color: "#F56C6C" }, () => h(DeleteFilled)),
|
|
336
|
+
h(ElIcon, { size: 24, color: "#E6A23C" }, () => h(Delete)),
|
|
337
|
+
h(
|
|
338
|
+
"span",
|
|
339
|
+
{ class: "text-sm text-gray-500 ml-2" },
|
|
340
|
+
"el-icon-platform-eleme / eleme / delete-filled / delete"
|
|
341
|
+
),
|
|
342
|
+
]
|
|
343
|
+
);
|
|
344
|
+
},
|
|
345
|
+
})
|
|
346
|
+
);
|
|
347
|
+
|
|
348
|
+
// ECharts 折柱图组件
|
|
349
|
+
const EChartsMixed = markRaw(
|
|
350
|
+
defineComponent({
|
|
351
|
+
name: "EChartsMixed",
|
|
352
|
+
setup() {
|
|
353
|
+
const chartRef = ref<HTMLDivElement | null>(null);
|
|
354
|
+
let chartInstance: echarts.ECharts | null = null;
|
|
355
|
+
|
|
356
|
+
const initChart = () => {
|
|
357
|
+
if (!chartRef.value) return;
|
|
358
|
+
chartInstance = echarts.init(chartRef.value);
|
|
359
|
+
const option = {
|
|
360
|
+
tooltip: {
|
|
361
|
+
trigger: "axis",
|
|
362
|
+
axisPointer: { type: "cross", crossStyle: { color: "#999" } },
|
|
363
|
+
},
|
|
364
|
+
toolbox: {
|
|
365
|
+
feature: {
|
|
366
|
+
dataView: { show: true, readOnly: false },
|
|
367
|
+
magicType: { show: true, type: ["line", "bar"] },
|
|
368
|
+
restore: { show: true },
|
|
369
|
+
saveAsImage: { show: true },
|
|
370
|
+
},
|
|
371
|
+
},
|
|
372
|
+
legend: {
|
|
373
|
+
data: ["Evaporation", "Precipitation", "Temperature"],
|
|
374
|
+
},
|
|
375
|
+
xAxis: [
|
|
376
|
+
{
|
|
377
|
+
type: "category",
|
|
378
|
+
data: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
|
|
379
|
+
axisPointer: { type: "shadow" },
|
|
380
|
+
},
|
|
381
|
+
],
|
|
382
|
+
yAxis: [
|
|
383
|
+
{
|
|
384
|
+
type: "value",
|
|
385
|
+
name: "Precipitation",
|
|
386
|
+
min: 0,
|
|
387
|
+
max: 250,
|
|
388
|
+
interval: 50,
|
|
389
|
+
axisLabel: { formatter: "{value} ml" },
|
|
390
|
+
},
|
|
391
|
+
{
|
|
392
|
+
type: "value",
|
|
393
|
+
name: "Temperature",
|
|
394
|
+
min: 0,
|
|
395
|
+
max: 25,
|
|
396
|
+
interval: 5,
|
|
397
|
+
axisLabel: { formatter: "{value} °C" },
|
|
398
|
+
},
|
|
399
|
+
],
|
|
400
|
+
series: [
|
|
401
|
+
{
|
|
402
|
+
name: "Evaporation",
|
|
403
|
+
type: "bar",
|
|
404
|
+
tooltip: { valueFormatter: (value: any) => value + " ml" },
|
|
405
|
+
data: [2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6],
|
|
406
|
+
},
|
|
407
|
+
{
|
|
408
|
+
name: "Precipitation",
|
|
409
|
+
type: "bar",
|
|
410
|
+
tooltip: { valueFormatter: (value: any) => value + " ml" },
|
|
411
|
+
data: [2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6],
|
|
412
|
+
},
|
|
413
|
+
{
|
|
414
|
+
name: "Temperature",
|
|
415
|
+
type: "line",
|
|
416
|
+
yAxisIndex: 1,
|
|
417
|
+
tooltip: { valueFormatter: (value: any) => value + " °C" },
|
|
418
|
+
data: [2.0, 2.2, 3.3, 4.5, 6.3, 10.2, 20.3],
|
|
419
|
+
},
|
|
420
|
+
],
|
|
421
|
+
};
|
|
422
|
+
chartInstance.setOption(option);
|
|
423
|
+
window.addEventListener("resize", () => chartInstance?.resize());
|
|
424
|
+
};
|
|
425
|
+
|
|
426
|
+
onMounted(() => {
|
|
427
|
+
nextTick(() => initChart());
|
|
428
|
+
});
|
|
429
|
+
|
|
430
|
+
onUnmounted(() => {
|
|
431
|
+
chartInstance?.dispose();
|
|
432
|
+
});
|
|
433
|
+
|
|
434
|
+
return () =>
|
|
435
|
+
h("div", { ref: chartRef, style: { width: "100%", height: "400px" } });
|
|
436
|
+
},
|
|
437
|
+
})
|
|
438
|
+
);
|
|
439
|
+
|
|
440
|
+
// ---------- 构建显示序列 ----------
|
|
441
|
+
type DisplayItem =
|
|
442
|
+
| { type: "text"; content: string }
|
|
443
|
+
| { type: "component"; component: Component };
|
|
444
|
+
|
|
445
|
+
const displaySequence = ref<DisplayItem[]>([
|
|
446
|
+
{ type: "text", content: para1 },
|
|
447
|
+
{ type: "component", component: ElStatusTable },
|
|
448
|
+
{ type: "text", content: "📌 带状态表格(高亮区分成功/信息/警告/危险)" },
|
|
449
|
+
{ type: "text", content: para2 },
|
|
450
|
+
{ type: "component", component: ButtonGroup },
|
|
451
|
+
{ type: "component", component: IconShowcase },
|
|
452
|
+
{ type: "text", content: para3 },
|
|
453
|
+
{ type: "component", component: EChartsMixed }, // 替换原断轴柱状图
|
|
454
|
+
{
|
|
455
|
+
type: "text",
|
|
456
|
+
content: "✅ 以上为整合 ECharts 图表与完整房地产报告的图文混排效果。",
|
|
457
|
+
},
|
|
458
|
+
]);
|
|
459
|
+
|
|
460
|
+
// ---------- 打字机效果实现 ----------
|
|
461
|
+
const renderedTexts = ref<string[]>(displaySequence.value.map(() => ""));
|
|
462
|
+
const textRefs = ref<HTMLElement[]>([]);
|
|
463
|
+
const isTypingActive = ref(false);
|
|
464
|
+
let currentTypingIndex = 0;
|
|
465
|
+
let typingTimer: number | null = null;
|
|
466
|
+
let currentCharIndex = 0;
|
|
467
|
+
|
|
468
|
+
// 停止当前打字
|
|
469
|
+
const stopTyping = () => {
|
|
470
|
+
if (typingTimer) {
|
|
471
|
+
clearTimeout(typingTimer);
|
|
472
|
+
typingTimer = null;
|
|
473
|
+
}
|
|
474
|
+
isTypingActive.value = false;
|
|
475
|
+
};
|
|
476
|
+
|
|
477
|
+
// 开始打字(从某个序列项开始)
|
|
478
|
+
const startTypingFrom = (startIdx: number) => {
|
|
479
|
+
stopTyping();
|
|
480
|
+
currentTypingIndex = startIdx;
|
|
481
|
+
currentCharIndex = 0;
|
|
482
|
+
isTypingActive.value = true;
|
|
483
|
+
typeNextChar();
|
|
484
|
+
};
|
|
485
|
+
|
|
486
|
+
const typeNextChar = () => {
|
|
487
|
+
// 找到下一个需要打字的文本项
|
|
488
|
+
while (currentTypingIndex < displaySequence.value.length) {
|
|
489
|
+
const item = displaySequence.value[currentTypingIndex];
|
|
490
|
+
if (!item) {
|
|
491
|
+
currentTypingIndex++;
|
|
492
|
+
currentCharIndex = 0;
|
|
493
|
+
continue;
|
|
494
|
+
}
|
|
495
|
+
if (item.type === "text") {
|
|
496
|
+
const fullText = item.content;
|
|
497
|
+
if (currentCharIndex < fullText.length) {
|
|
498
|
+
// 输出下一个字符
|
|
499
|
+
const currentText = renderedTexts.value[currentTypingIndex] || "";
|
|
500
|
+
renderedTexts.value[currentTypingIndex] =
|
|
501
|
+
currentText + fullText[currentCharIndex];
|
|
502
|
+
currentCharIndex++;
|
|
503
|
+
typingTimer = window.setTimeout(typeNextChar, 28);
|
|
504
|
+
return;
|
|
505
|
+
} else {
|
|
506
|
+
// 当前文本完成,移动到下一项
|
|
507
|
+
currentTypingIndex++;
|
|
508
|
+
currentCharIndex = 0;
|
|
509
|
+
continue;
|
|
510
|
+
}
|
|
511
|
+
} else {
|
|
512
|
+
// 组件项,直接跳过
|
|
513
|
+
currentTypingIndex++;
|
|
514
|
+
currentCharIndex = 0;
|
|
515
|
+
continue;
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
// 所有文本已完成
|
|
519
|
+
isTypingActive.value = false;
|
|
520
|
+
typingTimer = null;
|
|
521
|
+
};
|
|
522
|
+
|
|
523
|
+
const restartDemo = () => {
|
|
524
|
+
stopTyping();
|
|
525
|
+
// 重置所有渲染文本为空
|
|
526
|
+
renderedTexts.value = displaySequence.value.map(() => "");
|
|
527
|
+
currentTypingIndex = 0;
|
|
528
|
+
currentCharIndex = 0;
|
|
529
|
+
startTypingFrom(0);
|
|
530
|
+
};
|
|
531
|
+
|
|
532
|
+
// 确保在组件挂载后启动
|
|
533
|
+
onMounted(() => {
|
|
534
|
+
startTypingFrom(0);
|
|
535
|
+
});
|
|
536
|
+
|
|
537
|
+
onUnmounted(() => {
|
|
538
|
+
stopTyping();
|
|
539
|
+
});
|
|
540
|
+
</script>
|
|
541
|
+
|
|
542
|
+
<style scoped>
|
|
543
|
+
:deep(.el-table .success-row) {
|
|
544
|
+
background-color: #f0f9eb;
|
|
545
|
+
}
|
|
546
|
+
:deep(.el-table .info-row) {
|
|
547
|
+
background-color: #e6f7ff;
|
|
548
|
+
}
|
|
549
|
+
:deep(.el-table .warning-row) {
|
|
550
|
+
background-color: #fdf6ec;
|
|
551
|
+
}
|
|
552
|
+
:deep(.el-table .danger-row) {
|
|
553
|
+
background-color: #fef0f0;
|
|
554
|
+
}
|
|
555
|
+
.text-paragraph {
|
|
556
|
+
line-height: 1.8;
|
|
557
|
+
font-size: 15px;
|
|
558
|
+
letter-spacing: 0.01em;
|
|
559
|
+
color: #374151;
|
|
560
|
+
margin-bottom: 1rem;
|
|
561
|
+
white-space: pre-wrap;
|
|
562
|
+
}
|
|
563
|
+
@media print {
|
|
564
|
+
.no-print {
|
|
565
|
+
display: none !important;
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
</style>
|