This commit is contained in:
HuangHai
2026-01-20 08:30:04 +08:00
parent a5e8da0f9e
commit 3ec84e6cd3
4 changed files with 24 additions and 18 deletions

View File

@@ -31,7 +31,7 @@ def setup_api_logger():
logger = setup_api_logger() logger = setup_api_logger()
logger.info("YLT_Analytics_Api module imported") logger.info("驿来特AI智能分析系统模块导入完成!")
from Controller.YltAnalyticsController import router as ylt_router, init_db, close_db from Controller.YltAnalyticsController import router as ylt_router, init_db, close_db
from Controller.DegreeController import router as degree_router from Controller.DegreeController import router as degree_router
@@ -42,18 +42,18 @@ patch()
@asynccontextmanager @asynccontextmanager
async def lifespan(app: FastAPI): async def lifespan(app: FastAPI):
logger.info("YLT Analytics API startup") logger.info("驿来特AI智能分析系统开始启动...")
await init_db() await init_db()
# Initialize Redis connection # Initialize Redis connection
await RedisKit().get_connection() await RedisKit().get_connection()
try: try:
yield yield
finally: finally:
logger.info("YLT Analytics API shutdown") logger.info("驿来特AI智能分析系统关闭...")
await close_db() await close_db()
app = FastAPI(title="YLT Analytics API", lifespan=lifespan) app = FastAPI(title="驿来特AI智能分析系统", lifespan=lifespan)
static_dir = os.path.join(project_root, "static") static_dir = os.path.join(project_root, "static")
app.mount("/static", StaticFiles(directory=static_dir), name="static") app.mount("/static", StaticFiles(directory=static_dir), name="static")
@@ -64,7 +64,7 @@ app.include_router(degree_router)
if __name__ == "__main__": if __name__ == "__main__":
logger.info("Starting YLT Analytics API with uvicorn on http://0.0.0.0:8000") logger.info("Starting 驿来特AI智能分析系统 with uvicorn on http://0.0.0.0:8000")
import uvicorn import uvicorn
uvicorn.run(app, host="0.0.0.0", port=8000) uvicorn.run(app, host="0.0.0.0", port=8000)

View File

@@ -203,6 +203,7 @@ body {
z-index: 10; z-index: 10;
border-bottom: 1px solid var(--card-border); border-bottom: 1px solid var(--card-border);
box-shadow: 0 1px 2px rgba(0,0,0,0.2); box-shadow: 0 1px 2px rgba(0,0,0,0.2);
text-align: center;
} }
.station-table td { .station-table td {
@@ -210,6 +211,7 @@ body {
border-bottom: 1px solid var(--card-border); border-bottom: 1px solid var(--card-border);
color: var(--text-primary); color: var(--text-primary);
transition: background-color 0.15s; transition: background-color 0.15s;
text-align: center;
} }
.station-table tbody tr:hover td { .station-table tbody tr:hover td {

View File

@@ -79,12 +79,6 @@
</div> </div>
</div> </div>
<div style="text-align: center; margin: 10px 0;">
<button class="btn-primary" @click="startAiAnalysis" :disabled="aiLoading" style="width: 100%;">
{{ aiLoading ? '✨ AI 正在深入分析...' : '🚀 发起 AI 综合诊断' }}
</button>
</div>
<div class="ai-result" v-html="renderedAiText || placeholder" style="opacity: 0.9;"></div> <div class="ai-result" v-html="renderedAiText || placeholder" style="opacity: 0.9;"></div>
</div> </div>
</div> </div>
@@ -166,11 +160,6 @@
<script src="js/qrcode.min.js"></script> <script src="js/qrcode.min.js"></script>
<script src="js/axios.min.js"></script> <script src="js/axios.min.js"></script>
<script src="js/echarts.min.js"></script> <script src="js/echarts.min.js"></script>
<script src="js/marked.min.js"></script>
<!-- Katex for Math Rendering -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.8/dist/katex.min.css">
<script src="https://cdn.jsdelivr.net/npm/katex@0.16.8/dist/katex.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/katex@0.16.8/dist/contrib/auto-render.min.js"></script>
<script src="js/app.js"></script> <script src="js/app.js"></script>
</body> </body>
</html> </html>

View File

@@ -26,7 +26,7 @@ createApp({
]); ]);
const selectedOperator = ref("驿来特"); const selectedOperator = ref("驿来特");
const aiText = ref(""); const aiText = ref("");
const placeholder = ref("点击左侧按钮查询四家供应商最新24小时分时电价,再使用右侧AI综合分析功能对各司定价策略进行对比。"); const placeholder = ref("");
const loading = ref(false); const loading = ref(false);
const exporting = ref(false); const exporting = ref(false);
const exportingReport = ref(false); const exportingReport = ref(false);
@@ -447,6 +447,20 @@ createApp({
}); });
watch(queryResult, (newVal) => { watch(queryResult, (newVal) => {
nextTick(() => {
const el = document.querySelector('.markdown-body');
if (el && window.renderMathInElement) {
renderMathInElement(el, {
delimiters: [
{left: '$$', right: '$$', display: true},
{left: '$', right: '$', display: false},
{left: '\\(', right: '\\)', display: false},
{left: '\\[', right: '\\]', display: true}
],
throwOnError: false
});
}
});
if (newVal && newVal.includes('```echarts')) { if (newVal && newVal.includes('```echarts')) {
renderCharts(); renderCharts();
} }
@@ -459,6 +473,7 @@ createApp({
// Dashboard init // Dashboard init
initChart(); initChart();
loadAllOperatorsPrices(); loadAllOperatorsPrices();
startAiAnalysis();
// Degree QR Code // Degree QR Code
if (!isMobile.value && typeof QRCode !== 'undefined') { if (!isMobile.value && typeof QRCode !== 'undefined') {
@@ -487,4 +502,4 @@ createApp({
handleDegreeSearch, setExample, renderedResult, stopDegreeGeneration handleDegreeSearch, setExample, renderedResult, stopDegreeGeneration
}; };
} }
}).mount("#app"); }).use(ElementPlus).mount("#app");