diff options
| author | Danil S. <135337715+sh1shd@users.noreply.github.com> | 2025-12-04 01:37:27 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-12-04 01:37:27 +0300 |
| commit | 70f6d6b21a6761444c54898a6ed48793e72e7177 (patch) | |
| tree | 1e9cdf81fe84da349b525016f3c499f0992426aa /web/html | |
| parent | e8c509c720267f6da34b9a43104f83f3dd77ef88 (diff) | |
chore: use `Intl` for date formatting (#3588)
* chore: use `Intl` for date formatting
* fix: show last traffic reset
* chore: use raw timestamps
* fix: remove unnecessary import
Diffstat (limited to 'web/html')
| -rw-r--r-- | web/html/common/page.html | 1 | ||||
| -rw-r--r-- | web/html/component/aClientTable.html | 70 | ||||
| -rw-r--r-- | web/html/form/inbound.html | 4 | ||||
| -rw-r--r-- | web/html/inbounds.html | 28 | ||||
| -rw-r--r-- | web/html/index.html | 4 | ||||
| -rw-r--r-- | web/html/modals/inbound_info_modal.html | 21 | ||||
| -rw-r--r-- | web/html/settings/panel/subscription/subpage.html | 25 |
7 files changed, 26 insertions, 127 deletions
diff --git a/web/html/common/page.html b/web/html/common/page.html index f1c58fe1..c0a7ca63 100644 --- a/web/html/common/page.html +++ b/web/html/common/page.html @@ -44,7 +44,6 @@ <script src="{{ .base_path }}assets/axios/axios.min.js?{{ .cur_ver }}"></script> <script src="{{ .base_path }}assets/qs/qs.min.js"></script> <script src="{{ .base_path }}assets/js/axios-init.js?{{ .cur_ver }}"></script> -<script src="{{ .base_path }}assets/js/util/date-util.js?{{ .cur_ver }}"></script> <script src="{{ .base_path }}assets/js/util/index.js?{{ .cur_ver }}"></script> <script> const basePath = '{{ .base_path }}'; diff --git a/web/html/component/aClientTable.html b/web/html/component/aClientTable.html index f28b821b..d9a9b5f5 100644 --- a/web/html/component/aClientTable.html +++ b/web/html/component/aClientTable.html @@ -111,20 +111,12 @@ <template v-if="client.expiryTime !=0 && client.reset >0"> <a-popover :overlay-class-name="themeSwitcher.currentTheme"> <template slot="content"> - <span v-if="client.expiryTime < 0">{{ i18n "pages.client.delayedStart" }} - </span> - <span v-else> - <template v-if="app.datepicker === 'gregorian'"> - [[ DateUtil.formatMillis(client._expiryTime) ]] - </template> - <template v-else> - [[ DateUtil.convertToJalalian(moment(client._expiryTime)) ]] - </template> - </span> + <span v-if="client.expiryTime < 0">{{ i18n "pages.client.delayedStart" }}</span> + <span v-else>[[ IntlUtil.formatDate(client.expiryTime) ]]</span> </template> <table> <tr class="tr-table-box"> - <td class="tr-table-rt"> [[ remainedDays(client.expiryTime) ]] </td> + <td class="tr-table-rt"> [[ IntlUtil.formatRelativeTime(client.expiryTime) ]] </td> <td class="infinite-bar tr-table-bar"> <a-progress :show-info="false" :status="isClientDepleted(record, client.email)? 'exception' : ''" :percent="expireProgress(client.expiryTime, client.reset)" /> </td> @@ -136,18 +128,10 @@ <template v-else> <a-popover v-if="client.expiryTime != 0" :overlay-class-name="themeSwitcher.currentTheme"> <template slot="content"> - <span v-if="client.expiryTime < 0">{{ i18n "pages.client.delayedStart" }} - </span> - <span v-else> - <template v-if="app.datepicker === 'gregorian'"> - [[ DateUtil.formatMillis(client._expiryTime) ]] - </template> - <template v-else> - [[ DateUtil.convertToJalalian(moment(client._expiryTime)) ]] - </template> - </span> + <span v-if="client.expiryTime < 0">{{ i18n "pages.client.delayedStart" }}</span> + <span v-else>[[ IntlUtil.formatDate(client.expiryTime) ]]</span> </template> - <a-tag :style="{ minWidth: '50px', border: 'none' }" :color="ColorUtils.userExpiryColor(app.expireDiff, client, themeSwitcher.isDarkTheme)"> [[ remainedDays(client.expiryTime) ]] </a-tag> + <a-tag :style="{ minWidth: '50px', border: 'none' }" :color="ColorUtils.userExpiryColor(app.expireDiff, client, themeSwitcher.isDarkTheme)"> [[ IntlUtil.formatRelativeTime(client.expiryTime) ]] </a-tag> </a-popover> <a-tag v-else :color="ColorUtils.userExpiryColor(app.expireDiff, client, themeSwitcher.isDarkTheme)" :style="{ border: 'none' }" class="infinite-tag"> <svg height="10px" width="14px" viewBox="0 0 640 512" fill="currentColor"> @@ -232,20 +216,12 @@ </tr> <tr> <template v-if="client.expiryTime !=0 && client.reset >0"> - <td width="80px" :style="{ margin: '0', textAlign: 'right', fontSize: '1em' }"> [[ remainedDays(client.expiryTime) ]] </td> + <td width="80px" :style="{ margin: '0', textAlign: 'right', fontSize: '1em' }"> [[ IntlUtil.formatRelativeTime(client.expiryTime) ]] </td> <td width="120px" class="infinite-bar"> <a-popover :overlay-class-name="themeSwitcher.currentTheme"> <template slot="content"> - <span v-if="client.expiryTime < 0">{{ i18n "pages.client.delayedStart" }} - </span> - <span v-else> - <template v-if="app.datepicker === 'gregorian'"> - [[ DateUtil.formatMillis(client._expiryTime) ]] - </template> - <template v-else> - [[ DateUtil.convertToJalalian(moment(client._expiryTime)) ]] - </template> - </span> + <span v-if="client.expiryTime < 0">{{ i18n "pages.client.delayedStart" }}</span> + <span v-else>[[ IntlUtil.formatDate(client.expiryTime) ]]</span> </template> <a-progress :show-info="false" :status="isClientDepleted(record, client.email)? 'exception' : ''" :percent="expireProgress(client.expiryTime, client.reset)" /> </a-popover> @@ -256,18 +232,10 @@ <td colspan="3" :style="{ textAlign: 'center' }"> <a-popover v-if="client.expiryTime != 0" :overlay-class-name="themeSwitcher.currentTheme"> <template slot="content"> - <span v-if="client.expiryTime < 0">{{ i18n "pages.client.delayedStart" }} - </span> - <span v-else> - <template v-if="app.datepicker === 'gregorian'"> - [[ DateUtil.formatMillis(client._expiryTime) ]] - </template> - <template v-else> - [[ DateUtil.convertToJalalian(moment(client._expiryTime)) ]] - </template> - </span> + <span v-if="client.expiryTime < 0">{{ i18n "pages.client.delayedStart" }}</span> + <span v-else>[[ IntlUtil.formatDate(client.expiryTime) ]]</span> </template> - <a-tag :style="{ minWidth: '50px', border: 'none' }" :color="ColorUtils.userExpiryColor(app.expireDiff, client, themeSwitcher.isDarkTheme)"> [[ remainedDays(client.expiryTime) ]] </a-tag> + <a-tag :style="{ minWidth: '50px', border: 'none' }" :color="ColorUtils.userExpiryColor(app.expireDiff, client, themeSwitcher.isDarkTheme)"> [[ IntlUtil.formatRelativeTime(client.expiryTime) ]] </a-tag> </a-popover> <a-tag v-else :color="client.enable ? 'purple' : themeSwitcher.isDarkTheme ? '#2c3950' : '#bcbcbc'" class="infinite-tag"> <svg height="10px" width="14px" viewBox="0 0 640 512" fill="currentColor"> @@ -289,12 +257,7 @@ </template> <template slot="createdAt" slot-scope="text, client, index"> <template v-if="client.created_at"> - <template v-if="app.datepicker === 'gregorian'"> - [[ DateUtil.formatMillis(client.created_at) ]] - </template> - <template v-else> - [[ DateUtil.convertToJalalian(moment(client.created_at)) ]] - </template> + [[ IntlUtil.formatDate(client.created_at) ]] </template> <template v-else> - @@ -302,12 +265,7 @@ </template> <template slot="updatedAt" slot-scope="text, client, index"> <template v-if="client.updated_at"> - <template v-if="app.datepicker === 'gregorian'"> - [[ DateUtil.formatMillis(client.updated_at) ]] - </template> - <template v-else> - [[ DateUtil.convertToJalalian(moment(client.updated_at)) ]] - </template> + [[ IntlUtil.formatDate(client.updated_at) ]] </template> <template v-else> - diff --git a/web/html/form/inbound.html b/web/html/form/inbound.html index 00f97f6e..fdd381b0 100644 --- a/web/html/form/inbound.html +++ b/web/html/form/inbound.html @@ -52,9 +52,7 @@ <br v-if="dbInbound.lastTrafficResetTime && dbInbound.lastTrafficResetTime > 0"> <span v-if="dbInbound.lastTrafficResetTime && dbInbound.lastTrafficResetTime > 0"> <strong>{{ i18n "pages.inbounds.lastReset" }}:</strong> - <span v-if="datepicker == 'gregorian'">[[ - moment(dbInbound.lastTrafficResetTime).format('YYYY-MM-DD HH:mm:ss') ]]</span> - <span v-else>[[ DateUtil.convertToJalalian(moment(dbInbound.lastTrafficResetTime)) ]]</span> + <span>[[ IntlUtil.formatDate(dbInbound.lastTrafficResetTime) ]]</span> </span> </template> {{ i18n "pages.inbounds.periodicTrafficResetTitle" }} diff --git a/web/html/inbounds.html b/web/html/inbounds.html index 8616dce5..86bde2c8 100644 --- a/web/html/inbounds.html +++ b/web/html/inbounds.html @@ -384,15 +384,12 @@ </template> <template slot="expiryTime" slot-scope="text, dbInbound"> <a-popover v-if="dbInbound.expiryTime > 0" :overlay-class-name="themeSwitcher.currentTheme"> - <template slot="content" v-if="app.datepicker === 'gregorian'"> - [[ DateUtil.formatMillis(dbInbound.expiryTime) ]] - </template> - <template v-else slot="content"> - [[ DateUtil.convertToJalalian(moment(dbInbound.expiryTime)) ]] + <template slot="content"> + [[ IntlUtil.formatDate(dbInbound.expiryTime) ]] </template> <a-tag :style="{ minWidth: '50px' }" :color="ColorUtils.usageColor(new Date().getTime(), app.expireDiff, dbInbound._expiryTime)"> - [[ remainedDays(dbInbound._expiryTime) ]] + [[ IntlUtil.formatRelativeTime(dbInbound.expiryTime) ]] </a-tag> </a-popover> <a-tag v-else color="purple" class="infinite-tag"> @@ -549,12 +546,7 @@ <td> <a-tag :style="{ minWidth: '50px', textAlign: 'center' }" v-if="dbInbound.expiryTime > 0" :color="dbInbound.isExpiry? 'red': 'blue'"> - <template v-if="app.datepicker === 'gregorian'"> - [[ DateUtil.formatMillis(dbInbound.expiryTime) ]] - </template> - <template v-else> - [[ DateUtil.convertToJalalian(moment(dbInbound.expiryTime)) ]] - </template> + [[ IntlUtil.formatDate(dbInbound.expiryTime) ]] </a-tag> <a-tag v-else :style="{ textAlign: 'center' }" color="purple" class="infinite-tag"> <svg height="10px" width="14px" viewBox="0 0 640 512" fill="currentColor"> @@ -1407,13 +1399,6 @@ if (remainedSeconds >= resetSeconds) return 0; return 100 * (1 - (remainedSeconds / resetSeconds)); }, - remainedDays(expTime) { - if (expTime == 0) return null; - if (expTime < 0) return TimeFormatter.formatSecond(expTime / -1000); - now = new Date().getTime(); - if (expTime < now) return '{{ i18n "depleted" }}'; - return TimeFormatter.formatSecond((expTime - now) / 1000); - }, statsExpColor(dbInbound, email) { if (email.length == 0) return '#7a316f'; clientStats = dbInbound.clientStats.find(stats => stats.email === email); @@ -1458,10 +1443,7 @@ formatLastOnline(email) { const ts = this.getLastOnline(email) if (!ts) return '-' - if (this.datepicker === 'gregorian') { - return DateUtil.formatMillis(ts) - } - return DateUtil.convertToJalalian(moment(ts)) + return IntlUtil.formatDate(ts) }, isRemovable(dbInboundId) { return this.getInboundClients(this.dbInbounds.find(row => row.id === dbInboundId)).length > 1; diff --git a/web/html/index.html b/web/html/index.html index 1c6bb0be..9cbb019d 100644 --- a/web/html/index.html +++ b/web/html/index.html @@ -844,11 +844,9 @@ text = `<td>${log.Email}</td>`; } - const { locale, timeZone } = Intl.DateTimeFormat().resolvedOptions(); - formattedLogs += ` <tr ${outboundColor}> - <td><b>${new Date(log.DateTime).toLocaleString(locale, { timeZone })}</b></td> + <td><b>${IntlUtil.formatDate(log.DateTime)}</b></td> <td>${log.FromAddress}</td> <td>${log.ToAddress}</td> <td>${log.Inbound}</td> diff --git a/web/html/modals/inbound_info_modal.html b/web/html/modals/inbound_info_modal.html index 8e4bfc2e..72023e75 100644 --- a/web/html/modals/inbound_info_modal.html +++ b/web/html/modals/inbound_info_modal.html @@ -199,12 +199,7 @@ <td>{{ i18n "pages.inbounds.createdAt" }}</td> <td> <template v-if="infoModal.clientSettings && infoModal.clientSettings.created_at"> - <template v-if="app.datepicker === 'gregorian'"> - <a-tag>[[ DateUtil.formatMillis(infoModal.clientSettings.created_at) ]]</a-tag> - </template> - <template v-else> - <a-tag>[[ DateUtil.convertToJalalian(moment(infoModal.clientSettings.created_at)) ]]</a-tag> - </template> + <a-tag>[[ IntlUtil.formatDate(infoModal.clientSettings.created_at) ]]</a-tag> </template> <template v-else> <a-tag>-</a-tag> @@ -215,12 +210,7 @@ <td>{{ i18n "pages.inbounds.updatedAt" }}</td> <td> <template v-if="infoModal.clientSettings && infoModal.clientSettings.updated_at"> - <template v-if="app.datepicker === 'gregorian'"> - <a-tag>[[ DateUtil.formatMillis(infoModal.clientSettings.updated_at) ]]</a-tag> - </template> - <template v-else> - <a-tag>[[ DateUtil.convertToJalalian(moment(infoModal.clientSettings.updated_at)) ]]</a-tag> - </template> + <a-tag>[[ IntlUtil.formatDate(infoModal.clientSettings.updated_at) ]]</a-tag> </template> <template v-else> <a-tag>-</a-tag> @@ -282,12 +272,7 @@ <td> <template v-if="infoModal.clientSettings.expiryTime > 0"> <a-tag :color="ColorUtils.usageColor(new Date().getTime(), app.expireDiff, infoModal.clientSettings.expiryTime)"> - <template v-if="app.datepicker === 'gregorian'"> - [[ DateUtil.formatMillis(infoModal.clientSettings.expiryTime) ]] - </template> - <template v-else> - [[ DateUtil.convertToJalalian(moment(infoModal.clientSettings.expiryTime)) ]] - </template> + [[ IntlUtil.formatDate(infoModal.clientSettings.expiryTime) ]] </a-tag> </template> <a-tag v-else-if="infoModal.clientSettings.expiryTime < 0" color="green">[[ infoModal.clientSettings.expiryTime / -86400000 ]] {{ i18n "pages.client.days" }} diff --git a/web/html/settings/panel/subscription/subpage.html b/web/html/settings/panel/subscription/subpage.html index 670cc37b..0043d0d2 100644 --- a/web/html/settings/panel/subscription/subpage.html +++ b/web/html/settings/panel/subscription/subpage.html @@ -4,7 +4,6 @@ <script src="{{ .base_path }}assets/vue/vue.min.js?{{ .cur_ver }}"></script> <script src="{{ .base_path }}assets/ant-design-vue/antd.min.js"></script> <script src="{{ .base_path }}assets/js/util/index.js?{{ .cur_ver }}"></script> -<script src="{{ .base_path }}assets/js/util/date-util.js?{{ .cur_ver }}"></script> <script src="{{ .base_path }}assets/qrcode/qrious2.min.js?{{ .cur_ver }}"></script> {{ template "page/head_end" .}} @@ -141,17 +140,7 @@ <a-descriptions-item label='{{ i18n "lastOnline" }}'> <template v-if="app.lastOnlineMs > 0"> - <template - v-if="app.datepicker === 'gregorian'"> - [[ - DateUtil.formatMillis(app.lastOnlineMs) - ]] - </template> - <template v-else> - [[ - DateUtil.convertToJalalian(moment(app.lastOnlineMs)) - ]] - </template> + [[ IntlUtil.formatDate(app.lastOnlineMs) ]] </template> <template v-else> <span>-</span> @@ -163,17 +152,7 @@ {{ i18n "subscription.noExpiry" }} </template> <template v-else> - <template - v-if="app.datepicker === 'gregorian'"> - [[ - DateUtil.formatMillis(app.expireMs) - ]] - </template> - <template v-else> - [[ - DateUtil.convertToJalalian(moment(app.expireMs)) - ]] - </template> + [[ IntlUtil.formatDate(app.expireMs) ]] </template> </a-descriptions-item> </a-descriptions> |
