mirror of
https://github.com/algerkong/AlgerMusicPlayer.git
synced 2026-04-24 16:27:23 +08:00
✨ feat: 修改捐赠列表 API
This commit is contained in:
@@ -0,0 +1,20 @@
|
|||||||
|
import axios from 'axios';
|
||||||
|
|
||||||
|
export interface Donor {
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
amount: number;
|
||||||
|
date: string;
|
||||||
|
message?: string;
|
||||||
|
avatar?: string;
|
||||||
|
badge: string;
|
||||||
|
badgeColor: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取捐赠列表
|
||||||
|
*/
|
||||||
|
export const getDonationList = async (): Promise<Donor[]> => {
|
||||||
|
const { data } = await axios.get('http://110.42.251.190:8766/api/donations');
|
||||||
|
return data;
|
||||||
|
};
|
||||||
@@ -106,38 +106,24 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import axios from 'axios';
|
|
||||||
import { computed, onActivated, onMounted, ref } from 'vue';
|
import { computed, onActivated, onMounted, ref } from 'vue';
|
||||||
|
|
||||||
|
import type { Donor } from '@/api/donation';
|
||||||
|
import { getDonationList } from '@/api/donation';
|
||||||
import alipay from '@/assets/alipay.png';
|
import alipay from '@/assets/alipay.png';
|
||||||
import wechat from '@/assets/wechat.png';
|
import wechat from '@/assets/wechat.png';
|
||||||
|
|
||||||
// 默认头像
|
// 默认头像
|
||||||
const defaultAvatar = 'https://avatars.githubusercontent.com/u/0?v=4';
|
const defaultAvatar = 'https://avatars.githubusercontent.com/u/0?v=4';
|
||||||
|
|
||||||
// 捐赠者数据
|
|
||||||
interface Donor {
|
|
||||||
id: number;
|
|
||||||
name: string;
|
|
||||||
amount: number;
|
|
||||||
date: string;
|
|
||||||
message?: string;
|
|
||||||
avatar?: string;
|
|
||||||
badge: string;
|
|
||||||
badgeColor: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
const donors = ref<Donor[]>([]);
|
const donors = ref<Donor[]>([]);
|
||||||
|
|
||||||
const isLoading = ref(false);
|
const isLoading = ref(false);
|
||||||
|
|
||||||
const fetchDonors = async () => {
|
const fetchDonors = async () => {
|
||||||
isLoading.value = true;
|
isLoading.value = true;
|
||||||
try {
|
try {
|
||||||
const response = await axios.get(
|
const data = await getDonationList();
|
||||||
'https://www.ghproxy.cn/https://raw.githubusercontent.com/algerkong/data/main/donors.json'
|
donors.value = data.map((donor, index) => ({
|
||||||
);
|
|
||||||
donors.value = response.data.map((donor: Donor, index: number) => ({
|
|
||||||
...donor,
|
...donor,
|
||||||
avatar: `https://api.dicebear.com/7.x/micah/svg?seed=${index}`
|
avatar: `https://api.dicebear.com/7.x/micah/svg?seed=${index}`
|
||||||
}));
|
}));
|
||||||
|
|||||||
Reference in New Issue
Block a user