若依ruoyi左侧菜单栏增加新的主题色

操作步骤

1.添加自定义模板

src/layout/components/Settings/index.vue 目录下30行左右新增

			<div class="setting-drawer-block-checbox-item" @click="handleTheme('theme-blue')">
              <img src="@/assets/images/blue.svg" alt="custom">
              <div v-if="sideTheme === 'theme-blue'" class="setting-drawer-block-checbox-selectIcon" style="display: block;">
                <i aria-label="图标: check" class="anticon anticon-check">
                  <svg viewBox="64 64 896 896" data-icon="check" width="1em" height="1em" :fill="theme" aria-hidden="true" focusable="false" class="">
                    <path d="M912 190h-69.9c-9.8 0-19.1 4.5-25.1 12.2L404.7 724.5 207 474a32 32 0 0 0-25.1-12.2H112c-6.7 0-10.4 7.7-6.3 12.9l273.9 347c12.8 16.2 37.4 16.2 50.3 0l488.4-618.9c4.1-5.1.4-12.8-6.3-12.8z"/>
                  </svg>
                </i>
              </div>
            </div>

2. variables.scss

//新增样式名
$base-menu-blue-background:#0043B2;
$blue-sub-menu-background:#003793;
$blue-sub-menu-hover:#023281;

//新增导出
:export {
......
menuBlueBackground:$base-menu-blue-background;
}

这里的变量名可以自定义,但还是要注意和后面的一一对应

3.Logo.vue

<template>
  <div class="sidebar-logo-container" :class="{'collapse':collapse}" :style="{ backgroundColor: sideTheme === 'theme-dark' ? variables.menuBackground : sideTheme === 'theme-blue' ? variables.menuBlueBackground : variables.menuLightBackground }">
    <transition name="sidebarLogoFade">
      <router-link v-if="collapse" key="collapse" class="sidebar-logo-link" to="/">
        <img v-if="logo" :src="logo" class="sidebar-logo" />
        <h1 v-else class="sidebar-title" :style="{color:(sideTheme === 'theme-dark' || sideTheme === 'theme-blue') ? variables.logoTitleColor : variables.logoLightTitleColor }">{{ title }} </h1>
      </router-link>
      <router-link v-else key="expand" class="sidebar-logo-link" to="/">
        <img v-if="logo" :src="logo" class="sidebar-logo" />
        <h1 class="sidebar-title" :style="{ color: (sideTheme === 'theme-dark' || sideTheme === 'theme-blue') ? variables.logoTitleColor : variables.logoLightTitleColor }">{{ title }} </h1>
      </router-link>
    </transition>
  </div>
</template>

修改动态的style

4.Siderbar目录下的index.vue

//主要修改el-menu的这两个属性
    :background-color="settings.sideTheme === 'theme-dark' ? variables.menuBackground : settings.sideTheme === 'theme-blue' ? variables.menuBlueBackground : variables.menuLightBackground"
    
    :text-color="settings.sideTheme === 'theme-dark' ? variables.menuColor : settings.sideTheme === 'theme-blue' ? variables.menuColor : variables.menuLightColor"
    
    第2行修改
    <div :class="{'has-logo':showLogo}" :style="{ backgroundColor: settings.sideTheme === 'theme-dark' ? variables.menuBackground : settings.sideTheme === 'theme-blue' ? variables.menuBlueBackground : variables.menuLightBackground }">           

主题切换-效果图如下:

在这里插入图片描述

在这里插入图片描述

若依RuoYi)是一个基于SpringBoot的快速开发平台,其左侧菜单通常是根据后台数据动态生成的。左侧菜单表名称悬浮显示是指当用户将鼠标悬停在左侧导航栏的某个菜单项上时,会显示出该菜单项对应的表名称或相关信息。这种设计可以帮助用户更好地理解各个菜单项的功能和关联的数据库表。 要实现这样的功能,通常需要在前端进行一些配置或代码修改,例如: 1. 在菜单数据结构中添加一个字段用于存储表名称或备注信息。 2. 使用JavaScript或Vue.js等前端技术监听鼠标悬停事件。 3. 在鼠标悬停时,动态显示或修改DOM元素,以展示菜单项的表名称或备注信息。 具体的实现方法取决于你使用的前端框架和技术栈,以下是一个简单的示例代码片段,假设使用的是Vue.js: ```javascript // 假设菜单数据结构中的item有一个额外的字段叫做table const menuData = [ { path: '/dashboard', name: '仪表盘', table: 'dashboard_table', // 其他菜单项属性 }, // 其他菜单项... ]; // 在左侧菜单组件中 <template> <div v-for="item in menuData" :key="item.path"> <router-link :to="item.path"> <div @mouseover="showTableName(item.table)" @mouseleave="hideTableName"> {{ item.name }} </div> </router-link> </div> </template> <script> export default { data() { return { tableNameShowing: '' // 当前显示的表名称 }; }, methods: { showTableName(tableName) { this.tableNameShowing = tableName; // 这里可以添加显示表名称的逻辑,比如更DOM元素 }, hideTableName() { this.tableNameShowing = ''; // 这里可以添加隐藏表名称的逻辑 } } } </script> ``` 在实际项目中,可能需要结合实际情况调整事件监听和DOM操作的代码。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

石马农汪

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值