Merge branch 'fork/ming4762/timezone-20251020'
This commit is contained in:
@@ -13,6 +13,7 @@ import {
|
||||
LanguageToggle,
|
||||
PreferencesButton,
|
||||
ThemeToggle,
|
||||
TimezoneButton,
|
||||
} from '../../widgets';
|
||||
|
||||
interface Props {
|
||||
@@ -66,15 +67,21 @@ const rightSlots = computed(() => {
|
||||
name: 'language-toggle',
|
||||
});
|
||||
}
|
||||
if (preferences.widget.fullscreen) {
|
||||
if (preferences.widget.timezone) {
|
||||
list.push({
|
||||
index: REFERENCE_VALUE + 40,
|
||||
name: 'timezone',
|
||||
});
|
||||
}
|
||||
if (preferences.widget.fullscreen) {
|
||||
list.push({
|
||||
index: REFERENCE_VALUE + 50,
|
||||
name: 'fullscreen',
|
||||
});
|
||||
}
|
||||
if (preferences.widget.notification) {
|
||||
list.push({
|
||||
index: REFERENCE_VALUE + 50,
|
||||
index: REFERENCE_VALUE + 60,
|
||||
name: 'notification',
|
||||
});
|
||||
}
|
||||
@@ -166,6 +173,9 @@ function clearPreferencesAndLogout() {
|
||||
<template v-else-if="slot.name === 'fullscreen'">
|
||||
<VbenFullScreen class="mr-1" />
|
||||
</template>
|
||||
<template v-else-if="slot.name === 'timezone'">
|
||||
<TimezoneButton class="mr-1 mt-[2px]" />
|
||||
</template>
|
||||
</slot>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
@@ -302,6 +302,9 @@ const headerSlots = computed(() => {
|
||||
<template #notification>
|
||||
<slot name="notification"></slot>
|
||||
</template>
|
||||
<template #timezone>
|
||||
<slot name="timezone"></slot>
|
||||
</template>
|
||||
<template v-for="item in headerSlots" #[item]>
|
||||
<slot :name="item"></slot>
|
||||
</template>
|
||||
|
||||
@@ -8,4 +8,5 @@ export * from './lock-screen';
|
||||
export * from './notification';
|
||||
export * from './preferences';
|
||||
export * from './theme-toggle';
|
||||
export * from './timezone';
|
||||
export * from './user-dropdown';
|
||||
|
||||
1
packages/effects/layouts/src/widgets/timezone/index.ts
Normal file
1
packages/effects/layouts/src/widgets/timezone/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { default as TimezoneButton } from './timezone-button.vue';
|
||||
@@ -0,0 +1,87 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, unref } from 'vue';
|
||||
|
||||
import { createIconifyIcon } from '@vben/icons';
|
||||
import { $t } from '@vben/locales';
|
||||
import { useTimezoneStore } from '@vben/stores';
|
||||
|
||||
import { useVbenModal } from '@vben-core/popup-ui';
|
||||
import {
|
||||
RadioGroup,
|
||||
RadioGroupItem,
|
||||
VbenIconButton,
|
||||
} from '@vben-core/shadcn-ui';
|
||||
|
||||
const TimezoneIcon = createIconifyIcon('fluent-mdl2:world-clock');
|
||||
|
||||
const timezoneStore = useTimezoneStore();
|
||||
|
||||
const timezoneRef = ref<string | undefined>();
|
||||
|
||||
const timezoneOptionsRef = ref<
|
||||
{
|
||||
label: string;
|
||||
value: string;
|
||||
}[]
|
||||
>([]);
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
fullscreenButton: false,
|
||||
onConfirm: async () => {
|
||||
try {
|
||||
modalApi.setState({ confirmLoading: true });
|
||||
const timezone = unref(timezoneRef);
|
||||
if (timezone) {
|
||||
await timezoneStore.setTimezone(timezone);
|
||||
}
|
||||
modalApi.close();
|
||||
} finally {
|
||||
modalApi.setState({ confirmLoading: false });
|
||||
}
|
||||
},
|
||||
async onOpenChange(isOpen) {
|
||||
if (isOpen) {
|
||||
timezoneRef.value = unref(timezoneStore.timezone);
|
||||
timezoneOptionsRef.value = await timezoneStore.getTimezoneOptions();
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
const handleClick = () => {
|
||||
modalApi.open();
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<VbenIconButton
|
||||
:tooltip="$t('ui.widgets.timezone.setTimezone')"
|
||||
class="hover:animate-[shrink_0.3s_ease-in-out]"
|
||||
@click="handleClick"
|
||||
>
|
||||
<TimezoneIcon class="text-foreground size-4" />
|
||||
</VbenIconButton>
|
||||
<Modal :title="$t('ui.widgets.timezone.setTimezone')">
|
||||
<div class="timezone-container">
|
||||
<RadioGroup v-model="timezoneRef" class="flex flex-col gap-2">
|
||||
<div
|
||||
class="flex cursor-pointer items-center gap-2"
|
||||
v-for="item in timezoneOptionsRef"
|
||||
:key="`container${item.value}`"
|
||||
>
|
||||
<RadioGroupItem :id="item.value" :value="item.value" />
|
||||
<label :for="item.value" class="cursor-pointer">{{
|
||||
item.label
|
||||
}}</label>
|
||||
</div>
|
||||
</RadioGroup>
|
||||
</div>
|
||||
</Modal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.timezone-container {
|
||||
padding-left: 20px;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user