Skip to content

Commit

Permalink
Merge pull request #1 from beclab/feat/theme
Browse files Browse the repository at this point in the history
feat: add theme mode define
  • Loading branch information
yongheng2016 authored Jun 3, 2024
2 parents 619050b + 4234c88 commit 9163e57
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
5 changes: 4 additions & 1 deletion packages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import BtDialog from "./dialog";
import { NotifyDefinedType } from "./notify/type";
import BtTheme from "./theme";
import useColor from "./utils/useColor";
import { ThemeDefinedMode, themeModeName } from './theme/types'

const components = [
BtButton,
Expand Down Expand Up @@ -90,5 +91,7 @@ export {
NotifyDefinedType,
BtDialog,
BtTheme,
useColor
useColor,
ThemeDefinedMode,
themeModeName
};
13 changes: 12 additions & 1 deletion packages/theme/src/IndexPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<script setup lang="ts">
import { watchEffect, ref, defineProps } from "vue";
import { useQuasar, setCssVar, getCssVar, colors } from "quasar";
import { themeModeName, ThemeDefinedMode } from '../types';
interface Props {
showThemeToggle: boolean;
Expand Down Expand Up @@ -129,12 +130,22 @@ watchEffect(() => {
});
}
});
const themeValue = $q.cookies.get(themeModeName);
if (themeValue) {
const theme = Number(themeValue);
if (theme == ThemeDefinedMode.AUTO) {
$q.dark.set('auto');
} else {
$q.dark.set(theme == ThemeDefinedMode.DARK);
}
}
</script>
<script lang="ts">
import { defineComponent } from "vue";
export default defineComponent({
name: "BtTheme"
name: "BtTheme"
});
</script>
<style></style>
7 changes: 7 additions & 0 deletions packages/theme/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export enum ThemeDefinedMode {
AUTO = 0,
LIGHT = 1,
DARK = 2
}

export const themeModeName = 'theme_name';

0 comments on commit 9163e57

Please sign in to comment.