✨ feat: 默认改为暗色模式
This commit is contained in:
@@ -2,144 +2,15 @@
|
||||
<div class="dashboard-root">
|
||||
<!-- 第一行:头像+欢迎语 -->
|
||||
<UserGreeting />
|
||||
|
||||
<!-- 业务功能区 -->
|
||||
<div class="business-area-header">
|
||||
<h2 class="business-area-title">常用应用</h2>
|
||||
<button class="edit-btn" @click="showSettingDialog = true">
|
||||
<svg-icon icon-class="edit" /> 编辑常用
|
||||
</button>
|
||||
</div>
|
||||
<div class="business-modules">
|
||||
<div v-for="(module, index) in businessModules" :key="index"
|
||||
class="business-module" @click="handleLink(module.link)">
|
||||
<div class="business-module-icon">
|
||||
<svg-icon :icon-class="module.icon" />
|
||||
</div>
|
||||
<h3 class="business-module-title">{{ module.title }}</h3>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 全部应用 -->
|
||||
<AllApplications @addFavorites="handleAddFavorites" />
|
||||
|
||||
<!-- 设置弹窗 -->
|
||||
<div class="dialog-mask" v-if="showSettingDialog">
|
||||
<div class="setting-dialog">
|
||||
<div class="dialog-header">
|
||||
<h3>编辑常用应用</h3>
|
||||
<button class="close-btn" @click="showSettingDialog = false">
|
||||
<svg-icon icon-class="close" />
|
||||
</button>
|
||||
</div>
|
||||
<div class="dialog-content">
|
||||
<div class="empty-tip" v-if="businessModules.length === 0">
|
||||
暂无常用应用,可从下方"全部应用"中添加
|
||||
</div>
|
||||
<ul class="module-list" v-else>
|
||||
<li v-for="(module, index) in businessModules" :key="index" class="module-item">
|
||||
<div class="module-info">
|
||||
<span class="module-index">{{ index + 1 }}</span>
|
||||
<span class="module-name">{{ module.title }}</span>
|
||||
</div>
|
||||
<div class="module-actions">
|
||||
<el-button
|
||||
@click="moveModule(index, 'up')"
|
||||
:disabled="index === 0"
|
||||
icon="ArrowUp" type="primary"
|
||||
>
|
||||
</el-button>
|
||||
<el-button
|
||||
@click="moveModule(index, 'down')"
|
||||
:disabled="index === businessModules.length - 1"
|
||||
icon="ArrowDown" type="primary"
|
||||
>
|
||||
</el-button>
|
||||
<el-button @click="deleteModule(index)" icon="Delete" danger>
|
||||
</el-button>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="dialog-footer">
|
||||
<button class="cancel-btn" @click="showSettingDialog = false">取消</button>
|
||||
<button class="confirm-btn" @click="showSettingDialog = false">完成</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
import AllApplications from '@/components/AllApplications.vue';
|
||||
import UserGreeting from '@/views/components/Hello.vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { useStorage } from '@vueuse/core'
|
||||
|
||||
// 响应式数据
|
||||
const businessModules = useStorage('businessModules', [
|
||||
{
|
||||
title: '考勤日历',
|
||||
icon: 'code',
|
||||
link: '/people/calendar'
|
||||
},
|
||||
{
|
||||
title: '系统设置',
|
||||
icon: 'system',
|
||||
link: '/system/menu'
|
||||
},
|
||||
]);
|
||||
const showSettingDialog = ref(false); // 控制弹窗显示
|
||||
|
||||
// 路由实例
|
||||
const router = useRouter();
|
||||
|
||||
// 方法定义
|
||||
const handleLink = (link) => {
|
||||
if (link.startsWith('http') || link.endsWith('.html')) {
|
||||
window.open(link, '_blank');
|
||||
} else {
|
||||
router.push(link);
|
||||
}
|
||||
};
|
||||
|
||||
const handleAddFavorites = (appInfo) => {
|
||||
// 检查是否已经存在,如果已经存在就移除,否则添加
|
||||
const index = businessModules.value.findIndex(module => module.link === appInfo.fullPath)
|
||||
if (index !== -1) {
|
||||
businessModules.value.splice(index, 1)
|
||||
} else {
|
||||
businessModules.value.push({
|
||||
title: appInfo.child.meta.title,
|
||||
icon: appInfo.child.meta.icon,
|
||||
link: appInfo.fullPath
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
// 移动模块位置(排序功能)
|
||||
const moveModule = (index, direction) => {
|
||||
// 创建副本避免直接修改源数组导致的响应式问题
|
||||
const newModules = [...businessModules.value];
|
||||
// 上移:与前一个元素交换位置
|
||||
if (direction === 'up' && index > 0) {
|
||||
[newModules[index], newModules[index - 1]] = [newModules[index - 1], newModules[index]];
|
||||
}
|
||||
// 下移:与后一个元素交换位置
|
||||
if (direction === 'down' && index < newModules.length - 1) {
|
||||
[newModules[index], newModules[index + 1]] = [newModules[index + 1], newModules[index]];
|
||||
}
|
||||
// 更新响应式数据
|
||||
businessModules.value = newModules;
|
||||
};
|
||||
|
||||
// 删除模块
|
||||
const deleteModule = (index) => {
|
||||
if (confirm('确定要移除该常用应用吗?')) {
|
||||
businessModules.value.splice(index, 1);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
Reference in New Issue
Block a user