diff --git a/app/controllers/cities_controller.rb b/app/controllers/cities_controller.rb index 3c88b24..6317c30 100644 --- a/app/controllers/cities_controller.rb +++ b/app/controllers/cities_controller.rb @@ -65,7 +65,7 @@ class CitiesController < ApplicationController set_meta_tags( title: t("meta.cities.show.title", city_name: @city.name, country_name: @city&.country&.name.to_s), - description: t("meta.cities.show.description", city_name: @city.name), + description: t("meta.cities.show.description", city_name: @city.get_description("en", false, true, false)), keywords: t("meta.cities.show.keywords", city_name: @city.name, country_name: @city.country&.name.to_s), og: { image: @city.latest_weather_art&.image&.attached? ? url_for(@city.latest_weather_art.image) : nil diff --git a/app/models/city.rb b/app/models/city.rb index 5c3d590..2ff8bbe 100644 --- a/app/models/city.rb +++ b/app/models/city.rb @@ -251,7 +251,7 @@ class City < ApplicationRecord end # 获取城市描述,支持多语言 - def get_description(locale = I18n.locale.to_s, force_refresh = false, quick = false) + def get_description(locale = I18n.locale.to_s, force_refresh = false, quick = false, is_user = true) # 标准化语言代码为小写字符串 locale = locale.to_s.downcase @@ -266,7 +266,10 @@ class City < ApplicationRecord if quick GenerateCityDescriptionWorker.perform_async(id, force_refresh) - return "#{full_name} - Please wait a Minute. (City description is being generated in the background. Please refresh the page in a moment to see the complete description)." + temp_desc = !is_user ? + "#{full_name}" : + "#{full_name} - Please wait a Minute. (City description is being generated in the background. Please refresh the page in a moment to see the complete description)." + return temp_desc end # 否则,生成新的描述并保存 diff --git a/app/views/shared/_city_ai_description.html.erb b/app/views/shared/_city_ai_description.html.erb index 1fb1fcd..f51e36b 100644 --- a/app/views/shared/_city_ai_description.html.erb +++ b/app/views/shared/_city_ai_description.html.erb @@ -9,7 +9,7 @@ City Description
-

<%= city.get_description('en', false, true) %>

+

<%= city.get_description('en', false, true, true) %>