Skip to content

Commit

Permalink
feat(editor): date formats in entity
Browse files Browse the repository at this point in the history
  • Loading branch information
Novout committed Sep 21, 2021
1 parent 2c7d3be commit b8948e2
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/components/editor/aside/AsideBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
<HeroIcon>
<svg
xmlns="http://www.w3.org/2000/svg"
class="h-6 w-6"
class="h-5 w-5"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
Expand Down
5 changes: 5 additions & 0 deletions src/components/editor/text/TextInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

<script setup lang="ts">
import { ContextStatePageContent } from '@/types/context'
import { useFormat } from '@/use/format'
import { ref, computed, watch } from 'vue'
import { useI18n } from 'vue-i18n'
import { useStore } from 'vuex'
Expand Down Expand Up @@ -88,8 +89,12 @@
id: store.state.context.totalEntityCreated,
type: type.value,
raw: props.modelValue,
createdAt: useFormat().actually(),
updatedAt: useFormat().actually(),
} as ContextStatePageContent
console.log(content)
type.value = 'paragraph'
input.value.placeholder = t('editor.text.placeholder.paragraph')
Expand Down
1 change: 0 additions & 1 deletion src/store/module/context.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ContextState, ContextStatePageContent } from '@/types/context'
import { objectToString } from '@vue/shared'

export default {
namespaced: true,
Expand Down
2 changes: 2 additions & 0 deletions src/types/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ export interface ContextStatePageContent {
id: number
type: string
raw: string
createdAt: string
updatedAt: string
}
13 changes: 13 additions & 0 deletions src/use/format.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { format } from 'date-fns'

export const useFormat = () => {
const simple = (date: Date): string => {
return format(date, 'yyyy-MM-dd:HH:mm:ss.OOOO')
}

const actually = (): string => {
return simple(new Date())
}

return { simple, actually }
}

0 comments on commit b8948e2

Please sign in to comment.