Class: EasyAI::Base::UpdateNotifier

Inherits:
Object
  • Object
show all
Defined in:
lib/easyai/base/update_notifier.rb

Constant Summary collapse

VERSION_INFO_FILE =
File.expand_path('~/.easyai/version_info.yml')

Class Method Summary collapse

Class Method Details

.maybe_show_notificationObject

智能决定是否显示更新通知



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/easyai/base/update_notifier.rb', line 12

def maybe_show_notification
  return if ENV['EASYAI_NO_UPDATE_CHECK']
  return unless should_show_notification?
  
  notification = load_notification
  return unless notification && notification['new_version_available']
  
  # 使用简洁的单行提醒
  show_brief_notification(notification)
  update_shown_time
end

.show_on_exitObject

在程序退出时显示(如果有更新)



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/easyai/base/update_notifier.rb', line 25

def show_on_exit
  return if ENV['EASYAI_NO_UPDATE_CHECK']
  
  notification = load_notification
  return unless notification && notification['new_version_available']
  return if notification['shown_today']
  
  # 退出时显示稍微详细的信息
  show_exit_notification(notification)
  mark_as_shown_today
end