1
0
mirror of https://github.com/zclzone/vue-naive-admin.git synced 2025-04-30 22:29:01 +08:00

feat(guide): 添加操作指引 (#106)

* fix(slot): 优化部分slot写法,减少手动判断

* fix(slot): 优化部分slot写法,减少手动判断

* feat(guide): 添加操作指引
This commit is contained in:
leip247 2024-11-22 15:47:00 +08:00 committed by GitHub
parent 6af6eb3c99
commit 6563797afc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 154 additions and 6 deletions

View File

@ -48,7 +48,8 @@
"unplugin-vue-components": "^0.27.4",
"vite": "^5.4.9",
"vite-plugin-router-warn": "^1.0.0",
"vite-plugin-vue-devtools": "^7.5.2"
"vite-plugin-vue-devtools": "^7.5.2",
"vue3-intro-step": "^1.0.5"
},
"simple-git-hooks": {
"pre-commit": "pnpm lint-staged"

View File

@ -10,7 +10,7 @@
<div>
<n-tooltip trigger="hover" placement="left">
<template #trigger>
<div class="f-c-c rounded-4 bg-primary p-8" @click="modalRef.open()">
<div id="layout-setting" class="f-c-c rounded-4 bg-primary p-8" @click="modalRef.open()">
<i class="i-fe:settings cursor-pointer bg-white text-20" />
</div>
</template>

View File

@ -2,6 +2,7 @@
<n-tooltip trigger="hover">
<template #trigger>
<n-color-picker
id="theme-setting"
class="mr-16 h-32 w-32"
:value="appStore.primaryColor"
:swatches="primaryColors"

View File

@ -1,5 +1,6 @@
<template>
<i
id="toggleTheme"
class="mr-16 cursor-pointer"
:class="isDark ? 'i-fe:moon' : 'i-fe:sun'"
@click="toggleDark"

View File

@ -0,0 +1,138 @@
<template>
<n-tooltip trigger="hover">
<template #trigger>
<i
class="i-fe:beginner mr-16 cursor-pointer text-20"
@click="show = true"
/>
</template>
操作指引
</n-tooltip>
<Vue3IntroStep
ref="myIntroStep"
v-model:show="show"
class="beginner-guide"
:config="config"
>
<template #prev="{ tipItem, index }">
<NButton type="primary" color="#fff" text-color="#fff" ghost round size="small" @click="prev(tipItem, index)">
上一步
</NButton>
</template>
<template #next="{ tipItem }">
<NButton type="primary" color="#fff" text-color="#fff" ghost round size="small" @click="next(tipItem)">
下一步
</NButton>
</template>
<template #skip>
<NButton type="primary" color="#fff" text-color="#fff" ghost round size="small" @click="skip">
跳过
</NButton>
</template>
<template #done>
<NButton type="primary" color="#fff" text-color="#fff" ghost round size="small" @click="done">
完成
</NButton>
</template>
</Vue3IntroStep>
</template>
<script setup>
import { lStorage } from '@/utils'
import Vue3IntroStep from 'vue3-intro-step'
const myIntroStep = shallowRef(null)
const show = shallowRef(false)
const config = {
backgroundOpacity: 0.8,
titleStyle: {
textAlign: 'left',
fontSize: '18px',
},
contentStyle: {
textAlign: 'left',
fontSize: '14px',
},
tips: [
{
el: '#toggleTheme',
tipPosition: 'bottom',
title: '切换系统主题',
content: '一键开启护眼模式',
},
{
el: '#fullscreen',
tipPosition: 'bottom',
title: '全屏/退出全屏',
content: '一键开启全屏',
},
{
el: '#theme-setting',
tipPosition: 'bottom',
title: '设置主题色',
content: '调整为你喜欢的主题色',
},
{
el: '#user-dropdown',
tipPosition: 'bottom',
title: '个人中心',
content: '查看个人资料和退出系统',
},
{
el: '#menu-collapse',
tipPosition: 'bottom',
title: '展开/收起菜单',
content: '一键展开/收起菜单',
},
{
el: '#top-tab',
tipPosition: 'bottom',
title: '标签栏',
content: '鼠标滚轮滑动可调整至最佳视野',
},
{
el: '#layout-setting',
tipPosition: 'left',
title: '调整系统布局',
content: '将系统布局调整为你喜欢的样子',
},
],
}
onMounted(() => {
if (lStorage.get('beginner-guide') === true)
return
show.value = true
})
function skip() {
lStorage.set('beginner-guide', true)
show.value = false
}
function done() {
lStorage.set('beginner-guide', true)
show.value = false
}
function next() {
// tipItem
// vue3-intro-stepnext
myIntroStep.value.next()
}
function prev() {
// vue3-intro-stepprev
myIntroStep.value.prev()
}
</script>
<style lang="scss" scoped>
.beginner-guide {
.n-button {
margin-right: 12px;
}
}
</style>

View File

@ -1,5 +1,6 @@
<template>
<i
id="fullscreen"
class="mr-16 cursor-pointer"
:class="isFullscreen ? 'i-fe:minimize' : 'i-fe:maximize'"
@click="toggle"

View File

@ -8,6 +8,7 @@
<template>
<div
id="menu-collapse"
class="f-c-c cursor-pointer rounded-4 p-6 text-22 transition-all-300 auto-bg-hover"
@click="appStore.switchCollapsed"
>

View File

@ -8,7 +8,7 @@
<template>
<n-dropdown :options="options" @select="handleSelect">
<div class="flex cursor-pointer items-center">
<div id="user-dropdown" class="flex cursor-pointer items-center">
<n-avatar round :size="36" :src="userStore.avatar" />
<div v-if="userStore.userInfo" class="ml-12 flex-col flex-shrink-0 items-center">
<span class="text-14">{{ userStore.nickName ?? userStore.username }}</span>

View File

@ -1,3 +1,4 @@
export { default as BeginnerGuide } from './BeginnerGuide.vue'
export { default as BreadCrumb } from './BreadCrumb.vue'
export { default as Fullscreen } from './Fullscreen.vue'
export { default as MenuCollapse } from './MenuCollapse.vue'

View File

@ -7,7 +7,7 @@
--------------------------------->
<template>
<div>
<div id="top-tab">
<n-tabs
:value="tabStore.activeTab"
:closable="tabStore.tabs.length > 1"

View File

@ -13,6 +13,8 @@
<BreadCrumb />
<div class="ml-auto flex flex-shrink-0 items-center px-12 text-18">
<BeginnerGuide />
<ToggleTheme />
<Fullscreen />
@ -35,7 +37,7 @@
<script setup>
import { ToggleTheme } from '@/components'
import { BreadCrumb, Fullscreen, MenuCollapse, UserAvatar } from '@/layouts/components'
import { BeginnerGuide, BreadCrumb, Fullscreen, MenuCollapse, UserAvatar } from '@/layouts/components'
function handleLinkClick(link) {
window.open(link)

View File

@ -15,6 +15,8 @@
<span class="mx-6 opacity-20">|</span>
<div class="flex flex-shrink-0 items-center px-12 text-18">
<BeginnerGuide />
<ToggleTheme />
<Fullscreen />
@ -37,7 +39,7 @@
<script setup>
import { ToggleTheme } from '@/components'
import { AppTab, Fullscreen, MenuCollapse, UserAvatar } from '@/layouts/components'
import { AppTab, BeginnerGuide, Fullscreen, MenuCollapse, UserAvatar } from '@/layouts/components'
function handleLinkClick(link) {
window.open(link)