|
|
|
|
@ -1,105 +1,3 @@
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
|
import { useDynamicTitle } from '@/utils/dynamicTitle'
|
|
|
|
|
import useAppStore from '@/store/modules/app'
|
|
|
|
|
import useSettingsStore from '@/store/modules/settings'
|
|
|
|
|
import usePermissionStore from '@/store/modules/permission'
|
|
|
|
|
import { handleThemeStyle } from '@/utils/theme'
|
|
|
|
|
import { ComponentInternalInstance } from "vue";
|
|
|
|
|
import { SettingTypeEnum } from "@/enums/SettingTypeEnum";
|
|
|
|
|
|
|
|
|
|
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
|
|
|
|
const appStore = useAppStore()
|
|
|
|
|
const settingsStore = useSettingsStore()
|
|
|
|
|
const permissionStore = usePermissionStore()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const showSettings = ref(false);
|
|
|
|
|
const theme = ref(settingsStore.theme);
|
|
|
|
|
const sideTheme = ref(settingsStore.sideTheme);
|
|
|
|
|
const storeSettings = computed(() => settingsStore);
|
|
|
|
|
const predefineColors = ref(["#409EFF", "#ff4500", "#ff8c00", "#ffd700", "#90ee90", "#00ced1", "#1e90ff", "#c71585"]);
|
|
|
|
|
|
|
|
|
|
/** 是否需要topnav */
|
|
|
|
|
const topNav = computed({
|
|
|
|
|
get: () => storeSettings.value.topNav,
|
|
|
|
|
set: (val) => {
|
|
|
|
|
settingsStore.changeSetting({ key: SettingTypeEnum.TOP_NAV, value: val })
|
|
|
|
|
if (!val) {
|
|
|
|
|
appStore.toggleSideBarHide(false);
|
|
|
|
|
permissionStore.setSidebarRouters(permissionStore.defaultRoutes);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
/** 是否需要tagview */
|
|
|
|
|
const tagsView = computed({
|
|
|
|
|
get: () => storeSettings.value.tagsView,
|
|
|
|
|
set: (val) => {
|
|
|
|
|
settingsStore.changeSetting({ key: SettingTypeEnum.TAGS_VIEW, value: val })
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
/**是否需要固定头部 */
|
|
|
|
|
const fixedHeader = computed({
|
|
|
|
|
get: () => storeSettings.value.fixedHeader,
|
|
|
|
|
set: (val) => {
|
|
|
|
|
settingsStore.changeSetting({ key: SettingTypeEnum.FIXED_HEADER, value: val })
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
/**是否需要侧边栏的logo */
|
|
|
|
|
const sidebarLogo = computed({
|
|
|
|
|
get: () => storeSettings.value.sidebarLogo,
|
|
|
|
|
set: (val) => {
|
|
|
|
|
settingsStore.changeSetting({ key: SettingTypeEnum.SIDEBAR_LOGO, value: val })
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
/**是否需要侧边栏的动态网页的title */
|
|
|
|
|
const dynamicTitle = computed({
|
|
|
|
|
get: () => storeSettings.value.dynamicTitle,
|
|
|
|
|
set: (val) => {
|
|
|
|
|
settingsStore.changeSetting({ key: SettingTypeEnum.DYNAMIC_TITLE, value: val })
|
|
|
|
|
// 动态设置网页标题
|
|
|
|
|
useDynamicTitle()
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const themeChange = (val: string | null) => {
|
|
|
|
|
settingsStore.changeSetting({ key: SettingTypeEnum.THEME, value: val })
|
|
|
|
|
theme.value = val;
|
|
|
|
|
if (val) {
|
|
|
|
|
handleThemeStyle(val);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const handleTheme = (val: string) => {
|
|
|
|
|
settingsStore.changeSetting({ key: SettingTypeEnum.SIDE_THEME, value: val })
|
|
|
|
|
sideTheme.value = val;
|
|
|
|
|
}
|
|
|
|
|
const saveSetting = () => {
|
|
|
|
|
proxy?.$modal.loading("正在保存到本地,请稍候...");
|
|
|
|
|
let layoutSetting = {
|
|
|
|
|
"topNav": storeSettings.value.topNav,
|
|
|
|
|
"tagsView": storeSettings.value.tagsView,
|
|
|
|
|
"fixedHeader": storeSettings.value.fixedHeader,
|
|
|
|
|
"sidebarLogo": storeSettings.value.sidebarLogo,
|
|
|
|
|
"dynamicTitle": storeSettings.value.dynamicTitle,
|
|
|
|
|
"sideTheme": storeSettings.value.sideTheme,
|
|
|
|
|
"theme": storeSettings.value.theme
|
|
|
|
|
};
|
|
|
|
|
localStorage.setItem("layout-setting", JSON.stringify(layoutSetting));
|
|
|
|
|
setTimeout(() => {proxy?.$modal.closeLoading()}, 1000)
|
|
|
|
|
}
|
|
|
|
|
const resetSetting = () => {
|
|
|
|
|
proxy?.$modal.loading("正在清除设置缓存并刷新,请稍候...");
|
|
|
|
|
localStorage.removeItem("layout-setting")
|
|
|
|
|
setTimeout("window.location.reload()", 1000)
|
|
|
|
|
}
|
|
|
|
|
const openSetting = () => {
|
|
|
|
|
showSettings.value = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
defineExpose({
|
|
|
|
|
openSetting,
|
|
|
|
|
})
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
<el-drawer v-model="showSettings" :withHeader="false" direction="rtl" size="300px" close-on-click-modal>
|
|
|
|
|
<div class="setting-drawer-title">
|
|
|
|
|
@ -183,6 +81,108 @@ defineExpose({
|
|
|
|
|
</el-drawer>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
|
import { useDynamicTitle } from '@/utils/dynamicTitle'
|
|
|
|
|
import useAppStore from '@/store/modules/app'
|
|
|
|
|
import useSettingsStore from '@/store/modules/settings'
|
|
|
|
|
import usePermissionStore from '@/store/modules/permission'
|
|
|
|
|
import { handleThemeStyle } from '@/utils/theme'
|
|
|
|
|
import { ComponentInternalInstance } from "vue";
|
|
|
|
|
import { SettingTypeEnum } from "@/enums/SettingTypeEnum";
|
|
|
|
|
|
|
|
|
|
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
|
|
|
|
const appStore = useAppStore()
|
|
|
|
|
const settingsStore = useSettingsStore()
|
|
|
|
|
const permissionStore = usePermissionStore()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const showSettings = ref(false);
|
|
|
|
|
const theme = ref(settingsStore.theme);
|
|
|
|
|
const sideTheme = ref(settingsStore.sideTheme);
|
|
|
|
|
const storeSettings = computed(() => settingsStore);
|
|
|
|
|
const predefineColors = ref(["#409EFF", "#ff4500", "#ff8c00", "#ffd700", "#90ee90", "#00ced1", "#1e90ff", "#c71585"]);
|
|
|
|
|
|
|
|
|
|
/** 是否需要topnav */
|
|
|
|
|
const topNav = computed({
|
|
|
|
|
get: () => storeSettings.value.topNav,
|
|
|
|
|
set: (val) => {
|
|
|
|
|
settingsStore.changeSetting({ key: SettingTypeEnum.TOP_NAV, value: val })
|
|
|
|
|
if (!val) {
|
|
|
|
|
appStore.toggleSideBarHide(false);
|
|
|
|
|
permissionStore.setSidebarRouters(permissionStore.defaultRoutes);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
/** 是否需要tagview */
|
|
|
|
|
const tagsView = computed({
|
|
|
|
|
get: () => storeSettings.value.tagsView,
|
|
|
|
|
set: (val) => {
|
|
|
|
|
settingsStore.changeSetting({ key: SettingTypeEnum.TAGS_VIEW, value: val })
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
/**是否需要固定头部 */
|
|
|
|
|
const fixedHeader = computed({
|
|
|
|
|
get: () => storeSettings.value.fixedHeader,
|
|
|
|
|
set: (val) => {
|
|
|
|
|
settingsStore.changeSetting({ key: SettingTypeEnum.FIXED_HEADER, value: val })
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
/**是否需要侧边栏的logo */
|
|
|
|
|
const sidebarLogo = computed({
|
|
|
|
|
get: () => storeSettings.value.sidebarLogo,
|
|
|
|
|
set: (val) => {
|
|
|
|
|
settingsStore.changeSetting({ key: SettingTypeEnum.SIDEBAR_LOGO, value: val })
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
/**是否需要侧边栏的动态网页的title */
|
|
|
|
|
const dynamicTitle = computed({
|
|
|
|
|
get: () => storeSettings.value.dynamicTitle,
|
|
|
|
|
set: (val) => {
|
|
|
|
|
settingsStore.changeSetting({ key: SettingTypeEnum.DYNAMIC_TITLE, value: val })
|
|
|
|
|
// 动态设置网页标题
|
|
|
|
|
useDynamicTitle()
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const themeChange = (val: string | null) => {
|
|
|
|
|
settingsStore.changeSetting({ key: SettingTypeEnum.THEME, value: val })
|
|
|
|
|
theme.value = val;
|
|
|
|
|
if (val) {
|
|
|
|
|
handleThemeStyle(val);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const handleTheme = (val: string) => {
|
|
|
|
|
settingsStore.changeSetting({ key: SettingTypeEnum.SIDE_THEME, value: val })
|
|
|
|
|
sideTheme.value = val;
|
|
|
|
|
}
|
|
|
|
|
const saveSetting = () => {
|
|
|
|
|
proxy?.$modal.loading("正在保存到本地,请稍候...");
|
|
|
|
|
let layoutSetting = {
|
|
|
|
|
"topNav": storeSettings.value.topNav,
|
|
|
|
|
"tagsView": storeSettings.value.tagsView,
|
|
|
|
|
"fixedHeader": storeSettings.value.fixedHeader,
|
|
|
|
|
"sidebarLogo": storeSettings.value.sidebarLogo,
|
|
|
|
|
"dynamicTitle": storeSettings.value.dynamicTitle,
|
|
|
|
|
"sideTheme": storeSettings.value.sideTheme,
|
|
|
|
|
"theme": storeSettings.value.theme
|
|
|
|
|
};
|
|
|
|
|
localStorage.setItem("layout-setting", JSON.stringify(layoutSetting));
|
|
|
|
|
setTimeout(() => {proxy?.$modal.closeLoading()}, 1000)
|
|
|
|
|
}
|
|
|
|
|
const resetSetting = () => {
|
|
|
|
|
proxy?.$modal.loading("正在清除设置缓存并刷新,请稍候...");
|
|
|
|
|
localStorage.removeItem("layout-setting")
|
|
|
|
|
setTimeout("window.location.reload()", 1000)
|
|
|
|
|
}
|
|
|
|
|
const openSetting = () => {
|
|
|
|
|
showSettings.value = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
defineExpose({
|
|
|
|
|
openSetting,
|
|
|
|
|
})
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
.setting-drawer-title {
|
|
|
|
|
margin-bottom: 12px;
|
|
|
|
|
|