|
@@ -40,7 +40,11 @@
|
|
|
@click="colorChoose"
|
|
|
>
|
|
|
<t-button theme="default" variant="outline" shape="square">
|
|
|
- <t-icon name="logo-windows-filled" size="16"
|
|
|
+ <t-icon
|
|
|
+ name="chevron-down"
|
|
|
+ size="24"
|
|
|
+ color="#fff"
|
|
|
+ :style="{ background: themeColor, borderRadius: '2px' }"
|
|
|
/></t-button>
|
|
|
</t-dropdown>
|
|
|
<t-dropdown
|
|
@@ -53,6 +57,7 @@
|
|
|
<img src="../assets/imgs/user_head.png" />
|
|
|
</div>
|
|
|
<span class="real-name">{{ userStore.user?.realName }}</span>
|
|
|
+ <ChevronDownIcon size="16px" />
|
|
|
</div>
|
|
|
</t-dropdown>
|
|
|
</div>
|
|
@@ -69,7 +74,7 @@
|
|
|
</t-layout>
|
|
|
</template>
|
|
|
|
|
|
-<script setup name="Layout">
|
|
|
+<script setup name="Layout" lang="jsx">
|
|
|
import { ref, onMounted } from 'vue';
|
|
|
import { useAppStore, useUserStore } from '@/store';
|
|
|
import { useRouter, useRoute } from 'vue-router';
|
|
@@ -78,6 +83,7 @@ import { Color } from 'tvision-color';
|
|
|
import { generateColorMap, insertThemeStylesheet } from '@/config/color';
|
|
|
import { moduleMap } from '@/router/asyncRoutes';
|
|
|
import { ChevronDownIcon, UserIcon } from 'tdesign-icons-vue-next';
|
|
|
+import { clear, cookie } from '@/utils/tool';
|
|
|
|
|
|
const router = useRouter();
|
|
|
const route = useRoute();
|
|
@@ -92,25 +98,54 @@ const setModuleByPath = () => {
|
|
|
let curModuleName = moduleMap[firstPath];
|
|
|
userStore.setCurPageModule(curModuleName);
|
|
|
};
|
|
|
+const themeColor = ref(cookie.get('themeColor'));
|
|
|
onMounted(() => {
|
|
|
setModuleByPath();
|
|
|
+ setTheme(themeColor.value || '#0052d9');
|
|
|
});
|
|
|
const colorOptions = ref([
|
|
|
- { content: '默认主题', value: '#0052d9' },
|
|
|
- { content: '天蓝主题', value: '#2fa4e7' },
|
|
|
- { content: '橙色主题', value: '#e78b24' },
|
|
|
- { content: '红色主题', value: '#dd4814' },
|
|
|
+ {
|
|
|
+ content: '默认主题',
|
|
|
+ value: '#0052d9',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ content: '天蓝主题',
|
|
|
+ value: '#2fa4e7',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ content: '橙色主题',
|
|
|
+ value: '#e78b24',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ content: '红色主题',
|
|
|
+ value: '#dd4814',
|
|
|
+ },
|
|
|
]);
|
|
|
-const userOptions = ref([{ content: '修改密码', value: '1' }]);
|
|
|
-const colorChoose = (data) => {
|
|
|
- console.log('data:', data);
|
|
|
- const hex = data.value;
|
|
|
+const userOptions = ref([
|
|
|
+ { content: '修改密码', value: '1' },
|
|
|
+ { content: '退出', value: '2' },
|
|
|
+]);
|
|
|
+const clickHandler = (data) => {
|
|
|
+ if (data.content === '修改密码') {
|
|
|
+ router.push({ name: 'PasswordModify' });
|
|
|
+ } else if (data.content === '退出') {
|
|
|
+ clear();
|
|
|
+ window.location.href = '/';
|
|
|
+ }
|
|
|
+};
|
|
|
+const setTheme = (hex) => {
|
|
|
const newPalette = Color.getPaletteByGradation({
|
|
|
colors: [hex],
|
|
|
step: 10,
|
|
|
})[0];
|
|
|
const colorMap = generateColorMap(hex, newPalette);
|
|
|
insertThemeStylesheet(hex, colorMap);
|
|
|
+ cookie.set('themeColor', hex);
|
|
|
+ themeColor.value = hex;
|
|
|
+};
|
|
|
+const colorChoose = (data) => {
|
|
|
+ const hex = data.value;
|
|
|
+ setTheme(hex);
|
|
|
};
|
|
|
</script>
|
|
|
|