| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- <script setup lang="ts">
- import { useI18n } from "vue-i18n";
- import { emitter } from "@/utils/mitt";
- import { onClickOutside } from "@vueuse/core";
- import { ref, computed, onMounted, onBeforeUnmount } from "vue";
- import { useDataThemeChange } from "@/layout/hooks/useDataThemeChange";
- import CloseIcon from "~icons/ep/close";
- const target = ref(null);
- const show = ref<Boolean>(false);
- const iconClass = computed(() => {
- return [
- "w-[22px]",
- "h-[22px]",
- "flex",
- "justify-center",
- "items-center",
- "outline-hidden",
- "rounded-[4px]",
- "cursor-pointer",
- "transition-colors",
- "hover:bg-[#0000000f]",
- "dark:hover:bg-[#ffffff1f]",
- "dark:hover:text-[#ffffffd9]"
- ];
- });
- const { t } = useI18n();
- const { onReset } = useDataThemeChange();
- onClickOutside(target, (event: any) => {
- if (event.clientX > target.value.offsetLeft) return;
- show.value = false;
- });
- onMounted(() => {
- emitter.on("openPanel", () => {
- show.value = true;
- });
- });
- onBeforeUnmount(() => {
- // 解绑`openPanel`公共事件,防止多次触发
- emitter.off("openPanel");
- });
- </script>
- <template>
- <div :class="{ show }">
- <div class="right-panel-background" />
- <div ref="target" class="right-panel">
- <div
- class="project-configuration border-0 border-b-[1px] border-solid border-[var(--pure-border-color)]"
- >
- <h4 class="dark:text-white">
- {{ t("panel.pureSystemSet") }}
- </h4>
- <span
- v-tippy="{
- content: t('panel.pureCloseSystemSet'),
- placement: 'bottom-start',
- zIndex: 41000
- }"
- :class="iconClass"
- >
- <IconifyIconOffline
- class="dark:text-white"
- width="18px"
- height="18px"
- :icon="CloseIcon"
- @click="show = !show"
- />
- </span>
- </div>
- <el-scrollbar>
- <slot />
- </el-scrollbar>
- <div
- class="flex justify-end p-3 border-0 border-t-[1px] border-solid border-[var(--pure-border-color)]"
- >
- <el-button
- v-tippy="{
- content: t('panel.pureClearCacheAndToLogin'),
- placement: 'left-start',
- zIndex: 41000
- }"
- type="danger"
- text
- bg
- @click="onReset"
- >
- {{ t("panel.pureClearCache") }}
- </el-button>
- </div>
- </div>
- </div>
- </template>
- <style lang="scss" scoped>
- :deep(.el-scrollbar) {
- height: calc(100vh - 110px);
- }
- // 用 ::v-deep 穿透 scoped,确保全局 .dark 类能影响变量
- :deep(:root) {
- --panel-bg-color: #ffffff; // 浅色模式背景
- }
- :deep(:root.dark) {
- --panel-bg-color: #1e1e1e; // 深色模式背景
- }
- .right-panel-background {
- position: fixed;
- top: 0;
- left: 0;
- z-index: -1;
- background: rgb(0 0 0 / 20%);
- opacity: 0;
- transition: opacity 0.3s cubic-bezier(0.7, 0.3, 0.1, 1);
- }
- .right-panel {
- position: fixed;
- top: 0;
- right: 0;
- z-index: 40000;
- width: 100%;
- max-width: 280px;
- box-shadow: 0 0 15px 0 rgb(0 0 0 / 5%);
- transform: translate(100%);
- transition: all 0.25s cubic-bezier(0.7, 0.3, 0.1, 1);
- // 强制应用背景色变量(核心修复)
- background-color: var(--el-color-white) !important;
- }
- .dark .right-panel {
- position: fixed;
- top: 0;
- right: 0;
- z-index: 40000;
- width: 100%;
- max-width: 280px;
- box-shadow: 0 0 15px 0 rgb(0 0 0 / 5%);
- transform: translate(100%);
- transition: all 0.25s cubic-bezier(0.7, 0.3, 0.1, 1);
- // 强制应用背景色变量(核心修复)
- background-color: var(--el-color-black) !important;
- }
- .show {
- transition: all 0.3s cubic-bezier(0.7, 0.3, 0.1, 1);
- .right-panel-background {
- z-index: 20000;
- width: 100%;
- height: 100%;
- opacity: 1;
- }
- .right-panel {
- transform: translate(0);
- }
- }
- .project-configuration {
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 14px 20px;
- }
- </style>
|