diff --git a/web-front/public/list.html b/web-front/public/list.html index 0701d73..2917a9e 100644 --- a/web-front/public/list.html +++ b/web-front/public/list.html @@ -511,6 +511,7 @@ files.forEach(file => { const item = document.createElement('div'); + const metaText = fileMetaText(file); if (file.fileType === 'folder') { // 文件夹 @@ -520,9 +521,7 @@
${file.fileName || '未命名文件夹'}
-
- ${file.sizeStr || '0B'} · ${formatDate(file.createTime)} -
+ ${metaText ? `
${metaText}
` : ''} `; folderCount++; @@ -541,9 +540,7 @@
${file.fileName}
-
- ${file.sizeStr || '0B'} · ${formatDate(file.createTime)} -
+ ${metaText ? `
${metaText}
` : ''} `; fileCount++; @@ -675,19 +672,65 @@ renderBreadcrumb(); } + // 文件元信息 + function fileMetaText(file) { + const parts = []; + if (file.fileType !== 'folder') { + parts.push(file.sizeStr || '0B'); + } + const dateText = formatDate(file.createTime); + if (dateText) { + parts.push(dateText); + } + return parts.join(' · '); + } + + function hasValidTime(value) { + if (value === null || value === undefined) return false; + if (typeof value !== 'string') return true; + const trimmedValue = value.trim(); + return trimmedValue !== '' && trimmedValue !== 'null' && trimmedValue !== 'undefined'; + } + + function formatDateOnly(yearValue, monthValue, dayValue) { + const year = Number(yearValue); + const month = Number(monthValue); + const day = Number(dayValue); + const date = new Date(year, month - 1, day); + if ( + date.getFullYear() !== year || + date.getMonth() !== month - 1 || + date.getDate() !== day + ) { + return ''; + } + return `${yearValue}-${String(month).padStart(2, '0')}-${String(day).padStart(2, '0')}`; + } + // 格式化日期 function formatDate(dateString) { - if (!dateString) return '未知日期'; + if (!hasValidTime(dateString)) return ''; try { - const date = new Date(dateString); + const value = typeof dateString === 'string' ? dateString.trim() : dateString; + if (typeof value === 'string') { + const dateOnly = value.match(/^(\d{4})[-/](\d{1,2})[-/](\d{1,2})$/); + if (dateOnly) { + return formatDateOnly(dateOnly[1], dateOnly[2], dateOnly[3]); + } + const cnDateOnly = value.match(/^(\d{4})年\s*(\d{1,2})月\s*(\d{1,2})日$/); + if (cnDateOnly) { + return formatDateOnly(cnDateOnly[1], cnDateOnly[2], cnDateOnly[3]); + } + } + const date = new Date(value); return isNaN(date.getTime()) - ? '未知日期' + ? '' : `${date.getFullYear()}-${(date.getMonth() + 1).toString().padStart(2, '0')}-${date.getDate().toString().padStart(2, '0')}`; } catch { - return '未知日期'; + return ''; } } - \ No newline at end of file + diff --git a/web-front/src/components/DirectoryTree.vue b/web-front/src/components/DirectoryTree.vue index 53767bd..c907f4d 100644 --- a/web-front/src/components/DirectoryTree.vue +++ b/web-front/src/components/DirectoryTree.vue @@ -32,8 +32,8 @@
{{ file.fileName }}
-
- {{ formatDate(file.createTime) }} +
+ {{ fileMetaText(file) }}
@@ -168,7 +168,8 @@

类型: {{ getFileTypeClass(selectedNode) }}

大小: {{ selectedNode.sizeStr || '0B' }}

-

创建时间: {{ formatDate(selectedNode.createTime) }}

+

创建时间: {{ formatDate(selectedNode.createTime) }}

+

更新时间: {{ formatDate(selectedNode.updateTime) }}

@@ -244,7 +245,8 @@

类型: {{ getFileTypeClass(selectedNode) }}

大小: {{ selectedNode.sizeStr || '0B' }}

-

创建时间: {{ formatDate(selectedNode.createTime) }}

+

创建时间: {{ formatDate(selectedNode.createTime) }}

+

更新时间: {{ formatDate(selectedNode.updateTime) }}

@@ -314,8 +316,9 @@

{{ selectedFile?.fileName || '未命名文件' }}

- 大小: {{ selectedFile?.sizeStr || '0B' }}
- 创建时间: {{ formatDate(selectedFile?.createTime) }} +

@@ -444,6 +447,19 @@ export default { if (this.batchProgress.failed > 0) return 'exception' if (this.batchProgress.current >= this.batchProgress.total && this.batchProgress.total > 0) return 'success' return '' + }, + selectedFileInfoLines() { + if (!this.selectedFile) return [] + const lines = [`大小: ${this.selectedFile.sizeStr || '0B'}`] + const createTime = this.formatDate(this.selectedFile.createTime) + const updateTime = this.formatDate(this.selectedFile.updateTime) + if (createTime) { + lines.push(`创建时间: ${createTime}`) + } + if (updateTime) { + lines.push(`更新时间: ${updateTime}`) + } + return lines } }, watch: { @@ -815,11 +831,54 @@ export default { document.body.removeChild(a) } }, + hasValidTime(value) { + if (value === null || value === undefined) return false + if (typeof value !== 'string') return true + const trimmedValue = value.trim() + return trimmedValue !== '' && trimmedValue !== 'null' && trimmedValue !== 'undefined' + }, + formatDateOnly(yearValue, monthValue, dayValue) { + const year = Number(yearValue) + const month = Number(monthValue) + const day = Number(dayValue) + const date = new Date(year, month - 1, day) + if ( + date.getFullYear() !== year || + date.getMonth() !== month - 1 || + date.getDate() !== day + ) { + return '' + } + return `${yearValue}-${String(month).padStart(2, '0')}-${String(day).padStart(2, '0')}` + }, formatDate(timestamp) { - if (!timestamp) return '未知时间' - const date = new Date(timestamp) + if (!this.hasValidTime(timestamp)) return '' + const value = typeof timestamp === 'string' ? timestamp.trim() : timestamp + if (typeof value === 'string') { + const dateOnly = value.match(/^(\d{4})[-/](\d{1,2})[-/](\d{1,2})$/) + if (dateOnly) { + return this.formatDateOnly(dateOnly[1], dateOnly[2], dateOnly[3]) + } + const cnDateOnly = value.match(/^(\d{4})年\s*(\d{1,2})月\s*(\d{1,2})日$/) + if (cnDateOnly) { + return this.formatDateOnly(cnDateOnly[1], cnDateOnly[2], cnDateOnly[3]) + } + } + const date = new Date(value) + if (Number.isNaN(date.getTime())) return '' return date.toLocaleString('zh-CN') }, + fileMetaText(file) { + const parts = [] + if (file.fileType !== 'folder') { + parts.push(file.sizeStr || '0B') + } + const timeText = this.formatDate(file.createTime) + if (timeText) { + parts.push(timeText) + } + return parts.join(' · ') + }, checkTheme() { this.isDarkTheme = document.documentElement.classList.contains('dark') }, diff --git a/web-front/src/parserUrl1.js b/web-front/src/parserUrl1.js index 6b97e37..7c58aa2 100644 --- a/web-front/src/parserUrl1.js +++ b/web-front/src/parserUrl1.js @@ -238,8 +238,8 @@ storage: 'hash' }, 'ctfile': { - reg: /((?:https?:\/\/)?(?:[a-zA-Z\d-.]+)?(?:ctfile|545c|u062|ghpym|474b)\.com\/\w+\/[a-zA-Z\d-]+)/, - host: /(?:[a-zA-Z\d-.]+)?(?:ctfile|545c|u062|474b)\.com/, + reg: /((?:https?:\/\/)?(?:[a-zA-Z\d-.]+)?(?:ctfile|545c|u062|ghpym|474b)\.com\/(?:f(?:ile)?|d)\/[a-zA-Z\d_-]+\/?(?:\?[^#\s]*)?)/, + host: /(?:[a-zA-Z\d-.]+)?(?:ctfile|545c|u062|ghpym|474b)\.com/, input: ['#passcode'], button: ['.card-body button'], name: '城通网盘', diff --git a/web-front/src/utils/monacoTypes.js b/web-front/src/utils/monacoTypes.js index 833d043..ed11305 100644 --- a/web-front/src/utils/monacoTypes.js +++ b/web-front/src/utils/monacoTypes.js @@ -83,9 +83,9 @@ function registerTypeDefinitions(monaco) { clearHeaders(): JsHttpClient; getHeaders(): Record; setTimeout(seconds: number): JsHttpClient; - sendForm(data: Record): JsHttpResponse; + sendForm(url: string, data: Record): JsHttpResponse; sendMultipartForm(url: string, data: Record): JsHttpResponse; - sendJson(data: any): JsHttpResponse; + sendJson(url: string, data: any): JsHttpResponse; urlEncode(str: string): string; urlDecode(str: string): string; } @@ -244,17 +244,17 @@ function registerCompletionProvider(monaco) { range }, { - label: 'http.sendForm(data)', + label: 'http.sendForm(url, data)', kind: monaco.languages.CompletionItemKind.Method, - insertText: 'http.sendForm(${1:data})', + insertText: 'http.sendForm(${1:url}, ${2:data})', insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet, documentation: '发送表单数据', range }, { - label: 'http.sendJson(data)', + label: 'http.sendJson(url, data)', kind: monaco.languages.CompletionItemKind.Method, - insertText: 'http.sendJson(${1:data})', + insertText: 'http.sendJson(${1:url}, ${2:data})', insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet, documentation: '发送JSON数据', range