Skip to content

Commit

Permalink
feat: 支持字体大小调节 #12
Browse files Browse the repository at this point in the history
  • Loading branch information
imsyy committed Dec 5, 2023
1 parent 6786a41 commit feeb257
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 8 deletions.
37 changes: 31 additions & 6 deletions src/components/HotList.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
<template>
<n-card hoverable class="hot-list" :header-style="{ padding: '16px' }" :content-style="{ padding: '0 16px' }"
:footer-style="{ padding: '16px' }" @click="toList">
<n-card
hoverable
class="hot-list"
:header-style="{ padding: '16px' }"
:content-style="{ padding: '0 16px' }"
:footer-style="{ padding: '16px' }"
@click="toList"
>
<template #header>
<n-space class="title" justify="space-between">
<div class="name">
Expand Down Expand Up @@ -50,8 +56,15 @@
: index === 2
? 'three'
: null
" :depth="2">{{ index + 1 }}</n-text>
<n-text class="text" @click.stop="jumpLink(item)">
"
:depth="2"
>{{ index + 1 }}</n-text
>
<n-text
:style="{ fontSize: store.listFontSize + 'px' }"
class="text"
@click.stop="jumpLink(item)"
>
{{ item.title }}
</n-text>
</div>
Expand All @@ -75,7 +88,13 @@
<n-space class="controls">
<n-popover v-if="hotListData.data.length > 15">
<template #trigger>
<n-button size="tiny" secondary strong round @click.stop="toList">
<n-button
size="tiny"
secondary
strong
round
@click.stop="toList"
>
<template #icon>
<n-icon :component="More" />
</template>
Expand All @@ -85,7 +104,13 @@
</n-popover>
<n-popover>
<template #trigger>
<n-button size="tiny" secondary strong round @click.stop="getNewData">
<n-button
size="tiny"
secondary
strong
round
@click.stop="getNewData"
>
<template #icon>
<n-icon :component="Refresh" />
</template>
Expand Down
3 changes: 3 additions & 0 deletions src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ export const mainStore = defineStore("mainData", {
headerFixed: true,
// 时间数据
timeData: null,
// 字体大小
listFontSize: 14,
};
},
getters: {},
Expand Down Expand Up @@ -176,6 +178,7 @@ export const mainStore = defineStore("mainData", {
"newsArr",
"linkOpenType",
"headerFixed",
"listFontSize",
],
},
],
Expand Down
42 changes: 40 additions & 2 deletions src/views/Setting.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,37 @@
<n-switch v-model:value="headerFixed" :round="false" />
</div>
</n-card>
<n-card class="set-item">
<div class="top" style="flex-direction: column; align-items: flex-start">
<div class="name">
<n-text class="text">歌词文本大小</n-text>
<n-card
class="tip"
:style="{
backgroundColor: 'var(--n-border-color)',
margin: '12px 0',
}"
>
<n-text :style="{ fontSize: listFontSize + 'px' }">
我是将要显示的文字的大小
</n-text>
</n-card>
</div>

<n-slider
v-model:value="listFontSize"
:tooltip="false"
:max="20"
:min="14"
:step="0.01"
:marks="{
14: '默认',
16: '大一点',
20: '最大',
}"
/>
</div>
</n-card>
<n-card class="set-item">
<div class="top">
<div class="name">
Expand Down Expand Up @@ -120,8 +151,14 @@ import draggable from "vuedraggable";
const store = mainStore();
const osThemeRef = useOsTheme();
const { siteTheme, siteThemeAuto, newsArr, linkOpenType, headerFixed } =
storeToRefs(store);
const {
siteTheme,
siteThemeAuto,
newsArr,
linkOpenType,
headerFixed,
listFontSize,
} = storeToRefs(store);
// 深浅模式
const themeOptions = ref([
Expand Down Expand Up @@ -208,6 +245,7 @@ const reset = () => {
.tip {
font-size: 12px;
border-radius: 8px;
}
}
Expand Down

0 comments on commit feeb257

Please sign in to comment.