File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1414 "@mdi/js" : " ~7.2.96" ,
1515 "axios" : " ^1.4.0" ,
1616 "core-js" : " ^3.27.1" ,
17+ "date-fns" : " ^2.30.0" ,
1718 "pinia" : " ^2.0.30" ,
1819 "vue" : " ~2.7.14" ,
1920 "vue-clipboard2" : " ^0.3.3" ,
2021 "vue-router" : " ~3.6.5" ,
21- "vue-timeago" : " ^5.1.3" ,
2222 "vuelidate" : " ^0.7.7" ,
2323 "vuetify" : " ^2.6.13"
2424 },
Original file line number Diff line number Diff line change 11<template >
22 <div
3- class =" my-1 py-5"
4- :title =" value"
5- ><timeago v-if =" value" :datetime =" value" ></timeago ><span v-else >never</span ></div >
3+ class =" my-1 py-5"
4+ :title =" value"
5+ >
6+ <span v-text =" formattedValue" ></span >
7+ </div >
68</template >
79
810<script >
11+ import formatDistanceToNow from ' date-fns/formatDistanceToNow' ;
12+
913export default {
1014 name: ' TimeAgo' ,
1115 props: {
1216 value: {
1317 default: ' ' ,
1418 type: String ,
1519 },
20+ defaultText: {
21+ default: ' never' ,
22+ type: String ,
23+ },
1624 },
25+ computed: {
26+ formattedValue () {
27+ const inputTime = this .value ;
28+ if (! inputTime)
29+ return this .defaultText
30+
31+ const parsedTime = new Date (inputTime);
32+ return formatDistanceToNow (parsedTime, {addSuffix: true });
33+ }
34+ }
1735};
1836 </script >
1937
Original file line number Diff line number Diff line change @@ -11,15 +11,13 @@ import "@fontsource/roboto/400-italic.css" /* regular-italic */
1111import "@fontsource/roboto/500.css" /* medium */
1212import "@fontsource/roboto/700.css" /* bold */
1313import '@mdi/font/css/materialdesignicons.css'
14- import VueTimeago from 'vue-timeago'
1514import { createPinia , PiniaVuePlugin } from "pinia" ;
1615
1716
1817Vue . config . productionTip = false
1918VueClipboard . config . autoSetContainer = true
2019Vue . use ( VueClipboard )
2120Vue . use ( Vuelidate )
22- Vue . use ( VueTimeago , { } )
2321// `Pinia` replaces `vuex` as store.
2422Vue . use ( PiniaVuePlugin )
2523const pinia = createPinia ( )
You can’t perform that action at this time.
0 commit comments