fix(ssh): display SSH login logs in server timezone (#13869)

The SSH log page formatted dates with the browser timezone, so logs looked shifted when the client timezone differed from the server. Format the timestamp with the offset returned by the API so the page matches auth.log, the terminal and the CSV export. Refs #13860.
This commit is contained in:
王贺
2026-09-20 18:02:46 +08:00
committed by GitHub
parent 75b60b32e4
commit 65f6fdd045
2 changed files with 11 additions and 2 deletions
+9
View File
@@ -74,6 +74,15 @@ export function dateFormat(row: any, col: any, dataStr: any) {
return `${String(y)}-${String(m)}-${String(d)} ${String(h)}:${String(minute)}:${String(second)}`;
}
export function dateFormatServerTimezone(row: any, col: any, dataStr: any) {
const text = String(dataStr || '');
const matched = /^(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2})/.exec(text);
if (!matched) {
return text;
}
return `${matched[1]} ${matched[2]}`;
}
export function dateFormatSimple(dataStr: any) {
const date = new Date(dataStr);
const y = date.getFullYear();
+2 -2
View File
@@ -51,7 +51,7 @@
<el-table-column
prop="date"
:label="$t('commons.table.date')"
:formatter="dateFormat"
:formatter="dateFormatServerTimezone"
show-overflow-tooltip
/>
</ComplexTable>
@@ -94,7 +94,7 @@
<script setup lang="ts">
import ConfirmDialog from '@/components/confirm-dialog/index.vue';
import { dateFormat } from '@/utils/date';
import { dateFormatServerTimezone } from '@/utils/date';
import { downloadFile } from '@/utils/file';
import { onMounted, reactive, ref } from 'vue';
import { cleanSSHLogs, exportSSHLogs, loadSSHLogs } from '@/api/modules/host';