refactor: remove moment.js

closes #452
This commit is contained in:
Gauthier Roebroeck 2021-03-12 14:42:41 +08:00
parent 83ff4d23a8
commit 261a2177d3
10 changed files with 23 additions and 74 deletions

View file

@ -10,16 +10,15 @@
"@saekitominaga/isbn-verify": "^1.3.0",
"axios": "^0.21.1",
"core-js": "^3.6.5",
"date-fns": "^2.19.0",
"jquery": "^3.5.1",
"language-tags": "^1.0.5",
"lodash": "^4.17.19",
"moment": "^2.27.0",
"qs": "^6.9.4",
"vue": "^2.6.11",
"vue-cookies": "^1.7.3",
"vue-i18n": "^8.22.4",
"vue-line-clamp": "^1.3.2",
"vue-moment": "^4.1.0",
"vue-read-more-smooth": "^0.1.8",
"vue-router": "^3.3.4",
"vue-typed-mixins": "^0.2.0",
@ -56,7 +55,6 @@
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-vue": "^6.2.2",
"html-webpack-inject-attributes-plugin": "^1.0.3",
"moment-locales-webpack-plugin": "^1.2.0",
"sass": "^1.26.10",
"sass-loader": "^9.0.2",
"ts-jest": "^26.1.4",
@ -6537,6 +6535,18 @@
"webidl-conversions": "^4.0.2"
}
},
"node_modules/date-fns": {
"version": "2.19.0",
"resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.19.0.tgz",
"integrity": "sha512-X3bf2iTPgCAQp9wvjOQytnf5vO5rESYRXlPIVcgSbtT5OTScPcsf9eZU+B/YIkKAtYr5WeCii58BgATrNitlWg==",
"engines": {
"node": ">=0.11"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/date-fns"
}
},
"node_modules/de-indent": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/de-indent/-/de-indent-1.0.2.tgz",
@ -13929,12 +13939,6 @@
"integrity": "sha512-3j8wdDzYuWO3lM3Reg03MuQR957t287Rpcxp1njpEa8oDrikb+FwGdW3n+FELh/A6qib6yPit0j/pv9G/yeAqA==",
"dev": true
},
"node_modules/lodash.difference": {
"version": "4.5.0",
"resolved": "https://registry.npmjs.org/lodash.difference/-/lodash.difference-4.5.0.tgz",
"integrity": "sha1-nMtOUF1Ia5FlE0V3KIWi3yf9AXw=",
"dev": true
},
"node_modules/lodash.foreach": {
"version": "4.5.0",
"resolved": "https://registry.npmjs.org/lodash.foreach/-/lodash.foreach-4.5.0.tgz",
@ -14441,23 +14445,6 @@
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=",
"dev": true
},
"node_modules/moment": {
"version": "2.27.0",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.27.0.tgz",
"integrity": "sha512-al0MUK7cpIcglMv3YF13qSgdAIqxHTO7brRtaz3DlSULbqfazqkc5kEjNrLDOM7fsjshoFIihnU8snrP7zUvhQ==",
"engines": {
"node": "*"
}
},
"node_modules/moment-locales-webpack-plugin": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/moment-locales-webpack-plugin/-/moment-locales-webpack-plugin-1.2.0.tgz",
"integrity": "sha512-QAi5v0OlPUP7GXviKMtxnpBAo8WmTHrUNN7iciAhNOEAd9evCOvuN0g1N7ThIg3q11GLCkjY1zQ2saRcf/43nQ==",
"dev": true,
"dependencies": {
"lodash.difference": "^4.5.0"
}
},
"node_modules/move-concurrently": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/move-concurrently/-/move-concurrently-1.0.1.tgz",
@ -19804,14 +19791,6 @@
"integrity": "sha1-M7QHd3VMZDJXPBIMw4CLvRDUfwQ=",
"dev": true
},
"node_modules/vue-moment": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/vue-moment/-/vue-moment-4.1.0.tgz",
"integrity": "sha512-Gzisqpg82ItlrUyiD9d0Kfru+JorW2o4mQOH06lEDZNgxci0tv/fua1Hl0bo4DozDV2JK1r52Atn/8QVCu8qQw==",
"dependencies": {
"moment": "^2.19.2"
}
},
"node_modules/vue-read-more-smooth": {
"version": "0.1.8",
"resolved": "https://registry.npmjs.org/vue-read-more-smooth/-/vue-read-more-smooth-0.1.8.tgz",
@ -26603,6 +26582,11 @@
}
}
},
"date-fns": {
"version": "2.19.0",
"resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.19.0.tgz",
"integrity": "sha512-X3bf2iTPgCAQp9wvjOQytnf5vO5rESYRXlPIVcgSbtT5OTScPcsf9eZU+B/YIkKAtYr5WeCii58BgATrNitlWg=="
},
"de-indent": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/de-indent/-/de-indent-1.0.2.tgz",
@ -32646,12 +32630,6 @@
"integrity": "sha512-3j8wdDzYuWO3lM3Reg03MuQR957t287Rpcxp1njpEa8oDrikb+FwGdW3n+FELh/A6qib6yPit0j/pv9G/yeAqA==",
"dev": true
},
"lodash.difference": {
"version": "4.5.0",
"resolved": "https://registry.npmjs.org/lodash.difference/-/lodash.difference-4.5.0.tgz",
"integrity": "sha1-nMtOUF1Ia5FlE0V3KIWi3yf9AXw=",
"dev": true
},
"lodash.foreach": {
"version": "4.5.0",
"resolved": "https://registry.npmjs.org/lodash.foreach/-/lodash.foreach-4.5.0.tgz",
@ -33083,20 +33061,6 @@
}
}
},
"moment": {
"version": "2.27.0",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.27.0.tgz",
"integrity": "sha512-al0MUK7cpIcglMv3YF13qSgdAIqxHTO7brRtaz3DlSULbqfazqkc5kEjNrLDOM7fsjshoFIihnU8snrP7zUvhQ=="
},
"moment-locales-webpack-plugin": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/moment-locales-webpack-plugin/-/moment-locales-webpack-plugin-1.2.0.tgz",
"integrity": "sha512-QAi5v0OlPUP7GXviKMtxnpBAo8WmTHrUNN7iciAhNOEAd9evCOvuN0g1N7ThIg3q11GLCkjY1zQ2saRcf/43nQ==",
"dev": true,
"requires": {
"lodash.difference": "^4.5.0"
}
},
"move-concurrently": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/move-concurrently/-/move-concurrently-1.0.1.tgz",
@ -37617,14 +37581,6 @@
}
}
},
"vue-moment": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/vue-moment/-/vue-moment-4.1.0.tgz",
"integrity": "sha512-Gzisqpg82ItlrUyiD9d0Kfru+JorW2o4mQOH06lEDZNgxci0tv/fua1Hl0bo4DozDV2JK1r52Atn/8QVCu8qQw==",
"requires": {
"moment": "^2.19.2"
}
},
"vue-read-more-smooth": {
"version": "0.1.8",
"resolved": "https://registry.npmjs.org/vue-read-more-smooth/-/vue-read-more-smooth-0.1.8.tgz",

View file

@ -13,16 +13,15 @@
"@saekitominaga/isbn-verify": "^1.3.0",
"axios": "^0.21.1",
"core-js": "^3.6.5",
"date-fns": "^2.19.0",
"jquery": "^3.5.1",
"language-tags": "^1.0.5",
"lodash": "^4.17.19",
"moment": "^2.27.0",
"qs": "^6.9.4",
"vue": "^2.6.11",
"vue-cookies": "^1.7.3",
"vue-i18n": "^8.22.4",
"vue-line-clamp": "^1.3.2",
"vue-moment": "^4.1.0",
"vue-read-more-smooth": "^0.1.8",
"vue-router": "^3.3.4",
"vue-typed-mixins": "^0.2.0",
@ -59,7 +58,6 @@
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-vue": "^6.2.2",
"html-webpack-inject-attributes-plugin": "^1.0.3",
"moment-locales-webpack-plugin": "^1.2.0",
"sass": "^1.26.10",
"sass-loader": "^9.0.2",
"ts-jest": "^26.1.4",

View file

@ -295,13 +295,13 @@
<script lang="ts">
import {groupAuthorsByRole} from '@/functions/authors'
import {authorRoles} from '@/types/author-roles'
import moment from 'moment'
import Vue from 'vue'
import {helpers, requiredIf} from 'vuelidate/lib/validators'
import {BookDto} from '@/types/komga-books'
import ISBN from '@saekitominaga/isbn-verify'
import {isMatch} from 'date-fns'
const validDate = (value: string) => !helpers.req(value) || moment(value, 'YYYY-MM-DD', true).isValid()
const validDate = (value: string) => !helpers.req(value) || isMatch(value, 'yyyy-MM-dd')
const validIsbn = (value: string) => {
const isbn = new ISBN(value)
return (!helpers.req(value) || (isbn.isIsbn13() && isbn.isValid()))

View file

@ -26,7 +26,6 @@ import i18n from './i18n'
Vue.use(Vuelidate)
Vue.use(lineClamp)
Vue.use(VueCookies)
Vue.use(require('vue-moment'))
Vue.use(httpPlugin)
Vue.use(komgaFileSystem, { http: Vue.prototype.$http })

View file

@ -104,7 +104,7 @@
{{ book.metadata.number }} · {{ book.media.pagesCount }} {{ $t('common.pages') }}
</v-col>
<v-col cols="auto" v-if="book.metadata.releaseDate">
{{ book.metadata.releaseDate | moment('MMMM DD, YYYY') }}
{{ new Intl.DateTimeFormat($i18n.locale, { dateStyle: 'long' }).format(new Date(book.metadata.releaseDate)) }}
</v-col>
</v-row>

View file

@ -91,7 +91,7 @@
<v-col class="py-1">
<v-tooltip right>
<template v-slot:activator="{ on }">
<span v-on="on">{{ series.booksMetadata.releaseDate | moment('YYYY') }}</span>
<span v-on="on">{{ new Intl.DateTimeFormat($i18n.locale, { dateStyle: 'long' }).format(new Date(series.booksMetadata.releaseDate)) }}</span>
</template>
{{ $t('browse_series.earliest_year_from_release_dates') }}
</v-tooltip>

View file

@ -1,5 +1,4 @@
const htmlInject = require('html-webpack-inject-attributes-plugin')
const momentLocalesPlugin = require('moment-locales-webpack-plugin')
const _ = require('lodash')
// vue.config.js
@ -31,9 +30,6 @@ module.exports = {
config.plugin('html-inject')
.after('html')
.use(htmlInject)
config.plugin('momentLocalesPlugin')
.use(momentLocalesPlugin)
},
pluginOptions: {