Skip to content

Commit adfc7f1

Browse files
authored
Merge pull request #27 from ZeroCatDev/copilot/align-text-to-left
Left-align Hitokoto card text and apply custom font size settings
2 parents 4244f84 + 7bbae7f commit adfc7f1

File tree

2 files changed

+44
-5
lines changed

2 files changed

+44
-5
lines changed

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,3 +172,11 @@ dist
172172
vite.config.*.timestamp-*.mjs
173173
*.timestamp-*
174174

175+
# Auto-generated TypeScript declaration files
176+
auto-imports.d.ts
177+
components.d.ts
178+
typed-router.d.ts
179+
180+
# Package lock files (using pnpm)
181+
package-lock.json
182+

src/components/HitokotoCard.vue

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,24 @@
88
height="100%"
99
@click="fetchSentence"
1010
>
11-
<v-card-text class="pa-6 d-flex flex-column justify-center" style="height: 100%">
12-
<div class="text-h6 font-weight-medium mb-4 serif-font" style="white-space: pre-wrap; line-height: 1.6;">
11+
<v-card-text
12+
class="pa-6 d-flex flex-column justify-center"
13+
style="height: 100%"
14+
>
15+
<div
16+
class="font-weight-medium mb-4 serif-font"
17+
:style="contentStyle"
18+
>
1319
{{ sentence }}
1420
</div>
15-
<div class="text-subtitle-2 text-medium-emphasis text-right serif-font">
16-
<span v-if="author" class="mr-2">{{ author }}</span>
21+
<div
22+
class="text-medium-emphasis serif-font"
23+
:style="authorStyle"
24+
>
25+
<span
26+
v-if="author"
27+
class="mr-2"
28+
>{{ author }}</span>
1729
<span v-if="origin">《{{ origin }}》</span>
1830
</div>
1931
</v-card-text>
@@ -53,7 +65,25 @@ export default {
5365
origin: '',
5466
loading: false,
5567
timer: null,
56-
unwatch: null
68+
unwatch: null,
69+
fontSize: 28 // Will be updated in mounted()
70+
}
71+
},
72+
computed: {
73+
contentStyle() {
74+
return {
75+
'font-size': `${this.fontSize}px`,
76+
'white-space': 'pre-wrap',
77+
'line-height': '1.6',
78+
'text-align': 'left'
79+
}
80+
},
81+
authorStyle() {
82+
const AUTHOR_FONT_RATIO = 0.6 // Author font size is 60% of the main font size
83+
return {
84+
'font-size': `${this.fontSize * AUTHOR_FONT_RATIO}px`,
85+
'text-align': 'left'
86+
}
5787
}
5888
},
5989
async mounted() {
@@ -78,6 +108,7 @@ export default {
78108
loadLocalSettings() {
79109
this.enabled = SettingsManager.getSetting('hitokoto.enabled')
80110
this.refreshInterval = SettingsManager.getSetting('hitokoto.refreshInterval')
111+
this.fontSize = SettingsManager.getSetting('font.size')
81112
},
82113
async loadKvSettings() {
83114
try {

0 commit comments

Comments
 (0)