chore: update

This commit is contained in:
xiaoxian521
2022-08-15 15:53:27 +08:00
parent acaeb0cb42
commit f27787d560
11 changed files with 107 additions and 97 deletions

View File

@@ -1,23 +1,18 @@
<script setup lang="ts">
import {
h,
ref,
computed,
Transition,
defineComponent,
getCurrentInstance
} from "vue";
import { useGlobal } from "@pureadmin/utils";
import backTop from "/@/assets/svg/back_top.svg?component";
import { h, computed, Transition, defineComponent } from "vue";
import { usePermissionStoreHook } from "/@/store/modules/permission";
const props = defineProps({
fixedHeader: Boolean
});
const keepAlive: Boolean = ref(
getCurrentInstance().appContext.config.globalProperties.$config?.KeepAlive
);
const instance =
getCurrentInstance().appContext.app.config.globalProperties.$storage;
const { $storage, $config } = useGlobal<GlobalPropertiesApi>();
const keepAlive = computed(() => {
return $config?.KeepAlive;
});
const transitions = computed(() => {
return route => {
@@ -26,11 +21,11 @@ const transitions = computed(() => {
});
const hideTabs = computed(() => {
return instance?.configure.hideTabs;
return $storage?.configure.hideTabs;
});
const layout = computed(() => {
return instance?.layout.layout === "vertical";
return $storage?.layout.layout === "vertical";
});
const getSectionStyle = computed(() => {

View File

@@ -20,6 +20,7 @@ import { useDataThemeChange } from "/@/layout/hooks/useDataThemeChange";
import {
useDark,
debounce,
useGlobal,
storageLocal,
storageSession
} from "@pureadmin/utils";
@@ -31,6 +32,7 @@ import darkIcon from "/@/assets/svg/dark.svg?component";
const router = useRouter();
const { isDark } = useDark();
const { isSelect } = useCssModule();
const { $storage } = useGlobal<GlobalPropertiesApi>();
const mixRef = templateRef<HTMLElement | null>("mixRef", null);
const verticalRef = templateRef<HTMLElement | null>("verticalRef", null);
@@ -38,7 +40,6 @@ const horizontalRef = templateRef<HTMLElement | null>("horizontalRef", null);
const {
body,
instance,
dataTheme,
layoutTheme,
themeColors,
@@ -58,17 +59,17 @@ if (unref(layoutTheme)) {
}
/** 默认灵动模式 */
const markValue = ref(instance.configure?.showModel ?? "smart");
const markValue = ref($storage.configure?.showModel ?? "smart");
const logoVal = ref(instance.configure?.showLogo ?? true);
const logoVal = ref($storage.configure?.showLogo ?? true);
const settings = reactive({
greyVal: instance.configure.grey,
weakVal: instance.configure.weak,
tabsVal: instance.configure.hideTabs,
showLogo: instance.configure.showLogo,
showModel: instance.configure.showModel,
multiTagsCache: instance.configure.multiTagsCache
greyVal: $storage.configure.grey,
weakVal: $storage.configure.weak,
tabsVal: $storage.configure.hideTabs,
showLogo: $storage.configure.showLogo,
showModel: $storage.configure.showModel,
multiTagsCache: $storage.configure.multiTagsCache
});
const getThemeColorStyle = computed(() => {
@@ -85,9 +86,9 @@ const showThemeColors = computed(() => {
});
function storageConfigureChange<T>(key: string, val: T): void {
const storageConfigure = instance.configure;
const storageConfigure = $storage.configure;
storageConfigure[key] = val;
instance.configure = storageConfigure;
$storage.configure = storageConfigure;
}
function toggleClass(flag: boolean, clsName: string, target?: HTMLElement) {
@@ -116,7 +117,7 @@ const weekChange = (value): void => {
const tagsChange = () => {
let showVal = settings.tabsVal;
storageConfigureChange("hideTabs", showVal);
emitter.emit("tagViewsChange", showVal);
emitter.emit("tagViewsChange", showVal as unknown as string);
};
const multiTagsCacheChange = () => {
@@ -158,7 +159,7 @@ function setFalse(Doms): any {
});
}
watch(instance, ({ layout }) => {
watch($storage, ({ layout }) => {
/* 设置wangeditorV5主题色 */
body.style.setProperty("--w-e-toolbar-active-color", layout["epThemeColor"]);
switch (layout["layout"]) {
@@ -203,12 +204,11 @@ const getThemeColor = computed(() => {
function setLayoutModel(layout: string) {
layoutTheme.value.layout = layout;
window.document.body.setAttribute("layout", layout);
instance.layout = {
$storage.layout = {
layout,
theme: layoutTheme.value.theme,
darkMode: instance.layout.darkMode,
sidebarStatus: instance.layout.sidebarStatus,
epThemeColor: instance.layout.epThemeColor
darkMode: $storage.layout.darkMode,
sidebarStatus: $storage.layout.sidebarStatus
};
useAppStoreHook().setLayout(layout);
}

View File

@@ -6,10 +6,10 @@ import avatars from "/@/assets/avatars.jpg";
import { useNav } from "/@/layout/hooks/useNav";
import screenfull from "../screenfull/index.vue";
import { deviceDetection } from "@pureadmin/utils";
import { ref, watch, nextTick, onMounted } from "vue";
import { useTranslationLang } from "../../hooks/useTranslationLang";
import { usePermissionStoreHook } from "/@/store/modules/permission";
import globalization from "/@/assets/svg/globalization.svg?component";
import { ref, watch, nextTick, onMounted, onBeforeUnmount } from "vue";
const menuRef = ref();
@@ -29,10 +29,18 @@ const {
getDropdownItemClass
} = useNav();
onMounted(() => {
function onResizeMenu() {
nextTick(() => {
handleResize(menuRef.value);
});
}
onMounted(() => {
window.addEventListener("resize", onResizeMenu);
});
onBeforeUnmount(() => {
window.removeEventListener("resize", onResizeMenu);
});
watch(

View File

@@ -6,12 +6,12 @@ import { useNav } from "/@/layout/hooks/useNav";
import { transformI18n } from "/@/plugins/i18n";
import screenfull from "../screenfull/index.vue";
import { deviceDetection } from "@pureadmin/utils";
import { ref, toRaw, watch, nextTick, onMounted } from "vue";
import { useRenderIcon } from "/@/components/ReIcon/src/hooks";
import { getParentPaths, findRouteByPath } from "/@/router/utils";
import { useTranslationLang } from "../../hooks/useTranslationLang";
import { usePermissionStoreHook } from "/@/store/modules/permission";
import globalization from "/@/assets/svg/globalization.svg?component";
import { ref, toRaw, watch, nextTick, onMounted, onBeforeUnmount } from "vue";
const menuRef = ref();
let defaultActive = ref(null);
@@ -42,11 +42,19 @@ function getDefaultActive(routePath) {
)?.children[0]?.path;
}
onMounted(() => {
getDefaultActive(route.path);
function onResizeMenu() {
nextTick(() => {
handleResize(menuRef.value);
});
}
onMounted(() => {
getDefaultActive(route.path);
window.addEventListener("resize", onResizeMenu);
});
onBeforeUnmount(() => {
window.removeEventListener("resize", onResizeMenu);
});
watch(

View File

@@ -45,7 +45,7 @@ getSubMenuData(route.path);
onBeforeMount(() => {
emitter.on("logoChange", key => {
showLogo.value = key as unknown as boolean;
showLogo.value = key;
});
});