-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: vue修改默认主题&添加角色修改data.permission (#195)
* fix: vue添加角色修改data.permission * fix: vue默认主题改为smb主题 * fix: vue主题补充useTheme
- Loading branch information
Showing
8 changed files
with
116 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
packages/toolkits/pro/template/tinyvue/src/hooks/useTheme.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { useAppStore } from '@/store'; | ||
import { computed, onMounted, watch } from 'vue'; | ||
import * as Themes from '@/components/theme/type'; | ||
import TinyThemeTool from '@opentiny/vue-theme/theme-tool.js'; | ||
import { tinySmbTheme } from '@opentiny/vue-theme/theme'; | ||
import useThemes from './themes'; | ||
|
||
export const useTheme = (themeTool: typeof TinyThemeTool) => { | ||
const { themelist, $patch } = useAppStore(); | ||
const themeName = computed(() => | ||
themelist.length | ||
? `${themelist[0].toUpperCase()}${themelist.slice(1).toLowerCase()}Theme` | ||
: 'DefaultTheme', | ||
); | ||
const { isDark } = useThemes(); | ||
watch( | ||
themeName, | ||
() => { | ||
themeTool.changeTheme( | ||
themeName.value === 'DefaultTheme' | ||
? tinySmbTheme | ||
: (Themes as any)[themeName.value], | ||
); | ||
}, | ||
{ immediate: true }, | ||
); | ||
onMounted(() => { | ||
watch( | ||
isDark, | ||
() => { | ||
if (isDark.value) { | ||
document.body.style.filter = 'invert(0.9) hue-rotate(180deg)'; | ||
} else { | ||
document.body.style.filter = ''; | ||
} | ||
}, | ||
{ immediate: true }, | ||
); | ||
}); | ||
const toggleTheme = (name: string) => { | ||
$patch({ | ||
themelist: name, | ||
}); | ||
}; | ||
return { toggleTheme }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters