feat: 增加存储容量显示
This commit is contained in:
@@ -8,7 +8,7 @@
|
|||||||
custom-style="border-radius: 32rpx 32rpx 0 0; padding: 40rpx 32rpx"
|
custom-style="border-radius: 32rpx 32rpx 0 0; padding: 40rpx 32rpx"
|
||||||
@close="handeClosePopup"
|
@close="handeClosePopup"
|
||||||
>
|
>
|
||||||
<view class="flex flex-col max-h-[85vh] overflow-y-auto">
|
<view class="flex flex-col max-h-[70vh] overflow-y-auto">
|
||||||
<view class="mb-5 text-center text-[30rpx] font-semibold text-[#333] shrink-0">
|
<view class="mb-5 text-center text-[30rpx] font-semibold text-[#333] shrink-0">
|
||||||
{{ appStore.currentTip.title }}
|
{{ appStore.currentTip.title }}
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@@ -10,7 +10,8 @@
|
|||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="flex flex-col items-center">
|
<view class="flex flex-col items-center">
|
||||||
<wd-text :text="`${profileStore.storageTotal} / ${profileStore.storageMax}`"></wd-text>
|
<wd-text :text="`${profileStore.storageTotal} / ${profileStore.storageMax} 条`"></wd-text>
|
||||||
|
<wd-text :text="`共 ${profileStore.currentStorageSize} KB`"></wd-text>
|
||||||
<wd-progress
|
<wd-progress
|
||||||
:percentage="Number((profileStore.storageTotal / profileStore.storageMax * 100).toFixed(2))"
|
:percentage="Number((profileStore.storageTotal / profileStore.storageMax * 100).toFixed(2))"
|
||||||
:color="['#00c740', '#ffb300', '#e2231a']"/>
|
:color="['#00c740', '#ffb300', '#e2231a']"/>
|
||||||
@@ -44,8 +45,7 @@ function clearMonth(month: string) {
|
|||||||
success(res) {
|
success(res) {
|
||||||
if (res.confirm) {
|
if (res.confirm) {
|
||||||
deleteRecordByMonth(month)
|
deleteRecordByMonth(month)
|
||||||
profileStore.storageStats = countRecordsByMonth()
|
profileStore.refreshStorage()
|
||||||
profileStore.storageTotal = getTotalCount()
|
|
||||||
wx.showToast({ title: '已清除', icon: 'success' })
|
wx.showToast({ title: '已清除', icon: 'success' })
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -69,6 +69,9 @@
|
|||||||
</wd-card>
|
</wd-card>
|
||||||
|
|
||||||
<wd-card title="🔥 今日资讯">
|
<wd-card title="🔥 今日资讯">
|
||||||
|
<wd-empty v-if="tipList.length === 0" icon="no-content"
|
||||||
|
:tip="errorMessage || '获取资讯失败,请检查网络连接或联系管理员'" />
|
||||||
|
|
||||||
<view
|
<view
|
||||||
v-for="(item, index) in tipList"
|
v-for="(item, index) in tipList"
|
||||||
:key="index"
|
:key="index"
|
||||||
@@ -137,6 +140,7 @@ const appStore = useAppStore()
|
|||||||
|
|
||||||
const todayRecords = ref<IHealthRecord[]>([])
|
const todayRecords = ref<IHealthRecord[]>([])
|
||||||
const tipList = ref<ITip[]>([])
|
const tipList = ref<ITip[]>([])
|
||||||
|
const errorMessage = ref<string>("")
|
||||||
const hasSignedToday = ref(checkSignedToday())
|
const hasSignedToday = ref(checkSignedToday())
|
||||||
|
|
||||||
const now = new Date()
|
const now = new Date()
|
||||||
@@ -171,7 +175,14 @@ const today = computed(() => {
|
|||||||
onShow(() => {
|
onShow(() => {
|
||||||
todayRecords.value = getDayRecords(getDateStr(Date.now()))
|
todayRecords.value = getDayRecords(getDateStr(Date.now()))
|
||||||
hasSignedToday.value = checkSignedToday()
|
hasSignedToday.value = checkSignedToday()
|
||||||
|
getTipList()
|
||||||
|
})
|
||||||
|
|
||||||
|
watch(() => recordStore.isRecord, () => {
|
||||||
|
todayRecords.value = getDayRecords(getDateStr(Date.now()))
|
||||||
|
})
|
||||||
|
|
||||||
|
function getTipList() {
|
||||||
wx.request({
|
wx.request({
|
||||||
url: 'https://cxx0822.s.3q.hair/health-api/agent/tip/latest',
|
url: 'https://cxx0822.s.3q.hair/health-api/agent/tip/latest',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
@@ -181,13 +192,10 @@ onShow(() => {
|
|||||||
},
|
},
|
||||||
fail: (err) => {
|
fail: (err) => {
|
||||||
console.error('请求失败:', err);
|
console.error('请求失败:', err);
|
||||||
|
errorMessage.value = err.errMsg
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})
|
}
|
||||||
|
|
||||||
watch(() => recordStore.isRecord, () => {
|
|
||||||
todayRecords.value = getDayRecords(getDateStr(Date.now()))
|
|
||||||
})
|
|
||||||
|
|
||||||
const viewTipClick = (item: ITip) => {
|
const viewTipClick = (item: ITip) => {
|
||||||
appStore.currentTip = item
|
appStore.currentTip = item
|
||||||
|
|||||||
@@ -132,9 +132,7 @@ function openStatsPopup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function openStoragePopup() {
|
function openStoragePopup() {
|
||||||
profileStore.storageStats = countRecordsByMonth()
|
profileStore.refreshStorage()
|
||||||
profileStore.storageTotal = getTotalCount()
|
|
||||||
profileStore.storageMax = getMaxRecord()
|
|
||||||
profileStore.showStoragePopup = true
|
profileStore.showStoragePopup = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import type { ITip } from "@/type";
|
|||||||
|
|
||||||
export const useAppStore = defineStore('app', {
|
export const useAppStore = defineStore('app', {
|
||||||
state: () => ({
|
state: () => ({
|
||||||
version: '1.1.0',
|
version: '1.1.0.26090101',
|
||||||
viewRecordType: 'calendar',
|
viewRecordType: 'calendar',
|
||||||
points: 0,
|
points: 0,
|
||||||
recordCount: 0,
|
recordCount: 0,
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
import type {IDefaultRecordValue, IProfile} from "@/type/profile";
|
import type {IDefaultRecordValue, IProfile} from "@/type/profile";
|
||||||
import type {IStats} from "@/type";
|
import type {IStats} from "@/type";
|
||||||
|
import {countRecordsByMonth, getMaxRecord, getTotalCount} from "@/utils/record";
|
||||||
|
|
||||||
export const useProfileStore = defineStore('profile', {
|
export const useProfileStore = defineStore('profile', {
|
||||||
state: () => ({
|
state: () => ({
|
||||||
@@ -25,6 +26,7 @@ export const useProfileStore = defineStore('profile', {
|
|||||||
bloodSugarValue: 5.4,
|
bloodSugarValue: 5.4,
|
||||||
temperatureValue: 36.5,
|
temperatureValue: 36.5,
|
||||||
} as IDefaultRecordValue,
|
} as IDefaultRecordValue,
|
||||||
|
currentStorageSize: 0,
|
||||||
storageStats: [] as IStats[],
|
storageStats: [] as IStats[],
|
||||||
storageTotal: 0,
|
storageTotal: 0,
|
||||||
storageMax: 1000,
|
storageMax: 1000,
|
||||||
@@ -35,6 +37,12 @@ export const useProfileStore = defineStore('profile', {
|
|||||||
isRefresh: false,
|
isRefresh: false,
|
||||||
}),
|
}),
|
||||||
actions: {
|
actions: {
|
||||||
|
refreshStorage() {
|
||||||
|
const storageInfo = wx.getStorageInfoSync()
|
||||||
|
this.currentStorageSize = storageInfo.currentSize
|
||||||
|
this.storageStats = countRecordsByMonth()
|
||||||
|
this.storageTotal = getTotalCount()
|
||||||
|
this.storageMax = getMaxRecord()
|
||||||
|
}
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user