1.替换redis存储2.使用websocket传数据
This commit is contained in:
parent
8a1517f86e
commit
64c66f5d98
@ -9,9 +9,10 @@ FROM alpine
|
|||||||
|
|
||||||
COPY --from=builder /src/bin /app
|
COPY --from=builder /src/bin /app
|
||||||
COPY --from=builder /src/index.html /app/index.html
|
COPY --from=builder /src/index.html /app/index.html
|
||||||
|
COPY --from=builder /src/static /app/static
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
|
|
||||||
ENTRYPOINT ["./ownrss"]
|
ENTRYPOINT ["./rss-reader"]
|
||||||
|
|||||||
85
README.md
85
README.md
@ -4,7 +4,9 @@ RSS可以将信息聚合,曾寻找过一些RSS客户端,但觉得都太过
|
|||||||
使用缓存加快响应速度,但我想要看到的是,打开页面看到关注网站的热点消息即可(一般通过RSS订阅获取到的数据即是热点),
|
使用缓存加快响应速度,但我想要看到的是,打开页面看到关注网站的热点消息即可(一般通过RSS订阅获取到的数据即是热点),
|
||||||
看到有感兴趣的信息,可以跳转过去再详细的了解。
|
看到有感兴趣的信息,可以跳转过去再详细的了解。
|
||||||
|
|
||||||

|
2023年7月28日,进行了界面改版和升级
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
# 配置文件
|
# 配置文件
|
||||||
|
|
||||||
@ -12,82 +14,41 @@ RSS可以将信息聚合,曾寻找过一些RSS客户端,但觉得都太过
|
|||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"sources": [
|
"values": [
|
||||||
"https://rsshub.asksowhat.cn/v2ex/topics/latest",
|
"https://www.zhihu.com/rss",
|
||||||
"https://rsshub.asksowhat.cn/36kr/news/latest",
|
"https://tech.meituan.com/feed/",
|
||||||
"https://rsshub.asksowhat.cn/aliyun/developer/group/alitech",
|
"http://www.ruanyifeng.com/blog/atom.xml",
|
||||||
"https://rsshub.asksowhat.cn/blogread/newest",
|
"https://feeds.appinn.com/appinns/",
|
||||||
"https://rsshub.asksowhat.cn/juejin/category/backend",
|
"https://v2ex.com/feed/tab/tech.xml",
|
||||||
"https://rsshub.asksowhat.cn/edrawsoft/mindmap/8/PV/DESC/CN/1",
|
"https://www.cmooc.com/feed",
|
||||||
"https://hostloc.com/forum.php?mod=rss&fid=45&auth=3ba611tSbtZSmrvt5Zo2lBgahajeORVteWbX8IarKV66xIEkPiuIRFG2g5x0tQ"
|
"http://www.sciencenet.cn/xml/blog.aspx?di=30",
|
||||||
|
"https://www.douban.com/feed/review/book",
|
||||||
|
"https://www.douban.com/feed/review/movie",
|
||||||
|
"https://www.geekpark.net/rss",
|
||||||
|
"http://www.ftchinese.com/rss/news",
|
||||||
|
"https://cn.nytimes.com/rss.html",
|
||||||
|
"https://hostloc.com/forum.php?mod=rss&fid=45&auth=389ec3vtQanmEuRoghE%2FpZPWnYCPmvwWgSa7RsfjbQ%2BJpA%2F6y6eHAx%2FKqtmPOg"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
# 使用方式
|
# 使用方式
|
||||||
|
|
||||||
该项目仅仅只有一个html文件,将RSS订阅链接抽离为JSON配置文件,可以部署在GitHub Pages、VerCel等支持静态网页平台,也可
|
## Docker部署
|
||||||
在自己搭建的web容器中如Nginx。无论使用哪种都需要解决跨域问题,我所设想的最好方案不需要依赖外部的网络,但是没能找到合适
|
|
||||||
的,当前是通过[cors-anywhere](https://github.com/Rob--W/cors-anywhere)来解决的,需要在自己的服务器部署,当前内置的cors代理
|
|
||||||
是在我自己服务器部署的,这部分最好能自己去搭建。
|
|
||||||
|
|
||||||
## Docker部署(非自建cors代理)
|
|
||||||
|
|
||||||
环境要求:Git、Docker、Docker-Compose
|
环境要求:Git、Docker、Docker-Compose
|
||||||
|
|
||||||
克隆项目
|
克隆项目
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git clone https://github.com/asksowhat/ownrss.git
|
git clone https://github.com/srcrs/rss-reader
|
||||||
```
|
```
|
||||||
|
|
||||||
进入ownrss文件夹,运行项目
|
进入rss-reader文件夹,运行项目
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker-compose up -d ownrss
|
docker-compose up -d rss-reader
|
||||||
```
|
```
|
||||||
|
|
||||||
最后通过ip+端口号访问即可
|
部署成功后,通过ip+端口号访问
|
||||||
|
|
||||||
## Docker部署(自建cors代理,推荐)
|
|
||||||
|
|
||||||
```bash
|
|
||||||
git clone https://github.com/asksowhat/ownrss.git
|
|
||||||
```
|
|
||||||
|
|
||||||
进入ownrss文件夹,运行项目,这里于上一步有区别
|
|
||||||
|
|
||||||
```bash
|
|
||||||
docker-compose up -d
|
|
||||||
```
|
|
||||||
|
|
||||||
更改index.html中的代理
|
|
||||||
|
|
||||||
```html
|
|
||||||
const CORS_PROXY = 'https://cors.asksowhat.cn/'
|
|
||||||
```
|
|
||||||
|
|
||||||
替换为如下形式,IP是你服务器的ip,PORT即是cors-anywhere容器对外暴漏的端口,在项目中,该端口为10015
|
|
||||||
|
|
||||||
```html
|
|
||||||
const CORS_PROXY = 'http:IP:PORT/'
|
|
||||||
```
|
|
||||||
|
|
||||||
更改完之后保存,最后通过ip+端口号访问
|
|
||||||
|
|
||||||
|
|
||||||
## 非Docker部署
|
|
||||||
|
|
||||||
这里不通过Docker部署教程暂时不提供,大家可以参考该[cors-anywhere](https://github.com/Rob--W/cors-anywhere)项目说明,如何在没有服务器的情况下搭建cors代理,然后替换掉index.html中的代理CORS_PROXY,后面就可以在各种免费的Pages服务中使用了。
|
|
||||||
|
|
||||||
# 依赖项目说明及感谢
|
|
||||||
|
|
||||||
- [alpine](https://github.com/alpinejs/alpine)类似于一个极简的vue,可以非常方便的将标签和参数绑定
|
|
||||||
|
|
||||||
- [bulma](https://github.com/jgthms/bulma)非常好看的ui组件
|
|
||||||
|
|
||||||
- [cors-anywhere](https://github.com/Rob--W/cors-anywhere)解决了跨域的问题
|
|
||||||
|
|
||||||
- [rss-parser](https://github.com/rbren/rss-parser)获取RSS订阅的内容,并将其转换为对象
|
|
||||||
|
|
||||||
- [jquery](https://github.com/jquery/jquery)获取本地的JSON文件,并转换为对象
|
|
||||||
|
|||||||
22
config.json
22
config.json
@ -1,11 +1,17 @@
|
|||||||
{
|
{
|
||||||
"sources": [
|
"values": [
|
||||||
"https://rsshub.asksowhat.cn/v2ex/topics/latest",
|
"https://www.zhihu.com/rss",
|
||||||
"https://rsshub.asksowhat.cn/36kr/news/latest",
|
"https://tech.meituan.com/feed/",
|
||||||
"https://rsshub.asksowhat.cn/aliyun/developer/group/alitech",
|
"http://www.ruanyifeng.com/blog/atom.xml",
|
||||||
"https://rsshub.asksowhat.cn/blogread/newest",
|
"https://feeds.appinn.com/appinns/",
|
||||||
"https://rsshub.asksowhat.cn/juejin/category/backend",
|
"https://v2ex.com/feed/tab/tech.xml",
|
||||||
"https://rsshub.asksowhat.cn/edrawsoft/mindmap/8/PV/DESC/CN/1",
|
"https://www.cmooc.com/feed",
|
||||||
"https://hostloc.com/forum.php?mod=rss&fid=45&auth=3ba611tSbtZSmrvt5Zo2lBgahajeORVteWbX8IarKV66xIEkPiuIRFG2g5x0tQ"
|
"http://www.sciencenet.cn/xml/blog.aspx?di=30",
|
||||||
|
"https://www.douban.com/feed/review/book",
|
||||||
|
"https://www.douban.com/feed/review/movie",
|
||||||
|
"https://www.geekpark.net/rss",
|
||||||
|
"http://www.ftchinese.com/rss/news",
|
||||||
|
"https://cn.nytimes.com/rss.html",
|
||||||
|
"https://hostloc.com/forum.php?mod=rss&fid=45&auth=389ec3vtQanmEuRoghE%2FpZPWnYCPmvwWgSa7RsfjbQ%2BJpA%2F6y6eHAx%2FKqtmPOg"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,9 +4,10 @@ services:
|
|||||||
server:
|
server:
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
container_name: ownrss
|
container_name: rss-reader
|
||||||
restart: always
|
restart: always
|
||||||
ports:
|
ports:
|
||||||
- "10060:8080"
|
- "8080:8080"
|
||||||
volumes:
|
volumes:
|
||||||
- "$PWD/index.html:/app/index.html"
|
- "$PWD/index.html:/app/index.html"
|
||||||
|
- "$PWD/db:/app/db"
|
||||||
|
|||||||
15
go.mod
15
go.mod
@ -1,22 +1,27 @@
|
|||||||
module ownrss
|
module rss-reader
|
||||||
|
|
||||||
go 1.18
|
go 1.18
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/go-redis/redis/v8 v8.11.5
|
github.com/dgraph-io/badger v1.6.2
|
||||||
|
github.com/gorilla/websocket v1.5.0
|
||||||
github.com/mmcdole/gofeed v1.2.1
|
github.com/mmcdole/gofeed v1.2.1
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96 // indirect
|
||||||
github.com/PuerkitoBio/goquery v1.8.0 // indirect
|
github.com/PuerkitoBio/goquery v1.8.0 // indirect
|
||||||
github.com/andybalholm/cascadia v1.3.1 // indirect
|
github.com/andybalholm/cascadia v1.3.1 // indirect
|
||||||
github.com/cespare/xxhash/v2 v2.1.2 // indirect
|
github.com/cespare/xxhash v1.1.0 // indirect
|
||||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
github.com/dgraph-io/ristretto v0.0.2 // indirect
|
||||||
|
github.com/dustin/go-humanize v1.0.0 // indirect
|
||||||
|
github.com/golang/protobuf v1.3.1 // indirect
|
||||||
github.com/json-iterator/go v1.1.12 // indirect
|
github.com/json-iterator/go v1.1.12 // indirect
|
||||||
github.com/mmcdole/goxpp v1.1.0 // indirect
|
github.com/mmcdole/goxpp v1.1.0 // indirect
|
||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||||
|
github.com/pkg/errors v0.8.1 // indirect
|
||||||
golang.org/x/net v0.4.0 // indirect
|
golang.org/x/net v0.4.0 // indirect
|
||||||
|
golang.org/x/sys v0.3.0 // indirect
|
||||||
golang.org/x/text v0.5.0 // indirect
|
golang.org/x/text v0.5.0 // indirect
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
74
go.sum
74
go.sum
@ -1,20 +1,46 @@
|
|||||||
|
github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96 h1:cTp8I5+VIoKjsnZuH8vjyaysT/ses3EvZeaV/1UkF2M=
|
||||||
|
github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8=
|
||||||
|
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||||
|
github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE=
|
||||||
|
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
|
||||||
github.com/PuerkitoBio/goquery v1.8.0 h1:PJTF7AmFCFKk1N6V6jmKfrNH9tV5pNE6lZMkG0gta/U=
|
github.com/PuerkitoBio/goquery v1.8.0 h1:PJTF7AmFCFKk1N6V6jmKfrNH9tV5pNE6lZMkG0gta/U=
|
||||||
github.com/PuerkitoBio/goquery v1.8.0/go.mod h1:ypIiRMtY7COPGk+I/YbZLbxsxn9g5ejnI2HSMtkjZvI=
|
github.com/PuerkitoBio/goquery v1.8.0/go.mod h1:ypIiRMtY7COPGk+I/YbZLbxsxn9g5ejnI2HSMtkjZvI=
|
||||||
github.com/andybalholm/cascadia v1.3.1 h1:nhxRkql1kdYCc8Snf7D5/D3spOX+dBgjA6u8x004T2c=
|
github.com/andybalholm/cascadia v1.3.1 h1:nhxRkql1kdYCc8Snf7D5/D3spOX+dBgjA6u8x004T2c=
|
||||||
github.com/andybalholm/cascadia v1.3.1/go.mod h1:R4bJ1UQfqADjvDa4P6HZHLh/3OxWWEqc0Sk8XGwHqvA=
|
github.com/andybalholm/cascadia v1.3.1/go.mod h1:R4bJ1UQfqADjvDa4P6HZHLh/3OxWWEqc0Sk8XGwHqvA=
|
||||||
github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE=
|
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
|
||||||
github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko=
|
||||||
|
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
|
||||||
|
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
|
||||||
|
github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
|
||||||
|
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
|
||||||
|
github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
|
github.com/dgraph-io/badger v1.6.2 h1:mNw0qs90GVgGGWylh0umH5iag1j6n/PeJtNvL6KY/x8=
|
||||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
|
github.com/dgraph-io/badger v1.6.2/go.mod h1:JW2yswe3V058sS0kZ2h/AXeDSqFjxnZcRrVH//y2UQE=
|
||||||
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
|
github.com/dgraph-io/ristretto v0.0.2 h1:a5WaUrDa0qm0YrAAS1tUykT5El3kt62KNZZeMxQn3po=
|
||||||
github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI=
|
github.com/dgraph-io/ristretto v0.0.2/go.mod h1:KPxhHT9ZxKefz+PCeOGsrHpl1qZ7i70dGTu2u+Ahh6E=
|
||||||
github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo=
|
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2 h1:tdlZCpZ/P9DhczCTSixgIKmwPv6+wP5DGjqLYw5SUiA=
|
||||||
|
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw=
|
||||||
|
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
|
||||||
|
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
|
||||||
|
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||||
|
github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg=
|
||||||
|
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||||
|
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
|
||||||
|
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||||
|
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
||||||
|
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||||
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||||
|
github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
|
||||||
|
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||||
|
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||||
|
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
||||||
|
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||||
|
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||||
github.com/mmcdole/gofeed v1.2.1 h1:tPbFN+mfOLcM1kDF1x2c/N68ChbdBatkppdzf/vDe1s=
|
github.com/mmcdole/gofeed v1.2.1 h1:tPbFN+mfOLcM1kDF1x2c/N68ChbdBatkppdzf/vDe1s=
|
||||||
github.com/mmcdole/gofeed v1.2.1/go.mod h1:2wVInNpgmC85q16QTTuwbuKxtKkHLCDDtf0dCmnrNr4=
|
github.com/mmcdole/gofeed v1.2.1/go.mod h1:2wVInNpgmC85q16QTTuwbuKxtKkHLCDDtf0dCmnrNr4=
|
||||||
github.com/mmcdole/goxpp v1.1.0 h1:WwslZNF7KNAXTFuzRtn/OKZxFLJAAyOA9w82mDz2ZGI=
|
github.com/mmcdole/goxpp v1.1.0 h1:WwslZNF7KNAXTFuzRtn/OKZxFLJAAyOA9w82mDz2ZGI=
|
||||||
@ -24,26 +50,48 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w
|
|||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||||
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
||||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||||
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
|
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
|
||||||
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
|
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
|
||||||
github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE=
|
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
|
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
|
||||||
|
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
|
||||||
|
github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI=
|
||||||
|
github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
|
||||||
|
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
|
||||||
|
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
|
||||||
|
github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU=
|
||||||
|
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
|
||||||
|
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
||||||
|
github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
|
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||||
|
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||||
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
|
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
|
||||||
|
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
|
||||||
|
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
|
||||||
|
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||||
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
|
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
golang.org/x/net v0.0.0-20210916014120-12bc252f5db8/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
golang.org/x/net v0.0.0-20210916014120-12bc252f5db8/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||||
golang.org/x/net v0.4.0 h1:Q5QPcMlvfxFTAPV0+07Xz/MpK9NTXu2VDUuy0FeMfaU=
|
golang.org/x/net v0.4.0 h1:Q5QPcMlvfxFTAPV0+07Xz/MpK9NTXu2VDUuy0FeMfaU=
|
||||||
golang.org/x/net v0.4.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE=
|
golang.org/x/net v0.4.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE=
|
||||||
|
golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.3.0 h1:w8ZOecv6NaNa/zC8944JTU3vz4u6Lagfk4RPQxv92NQ=
|
golang.org/x/sys v0.3.0 h1:w8ZOecv6NaNa/zC8944JTU3vz4u6Lagfk4RPQxv92NQ=
|
||||||
|
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/text v0.5.0 h1:OLmvp0KP+FVG99Ct/qFiL/Fhk4zp4QQnZ7b2U+5piUM=
|
golang.org/x/text v0.5.0 h1:OLmvp0KP+FVG99Ct/qFiL/Fhk4zp4QQnZ7b2U+5piUM=
|
||||||
golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
|
|
||||||
|
|||||||
21
index.html
21
index.html
@ -4,7 +4,9 @@
|
|||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>RSS Reader</title>
|
<title>RSS Reader</title>
|
||||||
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
|
<!-- <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css"> -->
|
||||||
|
<link rel="stylesheet" href="static/index.css">
|
||||||
|
<link rel="icon" href="static/favicon.svg" type="image/x-icon">
|
||||||
<style>
|
<style>
|
||||||
body {
|
body {
|
||||||
font-family: "Avenir", Helvetica, Arial, sans-serif;
|
font-family: "Avenir", Helvetica, Arial, sans-serif;
|
||||||
@ -12,7 +14,7 @@
|
|||||||
-moz-osx-font-smoothing: grayscale;
|
-moz-osx-font-smoothing: grayscale;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
color: #2c3e50;
|
color: #2c3e50;
|
||||||
margin-top: 60px;
|
margin-top: 30px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.card-header {
|
.card-header {
|
||||||
@ -88,8 +90,11 @@
|
|||||||
</el-container>
|
</el-container>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="https://unpkg.com/vue@next"></script>
|
<!-- <script src="https://unpkg.com/vue@next"></script> -->
|
||||||
<script src="https://cdn.bootcdn.net/ajax/libs/element-plus/2.3.3/index.full.js"></script>
|
<script src="static/vue.global.js"></script>
|
||||||
|
|
||||||
|
<!-- <script src="https://cdn.bootcdn.net/ajax/libs/element-plus/2.3.3/index.full.js"></script> -->
|
||||||
|
<script src="static/index.full.js"></script>
|
||||||
<script>
|
<script>
|
||||||
const app = Vue.createApp({
|
const app = Vue.createApp({
|
||||||
data() {
|
data() {
|
||||||
@ -98,9 +103,11 @@
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
async created() {
|
async created() {
|
||||||
const response = await fetch("/feeds");
|
const socket = new WebSocket("ws://localhost:8080/ws");
|
||||||
const feeds = await response.json();
|
socket.onmessage = event => {
|
||||||
this.feeds = feeds;
|
const feed = JSON.parse(event.data);
|
||||||
|
this.feeds.push(feed);
|
||||||
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
139
main.go
139
main.go
@ -1,31 +1,61 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/go-redis/redis/v8"
|
"github.com/dgraph-io/badger"
|
||||||
|
"github.com/gorilla/websocket"
|
||||||
"github.com/mmcdole/gofeed"
|
"github.com/mmcdole/gofeed"
|
||||||
)
|
)
|
||||||
|
|
||||||
var ctx = context.Background()
|
type Config struct {
|
||||||
var rdb *redis.Client
|
Values []string `json:"values"`
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
db *badger.DB
|
||||||
|
rssUrls Config
|
||||||
|
upgrader = websocket.Upgrader{}
|
||||||
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
rdb = redis.NewClient(&redis.Options{
|
// 读取配置文件
|
||||||
Addr: "xx.xx.xx.xx:6399",
|
data, err := ioutil.ReadFile("config.json")
|
||||||
Password: "xxxxxx",
|
if err != nil {
|
||||||
DB: 0,
|
panic(err)
|
||||||
})
|
}
|
||||||
|
// 解析JSON数据到Config结构体
|
||||||
|
err = json.Unmarshal(data, &rssUrls)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
initDB()
|
||||||
|
}
|
||||||
|
|
||||||
|
func initDB() error {
|
||||||
|
var err error
|
||||||
|
options := badger.DefaultOptions("db").WithTruncate(false)
|
||||||
|
db, err = badger.Open(options)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
go updateFeeds()
|
go updateFeeds()
|
||||||
http.HandleFunc("/feeds", getFeedsHandler)
|
http.HandleFunc("/feeds", getFeedsHandler)
|
||||||
|
http.HandleFunc("/ws", wsHandler)
|
||||||
http.HandleFunc("/", serveHome)
|
http.HandleFunc("/", serveHome)
|
||||||
|
|
||||||
|
//加载静态文件
|
||||||
|
fs := http.FileServer(http.Dir("static"))
|
||||||
|
http.Handle("/static/", http.StripPrefix("/static/", fs))
|
||||||
log.Fatal(http.ListenAndServe(":8080", nil))
|
log.Fatal(http.ListenAndServe(":8080", nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,24 +63,36 @@ func serveHome(w http.ResponseWriter, r *http.Request) {
|
|||||||
http.ServeFile(w, r, "index.html")
|
http.ServeFile(w, r, "index.html")
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateFeeds() {
|
func wsHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
rssUrls := []string{
|
conn, err := upgrader.Upgrade(w, r, nil)
|
||||||
// 添加您的RSS订阅链接
|
if err != nil {
|
||||||
"https://www.zhihu.com/rss",
|
log.Printf("Upgrade failed: %v", err)
|
||||||
"https://tech.meituan.com/feed/",
|
return
|
||||||
"http://www.ruanyifeng.com/blog/atom.xml",
|
}
|
||||||
"https://cn.wsj.com/zh-hans/rss",
|
defer conn.Close()
|
||||||
"https://feeds.appinn.com/appinns/",
|
|
||||||
"https://v2ex.com/feed/tab/tech.xml",
|
for _, url := range rssUrls.Values {
|
||||||
"https://hostloc.com/forum.php?mod=rss&fid=45&auth=389ec3vtQanmEuRoghE%2FpZPWnYCPmvwWgSa7RsfjbQ%2BJpA%2F6y6eHAx%2FKqtmPOg",
|
feedJSON, err := get(url)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Error getting feed from Redis: %v", err)
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = conn.WriteMessage(websocket.TextMessage, []byte(feedJSON))
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Error sending message: %v", err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func updateFeeds() {
|
||||||
for {
|
for {
|
||||||
for _, url := range rssUrls {
|
for _, url := range rssUrls.Values {
|
||||||
fp := gofeed.NewParser()
|
fp := gofeed.NewParser()
|
||||||
feed, err := fp.ParseURL(url)
|
feed, err := fp.ParseURL(url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Error fetching feed: %v", err)
|
log.Printf("Error fetching feed: %v | %v", url, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,32 +102,23 @@ func updateFeeds() {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
err = rdb.Set(ctx, url, feedJSON, 0).Err()
|
err = update(url, string(feedJSON))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Error saving feed to Redis: %v", err)
|
log.Printf("Error saving feed to Redis: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
time.Sleep(10 * time.Minute)
|
log.Printf("update success")
|
||||||
|
time.Sleep(5 * time.Minute)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getFeedsHandler(w http.ResponseWriter, r *http.Request) {
|
func getFeedsHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
rssUrls := []string{
|
|
||||||
// 添加您的RSS订阅链接
|
|
||||||
"https://www.zhihu.com/rss",
|
|
||||||
"https://tech.meituan.com/feed/",
|
|
||||||
"http://www.ruanyifeng.com/blog/atom.xml",
|
|
||||||
"https://cn.wsj.com/zh-hans/rss",
|
|
||||||
"https://feeds.appinn.com/appinns/",
|
|
||||||
"https://v2ex.com/feed/tab/tech.xml",
|
|
||||||
"https://hostloc.com/forum.php?mod=rss&fid=45&auth=389ec3vtQanmEuRoghE%2FpZPWnYCPmvwWgSa7RsfjbQ%2BJpA%2F6y6eHAx%2FKqtmPOg",
|
|
||||||
}
|
|
||||||
|
|
||||||
feeds := make([]gofeed.Feed, 0, len(rssUrls))
|
feeds := make([]gofeed.Feed, 0, len(rssUrls.Values))
|
||||||
for _, url := range rssUrls {
|
for _, url := range rssUrls.Values {
|
||||||
feedJSON, err := rdb.Get(ctx, url).Result()
|
feedJSON, err := get(url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Error getting feed from Redis: %v", err)
|
log.Printf("Error getting feed from Redis: %v | %v", url, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,3 +136,35 @@ func getFeedsHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
json.NewEncoder(w).Encode(feeds)
|
json.NewEncoder(w).Encode(feeds)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func update(key, value string) error {
|
||||||
|
// 写入数据
|
||||||
|
if err := db.Update(func(txn *badger.Txn) error {
|
||||||
|
err := txn.Set([]byte(key), []byte(value))
|
||||||
|
return err
|
||||||
|
}); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func get(key string) (string, error) {
|
||||||
|
value := make([]byte, 0)
|
||||||
|
// 读取数据
|
||||||
|
if err := db.View(func(txn *badger.Txn) error {
|
||||||
|
if item, err := txn.Get([]byte(key)); err != nil {
|
||||||
|
return err
|
||||||
|
} else {
|
||||||
|
if value, err = item.ValueCopy(nil); err != nil {
|
||||||
|
return err
|
||||||
|
} else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}); err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
if string(value) == "" {
|
||||||
|
return "", fmt.Errorf("person not found")
|
||||||
|
}
|
||||||
|
return string(value), nil
|
||||||
|
}
|
||||||
|
|||||||
1
static/favicon.svg
Normal file
1
static/favicon.svg
Normal file
@ -0,0 +1 @@
|
|||||||
|
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1690474700709" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1055" xmlns:xlink="http://www.w3.org/1999/xlink" width="128" height="128"><path d="M512 729.984a218.048 218.048 0 1 1 218.048-218.048 43.584 43.584 0 0 1-87.232 0A130.816 130.816 0 1 0 512 642.752a43.584 43.584 0 0 1 0 87.232z m0 174.4a392.448 392.448 0 1 1 392.448-392.448 43.584 43.584 0 0 1-87.232 0 305.216 305.216 0 1 0-122.496 244.608L481.088 542.912a43.584 43.584 0 0 1 61.504-61.504l246.784 246.784a43.584 43.584 0 0 1 0 61.504A392.448 392.448 0 0 1 512 904.448z" fill="#000000" fill-opacity="0.9" p-id="1056"></path></svg>
|
||||||
|
After Width: | Height: | Size: 781 B |
1
static/index.css
Normal file
1
static/index.css
Normal file
File diff suppressed because one or more lines are too long
56373
static/index.full.js
Normal file
56373
static/index.full.js
Normal file
File diff suppressed because one or more lines are too long
15929
static/vue.global.js
Normal file
15929
static/vue.global.js
Normal file
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
Before Width: | Height: | Size: 432 KiB |
Loading…
Reference in New Issue
Block a user