Skip to content

Commit 96d7756

Browse files
committed
Merge branch 'master' of github.com:KyleBing/diary
# Conflicts: # package.json
2 parents d56238c + 1567f1c commit 96d7756

17 files changed

Lines changed: 172 additions & 47 deletions

File tree

.github/workflows/release.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Build and Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*.*"
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
build-and-release:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
19+
- name: Setup Node
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: 20
23+
cache: yarn
24+
25+
- name: Install Yarn Classic
26+
run: npm install -g yarn@1.22.22
27+
28+
- name: Set Yarn registry
29+
run: yarn config set registry https://registry.npmjs.org
30+
31+
- name: Install dependencies with Yarn
32+
id: yarn_install
33+
continue-on-error: true
34+
run: yarn install --frozen-lockfile
35+
36+
- name: Install dependencies with npm (fallback)
37+
if: steps.yarn_install.outcome == 'failure'
38+
run: npm install --legacy-peer-deps
39+
40+
- name: Build with Yarn
41+
id: yarn_build
42+
continue-on-error: true
43+
run: yarn build
44+
45+
- name: Build with npm (fallback)
46+
if: steps.yarn_build.outcome == 'failure'
47+
run: npm run build
48+
49+
- name: Archive build output
50+
run: |
51+
cd dist
52+
zip -r ../dist.zip .
53+
54+
- name: Create/Update Release and upload asset
55+
uses: softprops/action-gh-release@v2
56+
with:
57+
files: dist.zip
58+
generate_release_notes: true

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# 更新日志
22

3+
### v9.43 `2026-04-06`
4+
- fix 天气信息没有自动加载的问题
5+
- fix 关键接口数据的请求顺序
6+
37
### v9.40 `2026-04-03`
48
- 添加初始化引导
59
- 添加配置页面,不再需要单独修改前端页面进行配置

src/App.vue

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<template>
22
<ServerError v-if="isServerError"/>
3-
<RouterView v-else/>
3+
<RouterView v-else-if="isSetupRequired || isAppReady"/>
44
</template>
55
<script lang="ts" setup>
66
import {useProjectStore} from "./pinia/useProjectStore.ts";
77
const projectStore = useProjectStore()
8-
import {onBeforeMount, onMounted, onUnmounted, ref} from "vue";
8+
import {onBeforeMount, onMounted, onUnmounted, ref, watch} from "vue";
99
import {useRoute, useRouter} from "vue-router";
1010
import {useStatisticStore} from "./pinia/useStatisticStore.ts";
1111
import {useSystemConfigStore} from "./pinia/useSystemConfigStore.ts";
@@ -21,11 +21,9 @@ const systemConfigStore = useSystemConfigStore()
2121
import ServerError from "./components/ServerError.vue";
2222
const isServerError = ref(false)
2323
const isSetupRequired = ref(false)
24+
const isAppReady = ref(false)
2425
2526
onBeforeMount(() => {
26-
// 日记项目载入后,隐藏 preloading
27-
(document.querySelector('.preloading') as HTMLDivElement).style.display = 'none'
28-
2927
// 获取当前颜色模式
3028
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
3129
projectStore.colorMode= 'dark'
@@ -49,6 +47,7 @@ onMounted(()=> {
4947
5048
syncSetupStatus()
5149
window.addEventListener('setup-completed', handleSetupCompleted)
50+
watch([isServerError, isSetupRequired, isAppReady], hidePreloadingWhenReady, {immediate: true})
5251
5352
window.addEventListener('resize', () => {
5453
projectStore.insets = {
@@ -86,8 +85,7 @@ function syncSetupStatus() {
8685
return
8786
}
8887
89-
systemConfigStore.fetchConfig(true).catch(() => {})
90-
statisticStore.getCategoryAll()
88+
afterBackendReady()
9189
})
9290
.catch(() => {
9391
isServerError.value = true
@@ -97,8 +95,30 @@ function syncSetupStatus() {
9795
function handleSetupCompleted() {
9896
isSetupRequired.value = false
9997
isServerError.value = false
100-
systemConfigStore.fetchConfig(true).catch(() => {})
101-
statisticStore.getCategoryAll()
98+
afterBackendReady()
99+
}
100+
101+
async function afterBackendReady() {
102+
isAppReady.value = false
103+
try {
104+
// 类别是后续页面与统计依赖的基础数据,后端连通后优先拉取
105+
await statisticStore.getCategoryAll()
106+
await systemConfigStore.fetchConfig(true).catch(() => {})
107+
} finally {
108+
// 避免因单个初始化步骤异常导致页面永久停在 loading
109+
isAppReady.value = true
110+
}
111+
}
112+
113+
function hidePreloadingWhenReady() {
114+
// 使用 index.html 的 preloading,等待可渲染状态后再隐藏
115+
if (!isServerError.value && !isSetupRequired.value && !isAppReady.value) {
116+
return
117+
}
118+
const preloading = document.querySelector('.preloading') as HTMLDivElement | null
119+
if (preloading) {
120+
preloading.style.display = 'none'
121+
}
102122
}
103123
104124

src/components/ServerError.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<div class="logo-server-error">
55
<img :src="SVG_ICONS.logo_icons.logo_server_error" alt="logo error">
66
</div>
7-
<div class="server-error-title">遇到错误,请尝试刷新页面。</div>
7+
<div class="server-error-title">遇到错误,请尝试刷新页面,如果问题依旧,请联系管理员。</div>
88
</div>
99

1010
</template>

src/components/charts/ChartBar.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { useStatisticStore } from '@/pinia/useStatisticStore.ts';
2323
import { useProjectStore } from '@/pinia/useProjectStore.ts';
2424
import chartOption from "@/view/Statistics/chartOption.ts";
2525
26+
const statisticStore = useStatisticStore()
2627
2728
// 注册必须的组件
2829
echarts.use([
@@ -99,7 +100,9 @@ function resetData(newValue) {
99100
newValue.forEach(item => {
100101
seriesData.push(item.value)
101102
xAxisData.push(item.name)
102-
let color = useStatisticStore().categoryNameMap.get(item.key) && useStatisticStore().categoryObjectMap.get(item.key).color
103+
const color = statisticStore.categoryNameMap.get(item.key)
104+
? statisticStore.getCategoryColor(item.key)
105+
: undefined
103106
if (color){
104107
colorArray.push(color)
105108
}

src/components/charts/ChartPie.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ function initChart() {
131131
itemStyle: {
132132
color: item => {
133133
if (item.data.key){
134-
return useStatisticStore().categoryObjectMap.get(item.data.key).color // 返回类别对应的颜色
134+
return useStatisticStore().getCategoryColor(item.data.key)
135135
} else {
136136
return COLORS[item.dataIndex%(COLORS.length - 1)]
137137
}

src/pinia/useStatisticStore.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,11 @@ export const useStatisticStore = defineStore('statisticStore', {
7676
return false
7777
})
7878
},
79+
/** 类别未加载或 key 不存在时返回占位色,避免 UI 读取 undefined.color */
80+
getCategoryColor(nameEn: string | undefined | null): string {
81+
if (!nameEn) return '#888888'
82+
return this.categoryObjectMap.get(nameEn)?.color ?? '#888888'
83+
},
7984
// 获取统计信息
8085
getStatistic() {
8186
statisticApi

src/view/Calendar/CalendarDiary.vue

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ import {useRouter, useRoute} from "vue-router";
9090
import { useStatisticStore } from "@/pinia/useStatisticStore";
9191
import Loading from "@/components/Loading.vue";
9292
93+
const statisticStore = useStatisticStore()
94+
9395
interface CalendarDay {
9496
id: string, // 2025-08-02
9597
date: Date,
@@ -152,7 +154,7 @@ function getAllShowingCalendarDiaries() {
152154
.then(res => {
153155
isLoading.value = false
154156
diaryList.value = res.data.map((diary: EntityDiaryFromServerCategoryOnly) => {
155-
diary.categoryString = useStatisticStore().categoryNameMap.get(diary.category)
157+
diary.categoryString = statisticStore.categoryNameMap.get(diary.category)
156158
diary.weekday = dateProcess(diary.date).weekday
157159
diary.weekdayShort = EnumWeekDayShort[new Date(diary.date).getDay()]
158160
diary.dateString = dateProcess(diary.date).date
@@ -185,10 +187,10 @@ function getAllShowingCalendarDiaries() {
185187
key: item.id,
186188
bar: {
187189
style: {
188-
backgroundColor: useStatisticStore().categoryObjectMap.get(item.category).color
190+
backgroundColor: statisticStore.getCategoryColor(item.category)
189191
}
190192
},
191-
color: useStatisticStore().categoryObjectMap.get(item.category).color,
193+
color: statisticStore.getCategoryColor(item.category),
192194
dates: new Date(item.date),
193195
popover: {
194196
label: item.title,
@@ -234,11 +236,11 @@ function getDiaryListOfDay(day: CalendarDay) {
234236
if (diary.content) {
235237
diary.contentHtml = diary.content.replace(/\n/g, '<br/>')
236238
}
237-
diary.categoryString = useStatisticStore().categoryNameMap.get(diary.category)
239+
diary.categoryString = statisticStore.categoryNameMap.get(diary.category)
238240
diary.weekday = dateProcess(diary.date).weekday
239241
diary.weekdayShort = EnumWeekDayShort[new Date(diary.date).getDay()]
240242
diary.dateString = dateProcess(diary.date).date
241-
diary.color = useStatisticStore().categoryObjectMap.get(diary.category).color
243+
diary.color = statisticStore.getCategoryColor(diary.category)
242244
return diary
243245
})
244246
})

src/view/Detail/DetailHeader.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ const props = defineProps({
7070
7171
const categoryBgColor = computed<string>( () => {
7272
if (props.diary && props.diary.category){
73-
return `background-color: ${useStatisticStore().categoryObjectMap.get(props.diary.category).color}`
73+
return `background-color: ${useStatisticStore().getCategoryColor(props.diary.category)}`
7474
} else {
7575
return ''
7676
}

src/view/DiaryList/DiaryListItem/DiaryListItem.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
@click="emit('click')"
55
:style="diaryItemStyle"
66
>
7-
<i :class="['category']" :style="`background-color: ${statisticStore.categoryObjectMap.get(diary.category).color}`"></i>
7+
<i :class="['category']" :style="`background-color: ${statisticStore.getCategoryColor(diary.category)}`"></i>
88

99
<span class="date">{{ diary.day }}</span>
1010

@@ -65,7 +65,7 @@ const weatherIcon = computed(() => {
6565
})
6666
const diaryItemStyle = computed(() => {
6767
if (props.isActive){
68-
return `background-color: ${statisticStore.categoryObjectMap.get(props.diary.category).color}`
68+
return `background-color: ${statisticStore.getCategoryColor(props.diary.category)}`
6969
}
7070
})
7171
const contentIcon = computed(() => {

0 commit comments

Comments
 (0)