fix: daily page
This commit is contained in:
@@ -157,7 +157,7 @@ import {
|
||||
} from "@dcloudio/uni-app";
|
||||
import { useUserStore } from "@/stores/user";
|
||||
|
||||
import { getDailyInfo } from "@/api/daily";
|
||||
import { getDailyInfo, getDailyRandomGreeting } from "@/api/daily";
|
||||
|
||||
const userStore = useUserStore();
|
||||
|
||||
@@ -250,19 +250,37 @@ const hotList = ref([
|
||||
|
||||
const selectCategory = (id) => {
|
||||
currentCategory.value = id;
|
||||
// TODO: Call API to get quote for this category if API supports it
|
||||
// For now, we just reload daily info which might not be category specific
|
||||
// If the API supports category param, we should use it.
|
||||
// Assuming getDailyInfo might accept params but user didn't specify.
|
||||
// Or maybe we should just rely on refreshQuote?
|
||||
refreshQuote();
|
||||
};
|
||||
|
||||
const refreshQuote = () => {
|
||||
// Since we don't have a specific refresh API in the prompt, re-call loadDailyInfo
|
||||
// This might just reload the same "daily" greeting or a new one.
|
||||
// Ideally there should be a refresh API.
|
||||
loadDailyInfo();
|
||||
const refreshQuote = async () => {
|
||||
try {
|
||||
const res = await getDailyRandomGreeting(currentCategory.value);
|
||||
if (res) {
|
||||
const { greetingContent, backgroundUrl, greetingId } = res;
|
||||
let text = "";
|
||||
let highlight = "";
|
||||
if (greetingContent) {
|
||||
const parts = greetingContent.split(" ");
|
||||
if (parts.length > 1) {
|
||||
highlight = parts.pop();
|
||||
text = parts.join("\n");
|
||||
} else {
|
||||
text = greetingContent;
|
||||
}
|
||||
}
|
||||
|
||||
currentQuote.value = {
|
||||
...currentQuote.value,
|
||||
text,
|
||||
highlight,
|
||||
backgroundUrl: backgroundUrl || "",
|
||||
id: greetingId,
|
||||
};
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("Failed to refresh quote:", e);
|
||||
}
|
||||
};
|
||||
|
||||
const useHotItem = (item) => {
|
||||
|
||||
Reference in New Issue
Block a user