From 95d27a4a0a7c070e7553c8636d8cc2eee032aee3 Mon Sep 17 00:00:00 2001 From: "xiaoqi.cxq" Date: Fri, 23 Sep 2022 23:18:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E6=A1=A3=E7=89=88=E6=9C=AC=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E6=8F=90=E4=BA=A4=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/menus/HistoryMenu.vue | 9 +++ src/services/providers/gistProvider.js | 1 + src/services/providers/giteaProvider.js | 1 + .../providers/giteaWorkspaceProvider.js | 1 + .../providers/giteeAppDataProvider.js | 1 + src/services/providers/giteeProvider.js | 1 + .../providers/giteeWorkspaceProvider.js | 1 + src/services/providers/githubProvider.js | 7 +- .../providers/githubWorkspaceProvider.js | 7 +- src/services/providers/gitlabProvider.js | 1 + .../providers/gitlabWorkspaceProvider.js | 1 + src/services/timeSvc.js | 64 +------------------ 12 files changed, 29 insertions(+), 66 deletions(-) diff --git a/src/components/menus/HistoryMenu.vue b/src/components/menus/HistoryMenu.vue index 5aae0197..977bf339 100644 --- a/src/components/menus/HistoryMenu.vue +++ b/src/components/menus/HistoryMenu.vue @@ -33,6 +33,7 @@
{{revision.created | formatTime}}
+
{{revision.message}}
@@ -412,6 +413,14 @@ export default { opacity: 0.6; } +.revision__msg { + font-size: 0.75em; + opacity: 0.6; + white-space: pre-wrap; + word-break: break-word; + word-wrap: break-word; +} + .layout--revision { .cledit-section *, .cl-preview-section * { diff --git a/src/services/providers/gistProvider.js b/src/services/providers/gistProvider.js index 71463ede..b4ac7f74 100644 --- a/src/services/providers/gistProvider.js +++ b/src/services/providers/gistProvider.js @@ -70,6 +70,7 @@ export default new Provider({ return { sub, id: entry.version, + message: entry.commit && entry.commit.message, created: new Date(entry.committed_at).getTime(), }; }); diff --git a/src/services/providers/giteaProvider.js b/src/services/providers/giteaProvider.js index 8cbc8ff9..de8ce897 100644 --- a/src/services/providers/giteaProvider.js +++ b/src/services/providers/giteaProvider.js @@ -155,6 +155,7 @@ export default new Provider({ return { id: sha, sub, + message: commit.message, created: date ? new Date(date).getTime() : 1, }; }); diff --git a/src/services/providers/giteaWorkspaceProvider.js b/src/services/providers/giteaWorkspaceProvider.js index 8d8c57f8..f97d7723 100644 --- a/src/services/providers/giteaWorkspaceProvider.js +++ b/src/services/providers/giteaWorkspaceProvider.js @@ -278,6 +278,7 @@ export default new Provider({ return { id: sha, sub, + message: commit.message, created: new Date(date).getTime(), }; }); diff --git a/src/services/providers/giteeAppDataProvider.js b/src/services/providers/giteeAppDataProvider.js index bf944d2b..40b80bae 100644 --- a/src/services/providers/giteeAppDataProvider.js +++ b/src/services/providers/giteeAppDataProvider.js @@ -237,6 +237,7 @@ export default new Provider({ return { id: sha, sub, + message: commit.message, created: new Date(date).getTime(), }; }); diff --git a/src/services/providers/giteeProvider.js b/src/services/providers/giteeProvider.js index 7eabf703..abcaa09e 100644 --- a/src/services/providers/giteeProvider.js +++ b/src/services/providers/giteeProvider.js @@ -145,6 +145,7 @@ export default new Provider({ return { id: sha, sub, + message: commit.message, created: date ? new Date(date).getTime() : 1, }; }); diff --git a/src/services/providers/giteeWorkspaceProvider.js b/src/services/providers/giteeWorkspaceProvider.js index cead6717..65551072 100644 --- a/src/services/providers/giteeWorkspaceProvider.js +++ b/src/services/providers/giteeWorkspaceProvider.js @@ -266,6 +266,7 @@ export default new Provider({ return { id: sha, sub, + message: commit.message, created: new Date(date).getTime(), }; }); diff --git a/src/services/providers/githubProvider.js b/src/services/providers/githubProvider.js index 22d063e0..d0f32bc0 100644 --- a/src/services/providers/githubProvider.js +++ b/src/services/providers/githubProvider.js @@ -134,14 +134,17 @@ export default new Provider({ user = author; } else if (committer && committer.login) { user = committer; + } else if (commit && commit.author) { + user = commit.author; } - const sub = `${githubHelper.subPrefix}:${user.id}`; - userSvc.addUserInfo({ id: sub, name: user.login, imageUrl: user.avatar_url }); + const sub = `${githubHelper.subPrefix}:${user.id || user.name}`; + userSvc.addUserInfo({ id: sub, name: user.login || user.name, imageUrl: user.avatar_url }); const date = (commit.author && commit.author.date) || (commit.committer && commit.committer.date); return { id: sha, sub, + message: commit.message, created: date ? new Date(date).getTime() : 1, }; }); diff --git a/src/services/providers/githubWorkspaceProvider.js b/src/services/providers/githubWorkspaceProvider.js index ca470149..9a46822e 100644 --- a/src/services/providers/githubWorkspaceProvider.js +++ b/src/services/providers/githubWorkspaceProvider.js @@ -254,15 +254,18 @@ export default new Provider({ user = author; } else if (committer && committer.login) { user = committer; + } else if (commit && commit.author) { + user = commit.author; } - const sub = `${githubHelper.subPrefix}:${user.id}`; - userSvc.addUserInfo({ id: sub, name: user.login, imageUrl: user.avatar_url }); + const sub = `${githubHelper.subPrefix}:${user.id || user.name}`; + userSvc.addUserInfo({ id: sub, name: user.login || user.name, imageUrl: user.avatar_url }); const date = (commit.author && commit.author.date) || (commit.committer && commit.committer.date) || 1; return { id: sha, sub, + message: commit.message, created: new Date(date).getTime(), }; }); diff --git a/src/services/providers/gitlabProvider.js b/src/services/providers/gitlabProvider.js index c3db96b5..f19e723f 100644 --- a/src/services/providers/gitlabProvider.js +++ b/src/services/providers/gitlabProvider.js @@ -148,6 +148,7 @@ export default new Provider({ return { id: entry.id, sub, + message: entry.commit && entry.commit.message, created: date ? new Date(date).getTime() : 1, }; }); diff --git a/src/services/providers/gitlabWorkspaceProvider.js b/src/services/providers/gitlabWorkspaceProvider.js index 84a24cf8..c78df9c6 100644 --- a/src/services/providers/gitlabWorkspaceProvider.js +++ b/src/services/providers/gitlabWorkspaceProvider.js @@ -270,6 +270,7 @@ export default new Provider({ return { id: entry.id, sub, + message: entry.commit && entry.commit.message, created: date ? new Date(date).getTime() : 1, }; }); diff --git a/src/services/timeSvc.js b/src/services/timeSvc.js index f8895639..65552fe1 100644 --- a/src/services/timeSvc.js +++ b/src/services/timeSvc.js @@ -65,62 +65,6 @@ function strftime(time, formatString) { }); } -let dayFirst = null; -let yearSeparator = null; - -// Private: Determine if the day should be formatted before the month name in -// the user's current locale. For example, `9 Jun` for en-GB and `Jun 9` -// for en-US. -// -// Returns true if the day appears before the month. -function isDayFirst() { - if (dayFirst !== null) { - return dayFirst; - } - - if (!('Intl' in window)) { - return false; - } - - const options = { day: 'numeric', month: 'short' }; - const formatter = new window.Intl.DateTimeFormat(undefined, options); - const output = formatter.format(new Date(0)); - - dayFirst = !!output.match(/^\d/); - return dayFirst; -} - -// Private: Determine if the year should be separated from the month and day -// with a comma. For example, `9 Jun 2014` in en-GB and `Jun 9, 2014` in en-US. -// -// Returns true if the date needs a separator. -function isYearSeparator() { - if (yearSeparator !== null) { - return yearSeparator; - } - - if (!('Intl' in window)) { - return true; - } - - const options = { day: 'numeric', month: 'short', year: 'numeric' }; - const formatter = new window.Intl.DateTimeFormat(undefined, options); - const output = formatter.format(new Date(0)); - - yearSeparator = !!output.match(/\d,/); - return yearSeparator; -} - -// Private: Determine if the date occurs in the same year as today's date. -// -// date - The Date to test. -// -// Returns true if it's this year. -function isThisYear(date) { - const now = new Date(); - return now.getUTCFullYear() === date.getUTCFullYear(); -} - class RelativeTime { constructor(date) { this.date = date; @@ -128,7 +72,7 @@ class RelativeTime { toString() { const ago = this.timeElapsed(); - return ago || `on ${this.formatDate()}`; + return ago || `${this.formatDate()}`; } timeElapsed() { @@ -158,11 +102,7 @@ class RelativeTime { } formatDate() { - let format = isDayFirst() ? '%e %b' : '%b %e'; - if (!isThisYear(this.date)) { - format += isYearSeparator() ? ', %Y' : ' %Y'; - } - return strftime(this.date, format); + return strftime(this.date, '%Y-%m-%d'); } }