From e260e3fc719396d0554a942a56db5a2dec9d8494 Mon Sep 17 00:00:00 2001 From: ArvinLovegood Date: Wed, 12 Mar 2025 18:02:21 +0800 Subject: [PATCH] =?UTF-8?q?refactor(frontend):=E4=BC=98=E5=8C=96=E5=9F=BA?= =?UTF-8?q?=E9=87=91=E7=BB=84=E4=BB=B6=E5=B8=83=E5=B1=80=E5=92=8C=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 调整净值信息展示布局,使用 Flex 布局优化排版 - 替换标签组件为文本组件,提升用户体验 - 调整标签样式,增加间距和对齐方式 - 优化关注和取消关注按钮样式 --- backend/data/openai_api.go | 20 +++++++------- frontend/src/components/fund.vue | 45 +++++++++++++++++++++++--------- 2 files changed, 43 insertions(+), 22 deletions(-) diff --git a/backend/data/openai_api.go b/backend/data/openai_api.go index 96e0151..92b219e 100644 --- a/backend/data/openai_api.go +++ b/backend/data/openai_api.go @@ -158,7 +158,7 @@ func (o OpenAi) NewChatStream(stock, stockCode, userQuestion string) <-chan map[ } K := NewTushareApi(getConfig()).GetDaily(code, startDate, endDate, o.CrawlTimeOut) msg = append(msg, map[string]interface{}{ - "role": "assistant", + "role": "user", "content": stock + "日K数据如下:\n" + K, }) }() @@ -182,7 +182,7 @@ func (o OpenAi) NewChatStream(stock, stockCode, userQuestion string) <-chan map[ price += message + ";" } msg = append(msg, map[string]interface{}{ - "role": "assistant", + "role": "user", "content": stock + time.Now().Format(time.DateOnly) + "价格:" + price, }) }() @@ -208,7 +208,7 @@ func (o OpenAi) NewChatStream(stock, stockCode, userQuestion string) <-chan map[ } for _, message := range *messages { msg = append(msg, map[string]interface{}{ - "role": "assistant", + "role": "user", "content": stock + message, }) } @@ -225,7 +225,7 @@ func (o OpenAi) NewChatStream(stock, stockCode, userQuestion string) <-chan map[ } for _, message := range *messages { msg = append(msg, map[string]interface{}{ - "role": "assistant", + "role": "user", "content": message, }) } @@ -238,7 +238,7 @@ func (o OpenAi) NewChatStream(stock, stockCode, userQuestion string) <-chan map[ } for _, message := range *messages { msg = append(msg, map[string]interface{}{ - "role": "assistant", + "role": "user", "content": message, }) } @@ -255,7 +255,7 @@ func (o OpenAi) NewChatStream(stock, stockCode, userQuestion string) <-chan map[ // } // for _, message := range *messages { // msg = append(msg, map[string]interface{}{ - // "role": "assistant", + // "role": "user", // "content": message, // }) // } @@ -271,7 +271,7 @@ func (o OpenAi) NewChatStream(stock, stockCode, userQuestion string) <-chan map[ } for _, message := range *messages { msg = append(msg, map[string]interface{}{ - "role": "assistant", + "role": "user", "content": message, }) } @@ -293,7 +293,7 @@ func (o OpenAi) NewChatStream(stock, stockCode, userQuestion string) <-chan map[ } for _, message := range *messages { msg = append(msg, map[string]interface{}{ - "role": "assistant", + "role": "user", "content": message, }) } @@ -341,8 +341,8 @@ func (o OpenAi) NewChatStream(stock, stockCode, userQuestion string) <-chan map[ for scanner.Scan() { line := scanner.Text() logger.SugaredLogger.Infof("Received data: %s", line) - if strings.HasPrefix(line, "data: ") { - data := strings.TrimPrefix(line, "data: ") + if strings.HasPrefix(line, "data:") { + data := strutil.Trim(strings.TrimPrefix(line, "data:")) if data == "[DONE]" { return } diff --git a/frontend/src/components/fund.vue b/frontend/src/components/fund.vue index 0c9359e..35ac351 100644 --- a/frontend/src/components/fund.vue +++ b/frontend/src/components/fund.vue @@ -16,7 +16,7 @@ const danmus = ref([]) const ws = ref(null) const icon = ref(null) const message = useMessage() - +const modalShow = ref(false) const data = reactive({ modelName:"", chatId: "", @@ -142,6 +142,20 @@ function formatterTitle(title){ },{default: () => title,} ) } + +function search(code,name){ + setTimeout(() => { + window.open("https://fund.eastmoney.com/"+code+".html","_blank","noreferrer,width=1000,top=100,left=100,status=no,toolbar=no,location=no,scrollbars=no") + //window.open("https://finance.sina.com.cn/fund/quotes/"+code+"/bc.shtml","_blank","width=1000,height=800,top=100,left=100,toolbar=no,location=no") + }, 500) +} + +function newchart(code,name){ + modalShow.value=true + data.name=name + data.code=code + data.fenshiURL='https://image.sinajs.cn/newchart/v5/fund/nav/ss/'+code+'.gif'+"?t="+Date.now() +} - + + 估算净值:{{info.netEstimatedUnit}}  {{info.netEstimatedRate}} %    - ({{info.netEstimatedUnitTime}}) - - - 单位净值:{{info.netUnitValue}} ({{info.netUnitValueDate}}) - - + ({{info.netEstimatedUnitTime}}) +
+ + 单位净值:{{info.netUnitValue}}    ({{info.netUnitValueDate}}) +
+ 近一月:{{info.fundBasic.netGrowth1}}% 近三月:{{info.fundBasic.netGrowth3}}% 近六月:{{info.fundBasic.netGrowth6}}% @@ -173,20 +188,26 @@ function formatterTitle(title){ 成立来:{{info.fundBasic.netGrowthAll}}% - + + + + + +