Skip to content

Commit 3a189dd

Browse files
author
tingyuan
committed
-
1 parent cea6577 commit 3a189dd

10 files changed

Lines changed: 1561 additions & 1072 deletions

File tree

app.json

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,6 @@
4040
"usesCleartextTraffic": true
4141
}
4242
}
43-
],
44-
[
45-
"@sentry/react-native/expo",
46-
{
47-
"url": "https://sentry.io",
48-
"project": "hotsou",
49-
"organization": "tingyuan123"
50-
}
5143
]
5244
],
5345
"experiments": {
@@ -74,4 +66,4 @@
7466
"url": "https://u.expo.dev/8dc9d1fe-0fde-4416-a5f9-6f2947b0ccd4"
7567
}
7668
}
77-
}
69+
}

app/(drawer)/tengxun.tsx

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,43 @@ import { getTabUrl, TabsName } from '@/constants/Tabs'
33

44
function __$inject() {
55
if (location.pathname === '/ranking') {
6-
history.scrollRestoration = 'auto'
6+
// history.scrollRestoration = 'auto'
77
// @ts-ignore
88
window.__markReaded?.(
99
'[dt-eid="em_item_article"]',
1010
'[class^="ranking-item_text"]',
1111
'[dt-eid="em_item_article"] [class^="ranking-item_text"]'
1212
)
13-
// @ts-ignore
14-
// window.__keepScrollPosition?.()
13+
14+
document.addEventListener(
15+
'click',
16+
evt => {
17+
// @ts-ignore
18+
if (evt.target.closest('[dt-eid="em_item_article"]')) {
19+
// @ts-ignore
20+
localStorage.setItem('scroll-position', document.documentElement.scrollTop)
21+
}
22+
},
23+
true
24+
)
25+
const id = localStorage.getItem('scroll-position')
26+
if (id) {
27+
const timer = setInterval(() => {
28+
const nodes = document.querySelectorAll('[dt-eid="em_item_article"]')
29+
if (nodes.length > 20) {
30+
clearInterval(timer)
31+
window.scrollTo({
32+
top: Number(id),
33+
})
34+
}
35+
}, 200)
36+
localStorage.removeItem('scroll-position')
37+
}
1538
}
1639
}
1740

1841
export default function Tengxun() {
42+
console.log(99, getTabUrl(TabsName.tengxun))
1943
return (
2044
<WebView
2145
name={TabsName.tengxun}

app/(drawer)/toutiao.tsx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,32 @@ function __$inject() {
1111
}
1212
}, 200)
1313
}
14+
if (location.pathname === '/feoffline/hotspot_and_local/html/hot_list/index.html') {
15+
document.addEventListener(
16+
'click',
17+
evt => {
18+
// @ts-ignore
19+
if (evt.target.closest('.tt-show-monitor')) {
20+
// @ts-ignore
21+
localStorage.setItem('scroll-position', document.documentElement.scrollTop)
22+
}
23+
},
24+
true
25+
)
26+
const id = localStorage.getItem('scroll-position')
27+
if (id) {
28+
const timer = setInterval(() => {
29+
const nodes = document.querySelectorAll('.tt-show-monitor')
30+
if (nodes.length > 20) {
31+
clearInterval(timer)
32+
window.scrollTo({
33+
top: Number(id),
34+
})
35+
}
36+
}, 200)
37+
localStorage.removeItem('scroll-position')
38+
}
39+
}
1440
}
1541

1642
export default function Toutiao() {

app/(drawer)/wangyi.tsx

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ import WebView from '@/components/WebView'
22
import { getTabUrl, TabsName } from '@/constants/Tabs'
33

44
function __$inject() {
5+
// rank-container hot-search
56
if (location.pathname.includes('newsapp/hot-content/')) {
6-
history.scrollRestoration = 'auto'
7+
// history.scrollRestoration = 'auto'
78
const tabsConfig = [
89
{
910
name: '热议榜',
@@ -59,8 +60,6 @@ function __$inject() {
5960
evt.preventDefault()
6061
}
6162
})
62-
// @ts-ignore
63-
// window.__keepScrollPosition?.('.swiper-slide-active .rank-container')
6463

6564
const tabs = document.getElementById('tabContainer')
6665
if (tabs) {
@@ -93,6 +92,34 @@ function __$inject() {
9392

9493
observer.observe(tabs, config)
9594
}
95+
96+
document.addEventListener(
97+
'click',
98+
evt => {
99+
// @ts-ignore
100+
if (evt.target.closest('.s-item-wrapper')) {
101+
// @ts-ignore
102+
localStorage.setItem(
103+
'scroll-position',
104+
// @ts-ignore
105+
document.querySelector('.swiper-slide-active .rank-container').scrollTop
106+
)
107+
}
108+
},
109+
true
110+
)
111+
const id = localStorage.getItem('scroll-position')
112+
if (id) {
113+
const timer = setInterval(() => {
114+
const nodes = document.querySelectorAll('.s-item-wrapper')
115+
if (nodes.length > 20) {
116+
clearInterval(timer)
117+
// @ts-ignore
118+
document.querySelector('.swiper-slide-active .rank-container').scrollTop = id
119+
}
120+
}, 200)
121+
localStorage.removeItem('scroll-position')
122+
}
96123
}
97124
}
98125

app/(drawer)/zhihu.tsx

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,22 @@ function __$inject() {
1111
}, 200)
1212
// @ts-ignore
1313
window.__markReaded?.('.HotList-item', '.HotList-itemTitle', '.HotList-item .HotList-itemTitle')
14+
if (location.pathname.startsWith('/question/')) {
15+
const timer = setInterval(() => {
16+
const btns = Array.from(document.querySelectorAll('button'))
17+
for (const btn of btns) {
18+
// @ts-ignore
19+
if (btn.textContent.trim() === '查看问题描述​') {
20+
clearInterval(timer)
21+
btn.click()
22+
break
23+
}
24+
}
25+
}, 200)
26+
setTimeout(() => {
27+
clearInterval(timer)
28+
}, 5000)
29+
}
1430
}
1531

1632
export default function Zhihu() {
@@ -22,8 +38,7 @@ export default function Zhihu() {
2238
'zhihu-web-analytics.zhihu.com',
2339
'datahub.zhihu.com',
2440
'apm.zhihu.com',
25-
'www.zhihu.com/oia/answers/',
26-
'www.zhihu.com/oia/people/',
41+
'www.zhihu.com/oia/',
2742
]}
2843
css={`
2944
.OpenInAppButton,

app/_layout.tsx

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { DarkTheme, DefaultTheme, ThemeProvider } from '@react-navigation/native'
2-
import * as Sentry from '@sentry/react-native'
3-
import { isRunningInExpoGo } from 'expo'
4-
import { Stack, useNavigationContainerRef } from 'expo-router'
2+
// import * as Sentry from '@sentry/react-native'
3+
// import { isRunningInExpoGo } from 'expo'
4+
import { Stack } from 'expo-router'
55
import React from 'react'
66
import { Share } from 'react-native'
77

@@ -10,21 +10,21 @@ import ThemedIcon from '@/components/ThemedIcon'
1010
import { useColorScheme } from '@/hooks/useColorScheme'
1111

1212
// Construct a new integration instance. This is needed to communicate between the integration and React
13-
const navigationIntegration = Sentry.reactNavigationIntegration({
14-
enableTimeToInitialDisplay: !isRunningInExpoGo(),
15-
})
13+
// const navigationIntegration = Sentry.reactNavigationIntegration({
14+
// enableTimeToInitialDisplay: !isRunningInExpoGo(),
15+
// })
1616

17-
Sentry.init({
18-
dsn: process.env.EXPO_PUBLIC_SENTRY_DSN,
19-
enabled: !__DEV__,
20-
debug: __DEV__, // If `true`, Sentry will try to print out useful debugging information if something goes wrong with sending the event. Set it to `false` in production
21-
tracesSampleRate: 1.0, // Set tracesSampleRate to 1.0 to capture 100% of transactions for tracing. Adjusting this value in production.
22-
integrations: [
23-
// Pass integration
24-
navigationIntegration,
25-
],
26-
enableNativeFramesTracking: !isRunningInExpoGo(), // Tracks slow and frozen frames in the application
27-
})
17+
// Sentry.init({
18+
// dsn: process.env.EXPO_PUBLIC_SENTRY_DSN,
19+
// enabled: !__DEV__,
20+
// debug: __DEV__, // If `true`, Sentry will try to print out useful debugging information if something goes wrong with sending the event. Set it to `false` in production
21+
// tracesSampleRate: 1.0, // Set tracesSampleRate to 1.0 to capture 100% of transactions for tracing. Adjusting this value in production.
22+
// integrations: [
23+
// // Pass integration
24+
// navigationIntegration,
25+
// ],
26+
// enableNativeFramesTracking: !isRunningInExpoGo(), // Tracks slow and frozen frames in the application
27+
// })
2828

2929
function RootLayout() {
3030
const colorScheme = useColorScheme()
@@ -46,13 +46,13 @@ function RootLayout() {
4646
></ThemedIcon>
4747
)
4848
}
49-
const ref = useNavigationContainerRef()
49+
// const ref = useNavigationContainerRef()
5050

51-
React.useEffect(() => {
52-
if (ref?.current) {
53-
navigationIntegration.registerNavigationContainer(ref)
54-
}
55-
}, [ref])
51+
// React.useEffect(() => {
52+
// if (ref?.current) {
53+
// navigationIntegration.registerNavigationContainer(ref)
54+
// }
55+
// }, [ref])
5656

5757
return (
5858
<InitApp>
@@ -79,4 +79,4 @@ function RootLayout() {
7979
)
8080
}
8181

82-
export default __DEV__ ? RootLayout : Sentry.wrap(RootLayout)
82+
export default RootLayout

metro.config.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)