Skip to content

Commit 0572884

Browse files
committed
Style: 主题文件分离
1 parent 0672db3 commit 0572884

File tree

8 files changed

+48
-68
lines changed

8 files changed

+48
-68
lines changed

build/themeLoader.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ module.exports.pitch = function() {
149149
locals += theme + ','
150150
}
151151

152-
return `${resultSource}\nlet locals\n${first} && Object.keys(${first}).length && (locals = getOb({${locals}}))\nexport default locals`
152+
return `${resultSource}\nlet locals\n${first} && (locals = getOb({${locals}}))\nexport default locals`
153153
}
154154
/// 其他 ///
155155
module.exports.init = init

src/pages/index/App.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export default class extends Vue {
9393
}
9494

9595
set theme(theme: string) {
96-
statePrefer.setSkin(theme)
96+
statePrefer.setTheme(theme)
9797
}
9898
}
9999
</script>

src/pages/other/App.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ export default class extends Vue {
189189
}
190190

191191
set theme(theme: string) {
192-
statePrefer.setSkin(theme)
192+
statePrefer.setTheme(theme)
193193
}
194194
}
195195
</script>

src/store/prefer.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class Prefer extends VuexModule implements IPrefer {
4545
* @param {String} theme 皮肤名
4646
*/
4747
@Action
48-
setSkin(theme: string) {
48+
setTheme(theme: string) {
4949
this.context.commit('THEME', theme)
5050
}
5151

src/theme/dark/index.scss

+3-32
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*
1+
/** 深色主题
22
* @Description: 全局scss变量
33
* 【此文件中请勿出现具体样式,否则会打包到!所有!css chunk中】
44
* 【在此文件中导出的变量会混合到!所有!scss的导出中】
@@ -16,36 +16,7 @@
1616
@import '../parts/icon'; // 字体图标变量 【iconCase】
1717

1818
/* ---------------------- 我是一条分割线 (灬°ω°灬) ---------------------- */
19-
20-
/// 扩展(@extend %ellipsis;) ///
21-
22-
// 单行文本溢出省略号
23-
%ellipsis {
24-
overflow: hidden;
25-
white-space: nowrap;
26-
text-overflow: ellipsis;
27-
}
28-
29-
// 在页面居中【需要指定高宽】
30-
%centerPage {
31-
position: absolute;
32-
top: 0;
33-
right: 0;
34-
bottom: 0;
35-
left: 0;
36-
margin: auto;
37-
}
19+
@import '../parts/extend'; // 扩展 @extend %{var};
3820

3921
/* ---------------------- 我也是一条分割线 (*❦ω❦) ---------------------- */
40-
41-
/// 混入(@include name(args);) ///
42-
43-
// 多行溢出省略号(-webkit-有效,其它截断) 参数为行数
44-
@mixin ellipsis($clamp) {
45-
// -webkit-多行溢出省略号
46-
-webkit-box-orient: vertical; /* stylelint-disable-line property-no-vendor-prefix */
47-
-webkit-line-clamp: $clamp;
48-
display: -webkit-box; /* stylelint-disable-line value-no-vendor-prefix */
49-
overflow: hidden;
50-
word-break: break-word;
51-
}
22+
@import '../parts/mixin'; // 混入@include name(args);

src/theme/light/index.scss

+3-32
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*
1+
/** 浅色主题
22
* @Description: 全局scss变量
33
* 【此文件中请勿出现具体样式,否则会打包到!所有!css chunk中】
44
* 【在此文件中导出的变量会混合到!所有!scss的导出中】
@@ -16,36 +16,7 @@
1616
@import '../parts/icon'; // 字体图标变量 【iconCase】
1717

1818
/* ---------------------- 我是一条分割线 (灬°ω°灬) ---------------------- */
19-
20-
/// 扩展(@extend %ellipsis;) ///
21-
22-
// 单行文本溢出省略号
23-
%ellipsis {
24-
overflow: hidden;
25-
white-space: nowrap;
26-
text-overflow: ellipsis;
27-
}
28-
29-
// 在页面居中【需要指定高宽】
30-
%centerPage {
31-
position: absolute;
32-
top: 0;
33-
right: 0;
34-
bottom: 0;
35-
left: 0;
36-
margin: auto;
37-
}
19+
@import '../parts/extend'; // 扩展 @extend %{var};
3820

3921
/* ---------------------- 我也是一条分割线 (*❦ω❦) ---------------------- */
40-
41-
/// 混入(@include name(args);) ///
42-
43-
// 多行溢出省略号(-webkit-有效,其它截断) 参数为行数
44-
@mixin ellipsis($clamp) {
45-
// -webkit-多行溢出省略号
46-
-webkit-box-orient: vertical; /* stylelint-disable-line property-no-vendor-prefix */
47-
-webkit-line-clamp: $clamp;
48-
display: -webkit-box; /* stylelint-disable-line value-no-vendor-prefix */
49-
overflow: hidden;
50-
word-break: break-word;
51-
}
22+
@import '../parts/mixin'; // 混入@include name(args);

src/theme/parts/_extend.scss

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/// 扩展(@extend %ellipsis;) ///
2+
3+
// 单行文本溢出省略号
4+
%ellipsis {
5+
overflow: hidden;
6+
white-space: nowrap;
7+
text-overflow: ellipsis;
8+
}
9+
10+
// 在页面居中【需要指定高宽】
11+
%centerPage {
12+
position: absolute;
13+
top: 0;
14+
right: 0;
15+
bottom: 0;
16+
left: 0;
17+
margin: auto;
18+
}

src/theme/parts/_mixin.scss

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/// 混入(@include name(args);) ///
2+
3+
// 多行溢出省略号(-webkit-有效,其它截断) 参数为行数
4+
@mixin ellipsis($clamp) {
5+
// -webkit-多行溢出省略号
6+
-webkit-box-orient: vertical; /* stylelint-disable-line property-no-vendor-prefix */
7+
-webkit-line-clamp: $clamp;
8+
display: -webkit-box; /* stylelint-disable-line value-no-vendor-prefix */
9+
overflow: hidden;
10+
word-break: break-word;
11+
}
12+
13+
// 清除浮动
14+
@mixin clear($float: both) {
15+
&::after {
16+
display: block;
17+
clear: $float;
18+
content: '';
19+
}
20+
}

0 commit comments

Comments
 (0)