feat(status): edit history
This commit is contained in:
parent
eb3f2ab771
commit
36fc189064
11 changed files with 152 additions and 59 deletions
|
@ -1,7 +1,9 @@
|
|||
import type { StatusEdit } from 'masto'
|
||||
import type { Draft } from './statusDrafts'
|
||||
import { STORAGE_KEY_FIRST_VISIT, STORAGE_KEY_ZEN_MODE } from '~/constants'
|
||||
|
||||
export const imagePreview = ref({ src: '', alt: '' })
|
||||
export const statusEdit = ref<StatusEdit>()
|
||||
export const isFirstVisit = useLocalStorage(STORAGE_KEY_FIRST_VISIT, true)
|
||||
export const isZenMode = useLocalStorage(STORAGE_KEY_ZEN_MODE, false)
|
||||
export const toggleZenMode = useToggle(isZenMode)
|
||||
|
@ -10,6 +12,7 @@ export const isUserSwitcherOpen = ref(false)
|
|||
export const isSigninDialogOpen = ref(false)
|
||||
export const isPublishDialogOpen = ref(false)
|
||||
export const isImagePreviewDialogOpen = ref(false)
|
||||
export const isEditHistoryDialogOpen = ref(false)
|
||||
export const isPreviewHelpOpen = ref(isFirstVisit.value)
|
||||
|
||||
export function openUserSwitcher() {
|
||||
|
@ -38,6 +41,11 @@ export function openImagePreviewDialog(image: { src: string; alt: string }) {
|
|||
isImagePreviewDialogOpen.value = true
|
||||
}
|
||||
|
||||
export function openEditHistoryDialog(edit: StatusEdit) {
|
||||
statusEdit.value = edit
|
||||
isEditHistoryDialogOpen.value = true
|
||||
}
|
||||
|
||||
export function openPreviewHelp() {
|
||||
isPreviewHelpOpen.value = true
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import type { MaybeRef } from '@vueuse/core'
|
||||
import type { MaybeRef, UseTimeAgoOptions } from '@vueuse/core'
|
||||
|
||||
export const useFormattedDateTime = (
|
||||
value: MaybeRef<string | Date | undefined>,
|
||||
|
@ -10,3 +10,35 @@ export const useFormattedDateTime = (
|
|||
return v ? formatter.format(new Date(v)) : ''
|
||||
})
|
||||
}
|
||||
|
||||
export const timeAgoOptions: UseTimeAgoOptions<false> = {
|
||||
showSecond: true,
|
||||
messages: {
|
||||
justNow: 'just now',
|
||||
past: n => n,
|
||||
future: n => n.match(/\d/) ? `in ${n}` : n,
|
||||
month: (n, past) => n === 1
|
||||
? past
|
||||
? 'last month'
|
||||
: 'next month'
|
||||
: `${n}m`,
|
||||
year: (n, past) => n === 1
|
||||
? past
|
||||
? 'last year'
|
||||
: 'next year'
|
||||
: `${n}y`,
|
||||
day: (n, past) => n === 1
|
||||
? past
|
||||
? 'yesterday'
|
||||
: 'tomorrow'
|
||||
: `${n}d`,
|
||||
week: (n, past) => n === 1
|
||||
? past
|
||||
? 'last week'
|
||||
: 'next week'
|
||||
: `${n} week${n > 1 ? 's' : ''}`,
|
||||
hour: n => `${n}h`,
|
||||
minute: n => `${n}min`,
|
||||
second: n => `${n}s`,
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue