Skip to content

Commit 89c54f6

Browse files
committed
网络请求全部调整为axios
1 parent 4def9b5 commit 89c54f6

File tree

13 files changed

+295
-132
lines changed

13 files changed

+295
-132
lines changed

ada_lovelace.jpg

Loading

config/articles.db

0 Bytes
Binary file not shown.

config/index/index.html

+51-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,57 @@
11
<html>
22

3-
<head><title></title></head>
4-
<body>
3+
<head><title></title>
4+
<meta charset="UTF-8">
5+
</head>
6+
<body>
57

6-
默认首页
8+
<h2>RSS解决的痛点</h2>
79

8-
</body>
10+
<ul>
11+
<li>信息分散:为了获取多个信息,需要去多个渠道</li>
12+
<li>渠道质量:自己阅历有限,找到的渠道也不一定是比较好的</li>
13+
<li>信息泛滥:一个渠道里包含信息过多,自己真的感兴趣的可能被淹没其中</li>
14+
<li>时效性低:需要自己主动去寻找时,才可能看到信息,离它刚出现的时间已经很久</li>
15+
<li>没有渠道:有些信息并没有明确渠道提供,除了主动通过比如搜索引擎等方式去寻找,一般也就放弃了</li>
16+
<li>耗时费劲:操作繁杂、寻找费时、筛选费劲、还得时时关注</li>
17+
18+
</ul>
19+
<h2>聊聊怎么使用</h2>
20+
<p>
21+
当前阅读器理论上支持RSS的1.0版(代表为博客园)和2.0版协议(代表为CSDN)的解析。
22+
</p>
23+
24+
<p>
25+
阅读器其实就是解析RSS源(xml格式)得到数据之后下载到本地。所以源很重要 国内大部分应用和网站都已经不提供对RSS的支持了
26+
</p>
27+
28+
<p>
29+
无意中发现了 <a href="javascript:openExternal('https://github.com/DIYgod/RSSHub-Radar')">RssHub</a>,随之决定编写这款阅读器
30+
</p>
31+
32+
<p>安装插件:RssHub提供了插件,可以检测当前网站的RSS源。地址:<a href="javascript:openExternal('https://github.com/DIYgod/RSSHub-Radar')">https://github.com/DIYgod/RSSHub-Radar</a></p>
33+
34+
35+
<blockquote>
36+
RSSHub官网已经被墙了
37+
</blockquote>
38+
国内的镜像站
39+
<ul>
40+
<li>https://rsshub.uneasy.win</li>
41+
<li>http://rss.coder163.com</li>
42+
</ul>
43+
44+
<blockquote>
45+
如果遇到RSShub无法解析的站点怎么办?可以使用 Huginn ,只是我还在学习之中,所以不太好介绍
46+
</blockquote>
47+
48+
<h2>参考资料</h2>
49+
<ul>
50+
<li><a href="javascript:openExternal('https://www.ruanyifeng.com/blog/2006/01/rss.html')">如何使用RSS-阮一峰</a></li>
51+
<li><a href="javascript:openExternal('https://www.cnblogs.com/liujiangblog/p/12115804.html')">超详细!如何利用Huginn制作专属RSS </a></li>
52+
<li><a href="javascript:openExternal('https://www.ifanr.com/1318355')">RSS 二十年</a></li>
53+
</ul>
54+
55+
</body>
956

1057
</html>

image.png

1.11 MB
Loading

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
"private": true,
88
"scripts": {
99
"dev": " vite",
10-
"build": " vite build && electron-builder",
11-
"release": "cross-env GH_TOKEN=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 electron-builder"
10+
"build": " vite build && electron-builder"
1211
},
1312
"engines": {
1413
"node": ">=14.17.0"
@@ -41,6 +40,7 @@
4140
"dependencies": {
4241
"@quasar/extras": "^1.14.3",
4342
"cheerio": "^1.0.0-rc.12",
43+
"default-passive-events": "^2.0.0",
4444
"download": "^8.0.0",
4545
"electron-log": "^4.4.8",
4646
"electron-updater": "^5.2.1",

src/App.vue

+23-15
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,18 @@
77
<div class="side" :style="{ display: isHide }">
88

99
<q-bar class="q-electron-drag" style="background-color:#ecf0f6;">
10-
<img src="@/assets/logo.png" />
11-
<div>猿阅</div>
12-
<q-space />
10+
<!-- <q-btn flat class="q-electron-drag&#45;&#45;exception">-->
11+
<img src="@/assets/logo.png" class="q-electron-drag--exception"/>
12+
&nbsp;
13+
猿阅
14+
<!-- </q-btn>-->
15+
<q-space/>
1316
</q-bar>
1417
<side></side>
1518
</div>
1619
<!-- 主体内容 -->
1720
<div class="main-container">
18-
<top-tools />
21+
<top-tools/>
1922
<q-splitter v-model="splitterModel" :limits="[20, 95]">
2023
<template v-slot:before>
2124
<!-- 文章列表 -->
@@ -28,21 +31,21 @@
2831
</q-splitter>
2932
</div>
3033
</div>
31-
<setting-dialog />
32-
<update />
34+
<setting-dialog/>
35+
<update/>
3336

3437
</template>
3538

3639
<script setup lang="ts">
37-
import { onMounted, ref, computed } from "vue";
40+
import {onMounted, ref, computed,getCurrentInstance} from "vue";
3841
import ArticleList from "@/components/ArticleList.vue";
3942
import Content from "@/components/Content.vue";
4043
import Side from "./components/Side.vue";
4144
import Update from "@/components/Update.vue";
4245
import TopTools from "@/components/TopTools.vue";
4346
import SettingDialog from "@/components/SettingDialog.vue";
4447
45-
const { ipcRenderer } = window.require("electron");
48+
const {ipcRenderer} = window.require("electron");
4649
let splitterModel = ref(25) // start at 50%
4750
4851
let winHeight = ref<number>(document.documentElement.clientHeight);
@@ -67,13 +70,19 @@ ipcRenderer.on("key-event-l", (ev) => {
6770
});
6871
6972
onMounted(() => {
73+
74+
const $axios =getCurrentInstance()?.appContext.config.globalProperties.$axios ;
75+
76+
// $axios.get('https://rsshub.app/csdn/blog/csdngeeknews').then((response:any)=>{
77+
// console.log(response.data)
78+
// })
7079
//获取窗口大小,指定高度
7180
window.addEventListener(
72-
"resize",
73-
function () {
74-
winHeight.value = document.documentElement.clientHeight;
75-
},
76-
false
81+
"resize",
82+
function () {
83+
winHeight.value = document.documentElement.clientHeight;
84+
},
85+
false
7786
);
7887
});
7988
@@ -96,8 +105,7 @@ onMounted(() => {
96105
}
97106
98107
99-
100-
.q-bar--standard>div {
108+
.q-bar--standard > div {
101109
font-weight: 400;
102110
font-size: 14px !important;
103111
}

src/components/Content.vue

+49-19
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
<script setup lang="ts">
2424
// import ArticleList from "@/components/ArticleList.vue";
2525
import {onMounted, ref, getCurrentInstance, computed} from "vue"
26+
2627
const {ipcRenderer} = window.require("electron")
2728
import {getConfigPath} from '@/util/common'
2829
import Reptile from "@/reptile";
@@ -57,35 +58,28 @@ watch(filePath, async (value, oldValue, onCleanup) => {
5758
5859
document.querySelector("#content")?.scrollTo(0, 0);
5960
scrollArea.value?.setScrollPosition('vertical', 0)
60-
fs.readFile(filePath.value, "utf8", (err: NodeJS.ErrnoException | null, data: string) => {
61+
fs.readFile(filePath.value, "utf8", async (err: NodeJS.ErrnoException | null, data: string) => {
6162
if (err) {
6263
//防止读取失败依然加载
6364
loading.value = false;
6465
log.error(err.message)
6566
return
6667
}
67-
let article = articleitem.value
68-
//是否需要重新写入文件,如果图片变动,并做了替换
69-
let write = false
70-
7168
// //重新解析文章,替换img的src
72-
Reptile.parseAndDownloadImg(cheerio.load(data), article.link, article.path, (length: number, index: number, isWrite: boolean) => {
73-
loadingMessage.value = `正在缓存图片至本地,共 ${length} 张 当前 ${index + 1} 张,请稍后`
74-
write = isWrite;
75-
}).then((resp) => {
76-
loading.value = false;
77-
content.value = resp;
78-
if (write) {
79-
log.info(`图片解析完成,重写入文件${write}`)
80-
//重写本地文件
81-
fs.writeFileSync(filePath.value, resp)
69+
Reptile.downloadImg(cheerio.load(data), articleitem.value.link, articleitem.value.path, (length: number, index: number, html: string, mark: string) => {
70+
loadingMessage.value = `正在缓存图片至本地,${length}/${index + 1} ,请稍后`
71+
if ((length === (index + 1)) && (mark !== 'local')) {
72+
console.log(`图片下载完成,开始覆盖原来的HTML文件写入文件`)
73+
fs.writeFileSync(filePath.value, html)
74+
loading.value = false
75+
content.value = html
76+
} else if (length === (index + 1) || (length === 0)) {
77+
console.log(`本地图片,或者当前文章没有图片`)
78+
content.value = html
79+
loading.value = false
8280
}
83-
84-
}).catch((e) => {
85-
log.error(e)
8681
})
8782
88-
8983
})
9084
9185
@@ -224,6 +218,15 @@ code
224218
225219
226220
221+
222+
223+
224+
225+
226+
227+
228+
229+
227230
228231
229232
@@ -257,6 +260,15 @@ code
257260
258261
259262
263+
264+
265+
266+
267+
268+
269+
270+
271+
260272
261273
262274
@@ -286,6 +298,15 @@ code
286298
287299
288300
301+
302+
303+
304+
305+
306+
307+
308+
309+
289310
290311
291312
@@ -308,6 +329,15 @@ code
308329
309330
310331
332+
333+
334+
335+
336+
337+
338+
339+
340+
311341
312342
313343

src/components/SettingDialog.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ async function subTitleFocus() {
180180
})
181181
182182
}).catch((e) => {
183-
log.error(`解析失败:${NodeOption.link},错误描述${e}`)
183+
log.error(`解析失败:${NodeOption.link},错误描述${e.message}`)
184184
loading.value = false;
185185
})
186186

src/main.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {createApp} from 'vue'
22
import App from './App.vue'
3-
3+
//[Violation] Added non-passive event listener to a scroll-blocking 'mousewheel' event. Consider marking event handler as 'passive' to make the page more responsive.
4+
import 'default-passive-events'
45
const app = createApp(App);
56
// import { Quasar } from 'quasar'
67

@@ -25,7 +26,7 @@ import CopyButtonPlugin from './util/highlightjs-copy'
2526

2627
hljs.configure({
2728
//关闭xss攻击的警告(存在未转义的HTML标签)
28-
ignoreUnescapedHTML:true
29+
ignoreUnescapedHTML: true
2930
})
3031
hljs.addPlugin(new CopyButtonPlugin({}));
3132

@@ -45,13 +46,14 @@ app.directive('hljs', el => {
4546
});
4647
const {shell} = require('electron');
4748
//@ts-ignore
48-
window.openExternal=(url:string)=>{
49+
window.openExternal = (url: string) => {
4950
shell.openExternal(url);
5051
}
5152

5253
import store from './store'
54+
import instance from "@/util/api";
5355

54-
56+
app.config.globalProperties.$axios = instance
5557

5658
app.use(store)
5759

0 commit comments

Comments
 (0)