Change file-date set

This commit is contained in:
rulingcom 2026-03-13 12:12:29 +08:00
parent 085bace552
commit 7e691e6927
4 changed files with 20 additions and 7 deletions

View File

@ -37,7 +37,7 @@ class Admin::ArchiveFilesController < OrbitAdminController
end
end
@choose = ArchiveSortOrder.first['sort_order']
@table_fields = [:status, :category, :title, :updated_at,:last_modified,:created_at,"archive.downloaded_times"]
@table_fields = [:status, :category, :title, :updated_at,:last_modified,"archive.downloaded_times"]
@categories = @module_app.categories.enabled
@tags = @module_app.tags
@filter_fields = filter_fields(@categories, @tags)

View File

@ -292,13 +292,20 @@ class ArchiveFile
title = (file.file_title.blank? ? File.basename(file.file.path) : file.file_title) rescue ""
extension = file.file.file.extension.downcase rescue ""
serial_number += 1
real_file_time = ""
if file.file.present? && file.file.path && File.exist?(file.file.path)
real_file_time = File.mtime(file.file.path).localtime.strftime("%Y-%m-%d %H:%M")
else
# 如果找不到實體檔案,才回退到資料庫時間(或留空)
real_file_time = file.created_at.localtime.strftime("%Y-%m-%d %H:%M") rescue ""
end
files << {
"file-name" => title,
"file-type" => extension,
"file-url" => (file.file.present? ? "/xhr/archive/download?file=#{file.id}" : 'javascript:void(0)'),
"target" => "_blank",
"serial_number" => serial_number,
"file-date" => (file.created_at.localtime.strftime("%Y-%m-%d") rescue "")
"file-date" => real_file_time
}
end
end

View File

@ -7,11 +7,18 @@
<%= t(:no_file) %>
<% else %>
<%= link_to content_tag(:i) + form_file.file_identifier, form_file.file.url, {:class => 'file-link file-type', :target => '_blank', :title => form_file.file_identifier} %>
<% # 建議改放這裡:直接跟在檔案連結後面,確保是已存在檔案才顯示 %>
<span class="upload_time" style="margin-left: 15px; color: #0088cc; font-size: 0.9em;">
<% # 修正:這裡改為讀取實體檔案時間 %>
<%
real_time = ""
if form_file.file.present? && form_file.file.path && File.exist?(form_file.file.path)
real_time = File.mtime(form_file.file.path).localtime.strftime("%Y-%m-%d %H:%M")
else
real_time = form_file.created_at.localtime.strftime("%Y-%m-%d %H:%M") rescue "N/A"
end
%>
<span class="upload_time" style="margin-left: 10px; color: #999;">
<i class="icons-clock"></i>
<%= t('file.uploaded_at') rescue 'Uploaded at' %>:
<b><%= form_file.created_at.localtime.strftime("%Y-%m-%d %H:%M") rescue "N/A" %></b>
<%= t(:file_mtime) rescue '檔案時間' %>: <b><%= real_time %></b>
</span>
<% end %>
<% end %>

View File

@ -131,7 +131,6 @@
</td>
<td><%= format_value archive.updated_at rescue nil %></td>
<td><%= User.find(archive.update_user_id).user_name rescue nil %></td>
<td><%= format_value archive.created_at rescue nil %></td>
<% download_total = 0
archive.archive_file_multiples.each do |afm|
download_total = download_total + afm.download_count