-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4585 from Tinhone/improve-custom-font-family
[组件-自定义字体] feat: 改善组件代码和功能
- Loading branch information
Showing
10 changed files
with
249 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
export const fontFamilyDefaultValue = | ||
'Microsoft Yahei, Helvetica Neue, Helvetica, Arial, Hiragino Sans GB, Heiti SC, Malgun Gothic' | ||
|
||
export const coverOptionsName = [ | ||
{ camel: 'coverOrnament', kebab: 'cover-ornament', display: '装扮字体' }, | ||
{ camel: 'coverFansMedal', kebab: 'cover-fans-medal', display: '粉丝勋章字体' }, | ||
{ camel: 'coverDanmaku', kebab: 'cover-danmaku', display: '弹幕字体' }, | ||
{ camel: 'coverIconFont', kebab: 'cover-icon-font', display: '图标字体' }, | ||
{ camel: 'coverColumn', kebab: 'cover-column', display: '专栏自定义字体' }, | ||
{ camel: 'coverScore', kebab: 'cover-score', display: '评分字体' }, | ||
] | ||
|
||
export const coverOptionsDefaultValue = { | ||
coverOrnament: false, | ||
coverFansMedal: false, | ||
coverDanmaku: false, | ||
coverIconFont: false, | ||
coverColumn: false, | ||
coverScore: false, | ||
} |
16 changes: 0 additions & 16 deletions
16
registry/lib/components/style/custom-font-family/disable-quotation-mark-text-indent.scss
This file was deleted.
Oops, something went wrong.
26 changes: 26 additions & 0 deletions
26
registry/lib/components/style/custom-font-family/disable-title-punctuation-text-indent.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
$name: 'custom-font-family'; | ||
|
||
html[#{$name}--options--disable-title-punctuation-text-indent='true'] | ||
:is( | ||
p[title^='「'], | ||
p[title^='『'], | ||
p[title^='【'], | ||
h1[title^='「'], | ||
h1[title^='『'], | ||
h1[title^='【'], | ||
h3[title^='「'], | ||
h3[title^='『'], | ||
h3[title^='【'], | ||
p[title^='~'], | ||
h3[title^='~'], | ||
p[title^='《'], | ||
h3[title^='《'], | ||
p[title^='“'], | ||
h3[title^='“'], | ||
p[title^='~'], | ||
h3[title^='~'], | ||
p[title^='《'], | ||
h3[title^='《'] | ||
) { | ||
text-indent: initial !important; | ||
} |
2 changes: 1 addition & 1 deletion
2
registry/lib/components/style/custom-font-family/extra-options/Entry.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
115 changes: 115 additions & 0 deletions
115
registry/lib/components/style/custom-font-family/extra-options/SwitchOptionsMin.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
<!-- 这个 Vue 组件是因为无法正常从 @/components/SwitchOptions.vue 导入 SwitchOptions 组件而新建的 --> | ||
|
||
<template> | ||
<div class="switch-options-min"> | ||
<div class="switch-options-min-grid"> | ||
<component | ||
:is="options.radio ? 'RadioButton' : 'CheckBox'" | ||
v-for="name of Object.keys(options.switches)" | ||
:key="name" | ||
:class="{ dim: !(Number(componentOptions[name]) ^ Number(isDimAtChecked)) }" | ||
v-bind="mergedSwitchProps" | ||
:checked="componentOptions[name]" | ||
@change="componentOptions[name] = $event" | ||
> | ||
<!-- dim 这里原来的写法在使用 export default defineComponent 的情况下会报错,虽然能运行,但还是改了改 --> | ||
{{ options.switches[name].displayName }} | ||
</component> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { defineComponent } from 'vue' | ||
import { CheckBox, RadioButton } from '@/ui' | ||
import { getComponentSettings } from '@/core/settings' | ||
|
||
export default defineComponent({ | ||
name: 'SwitchOptionsMin', | ||
|
||
components: { | ||
CheckBox, | ||
RadioButton, | ||
}, | ||
|
||
props: { | ||
options: { | ||
type: Object, | ||
required: true, | ||
}, | ||
}, | ||
|
||
data() { | ||
const { componentName } = this.options | ||
const componentOptions = getComponentSettings(componentName).options | ||
const getIsDimAtChecked = () => { | ||
if (this.options.dimAt === 'checked' || this.options.dimAt === undefined) { | ||
return true | ||
} | ||
if (this.options.dimAt === 'notChecked') { | ||
return false | ||
} | ||
return false | ||
} | ||
const isDimAtChecked = getIsDimAtChecked() | ||
|
||
return { | ||
componentOptions, | ||
isDimAtChecked, | ||
} | ||
}, | ||
|
||
computed: { | ||
mergedSwitchProps() { | ||
return { | ||
checkedIcon: 'mdi-eye-off-outline', | ||
notCheckedIcon: 'mdi-eye-outline', | ||
...this.options.switchProps, | ||
} | ||
}, | ||
}, | ||
|
||
watch: { | ||
options() { | ||
this.updateColumnsCount() | ||
}, | ||
}, | ||
|
||
mounted() { | ||
this.updateColumnsCount() | ||
}, | ||
|
||
methods: { | ||
updateColumnsCount() { | ||
const element = this.$el as HTMLElement | ||
const columns = Math.ceil(Object.keys(this.options.switches).length / 12) | ||
element.style.setProperty('--columns', columns.toString()) | ||
}, | ||
}, | ||
}) | ||
</script> | ||
|
||
<style lang="scss"> | ||
@import 'common'; | ||
|
||
.switch-options-min { | ||
position: relative; | ||
--columns: 1; | ||
width: 100%; | ||
|
||
.switch-icon { | ||
margin-right: 8px; | ||
transform: scale(0.9); | ||
} | ||
|
||
.dim { | ||
opacity: 0.5; | ||
} | ||
|
||
& > &-grid { | ||
font-size: 12px; | ||
display: grid; | ||
grid-template-columns: repeat(auto-fill, 50%); | ||
} | ||
} | ||
</style> |
2 changes: 0 additions & 2 deletions
2
registry/lib/components/style/custom-font-family/font-family-default-value.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.