Skip to content

Commit

Permalink
Fix: 主题首次切换不生效
Browse files Browse the repository at this point in the history
Style: 调整主题文件结构
  • Loading branch information
Maorey committed Dec 15, 2019
1 parent 51fd0ef commit 54e19b6
Show file tree
Hide file tree
Showing 15 changed files with 72 additions and 29 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "vue-tpl",
"author": "毛瑞 <[email protected]>",
"version": "0.3.0",
"version": "0.3.1",
"private": false,
"license": "MIT",
"keywords": [
Expand Down
26 changes: 13 additions & 13 deletions src/pages/index/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,19 @@ export default class extends Vue {
}
</script>

<style lang="scss">
/// 全局样式 ///
@import '~@/scss/reset';
@import '~@/scss/icon';
@import '~@/scss/transitions';

html,
body {
height: 100%;
overflow: hidden;
}
</style>

<style lang="scss" module>
.nav {
position: absolute;
Expand Down Expand Up @@ -160,16 +173,3 @@ export default class extends Vue {
right: 5px;
}
</style>

<style lang="scss">
/// 全局样式 ///
@import '~@/scss/reset';
@import '~@/scss/icon';
@import '~@/scss/transitions';

html,
body {
height: 100%;
overflow: hidden;
}
</style>
44 changes: 44 additions & 0 deletions src/pages/other/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@
-->
<template>
<body :class="$style.wrapper">
<div :class="$style.skin">
<ElLink
v-for="item in SKIN"
:key="item.name"
:type="item.type"
:disabled="skin === item.name"
icon="el-icon-magic-stick"
@click="skin = item.name"
/>
</div>
<div :class="$style.nav">
<RouterLink to="/home">
Home
Expand Down Expand Up @@ -160,6 +170,30 @@
</body>
</template>

<script lang="ts">
import { Component, Vue } from 'vue-property-decorator'

import statePrefer from '@other/store/modules/prefer'

@Component
export default class extends Vue {
get SKIN() {
return [
{ name: 'light', type: 'danger' },
{ name: 'dark', type: 'primary' },
]
}

get skin() {
return statePrefer.skin
}

set skin(skin: string) {
statePrefer.setSkin(skin)
}
}
</script>

<style lang="scss" module>
.wrapper {
color: $colorTextCommon;
Expand All @@ -178,4 +212,14 @@
}
}
}

.skin {
position: absolute;
top: 5px;
right: 5px;

:global(.el-link) {
font-size: $large;
}
}
</style>
1 change: 0 additions & 1 deletion src/pages/other/theme/_colors.scss

This file was deleted.

1 change: 0 additions & 1 deletion src/pages/other/theme/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@
* @Author: 毛瑞
* @Date: 2019-07-23 20:46:21
*/
@import './colors';
@import './element';
12 changes: 6 additions & 6 deletions src/theme/dark/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
*/
/// 变量 (私有变量 _+camelCase)///
@import './colors'; // 颜色 【colorCase】: colorRed
@import '../light/border'; // 边框 【(border|shadow)Case】: borderSolidWidth
@import '../light/fontSIzes'; // 字号 【cssCase】: xSmaller、xxxLarge
@import '../light/zIndexes'; // z-index层级划分 【zCase】: zMessage
@import '../light/layout'; // 固定布局尺寸 【(height|width)Case】: heightHeader、widthLfetColumn
@import '../light/scrollBar'; // 滚动条变量 【scrollBarCase】
@import '../light/icon'; // 字体图标变量 【iconCase】
@import '../parts/border'; // 边框 【(border|shadow)Case】: borderSolidWidth
@import '../parts/fontSIzes'; // 字号 【cssCase】: xSmaller、xxxLarge
@import '../parts/zIndexes'; // z-index层级划分 【zCase】: zMessage
@import '../parts/layout'; // 固定布局尺寸 【(height|width)Case】: heightHeader、widthLfetColumn
@import '../parts/scrollBar'; // 滚动条变量 【scrollBarCase】
@import '../parts/icon'; // 字体图标变量 【iconCase】

/* ---------------------- 我是一条分割线 (灬°ω°灬) ---------------------- */

Expand Down
14 changes: 7 additions & 7 deletions src/theme/light/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
* @Date: 2019-06-19 11:34:44
*/
/// 变量 (私有变量 _+camelCase)///
@import './colors'; // 颜色 【colorCase】: colorRed
@import './border'; // 边框 【(border|shadow)Case】: borderSolidWidth
@import './fontSIzes'; // 字号 【cssCase】: xSmaller、xxxLarge
@import './zIndexes'; // z-index层级划分 【zCase】: zMessage
@import './layout'; // 固定布局尺寸 【(height|width)Case】: heightHeader、widthLfetColumn
@import './scrollBar'; // 滚动条变量 【scrollBarCase】
@import './icon'; // 字体图标变量 【iconCase】
@import '../parts/colors'; // 颜色 【colorCase】: colorRed
@import '../parts/border'; // 边框 【(border|shadow)Case】: borderSolidWidth
@import '../parts/fontSIzes'; // 字号 【cssCase】: xSmaller、xxxLarge
@import '../parts/zIndexes'; // z-index层级划分 【zCase】: zMessage
@import '../parts/layout'; // 固定布局尺寸 【(height|width)Case】: heightHeader、widthLfetColumn
@import '../parts/scrollBar'; // 滚动条变量 【scrollBarCase】
@import '../parts/icon'; // 字体图标变量 【iconCase】

/* ---------------------- 我是一条分割线 (灬°ω°灬) ---------------------- */

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions src/utils/skin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ function set(skin?: string) {
/// 切换样式 ///
let el
for (el of document.querySelectorAll<HTMLLinkElement>('link[title]')) {
el.disabled = true // 必须先disabled下
el.disabled = el.title !== skin
}

Expand Down

0 comments on commit 54e19b6

Please sign in to comment.