From 7c1922b5a62be090369552cbaa55a6beed97eaaf Mon Sep 17 00:00:00 2001 From: sfchu <183564171@qq.com> Date: Wed, 3 Dec 2025 16:36:43 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=B8=80=E5=A4=9A=E5=A4=A9=E6=B0=94=20=20W?= =?UTF-8?q?eather=20=E4=BB=A3=E7=A0=81=E5=9B=BD=E9=99=85=E5=8C=96=20&?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Weather/build-profile.json5 | 16 +- .../common/src/main/ets/mock/RequestData.ets | 29 +- Weather/common/src/main/ets/model/Main.ets | 4 +- .../common/src/main/ets/model/MenuData.ets | 4 +- .../main/resources/base/element/string.json | 36 ++ .../main/resources/en_US/element/string.json | 464 ++++++++++++++++++ .../main/resources/zh_CN/element/string.json | 460 +++++++++++++++++ .../default/src/main/ets/pages/AirQuality.ets | 2 +- .../default/src/main/ets/pages/CityList.ets | 15 +- .../src/main/ets/pages/IndexHeader.ets | 2 +- .../src/main/ets/pages/IndexTitleBar.ets | 9 +- .../src/main/ets/pages/SideContent.ets | 2 +- .../src/main/ets/pages/UpdateTimeDialog.ets | 10 +- .../main/resources/base/element/string.json | 2 +- .../main/resources/en_US/element/string.json | 2 +- 15 files changed, 1025 insertions(+), 32 deletions(-) create mode 100644 Weather/common/src/main/resources/en_US/element/string.json create mode 100644 Weather/common/src/main/resources/zh_CN/element/string.json diff --git a/Weather/build-profile.json5 b/Weather/build-profile.json5 index 7b2837f5..e8546c08 100644 --- a/Weather/build-profile.json5 +++ b/Weather/build-profile.json5 @@ -1,6 +1,20 @@ { "app": { - "signingConfigs": [], + "signingConfigs": [ + { + "name": "default", + "type": "HarmonyOS", + "material": { + "certpath": "C:\\Users\\Administrator\\.ohos\\config\\default_Weather_fZxSBgvKRwYTfhk1PIV9XFjshJGEodie8whx9gJkzKE=.cer", + "keyAlias": "debugKey", + "keyPassword": "0000001A15883937817B87AD225B3AF4542D42B687CF145ABA5AB343C0EEF98A2FFD82D55172E49284C0", + "profile": "C:\\Users\\Administrator\\.ohos\\config\\default_Weather_fZxSBgvKRwYTfhk1PIV9XFjshJGEodie8whx9gJkzKE=.p7b", + "signAlg": "SHA256withECDSA", + "storeFile": "C:\\Users\\Administrator\\.ohos\\config\\default_Weather_fZxSBgvKRwYTfhk1PIV9XFjshJGEodie8whx9gJkzKE=.p12", + "storePassword": "0000001AF91F4DDA653DF1813E9B877E24E3F96A8B6C57D3CB89373DB88812ED0375C9D142490602275F" + } + } + ], "products": [ { "name": "default", diff --git a/Weather/common/src/main/ets/mock/RequestData.ets b/Weather/common/src/main/ets/mock/RequestData.ets index 4ffcdf8b..7795e156 100644 --- a/Weather/common/src/main/ets/mock/RequestData.ets +++ b/Weather/common/src/main/ets/mock/RequestData.ets @@ -59,24 +59,24 @@ function getTypeIcon(data: string) { } } -function getUpdateTimes() { - let times: string[] = [ - '1小时', - '2小时', - '4小时', - '6小时', - '12小时', - '24小时', - '不更新' +function getUpdateTimes(): Resource[] { + let times: Resource[] = [ + $r('app.string.one_hour'), + $r('app.string.two_hour'), + $r('app.string.four_hour'), + $r('app.string.six_hour'), + $r('app.string.twelve_hour'), + $r('app.string.twenty_four_hour'), + $r('app.string.not_update') ]; return times; } -function getMenuInfo() { +function getMenuInfo(): MenuData[] { let data: MenuData[] = [ - new MenuData('管理城市', 'pages/CityList'), - new MenuData('更新间隔', '') + new MenuData($r('app.string.urban_management'), 'pages/CityList'), + new MenuData($r('app.string.update_interval'), '') ]; return data; } @@ -99,8 +99,7 @@ function getCityList() { let cities: Array = []; if (cityData) { cityData.forEach(item => { - cities.push(new City(resourceManager!.getStringSync(item.name as Resource), item.temp, - resourceManager!.getStringSync(item.weather as Resource))); + cities.push(new City(resourceManager!.getStringSync(item.name as Resource), item.temp, item.weather as Resource)); }) } return cities; @@ -109,7 +108,7 @@ function getCityList() { function addCity(city: City) { let cities: City[] | undefined = AppStorage.get('cityList'); let cityIndex = cities!.length % 5; - city.weather = resourceManager!.getStringSync(weather[cityIndex].data[1].wea as Resource); + city.weather = weather[cityIndex].data[1].wea as Resource; city.temp = weather[cityIndex].data[1].tem; cities!.push(city); AppStorage.setOrCreate('cityList', cities); diff --git a/Weather/common/src/main/ets/model/Main.ets b/Weather/common/src/main/ets/model/Main.ets index fcf70b28..2badcec5 100644 --- a/Weather/common/src/main/ets/model/Main.ets +++ b/Weather/common/src/main/ets/model/Main.ets @@ -117,9 +117,9 @@ class HeaderData { class City { public name: string; public temp: string; - public weather: ResourceStr; + public weather: Resource; - constructor(name: string, temp: string, weather: ResourceStr) { + constructor(name: string, temp: string, weather: Resource) { this.name = name; this.temp = temp; this.weather = weather; diff --git a/Weather/common/src/main/ets/model/MenuData.ets b/Weather/common/src/main/ets/model/MenuData.ets index eb30522a..f7bd2942 100644 --- a/Weather/common/src/main/ets/model/MenuData.ets +++ b/Weather/common/src/main/ets/model/MenuData.ets @@ -15,10 +15,10 @@ // 首页弹窗菜单 menu数据 export class MenuData { - public title: string; + public title: ResourceStr; public url: string; - constructor(title: string, url: string) { + constructor(title: ResourceStr, url: string) { this.title = title; this.url = url; } diff --git a/Weather/common/src/main/resources/base/element/string.json b/Weather/common/src/main/resources/base/element/string.json index dfb07d96..362b2a40 100644 --- a/Weather/common/src/main/resources/base/element/string.json +++ b/Weather/common/src/main/resources/base/element/string.json @@ -423,6 +423,42 @@ { "name": "night", "value": "night" + }, + { + "name": "one_hour", + "value": "1 hours" + }, + { + "name": "two_hour", + "value": "2 hours" + }, + { + "name": "four_hour", + "value": "4 hours" + }, + { + "name": "six_hour", + "value": "6 hours" + }, + { + "name": "twelve_hour", + "value": "12 hours" + }, + { + "name": "twenty_four_hour", + "value": "24 hours" + }, + { + "name": "not_update", + "value": "not update" + }, + { + "name": "urban_management", + "value": "Manage City" + }, + { + "name": "update_interval", + "value": "Update Interval" } ] } diff --git a/Weather/common/src/main/resources/en_US/element/string.json b/Weather/common/src/main/resources/en_US/element/string.json new file mode 100644 index 00000000..683ed8d1 --- /dev/null +++ b/Weather/common/src/main/resources/en_US/element/string.json @@ -0,0 +1,464 @@ +{ + "string": [ + { + "name": "page_show", + "value": "page from package" + }, + { + "name": "Beijing", + "value": "Bei Jing" + }, + { + "name": "Sunny", + "value": "Sunny" + }, + { + "name": "Shanghai", + "value": "Shang Hai" + }, + { + "name": "Cloudy", + "value": "Cloudy" + }, + { + "name": "Guangzhou", + "value": "Guangzhou" + }, + { + "name": "Rainy", + "value": "Rainy" + }, + { + "name": "Tianjin", + "value": "Tianjin" + }, + { + "name": "ModerateRain", + "value": "Moderate rain" + }, + { + "name": "Wuhan", + "value": "Wuhan" + }, + { + "name": "Shenyang", + "value": "Shenyang" + }, + { + "name": "Chongqing", + "value": "Chongqing" + }, + { + "name": "Hangzhou", + "value": "Hangzhou" + }, + { + "name": "Nanjing", + "value": "Nanjing" + }, + { + "name": "Harbin", + "value": "Harbin" + }, + { + "name": "Changchun", + "value": "Changchun" + }, + { + "name": "Shower", + "value": "Shower" + }, + { + "name": "Hohhot", + "value": "Hohhot" + }, + { + "name": "Shijiazhuang", + "value": "Shijiazhuang" + }, + { + "name": "Yinchuan", + "value": "Yinchuan" + }, + { + "name": "Urumqi", + "value": "Urumqi" + }, + { + "name": "Lhasa", + "value": "Lhasa" + }, + { + "name": "Xining", + "value": "Xining" + }, + { + "name": "Xian", + "value": "Xian" + }, + { + "name": "Lanzhou", + "value": "Lanzhou" + }, + { + "name": "Taiyuan", + "value": "Taiyuan" + }, + { + "name": "Kunming", + "value": "Kunming" + }, + { + "name": "Nanning", + "value": "Nanning" + }, + { + "name": "China", + "value": "China" + }, + { + "name": "23rd", + "value": "Tur,23rd" + }, + { + "name": "Thursday", + "value": "Thursday" + }, + { + "name": "SouthwestWind", + "value": "Southwest" + }, + { + "name": "winSpeed1", + "value": "5-6 -> 3-4" + }, + { + "name": "Excellent", + "value": "Excellent" + }, + { + "name": "24th", + "value": "Fri,24th" + }, + { + "name": "Friday", + "value": "Friday" + }, + { + "name": "25th", + "value": "Sat,25th" + }, + { + "name": "Saturday", + "value": "Saturday" + }, + { + "name": "26th", + "value": "Sun,26th" + }, + { + "name": "Sunday", + "value": "Sunday" + }, + { + "name": "27th", + "value": "Mon,27th" + }, + { + "name": "Monday", + "value": "Monday" + }, + { + "name": "28th", + "value": "Tue, 28th" + }, + { + "name": "Tuesday", + "value": "Tuesday" + }, + { + "name": "29th", + "value": "Wed, 29th" + }, + { + "name": "Wednesday", + "value": "Wednesday" + }, + { + "name": "winSpeed2", + "value": "3-4" + }, + { + "name": "airTips1", + "value": "Sunny and hot, avoid outdoors." + }, + { + "name": "WestWind", + "value": "West" + }, + { + "name": "NorthwestWind", + "value": "Northwest" + }, + { + "name": "SouthWind", + "value": "South" + }, + { + "name": "Humidity", + "value": "Humidity" + }, + { + "name": "Humidity_desc1", + "value": "Humidity perfect." + }, + { + "name": "Temperature", + "value": "Temperature" + }, + { + "name": "WindForce", + "value": "Wind force" + }, + { + "name": "Breeze", + "value": "Breeze" + }, + { + "name": "WindForce_desc1", + "value": "Breeze, great for outdoors." + }, + { + "name": "WindDirection", + "value": "Wind direction" + }, + { + "name": "NorthWind", + "value": "North" + }, + { + "name": "Clothing", + "value": "Clothing" + }, + { + "name": "TShirt", + "value": "T-shirt" + }, + { + "name": "Clothing_desc1", + "value": "Light summer clothes." + }, + { + "name": "Sport", + "value": "Sport" + }, + { + "name": "SportRecommended", + "value": "Indoor" + }, + { + "name": "Cold", + "value": "Cold" + }, + { + "name": "ColdEasy", + "value": "Prone to colds" + }, + { + "name": "ColdDesc", + "value": "Large day-night temperature difference. Prevent colds." + }, + { + "name": "UV", + "value": "UV" + }, + { + "name": "UVStrong", + "value": "Strong" + }, + { + "name": "UVDesc", + "value": "Strong radiation. Use SPF 8-12 sunscreen." + }, + { + "name": "WinDesc", + "value": "No sustained wind direction." + }, + { + "name": "airTips2", + "value": "Great air quality. Go outside, breathe fresh air, embrace nature!" + }, + { + "name": "MaskNeed1", + "value": "No mask needed." + }, + { + "name": "exercise1", + "value": "Ideal for exercise." + }, + { + "name": "goingOut1", + "value": "Good for going out." + }, + { + "name": "windows1", + "value": "Good to open windows." + }, + { + "name": "purifier1", + "value": "Turn off purifier." + }, + { + "name": "airTips3", + "value": "Cloudy, weak UV. Perfect for outings!" + }, + { + "name": "Weak", + "value": "Weak" + }, + { + "name": "UVDesc2", + "value": "Weak radiation. Use SPF 8-12 sunscreen." + }, + { + "name": "airTips4", + "value": "Cloudy now. Same temp as yesterday. Great for outings!" + }, + { + "name": "airTips5", + "value": "Light rain today. Cool weather." + }, + { + "name": "StrongWind", + "value": "Strong" + }, + { + "name": "SoutheastWind", + "value": "Southeast" + }, + { + "name": "LongSleeves", + "value": "Long sleeves" + }, + { + "name": "airTips6", + "value": "Good air quality, high humidity. Ideal for indoor activities!" + }, + { + "name": "airTips7", + "value": "Moderate rain today. Remember your umbrella!" + }, + { + "name": "Humidity_desc2", + "value": "High humidity" + }, + { + "name": "airTips8", + "value": "Good air quality. Go out, breathe fresh air, embrace nature!" + }, + { + "name": "airTips9", + "value": "Great air today. Perfect for outings. Remember sun protection!" + }, + { + "name": "SportRecommended1", + "value": "Outdoor recommended" + }, + { + "name": "42Per", + "value": "42%" + }, + { + "name": "tem28", + "value": "28°" + }, + { + "name": "45Per", + "value": "45%" + }, + { + "name": "50Per", + "value": "50%" + }, + { + "name": "tem27", + "value": "27°" + }, + { + "name": "55Per", + "value": "55%" + }, + { + "name": "tem35", + "value": "35°" + }, + { + "name": "tem20", + "value": "20°" + }, + { + "name": "tem25", + "value": "25°" + }, + { + "name": "morning", + "value": "morning" + }, + { + "name": "forenoon", + "value": "AM" + }, + { + "name": "midday", + "value": "midday" + }, + { + "name": "afternoon", + "value": "PM" + }, + { + "name": "sunset", + "value": "sunset" + }, + { + "name": "night", + "value": "night" + }, + { + "name": "one_hour", + "value": "1 hours" + }, + { + "name": "two_hour", + "value": "2 hours" + }, + { + "name": "four_hour", + "value": "4 hours" + }, + { + "name": "six_hour", + "value": "6 hours" + }, + { + "name": "twelve_hour", + "value": "12 hours" + }, + { + "name": "twenty_four_hour", + "value": "24 hours" + }, + { + "name": "not_update", + "value": "not update" + }, + { + "name": "urban_management", + "value": "Manage City" + }, + { + "name": "update_interval", + "value": "Update Interval" + } + ] +} diff --git a/Weather/common/src/main/resources/zh_CN/element/string.json b/Weather/common/src/main/resources/zh_CN/element/string.json new file mode 100644 index 00000000..661e5eac --- /dev/null +++ b/Weather/common/src/main/resources/zh_CN/element/string.json @@ -0,0 +1,460 @@ +{ + "string": [ + { + "name": "page_show", + "value": "page from package" + }, + { + "name": "Beijing", + "value": "北京" + }, + { + "name": "Sunny", + "value": "晴" + }, + { + "name": "Shanghai", + "value": "上海" + }, + { + "name": "Cloudy", + "value": "阴" + }, + { + "name": "Guangzhou", + "value": "广州" + }, + { + "name": "Rainy", + "value": "小雨" + }, + { + "name": "Tianjin", + "value": "天津" + }, + { + "name": "ModerateRain", + "value": "中雨" + }, + { + "name": "Wuhan", + "value": "武汉" + }, + { + "name": "Shenyang", + "value": "沈阳" + }, + { + "name": "Chongqing", + "value": "重庆" + }, + { + "name": "Hangzhou", + "value": "杭州" + }, + { + "name": "Nanjing", + "value": "南京" + }, + { + "name": "Harbin", + "value": "哈尔滨" + }, + { + "name": "Changchun", + "value": "长春" + }, + { + "name": "Shower", + "value": "阵雨" + }, + { + "name": "Hohhot", + "value": "呼和浩特" + }, + { + "name": "Shijiazhuang", + "value": "石家庄" + }, + { + "name": "Yinchuan", + "value": "银川" + }, + { + "name": "Urumqi", + "value": "乌鲁木齐" + }, + { + "name": "Lhasa", + "value": "拉萨" + }, + { + "name": "Xining", + "value": "西宁" + }, + { + "name": "Xian", + "value": "西安" + }, + { + "name": "Lanzhou", + "value": "兰州" + }, + { + "name": "Taiyuan", + "value": "太原" + }, + { + "name": "Kunming", + "value": "昆明" + }, + { + "name": "Nanning", + "value": "南宁" + }, + { + "name": "China", + "value": "中国" + }, + { + "name": "23rd", + "value": "23日(星期四)" + }, + { + "name": "Thursday", + "value": "星期四" + }, + { + "name": "SouthwestWind", + "value": "西南风" + }, + { + "name": "winSpeed1", + "value": "5-6 -> 3-4级" + }, + { + "name": "Excellent", + "value": "优" + }, + { + "name": "24th", + "value": "24日(星期五)" + }, + { + "name": "Friday", + "value": "星期五" + }, + { + "name": "25th", + "value": "25日(星期六)" + }, + { + "name": "Saturday", + "value": "星期六" + }, + { + "name": "26th", + "value": "26日(周日)" + }, + { + "name": "Sunday", + "value": "周日" + }, + { + "name": "27th", + "value": "27日(周一)" + }, + { + "name": "Monday", + "value": "周一" + }, + { + "name": "28th", + "value": "28日(星期二)" + }, + { + "name": "Tuesday", + "value": "星期二" + }, + { + "name": "Wednesday", + "value": "星期三" + }, + { + "name": "winSpeed2", + "value": "3-4" + }, + { + "name": "airTips1", + "value": "当前晴,炎热,不适合外出游玩" + }, + { + "name": "WestWind", + "value": "西风" + }, + { + "name": "NorthwestWind", + "value": "西北风" + }, + { + "name": "SouthWind", + "value": "南风" + }, + { + "name": "Humidity", + "value": "湿度" + }, + { + "name": "Humidity_desc1", + "value": "湿度刚好" + }, + { + "name": "Temperature", + "value": "体感温度" + }, + { + "name": "WindForce", + "value": "风力" + }, + { + "name": "Breeze", + "value": "威风" + }, + { + "name": "WindForce_desc1", + "value": "风力较弱,适宜户外活动。" + }, + { + "name": "WindDirection", + "value": "风向" + }, + { + "name": "NorthWind", + "value": "北风" + }, + { + "name": "Clothing", + "value": "穿着" + }, + { + "name": "TShirt", + "value": "短袖" + }, + { + "name": "Clothing_desc1", + "value": "建议穿短衫、短裤等清凉夏季服装。" + }, + { + "name": "Sport", + "value": "运动" + }, + { + "name": "SportRecommended", + "value": "宜室内" + }, + { + "name": "Cold", + "value": "感冒" + }, + { + "name": "ColdEasy", + "value": "容易" + }, + { + "name": "ColdDesc", + "value": "昼夜温差大,注意预防感冒。" + }, + { + "name": "UV", + "value": "紫外线" + }, + { + "name": "UVStrong", + "value": "强" + }, + { + "name": "UVDesc", + "value": "辐射强,涂擦SPF8-12防晒护肤品。" + }, + { + "name": "WinDesc", + "value": "无持续风向" + }, + { + "name": "airTips2", + "value": "空气很好,可以外出活动,呼吸新鲜空气,拥抱大自然!" + }, + { + "name": "MaskNeed1", + "value": "不用佩戴口罩" + }, + { + "name": "exercise1", + "value": "非常适宜运动" + }, + { + "name": "goingOut1", + "value": "适宜外出" + }, + { + "name": "windows1", + "value": "适宜开窗" + }, + { + "name": "purifier1", + "value": "关闭净化器" + }, + { + "name": "airTips3", + "value": "当前阴,紫外线弱,适合外出游玩!" + }, + { + "name": "Weak", + "value": "弱" + }, + { + "name": "UVDesc2", + "value": "辐射弱,涂擦SPF8-12防晒护肤品。" + }, + { + "name": "airTips4", + "value": "当前多云,昨天和今天温度一致,适合外出游玩!" + }, + { + "name": "airTips5", + "value": "今天小雨,天气凉爽" + }, + { + "name": "StrongWind", + "value": "大风" + }, + { + "name": "SoutheastWind", + "value": "东南风" + }, + { + "name": "LongSleeves", + "value": "长袖" + }, + { + "name": "airTips6", + "value": "空气良好,湿度较高,适宜室内活动!" + }, + { + "name": "airTips7", + "value": "今天中雨,出门记得带伞哦!" + }, + { + "name": "Humidity_desc2", + "value": "湿度较高。" + }, + { + "name": "airTips8", + "value": "空气良好,可以外出活动,呼吸新鲜空气,拥抱大自然!" + }, + { + "name": "airTips9", + "value": "今天空气很好,适合外出游玩,注意防晒!" + }, + { + "name": "SportRecommended1", + "value": "宜室外" + }, + { + "name": "42Per", + "value": "42%" + }, + { + "name": "tem28", + "value": "28°" + }, + { + "name": "45Per", + "value": "45%" + }, + { + "name": "50Per", + "value": "50%" + }, + { + "name": "tem27", + "value": "27°" + }, + { + "name": "55Per", + "value": "55%" + }, + { + "name": "tem35", + "value": "35°" + }, + { + "name": "tem20", + "value": "20°" + }, + { + "name": "tem25", + "value": "25°" + }, + { + "name": "morning", + "value": "早上" + }, + { + "name": "forenoon", + "value": "上午" + }, + { + "name": "midday", + "value": "中午" + }, + { + "name": "afternoon", + "value": "下午" + }, + { + "name": "sunset", + "value": "傍晚" + }, + { + "name": "night", + "value": "晚上" + }, + { + "name": "one_hour", + "value": "1小时" + }, + { + "name": "two_hour", + "value": "2小时" + }, + { + "name": "four_hour", + "value": "4小时" + }, + { + "name": "six_hour", + "value": "6小时" + }, + { + "name": "twelve_hour", + "value": "12小时" + }, + { + "name": "twenty_four_hour", + "value": "24小时" + }, + { + "name": "not_update", + "value": "不更新" + }, + { + "name": "urban_management", + "value": "管理城市" + }, + { + "name": "update_interval", + "value": "更新间隔" + } + ] +} \ No newline at end of file diff --git a/Weather/product/default/src/main/ets/pages/AirQuality.ets b/Weather/product/default/src/main/ets/pages/AirQuality.ets index 8ec2a626..7c753951 100644 --- a/Weather/product/default/src/main/ets/pages/AirQuality.ets +++ b/Weather/product/default/src/main/ets/pages/AirQuality.ets @@ -22,7 +22,7 @@ export default struct AirQuality { settings: RenderingContextSettings = new RenderingContextSettings(true); context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings); airIndexData: AirIndex[] = getAirIndexData(0); - airData: AirData = getHeaderDate(0).airData; + airData: AirData = getHeaderDate(0).airData!; build() { Row() { diff --git a/Weather/product/default/src/main/ets/pages/CityList.ets b/Weather/product/default/src/main/ets/pages/CityList.ets index 39358c91..27e32b35 100644 --- a/Weather/product/default/src/main/ets/pages/CityList.ets +++ b/Weather/product/default/src/main/ets/pages/CityList.ets @@ -13,6 +13,7 @@ * limitations under the License. */ +import { hilog } from '@kit.PerformanceAnalysisKit'; import { City, getSideBg, MyDataSource, Style } from 'common'; @Entry @@ -42,6 +43,17 @@ struct CityList { return 0; } + getResourceFile(weather: Resource): Resource | undefined { + try { + return getSideBg(this.getUIContext() + .getHostContext()?.resourceManager.getStringSync((weather as Resource)) as string); + } catch (error) { + hilog.error(0x0000, 'testTag', '%{public}s', + `getStringSync failed, error code: ${error.code}, message: ${error.message}.`); + return undefined; + } + } + @Builder CityInfo(item: City, index: number) { Row() { @@ -78,8 +90,7 @@ struct CityList { .borderRadius(Style.NORMAL_RADIUS) .alignItems(VerticalAlign.Center) .backgroundImageSize(ImageSize.Cover) - .backgroundImage(getSideBg(this.getUIContext() - .getHostContext()?.resourceManager.getStringSync((item.weather as Resource))as string)) + .backgroundImage(this.getResourceFile(item.weather)) } build() { diff --git a/Weather/product/default/src/main/ets/pages/IndexHeader.ets b/Weather/product/default/src/main/ets/pages/IndexHeader.ets index 4b456643..b717a106 100644 --- a/Weather/product/default/src/main/ets/pages/IndexHeader.ets +++ b/Weather/product/default/src/main/ets/pages/IndexHeader.ets @@ -18,7 +18,7 @@ import { getHeaderDate, HeaderData, Style } from 'common'; @Preview @Component export default struct IndexHeader { - headerDate: HeaderData = getHeaderDate(0); + headerDate: HeaderData = getHeaderDate(0)!; index: number = 0; build() { diff --git a/Weather/product/default/src/main/ets/pages/IndexTitleBar.ets b/Weather/product/default/src/main/ets/pages/IndexTitleBar.ets index a39c5bf1..24a757b6 100644 --- a/Weather/product/default/src/main/ets/pages/IndexTitleBar.ets +++ b/Weather/product/default/src/main/ets/pages/IndexTitleBar.ets @@ -13,6 +13,8 @@ * limitations under the License. */ +import { BusinessError } from '@kit.BasicServicesKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; import UpdateTimeDialog from './UpdateTimeDialog'; import { getMenuInfo, MenuData, Style } from 'common'; @@ -49,7 +51,10 @@ export default struct IndexTitleBar { if (this.showSideBar) { this.showSideBar = false; } - this.getUIContext().getRouter().pushUrl({ url: item.url }); + this.getUIContext().getRouter().pushUrl({ url: item.url }).catch((error: BusinessError) => { + hilog.error(0x0000, 'testTag', '%{public}s', + `pushUrl failed, code is ${error.code}, message is ${error.message}`); + }); } else { if (this.dialogController === undefined) { this.dialogController = new CustomDialogController({ @@ -99,7 +104,7 @@ export default struct IndexTitleBar { builder: this.popupBuilder, placement: Placement.BottomLeft, maskColor: 0x33000000, - popupColor: '#00000000', + popupColor: Color.White, enableArrow: false, onStateChange: (e) => { if (!e.isVisible) { diff --git a/Weather/product/default/src/main/ets/pages/SideContent.ets b/Weather/product/default/src/main/ets/pages/SideContent.ets index 65d92f4a..98b39e27 100644 --- a/Weather/product/default/src/main/ets/pages/SideContent.ets +++ b/Weather/product/default/src/main/ets/pages/SideContent.ets @@ -93,7 +93,7 @@ struct CityItem { getResourceFile(): Resource | undefined { try { return getSideBg(this.getUIContext() - .getHostContext()?.resourceManager.getStringSync((this.cityInfo!.weather as Resource).id) as string); + .getHostContext()?.resourceManager.getStringSync((this.cityInfo!.weather as Resource)) as string); } catch (error) { hilog.error(DOMAIN, 'testTag', '%{public}s', `getStringSync failed, error code: ${error.code}, message: ${error.message}.`); diff --git a/Weather/product/default/src/main/ets/pages/UpdateTimeDialog.ets b/Weather/product/default/src/main/ets/pages/UpdateTimeDialog.ets index 0f6d3488..f7502718 100644 --- a/Weather/product/default/src/main/ets/pages/UpdateTimeDialog.ets +++ b/Weather/product/default/src/main/ets/pages/UpdateTimeDialog.ets @@ -20,7 +20,7 @@ import { getUpdateTimes, Style } from 'common'; export default struct UpdateTimeDialog { @StorageLink('curBp') curBp: string = 'md'; controller: CustomDialogController; - updateTimes: string[] = getUpdateTimes(); + updateTimes: Resource[] = getUpdateTimes(); handleCancelDialog: () => void = () => { }; @@ -39,9 +39,13 @@ export default struct UpdateTimeDialog { .fontWeight(FontWeight.Medium) .margin({ top: 14 }) List() { - ForEach(this.updateTimes, (item: string, index: number) => { + ForEach(this.updateTimes, (item: Resource, index: number) => { ListItem() { - UpdateTimeItem({ index: index, updateTime: item }) + UpdateTimeItem({ + index: index, + updateTime: this.getUIContext() + .getHostContext()?.resourceManager.getStringSync((item as Resource).id) as string + }) } }, (item: string, index: number) => JSON.stringify(item) + index) } diff --git a/Weather/product/default/src/main/resources/base/element/string.json b/Weather/product/default/src/main/resources/base/element/string.json index c12b9e00..280d7e31 100644 --- a/Weather/product/default/src/main/resources/base/element/string.json +++ b/Weather/product/default/src/main/resources/base/element/string.json @@ -66,7 +66,7 @@ }, { "name": "manage_city", - "value": "Urban management" + "value": "Manage City" }, { "name": "add_city", diff --git a/Weather/product/default/src/main/resources/en_US/element/string.json b/Weather/product/default/src/main/resources/en_US/element/string.json index c12b9e00..280d7e31 100644 --- a/Weather/product/default/src/main/resources/en_US/element/string.json +++ b/Weather/product/default/src/main/resources/en_US/element/string.json @@ -66,7 +66,7 @@ }, { "name": "manage_city", - "value": "Urban management" + "value": "Manage City" }, { "name": "add_city", -- Gitee From ba3bd0f26a4900723fddcf32dff8a6153019ea77 Mon Sep 17 00:00:00 2001 From: sfchu <183564171@qq.com> Date: Wed, 3 Dec 2025 16:37:46 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=8E=BB=E7=AD=BE=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Weather/build-profile.json5 | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/Weather/build-profile.json5 b/Weather/build-profile.json5 index e8546c08..7b2837f5 100644 --- a/Weather/build-profile.json5 +++ b/Weather/build-profile.json5 @@ -1,20 +1,6 @@ { "app": { - "signingConfigs": [ - { - "name": "default", - "type": "HarmonyOS", - "material": { - "certpath": "C:\\Users\\Administrator\\.ohos\\config\\default_Weather_fZxSBgvKRwYTfhk1PIV9XFjshJGEodie8whx9gJkzKE=.cer", - "keyAlias": "debugKey", - "keyPassword": "0000001A15883937817B87AD225B3AF4542D42B687CF145ABA5AB343C0EEF98A2FFD82D55172E49284C0", - "profile": "C:\\Users\\Administrator\\.ohos\\config\\default_Weather_fZxSBgvKRwYTfhk1PIV9XFjshJGEodie8whx9gJkzKE=.p7b", - "signAlg": "SHA256withECDSA", - "storeFile": "C:\\Users\\Administrator\\.ohos\\config\\default_Weather_fZxSBgvKRwYTfhk1PIV9XFjshJGEodie8whx9gJkzKE=.p12", - "storePassword": "0000001AF91F4DDA653DF1813E9B877E24E3F96A8B6C57D3CB89373DB88812ED0375C9D142490602275F" - } - } - ], + "signingConfigs": [], "products": [ { "name": "default", -- Gitee From 81817d70e9df194369bc80db8eebd44f91ddc6a0 Mon Sep 17 00:00:00 2001 From: sfchu <183564171@qq.com> Date: Wed, 3 Dec 2025 16:50:54 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../product/default/src/main/ets/pages/UpdateTimeDialog.ets | 2 +- .../default/src/main/resources/base/element/string.json | 4 ++-- .../default/src/main/resources/en_US/element/string.json | 4 ++-- .../default/src/main/resources/zh_CN/element/string.json | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Weather/product/default/src/main/ets/pages/UpdateTimeDialog.ets b/Weather/product/default/src/main/ets/pages/UpdateTimeDialog.ets index f7502718..295c716f 100644 --- a/Weather/product/default/src/main/ets/pages/UpdateTimeDialog.ets +++ b/Weather/product/default/src/main/ets/pages/UpdateTimeDialog.ets @@ -33,7 +33,7 @@ export default struct UpdateTimeDialog { GridCol({ span: 4, offset: { sm: 0, md: 2, lg: 4 } }) { Row() { Column() { - Text($r('app.string.update_time')) + Text($r('app.string.update_interval')) .width('100%') .fontSize(20) .fontWeight(FontWeight.Medium) diff --git a/Weather/product/default/src/main/resources/base/element/string.json b/Weather/product/default/src/main/resources/base/element/string.json index 280d7e31..94afc69c 100644 --- a/Weather/product/default/src/main/resources/base/element/string.json +++ b/Weather/product/default/src/main/resources/base/element/string.json @@ -77,8 +77,8 @@ "value": "Search for city (Chinese/Pinyin)" }, { - "name": "update_time", - "value": "Update Time" + "name": "update_interval", + "value": "Update Interval" }, { "name": "cancel", diff --git a/Weather/product/default/src/main/resources/en_US/element/string.json b/Weather/product/default/src/main/resources/en_US/element/string.json index 280d7e31..94afc69c 100644 --- a/Weather/product/default/src/main/resources/en_US/element/string.json +++ b/Weather/product/default/src/main/resources/en_US/element/string.json @@ -77,8 +77,8 @@ "value": "Search for city (Chinese/Pinyin)" }, { - "name": "update_time", - "value": "Update Time" + "name": "update_interval", + "value": "Update Interval" }, { "name": "cancel", diff --git a/Weather/product/default/src/main/resources/zh_CN/element/string.json b/Weather/product/default/src/main/resources/zh_CN/element/string.json index 5375831c..7a69762e 100644 --- a/Weather/product/default/src/main/resources/zh_CN/element/string.json +++ b/Weather/product/default/src/main/resources/zh_CN/element/string.json @@ -77,8 +77,8 @@ "value": "搜索城市(中文/拼音)" }, { - "name": "update_time", - "value": "更新时间" + "name": "update_interval", + "value": "更新间隔" }, { "name": "cancel", -- Gitee