import { get } from '../utils/request'; import { showMessage } from '../common/toast/toast' import { isLofter, isAndroid } from 'nw-detect' import { openAppLofter } from 'nw-app-lofter' export const fetchColDetail = (colIds: number[]) => { return get('//www.lofter.com/spread/collectionShowAct/getCollectionDetail', { // return get('https://nei.hz.netease.com/api/apimock-v2/c6da9202198a943efec7f11c8a937f16/collectionShowAct/getCollectionDetail', { collectionIds: colIds.join(',') }).then(res => { if (res.code === 200) { return res } else { showMessage({ text: res.msg }) return Promise.reject() } }).catch(() => { showMessage({ text: '请求失败' }) return Promise.reject() }) } export const gotToCol = (blogName: string, collectionId: number) => { if (!blogName) return // 去除 blogName 中所有的 - 字符 let reg = /(-)/g blogName = blogName.replace(reg, '') let link = `http://www.lofter.com/collection/${blogName}/?op=collectionDetail&collectionId=${collectionId}` if (isAndroid()) { link = `http://www.lofter.com/collection/${blogName}/?op=collectionDetail&collectionId=${collectionId}&sort=1&invitationId=0` } if (isLofter()) { window.location.href = link } else { openAppLofter({ path: 'webview', query: { url: link } }) } } export const goToUserPage = (blogName: string) => { if (!blogName) return if (isLofter()) { window.location.href = `lofter://${blogName}.lofter.com/` } else { openAppLofter({ path: 'homepage', query: { id: blogName } }) } }