From 2dd4c077afca188f630b755fe8b50cf9a07587c3 Mon Sep 17 00:00:00 2001 From: clz Date: Tue, 28 Jul 2026 19:00:44 +0800 Subject: [PATCH] =?UTF-8?q?refactor(ai-pick):=20=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E5=9C=B0=E5=9D=80=E8=B5=84=E6=BA=90=E4=B8=8E=E6=9C=AB=E8=A1=8C?= =?UTF-8?q?=E5=88=86=E9=9A=94=E7=BA=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/ets/ai-pick/AiPickConstant.ets | 5 --- .../main/ets/ai-pick/AiPickNodeComponent.ets | 31 ++++++++++--------- .../src/main/resources/base/element/url.json | 24 ++++++++++++++ 3 files changed, 41 insertions(+), 19 deletions(-) create mode 100644 entry/src/main/resources/base/element/url.json diff --git a/entry/src/main/ets/ai-pick/AiPickConstant.ets b/entry/src/main/ets/ai-pick/AiPickConstant.ets index eafb40f..b7a53ae 100644 --- a/entry/src/main/ets/ai-pick/AiPickConstant.ets +++ b/entry/src/main/ets/ai-pick/AiPickConstant.ets @@ -27,11 +27,6 @@ export const INFO_IMAGE_LIGHT = 'https://u.thsi.cn/imgsrc/bbs/e1e9b6d81b9f4f6fa817cbeb71e98ff1.png'; export const INFO_IMAGE_DARK = 'https://u.thsi.cn/imgsrc/bbs/19f7f20bcf800ec2b8e9fc0fa0d73369.png'; -export const EMPTY_IMAGE_LIGHT = - 'https://u.thsi.cn/imgsrc/bbs/8eee9cd4fa7e359032de11a3f7c2a70b_300_230.png'; -export const EMPTY_IMAGE_DARK = - 'https://u.thsi.cn/imgsrc/bbs/1c4e679244ed87231befad2b04cddfe2_300_230.png'; - // 字段黑名单:过滤 field_list 中不应展示的字段 export const BLACK_LIST: string[] = [ '合约代码', diff --git a/entry/src/main/ets/ai-pick/AiPickNodeComponent.ets b/entry/src/main/ets/ai-pick/AiPickNodeComponent.ets index 7507006..75a0deb 100644 --- a/entry/src/main/ets/ai-pick/AiPickNodeComponent.ets +++ b/entry/src/main/ets/ai-pick/AiPickNodeComponent.ets @@ -15,8 +15,6 @@ import { EventListener, } from '../common/EventEmitter'; import { - EMPTY_IMAGE_DARK, - EMPTY_IMAGE_LIGHT, INFO_IMAGE_DARK, INFO_IMAGE_LIGHT, RIGHT_ARROW_DARK, @@ -43,6 +41,10 @@ export struct AiPickNodeComponent { // Tab 状态及滚动区域 @State tabIdx: number = 0; + + private getUrl(resource: Resource): string { + return getContext(this).resourceManager.getStringSync(resource); + } @State tabViewportWidth: number = 0; @State tabContentWidth: number = 0; @State tabScrollOffset: number = 0; @@ -192,7 +194,7 @@ export struct AiPickNodeComponent { // 跳转到一句话定制策略主页。 // todo: 后续跳转为真实的客户端页面。 private jumpToNewHome(): void { - const pageUrl = 'https://fupage.10jqka.com.cn/ai-web/ai-diagnosis-home.html?sync=1'; + const pageUrl: string = this.getUrl($r('app.string.ai_pick_home_url')); const clientUrl = `client://client.html?action=ymtz^ishiddenbar=1^mode=new^webid=2804^url=${pageUrl}^title=AI选期`; console.info(`[AiPick] home url: ${clientUrl}`); @@ -209,7 +211,7 @@ export struct AiPickNodeComponent { // 跳转到策略详情页。 // todo: 后续跳转为真实的客户端页面。 private jumpToStrategyDetail(strategy: PickStrategy): void { - const pageUrl = 'https://fupage.10jqka.com.cn/ai-web/ai-diagnosis-detail.html' + + const pageUrl: string = this.getUrl($r('app.string.ai_pick_strategy_detail_url')) + `?id=${strategy.id}&type=${strategy.periodType}&name=${encodeURIComponent(strategy.name)}`; const clientUrl = `client://client.html?action=ymtz^ishiddenbar=1^mode=new^webid=2804^url=${pageUrl}^title=AI选期`; @@ -230,7 +232,7 @@ export struct AiPickNodeComponent { // 跳转到策略标签页。 // todo: 后续跳转为真实的客户端页面。 private jumpToLabel(strategy: PickStrategy, label: string): void { - const pageUrl = 'https://fupage.10jqka.com.cn/ai-web/ai-diagnosis-label.html' + + const pageUrl: string = this.getUrl($r('app.string.ai_pick_strategy_label_url')) + `?id=${strategy.id}&type=${strategy.periodType}&label=${encodeURIComponent(label)}`; const clientUrl = `client://client.html?action=ymtz^ishiddenbar=1^mode=new^webid=2804^url=${pageUrl}^title=AI选期`; @@ -540,7 +542,7 @@ export struct AiPickNodeComponent { // ── 合约列表 ──────────────────────────────────────── ForEach( this.cardData.tabs[this.tabIdx].items, - (item: PickContractItem, index: number) => { + (item: PickContractItem) => { Row({ space: 8 }) { Row({ space: 5 }) { Text(item.name) @@ -599,13 +601,7 @@ export struct AiPickNodeComponent { .width('100%') .height(45) .alignItems(VerticalAlign.Center) - .border({ - width: { - top: 1, - bottom: index === this.cardData.tabs[this.tabIdx].items.length - 1 ? 1 : 0, - }, - color: $r('app.color.divider_color'), - }) + .border({ width: { top: 1 }, color: $r('app.color.divider_color') }) .onClick(() => { this.jumpToDetail(item); }) @@ -614,6 +610,11 @@ export struct AiPickNodeComponent { (item: PickContractItem) => `${item.contract}_${item.market}_${item.price ?? ''}_${item.priceChg ?? ''}`, ) + + Divider() + .width('100%') + .strokeWidth(1) + .color($r('app.color.divider_color')) } .width('100%') } @@ -643,7 +644,9 @@ export struct AiPickNodeComponent { @Builder EmptyState(message: ResourceStr) { Column() { - Image(this.isDarkMode ? EMPTY_IMAGE_DARK : EMPTY_IMAGE_LIGHT) + Image(this.isDarkMode ? + $r('app.string.ai_pick_empty_image_dark_url') : + $r('app.string.ai_pick_empty_image_light_url')) .width(100) .height(100) Text(message) diff --git a/entry/src/main/resources/base/element/url.json b/entry/src/main/resources/base/element/url.json new file mode 100644 index 0000000..8e5848b --- /dev/null +++ b/entry/src/main/resources/base/element/url.json @@ -0,0 +1,24 @@ +{ + "string": [ + { + "name": "ai_pick_empty_image_light_url", + "value": "https://u.thsi.cn/imgsrc/bbs/8eee9cd4fa7e359032de11a3f7c2a70b_300_230.png" + }, + { + "name": "ai_pick_empty_image_dark_url", + "value": "https://u.thsi.cn/imgsrc/bbs/1c4e679244ed87231befad2b04cddfe2_300_230.png" + }, + { + "name": "ai_pick_home_url", + "value": "https://fupage.10jqka.com.cn/ai-web/ai-diagnosis-home.html?sync=1" + }, + { + "name": "ai_pick_strategy_detail_url", + "value": "https://fupage.10jqka.com.cn/ai-web/ai-diagnosis-detail.html" + }, + { + "name": "ai_pick_strategy_label_url", + "value": "https://fupage.10jqka.com.cn/ai-web/ai-diagnosis-label.html" + } + ] +}