client: make time components computed
Some checks failed
ci/woodpecker/push/lint-client Pipeline failed
ci/woodpecker/push/lint-backend Pipeline failed
ci/woodpecker/push/lint-foundkey-js Pipeline was successful
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/lint-sw Pipeline failed
ci/woodpecker/push/test Pipeline failed
Some checks failed
ci/woodpecker/push/lint-client Pipeline failed
ci/woodpecker/push/lint-backend Pipeline failed
ci/woodpecker/push/lint-foundkey-js Pipeline was successful
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/lint-sw Pipeline failed
ci/woodpecker/push/test Pipeline failed
Previously, if a property of the `MkTime` component was changed the displayed value would not update because the necessary values were computed once on setup and not made `$computed` so they would be re-computed when necessary.
This commit is contained in:
parent
dbe2b7611d
commit
b39716a199
1 changed files with 3 additions and 3 deletions
|
@ -23,15 +23,15 @@ const props = withDefaults(defineProps<{
|
|||
utc: false,
|
||||
});
|
||||
|
||||
const _time = typeof props.time === 'string' ? new Date(props.time) : props.time;
|
||||
const absolute = ((): string => {
|
||||
const _time = $computed((): Date => typeof props.time === 'string' ? new Date(props.time) : props.time);
|
||||
const absolute = $computed((): string => {
|
||||
const options = props.utc ? { timeZone: 'UTC' } : {};
|
||||
switch (props.format) {
|
||||
case 'date': return _time.toLocaleDateString(lang ?? 'en-US', options);
|
||||
case 'time': return _time.toLocaleTimeString(lang ?? 'en-US', options);
|
||||
default: return _time.toLocaleString(lang ?? 'en-US', options);
|
||||
}
|
||||
})();
|
||||
});
|
||||
|
||||
let now = $ref(new Date());
|
||||
const relative = $computed(() => {
|
||||
|
|
Loading…
Reference in a new issue