Skip to content

Commit

Permalink
Merge branch 'main' of github.com:beclab/ui
Browse files Browse the repository at this point in the history
  • Loading branch information
wushuangs committed Dec 2, 2024
2 parents a613493 + f667f5a commit b852426
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 31 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bytetrade/ui",
"version": "0.1.30",
"version": "0.1.37",
"private": false,
"scripts": {
"serve": "vue-cli-service serve",
Expand Down
6 changes: 4 additions & 2 deletions packages/Menu/src/index.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div class="bt-menu-container q-pa-md">
<Theme :show-theme-toggle="props.showThemeToggle"></Theme>
<Theme v-if="props.showThemeToggle" :follow-system="props.followSystem"/>
<div class="q-pb-lg" v-if="$slots.header">
<slot name="header"></slot>
</div>
Expand Down Expand Up @@ -143,10 +143,12 @@ interface Props {
sameActiveable: boolean;
showThemeToggle: boolean;
followSystem?:boolean;
}
const props = withDefaults(defineProps<Props>(), {
sameActiveable: false,
showThemeToggle: false
showThemeToggle: true,
followSystem: true
});
const link = ref(props.defaultActive || props.modelValue);
Expand Down
7 changes: 7 additions & 0 deletions packages/global.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
try {
if (navigator.platform.indexOf('Win') !== -1) {
document.body.classList.add('olares-windows');
}
} catch (error) {
//
}
44 changes: 28 additions & 16 deletions packages/theme/src/IndexPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,18 @@
</template>

<script setup lang="ts">
import { ref, defineProps, onMounted } from 'vue';
import { ref, defineProps, onMounted, watch } from 'vue';
import { useQuasar } from 'quasar';
import { themeModeName, ThemeDefinedMode } from '../types';
interface Props {
showThemeToggle: boolean;
showThemeToggle?: boolean;
followSystem?:boolean
}
const props = withDefaults(defineProps<Props>(), {
showToggle: false
showThemeToggle: false,
followSystem: true
});
const $q = useQuasar();
Expand Down Expand Up @@ -46,24 +48,26 @@ function getCookie(name: string) {
return '';
}
let themeValue = '';
if ($q.cookies) {
themeValue = $q.cookies.get(themeModeName);
} else {
themeValue = getCookie(themeModeName);
}
if (themeValue) {
const theme = Number(themeValue);
if (theme == ThemeDefinedMode.AUTO) {
$q.dark.set('auto');
function setTheme() {
let themeValue = '';
if ($q.cookies) {
themeValue = $q.cookies.get(themeModeName);
} else {
$q.dark.set(theme == ThemeDefinedMode.DARK);
themeValue = getCookie(themeModeName);
}
if (themeValue) {
const theme = Number(themeValue);
if (theme == ThemeDefinedMode.AUTO) {
$q.dark.set('auto');
} else {
$q.dark.set(theme == ThemeDefinedMode.DARK);
}
}
}
const message = (event: any) => {
if (event.data.message === 'theme_apps_update') {
if (props.followSystem && event.data.message === 'theme_apps_update') {
if (event.data.info.theme.toString() === '1') {
$q.dark.set(false);
} else {
Expand All @@ -72,9 +76,17 @@ const message = (event: any) => {
}
};
setTheme();
onMounted(() => {
window && window.addEventListener('message', message);
});
watch(()=> props.followSystem, (newValue) => {
if(newValue) {
setTheme();
}
})
</script>
<script lang="ts">
import { defineComponent } from 'vue';
Expand Down
26 changes: 14 additions & 12 deletions packages/utils/useColor.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
import { useQuasar, colors, Dark } from "quasar";
import { ref, watchEffect } from "vue";
import { useQuasar, colors, Dark } from 'quasar';
import { ref, watchEffect } from 'vue';

const { getPaletteColor } = colors;

function useColor(variable: string) {
const $q = useQuasar();
const dark = $q?.dark || Dark;
const color = ref(getPaletteColor(variable));
const $q = useQuasar();
const dark = $q?.dark || Dark;
const color = ref();
try {
color.value = getPaletteColor(variable);

watchEffect(() => {
color.value = dark.isActive
? getPaletteColor(variable)
: getPaletteColor(variable);
});

return { color };
watchEffect(() => {
color.value = dark.isActive ? getPaletteColor(variable) : getPaletteColor(variable);
});
return { color };
} catch (error) {
return { color };
}
}

export default useColor;
17 changes: 17 additions & 0 deletions src/styles/global.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
body.olares-windows {
::-webkit-scrollbar {
width: 6px;
height: 8px;
background-color: rgba(255, 255, 255, 0);
}

::-webkit-scrollbar-thumb {
background-color: #bcbdbe;
border-radius: 999px;
}
::-webkit-scrollbar-track {
background: rgba(255, 255, 255, 0);
}
}


1 change: 1 addition & 0 deletions src/styles/quasar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
@import "./variables-text.sass";
@import "./variables-bg.sass";
@import "./mobile-font-text.sass";
@import "./global.scss";

.material-symbols-rounded {
font-variation-settings: "FILL" 0, "wght" 300, "GRAD" 0, "opsz" 20;
Expand Down

0 comments on commit b852426

Please sign in to comment.