mirror of
https://github.com/ourongxing/newsnow.git
synced 2025-01-19 11:19:14 +08:00
feat: use mobile url if source had
This commit is contained in:
parent
3b66d0f081
commit
cc1aee2ae8
@ -8,6 +8,7 @@ import { forwardRef, useCallback, useImperativeHandle, useMemo, useRef } from "r
|
|||||||
import { sources } from "@shared/sources"
|
import { sources } from "@shared/sources"
|
||||||
import type { SyntheticListenerMap } from "@dnd-kit/core/dist/hooks/utilities"
|
import type { SyntheticListenerMap } from "@dnd-kit/core/dist/hooks/utilities"
|
||||||
import { ofetch } from "ofetch"
|
import { ofetch } from "ofetch"
|
||||||
|
import { useWindowSize } from "react-use"
|
||||||
import { OverlayScrollbar } from "../common/overlay-scrollbar"
|
import { OverlayScrollbar } from "../common/overlay-scrollbar"
|
||||||
import { focusSourcesAtom, refetchSourcesAtom } from "~/atoms"
|
import { focusSourcesAtom, refetchSourcesAtom } from "~/atoms"
|
||||||
import { useRelativeTime } from "~/hooks/useRelativeTime"
|
import { useRelativeTime } from "~/hooks/useRelativeTime"
|
||||||
@ -173,14 +174,14 @@ function NewsUpdatedTime({ date }: { date: string }) {
|
|||||||
const relativeTime = useRelativeTime(date)
|
const relativeTime = useRelativeTime(date)
|
||||||
return <>{relativeTime}</>
|
return <>{relativeTime}</>
|
||||||
}
|
}
|
||||||
|
|
||||||
function NewsListHot({ query }: Query) {
|
function NewsListHot({ query }: Query) {
|
||||||
const items = query.data?.items
|
const items = query.data?.items
|
||||||
|
const { width } = useWindowSize()
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{items?.map((item, i) => (
|
{items?.map((item, i) => (
|
||||||
<a
|
<a
|
||||||
href={item.url}
|
href={width < 768 ? item.mobileUrl || item.url : item.url}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
key={item.id}
|
key={item.id}
|
||||||
className={clsx(
|
className={clsx(
|
||||||
@ -207,6 +208,7 @@ function NewsListHot({ query }: Query) {
|
|||||||
|
|
||||||
function NewsListTimeLine({ query }: Query) {
|
function NewsListTimeLine({ query }: Query) {
|
||||||
const items = query.data?.items
|
const items = query.data?.items
|
||||||
|
const { width } = useWindowSize()
|
||||||
return (
|
return (
|
||||||
<ol className="border-s border-neutral-400/50 flex flex-col ml-1">
|
<ol className="border-s border-neutral-400/50 flex flex-col ml-1">
|
||||||
{items?.map(item => (
|
{items?.map(item => (
|
||||||
@ -220,7 +222,11 @@ function NewsListTimeLine({ query }: Query) {
|
|||||||
<ExtraInfo item={item} />
|
<ExtraInfo item={item} />
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
<a className={clsx("ml-2 px-1 hover:bg-neutral-400/10 rounded-md visited:(text-neutral-400/80)")} href={item.url} target="_blank">
|
<a
|
||||||
|
className={clsx("ml-2 px-1 hover:bg-neutral-400/10 rounded-md visited:(text-neutral-400/80)")}
|
||||||
|
href={width < 768 ? item.mobileUrl || item.url : item.url}
|
||||||
|
target="_blank"
|
||||||
|
>
|
||||||
{item.title}
|
{item.title}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user