2020</template >
2121
2222<script setup lang="ts">
23- import axios , { type AxiosRequestConfig , type AxiosResponse } from ' axios'
24- import qs from ' query-string'
2523import { isHttp } from ' @/utils/validate'
2624
2725export interface DataItem {
@@ -33,45 +31,34 @@ export interface DataItem {
3331const images = ref <DataItem []>([
3432 {
3533 name: ' 公众号' ,
36- img: ` https://continew.top/qrcode-text .jpg?${new Date ().getTime ()} ` ,
37- url: ' https://continew.top/about/intro .html' ,
34+ img: ` https://continew.top/images/sponsor/ads/cn-qrcode .jpg?${new Date ().getTime ()} ` ,
35+ url: ' https://continew.top/discussion .html' ,
3836 },
3937 {
4038 name: ' 赞助' ,
41- img: ` https://continew.top/sponsor.jpg?${new Date ().getTime ()} ` ,
42- url: ' https://continew.top/sponsor.html ' ,
39+ img: ` https://continew.top/images/sponsor/ads/cn- sponsor.jpg?${new Date ().getTime ()} ` ,
40+ url: ' https://continew.top/sponsor/ ' ,
4341 },
4442])
4543
46- const get = <T = unknown >(url : string , params ? : object , config ? : AxiosRequestConfig ): Promise <ApiRes <T >> => {
47- return new Promise ((resolve , reject ) => {
48- axios
49- .request <T >({
50- method: ' get' ,
51- url ,
52- params ,
53- paramsSerializer : (obj ) => {
54- return qs .stringify (obj )
55- },
56- ... config ,
57- })
58- .then ((res : AxiosResponse ) => resolve (res .data ))
59- .catch ((err : { msg: string }) => reject (err ))
60- })
61- }
62-
6344const dataList = ref <DataItem []>([])
6445const loading = ref (false )
6546// 查询列表数据
6647const getDataList = async () => {
6748 try {
6849 loading .value = true
69- const { data } = await get (' https://api.charles7c.top/sponsor/platinum' )
50+ const base = ` https://continew.top `
51+ const data = await (await fetch (` ${base }/sponsor.json ` )).json ()
7052 if (data ) {
71- data .forEach ((item ) => {
53+ // 只获取 special 和 platinum 赞助者
54+ const sponsors = [... data .special , data .platinum ]
55+ sponsors .forEach ((item ) => {
56+ if (! item .name ) {
57+ return
58+ }
7259 dataList .value .push ({
7360 name: item .name ,
74- img: isHttp (item .img ) ? item .img : ` https://continew.top ${item .img }` ,
61+ img: isHttp (item .img ) ? item .img : ` ${ base }/images/sponsor/ads/ ${item .img }` ,
7562 url: item .url ,
7663 })
7764 })
0 commit comments