feat: radar
This commit is contained in:
@@ -305,16 +305,6 @@ function createDefaultMeasurements(): Record<string, MeasurementStation> {
|
||||
};
|
||||
}
|
||||
|
||||
function createDefaultRadarData() {
|
||||
return {
|
||||
strength: 65,
|
||||
balance: 60,
|
||||
flexibility: 55,
|
||||
agility: 70,
|
||||
cardio: 62,
|
||||
};
|
||||
}
|
||||
|
||||
export const useAppStore = defineStore("app", () => {
|
||||
const isLoggedIn = ref(false);
|
||||
const isAuthInitialized = ref(false);
|
||||
@@ -327,8 +317,6 @@ export const useAppStore = defineStore("app", () => {
|
||||
const measurements = ref<Record<string, MeasurementStation>>(
|
||||
createDefaultMeasurements(),
|
||||
);
|
||||
const radarData = ref(createDefaultRadarData());
|
||||
const isReportGenerated = ref(false);
|
||||
|
||||
const completedStationsCount = computed(() => {
|
||||
return Object.values(measurements.value).filter(
|
||||
@@ -625,57 +613,6 @@ export const useAppStore = defineStore("app", () => {
|
||||
measurement.time = timeStr;
|
||||
}
|
||||
|
||||
function generateFinalReport() {
|
||||
const currentMeasurements = measurements.value;
|
||||
|
||||
let strScore = 65;
|
||||
if (currentMeasurements.GripStrength.completed) {
|
||||
const avgGrip =
|
||||
((currentMeasurements.GripStrength.values.leftHand || 0) +
|
||||
(currentMeasurements.GripStrength.values.rightHand || 0)) /
|
||||
2;
|
||||
const limit = userProfile.value.gender === "男" ? 30 : 20;
|
||||
strScore = Math.min(95, Math.max(50, Math.round((avgGrip / limit) * 75)));
|
||||
}
|
||||
|
||||
let balScore = 60;
|
||||
if (currentMeasurements.OneLegTest.completed) {
|
||||
const maxSec = Math.max(
|
||||
currentMeasurements.OneLegTest.values.leftSeconds || 0,
|
||||
currentMeasurements.OneLegTest.values.rightSeconds || 0,
|
||||
);
|
||||
balScore = Math.min(98, Math.max(40, Math.round((maxSec / 30) * 90)));
|
||||
}
|
||||
|
||||
let flexScore = 55;
|
||||
if (currentMeasurements.SitReachTest.completed) {
|
||||
const dist = currentMeasurements.SitReachTest.values.distanceCm || 0;
|
||||
flexScore = Math.min(95, Math.max(45, 60 + dist * 1.5));
|
||||
}
|
||||
|
||||
let agiScore = 70;
|
||||
if (currentMeasurements.UpGo8ft.completed) {
|
||||
const sec = currentMeasurements.UpGo8ft.values.durationSeconds || 10;
|
||||
agiScore = Math.min(95, Math.max(40, Math.round(100 - sec * 5)));
|
||||
}
|
||||
|
||||
let cardScore = 62;
|
||||
if (currentMeasurements.StepTest.completed) {
|
||||
const count = currentMeasurements.StepTest.values.count || 60;
|
||||
cardScore = Math.min(95, Math.max(45, Math.round((count / 80) * 80)));
|
||||
}
|
||||
|
||||
radarData.value = {
|
||||
strength: strScore,
|
||||
balance: balScore,
|
||||
flexibility: flexScore,
|
||||
agility: agiScore,
|
||||
cardio: cardScore,
|
||||
};
|
||||
|
||||
isReportGenerated.value = true;
|
||||
}
|
||||
|
||||
function resetMeasurements() {
|
||||
for (const [key, measurement] of Object.entries(measurements.value)) {
|
||||
if (key !== "BloodPressure" && key !== "BodyFat") {
|
||||
@@ -686,9 +623,6 @@ export const useAppStore = defineStore("app", () => {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
isReportGenerated.value = false;
|
||||
radarData.value = createDefaultRadarData();
|
||||
}
|
||||
|
||||
return {
|
||||
@@ -699,8 +633,6 @@ export const useAppStore = defineStore("app", () => {
|
||||
selfAssessment,
|
||||
appointments,
|
||||
measurements,
|
||||
radarData,
|
||||
isReportGenerated,
|
||||
completedStationsCount,
|
||||
totalStationsCount,
|
||||
progressPercent,
|
||||
@@ -719,7 +651,6 @@ export const useAppStore = defineStore("app", () => {
|
||||
cancelAppointment,
|
||||
checkinAppointment,
|
||||
saveMeasurement,
|
||||
generateFinalReport,
|
||||
resetMeasurements,
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user