Skip to content

Commit 0c7bf02

Browse files
Merge branch 'main' into stable
2 parents 7e85535 + e758df7 commit 0c7bf02

File tree

3 files changed

+142
-15
lines changed

3 files changed

+142
-15
lines changed

public/temp/index.html

Lines changed: 50 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
<meta charset="UTF-8" />
1313
<meta
1414
name="description"
15-
content="大翻墙运动 信息倒灌行动 墙倒众人推 拆除互联网防火墙 拆墙运动 声援乔鑫鑫 杨泽伟 编程随想 阮晓寰 "
15+
content="大翻墙运动 信息倒灌行动 墙倒众人推 拆除互联网防火墙 拆墙运动 声援乔鑫鑫 杨泽伟 编程随想 阮晓寰 推墙大联盟 李老师不是你老师 中国新闻 中国禁闻 中国审查 GFW 自由 民主 人权 宪政 防火墙 突破防火墙 国内新闻 中国热点事件 中国新闻总结 李老师不是你老师 推文离线下载 离线PDF推文 免费翻墙 翻墙节点 敏感词"
1616
/>
1717
<meta
1818
name="keywords"
19-
content="大翻墙运动 信息倒灌行动 墙倒众人推 完全免费翻墙软件 梯子 机场 拆墙机场 回国机场 回国梯子 代理 Vmess Shadowsocks Trojan v2ray v2board Shadowrocket GFW 突破防火墙 VPN 防火墙 拆墙运动 拆墙 推墙 fanqiang 科学上网 自由上网 免费科学上网 免费翻墙 油管youtube 电脑、手机、iOS、安卓、windows、Mac、Linux 推特"
19+
content="大翻墙运动 信息倒灌行动 墙倒众人推 完全免费翻墙软件 梯子 机场 拆墙机场 回国机场 回国梯子 代理 Vmess Shadowsocks Trojan v2ray v2board Shadowrocket GFW 突破防火墙 VPN 防火墙 拆墙运动 拆墙 推墙 fanqiang 科学上网 自由上网 免费科学上网 免费翻墙 油管youtube 电脑、手机、iOS、安卓、windows、Mac、Linux 推特 推墙大联盟 李老师不是你老师 中国新闻 中国禁闻 中国审查 GFW 自由 民主 人权 宪政 防火墙 突破防火墙 国内新闻 中国热点事件 中国新闻总结 李老师不是你老师 推文离线下载 离线PDF推文 免费翻墙 翻墙节点 敏感词"
2020
/>
2121

2222
<script>
@@ -162,7 +162,46 @@ <h1>
162162
name="day"
163163
class="mt-2 inline-block sm:3/12 lg:w-2/12 rounded-md border-0 py-1.5 px-1 text-gray-900 ring-1 ring-inset ring-gray-300 focus:ring-2 focus:ring-indigo-600 sm:text-sm sm:leading-6"
164164
>
165-
<option selected value="">日期</option>
165+
<option selected value="">开始日期</option>
166+
<option value="01">1</option>
167+
<option value="02">2</option>
168+
<option value="03">3</option>
169+
<option value="04">4</option>
170+
<option value="05">5</option>
171+
<option value="06">6</option>
172+
<option value="07">7</option>
173+
<option value="08">8</option>
174+
<option value="09">9</option>
175+
<option value="10">10</option>
176+
<option value="11">11</option>
177+
<option value="12">12</option>
178+
<option value="13">13</option>
179+
<option value="14">14</option>
180+
<option value="15">15</option>
181+
<option value="16">16</option>
182+
<option value="17">17</option>
183+
<option value="18">18</option>
184+
<option value="19">19</option>
185+
<option value="20">20</option>
186+
<option value="21">21</option>
187+
<option value="22">22</option>
188+
<option value="23">23</option>
189+
<option value="24">24</option>
190+
<option value="25">25</option>
191+
<option value="26">26</option>
192+
<option value="27">27</option>
193+
<option value="28">28</option>
194+
<option value="29">29</option>
195+
<option value="30">30</option>
196+
<option value="31">31</option>
197+
</select>
198+
199+
<select
200+
id="end-day"
201+
name="end-day"
202+
class="mt-2 inline-block sm:3/12 lg:w-2/12 rounded-md border-0 py-1.5 px-1 text-gray-900 ring-1 ring-inset ring-gray-300 focus:ring-2 focus:ring-indigo-600 sm:text-sm sm:leading-6"
203+
>
204+
<option selected value="">结束日期</option>
166205
<option value="01">1</option>
167206
<option value="02">2</option>
168207
<option value="03">3</option>
@@ -580,12 +619,14 @@ <h1>
580619
const yearElement = document.getElementById('year');
581620
const monthElement = document.getElementById('month');
582621
const dayElement = document.getElementById('day');
622+
const endDayElement = document.getElementById('end-day');
583623

584624
const year = yearElement.value;
585625
const month = monthElement.value;
586626
const day = dayElement.value;
627+
const endDay = endDayElement.value;
587628

588-
getTweet(year, month, day);
629+
getTweet(year, month, day, endDay);
589630
}
590631

591632
function getMonthlyTweet() {
@@ -728,12 +769,12 @@ <h1>
728769
pdfElement.innerHTML = elements.join('');
729770
}
730771

731-
async function getTweet(year, month, day) {
772+
async function getTweet(year, month, day, endDay = '') {
732773
let temp = [];
733774

734775
try {
735776
const res = await fetch(
736-
`/tweet?year=${year}&month=${month}&day=${day}&id=whyyoutouzhele`
777+
`/tweet?year=${year}&month=${month}&day=${day}&endDay=${endDay}&id=whyyoutouzhele`
737778
);
738779

739780
temp = await res.json();
@@ -872,18 +913,20 @@ <h1>
872913
const yearElement = document.getElementById('year');
873914
const monthElement = document.getElementById('month');
874915
const dayElement = document.getElementById('day');
916+
const endDayElement = document.getElementById('end-day');
875917

876918
const year = yearElement.value;
877919
const month = monthElement.value;
878920
const day = dayElement.value;
921+
const endDay = endDayElement.value;
879922

880923
try {
881924
/* const res = await fetch(
882925
`/tweet-page?year=${year}&month=${month}&day=${day}&id=whyyoutouzhele`
883926
);*/
884927

885928
window.open(
886-
`/tweet-page?year=${year}&month=${month}&day=${day}&id=whyyoutouzhele`
929+
`/tweet-page?year=${year}&month=${month}&day=${day}&endDay=${endDay}&id=whyyoutouzhele`
887930
);
888931

889932
/* const htmlContent = await res.text();

public/temp/qa.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,18 @@
203203
</dd>
204204
</div> -->
205205

206+
<div class="pt-8 lg:grid lg:grid-cols-12 lg:gap-8">
207+
<dt
208+
class="text-base font-semibold leading-7 text-gray-900 lg:col-span-5"
209+
>
210+
下载PDF乱码
211+
</dt>
212+
<dd class="mt-4 lg:col-span-7 lg:mt-0">
213+
请在浏览器设置-> 外观 -> 自定义字体 ->选择 微软雅黑 字体
214+
<br />
215+
</dd>
216+
</div>
217+
206218
<div class="pt-8 lg:grid lg:grid-cols-12 lg:gap-8">
207219
<dt
208220
class="text-base font-semibold leading-7 text-gray-900 lg:col-span-5"

src/proxy.js

Lines changed: 80 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
import axios from 'axios';
23
import express from 'express';
34
// import * as fs from 'fs';
@@ -124,6 +125,7 @@ app.get('/tweet-page', async (req, res) => {
124125
const year = req.query?.year;
125126
const month = req.query?.month;
126127
const day = req.query?.day;
128+
const endDay = req.query?.endDay;
127129
const id = req.query?.id;
128130

129131
let url = `https://raw.githubusercontent.com/hello-world-1989/json/main/tweet/${year}`;
@@ -146,10 +148,43 @@ app.get('/tweet-page', async (req, res) => {
146148
}
147149
};
148150

151+
let result = [];
152+
149153
try {
150154
const response = await axios.get(url);
155+
result = response?.data ?? [];
156+
} catch (err) {
157+
console.error('tweet page error', err);
158+
}
159+
160+
try {
161+
if (month && day && endDay) {
162+
const startDayNumber = parseInt(day);
163+
const endDayNumber = parseInt(endDay);
164+
165+
for (let i = startDayNumber + 1; i <= endDayNumber; i++) {
166+
let endDayStr = i + '';
167+
if (i < 10) endDayStr = '0' + i;
168+
169+
try {
170+
let endDayURL = `https://raw.githubusercontent.com/hello-world-1989/json/main/tweet/${year}/${month}/${endDayStr}/${id}.json`;
171+
172+
const currentResponse = await axios.get(endDayURL);
173+
174+
const currentData = currentResponse?.data ?? [];
175+
result.push(...currentData);
176+
} catch (err) {
177+
console.error('end day error', err);
178+
continue;
179+
}
180+
}
181+
}
182+
} catch (err) {
183+
console.error('end day error', err);
184+
}
151185

152-
const tweets = response?.data
186+
try {
187+
const tweets = result
153188
?.sort((a, b) => sort(a, b))
154189
.map((item) => {
155190
const images = item?.images?.split(',') ?? [];
@@ -183,13 +218,21 @@ app.get('/search-tweet-page', async (req, res) => {
183218

184219
let url = `https://api.github.com/search/code?q=${keyword} in:file repo:hello-world-1989/json`;
185220

186-
const response = await axios.get(url, {
187-
headers: {
188-
Authorization: `Bearer ${process.env.GITHUB_TOKEN}`,
189-
},
190-
});
221+
let result = [];
191222

192-
const promises = response?.data?.items
223+
try {
224+
const response = await axios.get(url, {
225+
headers: {
226+
Authorization: `Bearer ${process.env.GITHUB_TOKEN}`,
227+
},
228+
});
229+
230+
result = response?.data;
231+
} catch (err) {
232+
console.error('search tweet page err', err);
233+
}
234+
235+
const promises = result?.items
193236
?.filter((item) => item.name === 'whyyoutouzhele.json')
194237
.map((item) => {
195238
let url = `https://raw.githubusercontent.com/hello-world-1989/json/main/${item.path}`;
@@ -465,6 +508,7 @@ app.use('/tweet', async (req, res) => {
465508
const year = req.query?.year;
466509
const month = req.query?.month;
467510
const day = req.query?.day;
511+
const endDay = req.query?.endDay;
468512
const id = req.query?.id;
469513

470514
let url = `https://raw.githubusercontent.com/hello-world-1989/json/main/tweet/${year}`;
@@ -481,7 +525,35 @@ app.use('/tweet', async (req, res) => {
481525

482526
const response = await axios.get(url);
483527

484-
res.send(response?.data);
528+
let result = response?.data ?? [];
529+
530+
try {
531+
if (month && day && endDay) {
532+
const startDayNumber = parseInt(day);
533+
const endDayNumber = parseInt(endDay);
534+
535+
for (let i = startDayNumber + 1; i <= endDayNumber; i++) {
536+
let endDayStr = i + '';
537+
if (i < 10) endDayStr = '0' + i;
538+
539+
try {
540+
let endDayURL = `https://raw.githubusercontent.com/hello-world-1989/json/main/tweet/${year}/${month}/${endDayStr}/${id}.json`;
541+
542+
const currentResponse = await axios.get(endDayURL);
543+
544+
const currentData = currentResponse?.data ?? [];
545+
result.push(...currentData);
546+
} catch (err) {
547+
console.error('end day error', err);
548+
continue;
549+
}
550+
}
551+
}
552+
} catch (err) {
553+
console.error('end day error', err);
554+
}
555+
556+
res.send(result);
485557
} catch (err) {
486558
console.log(err);
487559
res.send('');

0 commit comments

Comments
 (0)