Skip to content

Commit 839b601

Browse files
feat(Layout): Add classic layout
1 parent 958edef commit 839b601

File tree

26 files changed

+630
-145
lines changed

26 files changed

+630
-145
lines changed

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@
1414
"i18n-ally.enabledParsers": ["ts"],
1515
"i18n-ally.sourceLanguage": "en",
1616
"i18n-ally.displayLanguage": "zh-CN",
17-
"i18n-ally.enabledFrameworks": ["vue", "react"]
17+
"i18n-ally.enabledFrameworks": ["vue", "react"],
18+
"god.tsconfig": "./tsconfig.json"
1819
}

src/App.vue

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import { isDark } from '@/utils/is'
66
77
const appStore = useAppStore()
88
9-
const size = computed(() => appStore.size)
9+
const currentSize = computed(() => appStore.getCurrentSize)
10+
11+
const greyMode = computed(() => appStore.getGreyMode)
1012
1113
const initDark = () => {
1214
const isDarkTheme = isDark()
@@ -17,12 +19,14 @@ initDark()
1719
</script>
1820

1921
<template>
20-
<ConfigGlobal :size="size">
21-
<RouterView />
22+
<ConfigGlobal :size="currentSize">
23+
<RouterView :class="{ 'v-grey__mode': greyMode }" />
2224
</ConfigGlobal>
2325
</template>
2426

2527
<style lang="less">
28+
@prefix-cls: ~'@{namespace}-grey';
29+
2630
.size {
2731
width: 100%;
2832
height: 100%;
@@ -39,4 +43,13 @@ body {
3943
.size;
4044
}
4145
}
46+
47+
.@{prefix-cls}__mode {
48+
-webkit-filter: grayscale(100%);
49+
-moz-filter: grayscale(100%);
50+
-ms-filter: grayscale(100%);
51+
-o-filter: grayscale(100%);
52+
filter: grayscale(100%);
53+
filter: progid:dximagetransform.microsoft.basicimage(grayscale=1);
54+
}
4255
</style>

src/components/Breadcrumb/src/Breadcrumb.vue

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,18 @@
22
import { ElBreadcrumb, ElBreadcrumbItem } from 'element-plus'
33
import { ref, watch, computed, unref, defineComponent, TransitionGroup } from 'vue'
44
import { useRouter } from 'vue-router'
5-
// import { compile } from 'path-to-regexp'
65
import { usePermissionStore } from '@/store/modules/permission'
76
import { filterBreadcrumb } from './helper'
87
import { filter, treeToList } from '@/utils/tree'
98
import type { RouteLocationNormalizedLoaded, RouteMeta } from 'vue-router'
109
import { useI18n } from '@/hooks/web/useI18n'
1110
import { Icon } from '@/components/Icon'
11+
import { useAppStore } from '@/store/modules/app'
12+
13+
const appStore = useAppStore()
14+
15+
// 面包屑图标
16+
const breadcrumbIcon = computed(() => appStore.getBreadcrumbIcon)
1217
1318
export default defineComponent({
1419
name: 'Breadcrumb',
@@ -41,7 +46,7 @@ export default defineComponent({
4146
const meta = v.meta as RouteMeta
4247
return (
4348
<ElBreadcrumbItem to={{ path: disabled ? '' : v.path }} key={v.name}>
44-
{meta?.icon ? (
49+
{meta?.icon && breadcrumbIcon.value ? (
4550
<>
4651
<Icon icon={meta.icon} class="mr-[5px]"></Icon> {t(v?.meta?.title)}
4752
</>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import ColorRadioPicker from './src/ColorRadioPicker.vue'
2+
3+
export { ColorRadioPicker }
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<script setup lang="ts">
2+
import { PropType, watch, unref, ref } from 'vue'
3+
import { propTypes } from '@/utils/propTypes'
4+
5+
const props = defineProps({
6+
schema: {
7+
type: Array as PropType<string[]>,
8+
default: () => []
9+
},
10+
modelValue: propTypes.string.def('')
11+
})
12+
13+
const emit = defineEmits(['update:modelValue', 'change'])
14+
15+
const colorVal = ref(props.modelValue)
16+
17+
watch(
18+
() => props.modelValue,
19+
(val: string) => {
20+
if (val === unref(colorVal)) return
21+
colorVal.value = val
22+
}
23+
)
24+
25+
// 监听
26+
watch(
27+
() => colorVal.value,
28+
(val: string) => {
29+
emit('update:modelValue', val)
30+
emit('change', val)
31+
}
32+
)
33+
</script>
34+
35+
<template>
36+
<div class="v-color-radio-picker flex flex-wrap space-x-14px">
37+
<span
38+
v-for="(item, i) in schema"
39+
:key="`radio-${i}`"
40+
class="v-color-radio-picker w-20px h-20px cursor-pointer rounded-2px border-solid border-gray-300 border-2px text-center leading-20px mb-5px"
41+
:class="{ 'is-active': colorVal === item }"
42+
:style="{
43+
background: item
44+
}"
45+
@click="colorVal = item"
46+
>
47+
<Icon v-if="colorVal === item" color="#fff" icon="ep:check" :size="16" />
48+
</span>
49+
</div>
50+
</template>
51+
52+
<style lang="less" scoped>
53+
@prefix-cls: ~'@{namespace}-color-radio-picker';
54+
55+
.@{prefix-cls} {
56+
.is-active {
57+
border-color: var(--el-color-primary);
58+
}
59+
}
60+
</style>

src/components/ConfigGlobal/src/ConfigGlobal.vue

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script setup lang="ts">
2-
import { provide, computed, watch } from 'vue'
2+
import { provide, computed, watch, onMounted } from 'vue'
33
import { propTypes } from '@/utils/propTypes'
44
import { ElConfigProvider } from 'element-plus'
55
import { useLocaleStore } from '@/store/modules/locale'
@@ -9,8 +9,20 @@ import { setCssVar } from '@/utils'
99
1010
const appStore = useAppStore()
1111
12+
const props = defineProps({
13+
size: propTypes.oneOf<ElememtPlusSzie[]>(['default', 'small', 'large']).def('default')
14+
})
15+
16+
provide('configGlobal', props)
17+
18+
// 初始化所有主题色
19+
onMounted(() => {
20+
appStore.setCssVarTheme()
21+
})
22+
1223
const { width } = useWindowSize()
1324
25+
// 监听窗口变化
1426
watch(
1527
() => width.value,
1628
(width: number) => {
@@ -29,19 +41,14 @@ watch(
2941
}
3042
)
3143
44+
// 多语言相关
3245
const localeStore = useLocaleStore()
3346
34-
const locale = computed(() => localeStore.locale)
35-
36-
const props = defineProps({
37-
size: propTypes.oneOf<ElememtPlusSzie[]>(['default', 'small', 'large']).def('default')
38-
})
39-
40-
provide('configGlobal', props)
47+
const currentLocale = computed(() => localeStore.currentLocale)
4148
</script>
4249

4350
<template>
44-
<ElConfigProvider :locale="locale.elLocale" :message="{ max: 1 }" :size="size">
51+
<ElConfigProvider :locale="currentLocale.elLocale" :message="{ max: 1 }" :size="size">
4552
<slot></slot>
4653
</ElConfigProvider>
4754
</template>

src/components/LocaleDropdown/src/LocaleDropdown.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ const localeStore = useLocaleStore()
88
99
const langMap = computed(() => localeStore.getLocaleMap)
1010
11-
const currentLang = computed(() => localeStore.getLocale)
11+
const currentLang = computed(() => localeStore.getCurrentLocale)
1212
1313
const setLang = (lang: LocaleType) => {
1414
if (lang === unref(currentLang).lang) return
1515
// 需要重新加载页面让整个语言多初始化
1616
window.location.reload()
17-
localeStore.setLocale({
17+
localeStore.setCurrentLocale({
1818
lang
1919
})
2020
const { changeLocale } = useLocale()

src/components/Logo/src/Logo.vue

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script setup lang="ts">
2-
import { ref, watch, computed } from 'vue'
2+
import { ref, watch, computed, onMounted, unref } from 'vue'
33
import { useAppStore } from '@/store/modules/app'
44
55
const appStore = useAppStore()
@@ -12,6 +12,10 @@ const layout = computed(() => appStore.getLayout)
1212
1313
const collapse = computed(() => appStore.getCollapse)
1414
15+
onMounted(() => {
16+
if (unref(collapse)) show.value = false
17+
})
18+
1519
watch(
1620
() => collapse.value,
1721
(collapse: boolean) => {
@@ -37,7 +41,7 @@ watch(
3741
{
3842
'v-logo__Top': layout !== 'classic'
3943
},
40-
'flex h-[var(--logo-height)] items-center cursor-pointer pl-8px'
44+
'flex h-[var(--logo-height)] items-center cursor-pointer pl-8px relative'
4145
]"
4246
to="/"
4347
>
@@ -50,3 +54,18 @@ watch(
5054
}}</div>
5155
</router-link>
5256
</template>
57+
58+
<style lang="less" scoped>
59+
@prefix-cls: ~'@{namespace}-logo';
60+
61+
.@{prefix-cls} {
62+
&:after {
63+
position: absolute;
64+
right: 0;
65+
bottom: 0;
66+
width: 100%;
67+
border-bottom: 1px solid var(--logo-border-color);
68+
content: '';
69+
}
70+
}
71+
</style>

src/components/Menu/src/Menu.vue

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ export default defineComponent({
1414
setup() {
1515
const appStore = useAppStore()
1616
17+
// logo
18+
const logo = computed(() => appStore.logo)
19+
1720
const { push, currentRoute } = useRouter()
1821
1922
const permissionStore = usePermissionStore()
@@ -61,8 +64,8 @@ export default defineComponent({
6164
'bg-[var(--left-menu-bg-color)]'
6265
]}
6366
>
64-
<Logo></Logo>
65-
<ElScrollbar class={[{ '!h-[calc(100%-var(--top-tool-height))]': true }]}>
67+
{logo.value ? <Logo></Logo> : undefined}
68+
<ElScrollbar class={[{ '!h-[calc(100%-var(--logo-height))]': logo.value }]}>
6669
<ElMenu
6770
defaultActive={unref(activeMenu)}
6871
mode={unref(menuMode)}
@@ -89,9 +92,28 @@ export default defineComponent({
8992
<style lang="less" scoped>
9093
@prefix-cls: ~'@{namespace}-menu';
9194
95+
.is-active--after {
96+
position: absolute;
97+
top: 0;
98+
right: 0;
99+
width: 4px;
100+
height: 100%;
101+
background-color: var(--el-color-primary);
102+
content: '';
103+
}
104+
92105
.@{prefix-cls} {
93106
transition: width var(--transition-time-02);
94107
108+
&:after {
109+
position: absolute;
110+
top: 0;
111+
right: 0;
112+
height: 100%;
113+
border-left: 1px solid var(--left-menu-border-color);
114+
content: '';
115+
}
116+
95117
:deep(.el-menu) {
96118
width: 100% !important;
97119
border-right: none;
@@ -123,6 +145,14 @@ export default defineComponent({
123145
}
124146
}
125147
148+
.el-menu-item.is-active {
149+
position: relative;
150+
151+
&:after {
152+
.is-active--after;
153+
}
154+
}
155+
126156
// 设置子菜单的背景颜色
127157
.el-menu {
128158
.el-sub-menu__title,
@@ -138,7 +168,12 @@ export default defineComponent({
138168
139169
& > .is-active,
140170
& > .is-active > .el-sub-menu__title {
171+
position: relative;
141172
background-color: var(--left-menu-collapse-bg-active-color) !important;
173+
174+
&:after {
175+
.is-active--after;
176+
}
142177
}
143178
}
144179
@@ -155,6 +190,16 @@ export default defineComponent({
155190
<style lang="less">
156191
@prefix-cls: ~'@{namespace}-menu-popper';
157192
193+
.is-active--after {
194+
position: absolute;
195+
top: 0;
196+
right: 0;
197+
width: 4px;
198+
height: 100%;
199+
background-color: var(--el-color-primary);
200+
content: '';
201+
}
202+
158203
.@{prefix-cls} {
159204
&--vertical {
160205
// 设置选中时子标题的颜色
@@ -175,11 +220,16 @@ export default defineComponent({
175220
176221
// 设置选中时的高亮背景
177222
.el-menu-item.is-active {
223+
position: relative;
178224
background-color: var(--left-menu-bg-active-color) !important;
179225
180226
&:hover {
181227
background-color: var(--left-menu-bg-active-color) !important;
182228
}
229+
230+
&:after {
231+
.is-active--after;
232+
}
183233
}
184234
}
185235
}

0 commit comments

Comments
 (0)