Skip to content

Commit

Permalink
Merge branch 'demo'
Browse files Browse the repository at this point in the history
  • Loading branch information
codercup2 committed Apr 7, 2024
2 parents 2f2ef0f + 1b009d4 commit fefb25f
Show file tree
Hide file tree
Showing 7 changed files with 122 additions and 8 deletions.
7 changes: 5 additions & 2 deletions .stylelintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module.exports = {
'stylelint-config-html/vue',
'stylelint-config-recess-order',
],
plugins: ['stylelint-prettier'],
overrides: [
// 扫描 .vue/html 文件中的<style>标签内的样式
{
Expand All @@ -22,6 +23,7 @@ module.exports = {
],
// 自定义规则
rules: {
'prettier/prettier': true,
// 允许 global 、export 、v-deep等伪类
'selector-pseudo-class-no-unknown': [
true,
Expand All @@ -42,9 +44,10 @@ module.exports = {
ignoreTypes: ['page'],
},
],
'comment-empty-line-before': 'never',
'comment-empty-line-before': 'never', // never|always|always-multi-line|never-multi-line
'custom-property-empty-line-before': 'never',
'no-empty-source': null,
'scss/comment-no-empty': null,
'comment-no-empty': null,
'no-duplicate-selectors': null,
},
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@
"stylelint-config-recommended-vue": "^1.5.0",
"stylelint-config-standard": "^35.0.0",
"stylelint-config-standard-scss": "^12.0.0",
"stylelint-prettier": "^5.0.0",
"terser": "^5.26.0",
"typescript": "^4.9.4",
"unocss": "^0.58.0",
Expand Down
26 changes: 20 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions src/pages.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@
"navigationBarTitleText": "auto import component"
}
},
{
"path": "pages/demo/base/css",
"type": "page",
"layout": "demo",
"style": {
"navigationBarTitleText": "css 格式化问题"
}
},
{
"path": "pages/demo/base/enum",
"type": "page",
Expand Down
Binary file added src/pages/demo/base/css.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions src/pages/demo/base/css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// .test{
// background: #FFF;
// .test1{
// color: #F9FF99;
// }
// }
// 上面的代码在 scss里面格式化是OK的,在Vue里面会有问题

.test {
background: #fff;

.test1 {
color: #f9ff99;
}
}
73 changes: 73 additions & 0 deletions src/pages/demo/base/css.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<route lang="json5" type="page">
{
layout: 'demo',
style: {
navigationBarTitleText: 'css 格式化问题',
},
}
</route>

<template>
<view class="mt-4">
进过多次测试发现,粘贴的css代码块在如下情况时会出现格式化问题:
<view class="ml-4">粘贴的css代码块中类名上面不包含空行(与大小写无关)</view>
<view class="ml-4 text-green-600">1. 中间有空行的,正常,不用处理;</view>
<view class="ml-4 text-red-600">
2. 中间没有空行的,格式化异常,通过 ctrl+Z,ctrl+S 可以搞定
</view>
<image src="./css.png" mode="scaleToFill" class="css-img mt-2" width="688" height="885" />
</view>
</template>

<script lang="ts" setup>
//
</script>

<style lang="scss" scoped>
// 最初的代码如下(版本1)
/*
.test{
background: #FFF;
.test1{
color: #F9FF99;
}
}
*/
// 中间有空行可以正常格式化(版本2)
/*
.test{
background: #FFF;
.test1{
color: #F9FF99;
}
}
*/
// 上面的版本1格式化会变成下面的,错误格式,可以通过 ctrl + z , ctrl + S 解决
// .test {
// background: #fff;
// t1{fff
// color: #F9FF99;
// }
// }
// 上面的版本2格式化会变成下面的,正常
.test {
background: #fff;
.test1 {
color: #f9ff99;
}
}
// 下面是图片的样式,无关
.css-img {
width: 90vw;
max-width: 688px;
height: calc(885 / 688 * 90vw);
max-height: 885px;
}
</style>

0 comments on commit fefb25f

Please sign in to comment.