feat: change theme
This commit is contained in:
parent
88909e4b1e
commit
9d16afa474
4 changed files with 134 additions and 27 deletions
|
|
@ -1,10 +1,14 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { onMounted, ref } from 'vue';
|
import { computed, onMounted, ref, watch } from 'vue';
|
||||||
|
import { useQuasar } from 'quasar';
|
||||||
// import useOption from 'src/stores/option';
|
// import useOption from 'src/stores/option';
|
||||||
|
|
||||||
// const optionStore = useOption();
|
// const optionStore = useOption();
|
||||||
import { getName, getRealm, getRole, isLoggedIn } from 'src/services/keycloak';
|
import { getName, getRealm, getRole, isLoggedIn } from 'src/services/keycloak';
|
||||||
|
|
||||||
|
const $q = useQuasar();
|
||||||
|
|
||||||
|
const themeRef = ref();
|
||||||
const userImage = ref<string>('');
|
const userImage = ref<string>('');
|
||||||
const filterRole = ref<string[]>();
|
const filterRole = ref<string[]>();
|
||||||
const inputFile = document.createElement('input');
|
const inputFile = document.createElement('input');
|
||||||
|
|
@ -24,8 +28,33 @@ const options = ref([
|
||||||
value: 'op2',
|
value: 'op2',
|
||||||
color: 'grey',
|
color: 'grey',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
icon: 'mdi-brightness-6',
|
||||||
|
label: 'mode',
|
||||||
|
value: 'op3',
|
||||||
|
color: 'grey',
|
||||||
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
const themeMode = ref([
|
||||||
|
{
|
||||||
|
label: 'light',
|
||||||
|
value: 'light',
|
||||||
|
isActive: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'dark',
|
||||||
|
value: 'dark',
|
||||||
|
isActive: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'baseOnDevice',
|
||||||
|
value: 'baseOnDevice',
|
||||||
|
isActive: false,
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
const isDarkActive = computed(() => $q.dark.isActive);
|
||||||
// inputFile.addEventListener('change', async (e) => {
|
// inputFile.addEventListener('change', async (e) => {
|
||||||
// profileFile.value = await (e.currentTarget as HTMLInputElement).files?.[0];
|
// profileFile.value = await (e.currentTarget as HTMLInputElement).files?.[0];
|
||||||
// if (profileFile.value) {
|
// if (profileFile.value) {
|
||||||
|
|
@ -33,11 +62,26 @@ const options = ref([
|
||||||
// }
|
// }
|
||||||
// userImage.value = (await storageStore.getProfile()) ?? '';
|
// userImage.value = (await storageStore.getProfile()) ?? '';
|
||||||
// });
|
// });
|
||||||
|
watch(
|
||||||
|
() => isDarkActive.value,
|
||||||
|
() => {
|
||||||
|
if ($q.dark.isActive) {
|
||||||
|
themeMode.value[1].isActive = true;
|
||||||
|
themeMode.value[0].isActive = false;
|
||||||
|
} else {
|
||||||
|
themeMode.value[0].isActive = true;
|
||||||
|
themeMode.value[1].isActive = false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
// if (isLoggedIn()) {
|
// if (isLoggedIn()) {
|
||||||
// userImage.value = (await storageStore.getProfile()) ?? '';
|
// userImage.value = (await storageStore.getProfile()) ?? '';
|
||||||
// }
|
// }
|
||||||
|
isDarkActive.value
|
||||||
|
? (themeMode.value[1].isActive = true)
|
||||||
|
: (themeMode.value[0].isActive = true);
|
||||||
|
|
||||||
const userRoles = getRole();
|
const userRoles = getRole();
|
||||||
if (userRoles) {
|
if (userRoles) {
|
||||||
|
|
@ -152,33 +196,84 @@ onMounted(async () => {
|
||||||
|
|
||||||
<div class="column col-12">
|
<div class="column col-12">
|
||||||
<q-separator />
|
<q-separator />
|
||||||
<div class="column justify-center q-mb-md">
|
<div class="column justify-center">
|
||||||
<div v-for="op in options" :key="op.label">
|
<q-list :dense="true" v-for="op in options" :key="op.label">
|
||||||
<q-list :dense="true">
|
<q-item
|
||||||
<q-separator v-if="op.label === 'option'" />
|
v-if="op.label !== 'mode'"
|
||||||
<q-item
|
clickable
|
||||||
clickable
|
:id="`btn-${op.label}`"
|
||||||
:id="`btn-${op.label}`"
|
@click="$emit(op.label)"
|
||||||
@click="$emit(op.label)"
|
>
|
||||||
>
|
<q-item-section avatar>
|
||||||
<q-item-section avatar>
|
<q-icon :name="op.icon" :color="op.color" size="20px" />
|
||||||
<q-icon :name="op.icon" :color="op.color" size="20px" />
|
</q-item-section>
|
||||||
</q-item-section>
|
<q-item-section class="q-py-sm">
|
||||||
<q-item-section class="q-py-sm">
|
{{ $t(op.label) }}
|
||||||
{{ $t(op.label) }}
|
</q-item-section>
|
||||||
</q-item-section>
|
</q-item>
|
||||||
</q-item>
|
|
||||||
</q-list>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
<q-separator v-if="op.label === 'mode'" />
|
||||||
|
<q-item
|
||||||
|
v-if="op.label === 'mode'"
|
||||||
|
clickable
|
||||||
|
:id="`btn-${op.label}`"
|
||||||
|
@click="$emit(op.label)"
|
||||||
|
>
|
||||||
|
<q-item-section avatar>
|
||||||
|
<q-icon :name="op.icon" :color="op.color" size="20px" />
|
||||||
|
</q-item-section>
|
||||||
|
<q-item-section class="q-py-sm">
|
||||||
|
<div class="row justify-between">
|
||||||
|
<span>
|
||||||
|
{{ $t(op.label) }}
|
||||||
|
</span>
|
||||||
|
<span class="app-text-muted-2">
|
||||||
|
{{ isDarkActive ? $t('dark') : $t('light') }}
|
||||||
|
<q-icon name="mdi-chevron-right" />
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</q-item-section>
|
||||||
|
|
||||||
|
<q-menu
|
||||||
|
ref="themeRef"
|
||||||
|
class="bordered rounded"
|
||||||
|
anchor="top right"
|
||||||
|
self="top left"
|
||||||
|
max-width="200"
|
||||||
|
:offset="[10, 0]"
|
||||||
|
style="width: 160px"
|
||||||
|
>
|
||||||
|
<div v-for="(mode, index) in themeMode" :key="index">
|
||||||
|
<q-item
|
||||||
|
clickable
|
||||||
|
@click="
|
||||||
|
() => {
|
||||||
|
mode.isActive ? '' : $q.dark.toggle();
|
||||||
|
}
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<q-item-section>
|
||||||
|
<div class="row justify-between">
|
||||||
|
<span>
|
||||||
|
{{ $t(mode.label) }}
|
||||||
|
</span>
|
||||||
|
<q-icon v-if="mode.isActive" name="mdi-check" />
|
||||||
|
</div>
|
||||||
|
</q-item-section>
|
||||||
|
</q-item>
|
||||||
|
</div>
|
||||||
|
</q-menu>
|
||||||
|
</q-item>
|
||||||
|
</q-list>
|
||||||
|
</div>
|
||||||
|
<q-separator />
|
||||||
<q-btn
|
<q-btn
|
||||||
v-if="isLoggedIn()"
|
v-if="isLoggedIn()"
|
||||||
no-caps
|
no-caps
|
||||||
dense
|
dense
|
||||||
color="negative"
|
color="negative"
|
||||||
unelevated
|
unelevated
|
||||||
class="q-ma-sm app-text-negative"
|
class="q-ma-md app-text-negative"
|
||||||
:class="{ dark: $q.dark.isActive }"
|
:class="{ dark: $q.dark.isActive }"
|
||||||
:label="$t('logout')"
|
:label="$t('logout')"
|
||||||
@click="$emit('logout')"
|
@click="$emit('logout')"
|
||||||
|
|
@ -191,7 +286,7 @@ onMounted(async () => {
|
||||||
dense
|
dense
|
||||||
color="primary"
|
color="primary"
|
||||||
unelevated
|
unelevated
|
||||||
class="q-ma-sm app-text-negative"
|
class="q-ma-md app-text-negative"
|
||||||
:label="$t('login')"
|
:label="$t('login')"
|
||||||
@click="$emit('login')"
|
@click="$emit('login')"
|
||||||
id="btn-login"
|
id="btn-login"
|
||||||
|
|
@ -202,7 +297,7 @@ onMounted(async () => {
|
||||||
</q-btn-dropdown>
|
</q-btn-dropdown>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<style scoped>
|
<style scoped lang="scss">
|
||||||
.account-menu-down {
|
.account-menu-down {
|
||||||
& ::before {
|
& ::before {
|
||||||
color: var(--foreground);
|
color: var(--foreground);
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,11 @@ export default {
|
||||||
logout: 'Logout',
|
logout: 'Logout',
|
||||||
list: 'Item',
|
list: 'Item',
|
||||||
manage: 'Manage',
|
manage: 'Manage',
|
||||||
|
mode: 'Mode',
|
||||||
|
theme: 'Theme',
|
||||||
|
light: 'Light',
|
||||||
|
dark: 'Dark',
|
||||||
|
baseOnDevice: 'Base on Device',
|
||||||
...status,
|
...status,
|
||||||
...main,
|
...main,
|
||||||
...address,
|
...address,
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,11 @@ export default {
|
||||||
logout: 'ออกจากระบบ',
|
logout: 'ออกจากระบบ',
|
||||||
list: 'รายการ',
|
list: 'รายการ',
|
||||||
manage: 'จัดการ',
|
manage: 'จัดการ',
|
||||||
|
mode: 'โหมด',
|
||||||
|
theme: 'ธีม',
|
||||||
|
light: 'สว่าง',
|
||||||
|
dark: 'มืด',
|
||||||
|
baseOnDevice: 'สีตามอุปกรณ์',
|
||||||
...status,
|
...status,
|
||||||
...main,
|
...main,
|
||||||
...address,
|
...address,
|
||||||
|
|
|
||||||
|
|
@ -338,7 +338,7 @@ onMounted(async () => {
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<!-- theme -->
|
<!-- theme -->
|
||||||
<q-btn
|
<!-- <q-btn
|
||||||
round
|
round
|
||||||
unelevated
|
unelevated
|
||||||
id="drawer-toggler"
|
id="drawer-toggler"
|
||||||
|
|
@ -347,7 +347,7 @@ onMounted(async () => {
|
||||||
class="surface-2"
|
class="surface-2"
|
||||||
style="color: var(--gray-6)"
|
style="color: var(--gray-6)"
|
||||||
@click="$q.dark.toggle()"
|
@click="$q.dark.toggle()"
|
||||||
/>
|
/> -->
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</q-header>
|
</q-header>
|
||||||
|
|
@ -361,10 +361,12 @@ onMounted(async () => {
|
||||||
<drawer-component v-model:leftDrawerOpen="leftDrawerOpen" />
|
<drawer-component v-model:leftDrawerOpen="leftDrawerOpen" />
|
||||||
|
|
||||||
<FormDialog
|
<FormDialog
|
||||||
|
width="800px"
|
||||||
|
height="550px"
|
||||||
v-model:modal="canvasModal"
|
v-model:modal="canvasModal"
|
||||||
:title="$t('addSignature')"
|
|
||||||
no-app-box
|
no-app-box
|
||||||
max-width="80%"
|
:title="$t('addSignature')"
|
||||||
|
:close="() => (canvasModal = false)"
|
||||||
>
|
>
|
||||||
<CanvasComponent ref="canvasRef" v-model:modal="canvasModal" />
|
<CanvasComponent ref="canvasRef" v-model:modal="canvasModal" />
|
||||||
<template #footer>
|
<template #footer>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue