style: use unocss rewrite css

This commit is contained in:
张传龙 2022-07-14 18:05:47 +08:00
parent d10b8f0e96
commit 5856f601fa
16 changed files with 51 additions and 93 deletions

View File

@ -9,12 +9,3 @@
<script setup> <script setup>
import AppProvider from '@/components/common/AppProvider.vue' import AppProvider from '@/components/common/AppProvider.vue'
</script> </script>
<style lang="scss">
#app {
height: 100%;
.n-config-provider {
height: inherit;
}
}
</style>

View File

@ -1,5 +1,5 @@
<template> <template>
<n-config-provider :theme-overrides="themStore.naiveThemeOverrides"> <n-config-provider wh-full :theme-overrides="themStore.naiveThemeOverrides">
<n-loading-bar-provider> <n-loading-bar-provider>
<n-dialog-provider> <n-dialog-provider>
<n-notification-provider> <n-notification-provider>

View File

@ -15,7 +15,8 @@
:class="{ overflow: isOverflow && showArrow }" :class="{ overflow: isOverflow && showArrow }"
:style="{ :style="{
transform: `translateX(${translateX}px)`, transform: `translateX(${translateX}px)`,
}"> }"
>
<slot /> <slot />
</div> </div>
</div> </div>

View File

@ -1,5 +1,5 @@
<template> <template>
<n-icon mr20 size="18" style="cursor: pointer" @click="handleLinkClick"> <n-icon mr-20 size="18" style="cursor: pointer" @click="handleLinkClick">
<icon-mdi:github /> <icon-mdi:github />
</n-icon> </n-icon>
</template> </template>
@ -9,5 +9,3 @@ function handleLinkClick() {
window.open('https://github.com/zclzone/vue-naive-admin') window.open('https://github.com/zclzone/vue-naive-admin')
} }
</script> </script>
<style lang="scss" scoped></style>

View File

@ -1,5 +1,5 @@
<template> <template>
<n-icon size="20" style="cursor: pointer" @click="appStore.switchCollapsed"> <n-icon size="20" cursor-pointer @click="appStore.switchCollapsed">
<icon-mdi:format-indent-increase v-if="appStore.collapsed" /> <icon-mdi:format-indent-increase v-if="appStore.collapsed" />
<icon-mdi:format-indent-decrease v-else /> <icon-mdi:format-indent-decrease v-else />
</n-icon> </n-icon>

View File

@ -1,7 +1,7 @@
<template> <template>
<n-dropdown :options="options" @select="handleSelect"> <n-dropdown :options="options" @select="handleSelect">
<div class="avatar"> <div flex items-center cursor-pointer>
<img :src="userStore.avatar" /> <img :src="userStore.avatar" mr10 w-35 h-35 rounded-full />
<span>{{ userStore.name }}</span> <span>{{ userStore.name }}</span>
</div> </div>
</n-dropdown> </n-dropdown>
@ -35,18 +35,3 @@ function handleSelect(key) {
} }
} }
</script> </script>
<style lang="scss" scoped>
.avatar {
display: flex;
align-items: center;
cursor: pointer;
img {
width: 100%;
width: 35px;
height: 35px;
border-radius: 50%;
margin-right: 10px;
}
}
</style>

View File

@ -1,10 +1,10 @@
<template> <template>
<header class="header"> <header px-15 h-full flex items-center>
<div class="h-left"> <div flex items-center>
<MenuCollapse /> <MenuCollapse />
<BreadCrumb ml-15 /> <BreadCrumb ml-15 />
</div> </div>
<div class="h-right"> <div ml-auto flex items-center>
<GithubSite /> <GithubSite />
<FullScreen /> <FullScreen />
<UserAvatar /> <UserAvatar />
@ -19,21 +19,3 @@ import FullScreen from './components/FullScreen.vue'
import UserAvatar from './components/UserAvatar.vue' import UserAvatar from './components/UserAvatar.vue'
import GithubSite from './components/GithubSite.vue' import GithubSite from './components/GithubSite.vue'
</script> </script>
<style lang="scss" scoped>
.header {
padding: 0 15px;
height: 100%;
display: flex;
align-items: center;
justify-content: space-between;
.h-left {
display: flex;
align-items: center;
}
.h-right {
display: flex;
align-items: center;
}
}
</style>

View File

@ -7,7 +7,8 @@
:collapsed-width="64" :collapsed-width="64"
:options="menuOptions" :options="menuOptions"
:value="(currentRoute.meta && currentRoute.meta.activeMenu) || currentRoute.name" :value="(currentRoute.meta && currentRoute.meta.activeMenu) || currentRoute.name"
@update:value="handleMenuSelect" /> @update:value="handleMenuSelect"
/>
</template> </template>
<script setup> <script setup>

View File

@ -6,7 +6,8 @@
:y="y" :y="y"
placement="bottom-start" placement="bottom-start"
@clickoutside="handleHideDropdown" @clickoutside="handleHideDropdown"
@select="handleSelect" /> @select="handleSelect"
/>
</template> </template>
<script setup> <script setup>

View File

@ -3,11 +3,13 @@
<n-tag <n-tag
v-for="tag in tagsStore.tags" v-for="tag in tagsStore.tags"
:key="tag.path" :key="tag.path"
class="px-15 mx-5 cursor-pointer hover:color-primary"
:type="tagsStore.activeTag === tag.path ? 'primary' : 'default'" :type="tagsStore.activeTag === tag.path ? 'primary' : 'default'"
:closable="tagsStore.tags.length > 1" :closable="tagsStore.tags.length > 1"
@click="handleTagClick(tag.path)" @click="handleTagClick(tag.path)"
@close.stop="tagsStore.removeTag(tag.path)" @close.stop="tagsStore.removeTag(tag.path)"
@contextmenu.prevent="handleContextMenu($event, tag)"> @contextmenu.prevent="handleContextMenu($event, tag)"
>
{{ tag.title }} {{ tag.title }}
</n-tag> </n-tag>
</ScrollX> </ScrollX>
@ -16,7 +18,8 @@
v-model:show="contextMenuOption.show" v-model:show="contextMenuOption.show"
:current-path="contextMenuOption.currentPath" :current-path="contextMenuOption.currentPath"
:x="contextMenuOption.x" :x="contextMenuOption.x"
:y="contextMenuOption.y" /> :y="contextMenuOption.y"
/>
</template> </template>
<script setup name="Tags"> <script setup name="Tags">
@ -73,24 +76,16 @@ async function handleContextMenu(e, tagItem) {
</script> </script>
<style lang="scss"> <style lang="scss">
.n-tag { .n-tag__close {
padding: 0 15px; margin-left: 5px;
margin: 0 5px; box-sizing: content-box;
cursor: pointer; font-size: 12px;
.n-tag__close { padding: 2px;
margin-left: 5px; border-radius: 50%;
box-sizing: content-box; transition: all 0.7s;
font-size: 12px;
padding: 2px;
border-radius: 50%;
transition: all 0.7s;
&:hover {
color: #fff;
background-color: var(--primaryColor);
}
}
&:hover { &:hover {
color: var(--primaryColor); color: #fff;
background-color: var(--primaryColor);
} }
} }
</style> </style>

View File

@ -1,27 +1,29 @@
<template> <template>
<n-layout has-sider style="height: 100%"> <n-layout has-sider h-full>
<n-layout-sider <n-layout-sider
bordered bordered
collapse-mode="width" collapse-mode="width"
:collapsed-width="64" :collapsed-width="64"
:width="220" :width="220"
:native-scrollbar="false" :native-scrollbar="false"
:collapsed="appStore.collapsed"> :collapsed="appStore.collapsed"
>
<SideBar /> <SideBar />
</n-layout-sider> </n-layout-sider>
<n-layout> <n-layout>
<n-layout-header :style="{ height: useTheme.header.height + 'px' }"> <n-layout-header bg-white border-b bc-eee :style="`height: ${useTheme.header.height ?? 60}px`">
<AppHeader /> <AppHeader />
</n-layout-header> </n-layout-header>
<n-layout style="background-color: #f5f6fb" :style="`height: calc(100% - ${useTheme.header.height}px)`"> <n-layout bg="#f5f6fb" :style="`height: calc(100% - ${useTheme.header.height ?? 60}px)`">
<AppTags v-if="useTheme.tags.visible" /> <AppTags v-if="useTheme.tags.visible" />
<AppMain <AppMain
class="cur-scroll border-t bc-eee" class="cur-scroll border-t bc-eee"
:style="{ :style="{
height: `calc(100% - ${useTheme.tags.visible ? useTheme.tags.height : 0}px)`, height: `calc(100% - ${useTheme.tags.visible ? useTheme.tags.height ?? 50 : 0}px)`,
overflow: 'auto', overflow: 'auto',
}" /> }"
/>
</n-layout> </n-layout>
</n-layout> </n-layout>
</n-layout> </n-layout>
@ -38,11 +40,3 @@ import { useAppStore } from '@/store/modules/app'
const useTheme = useThemeStore() const useTheme = useThemeStore()
const appStore = useAppStore() const appStore = useAppStore()
</script> </script>
<style lang="scss" scoped>
.n-layout-header {
height: 60px;
background-color: #fff;
border-bottom: 1px solid #eee;
}
</style>

View File

@ -11,6 +11,11 @@ body {
font-family: 'Encode Sans Condensed', sans-serif; font-family: 'Encode Sans Condensed', sans-serif;
} }
#app {
width: 100%;
height: 100%;
}
/* router view transition fade-slide */ /* router view transition fade-slide */
.fade-slide-leave-active, .fade-slide-leave-active,
.fade-slide-enter-active { .fade-slide-enter-active {

View File

@ -36,7 +36,8 @@
class="w-300 flex-shrink-0 mt-10 mb-10 cursor-pointer" class="w-300 flex-shrink-0 mt-10 mb-10 cursor-pointer"
hover:card-shadow hover:card-shadow
title="Vue Naive Admin" title="Vue Naive Admin"
size="small"> size="small"
>
<p op-60>一个基于 Vue3.0ViteNaive UI 的轻量级后台管理模板</p> <p op-60>一个基于 Vue3.0ViteNaive UI 的轻量级后台管理模板</p>
</n-card> </n-card>
<div w-300 h-0></div> <div w-300 h-0></div>

View File

@ -5,7 +5,8 @@
v-model="post.title" v-model="post.title"
class="flex-1 pt-15 pb-15 mr-20 text-20 font-bold color-primary" class="flex-1 pt-15 pb-15 mr-20 text-20 font-bold color-primary"
type="text" type="text"
placeholder="输入文章标题..." /> placeholder="输入文章标题..."
/>
<n-button type="primary" style="width: 80px" :loading="btnLoading" @click="handleSavePost">保存</n-button> <n-button type="primary" style="width: 80px" :loading="btnLoading" @click="handleSavePost">保存</n-button>
</div> </div>
<MdEditor v-model="post.content" style="height: calc(100vh - 220px)" /> <MdEditor v-model="post.content" style="height: calc(100vh - 220px)" />

View File

@ -11,7 +11,8 @@
:columns="columns" :columns="columns"
:pagination="pagination" :pagination="pagination"
:row-key="(row) => row.id" :row-key="(row) => row.id"
@update:checked-row-keys="handleCheck" /> @update:checked-row-keys="handleCheck"
/>
</div> </div>
</template> </template>

View File

@ -16,7 +16,8 @@
autofocus autofocus
class="text-16 items-center h-50 pl-10" class="text-16 items-center h-50 pl-10"
placeholder="admin" placeholder="admin"
:maxlength="20"> :maxlength="20"
>
</n-input> </n-input>
</div> </div>
<div mt-30 w-full max-w-360> <div mt-30 w-full max-w-360>
@ -27,7 +28,8 @@
show-password-on="mousedown" show-password-on="mousedown"
placeholder="123456" placeholder="123456"
:maxlength="20" :maxlength="20"
@keydown.enter="handleLogin" /> @keydown.enter="handleLogin"
/>
</div> </div>
<div mt-20 w-full max-w-360> <div mt-20 w-full max-w-360>