Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/base/node/feed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const parseRss = (xml: any): Omit<Feed, 'url'> => {
url: gettrim(v, 'link[0]'),
content: gettrim(v, 'content:encoded[0]') || gettrim(v, 'description[0]'),
pubTime: gettrim(v, 'pubDate[0]'),
author: gettrim(v, 'author[0]', '') || gettrim(v, 'dc:creator[0]', ''),
})),
}
}
Expand All @@ -30,10 +31,11 @@ const parseAtom = (xml: any): Omit<Feed, 'url'> => {
description: '',
link: '',
items: (feed.entry || []).map((v: any) => ({
title: gettrim(v, 'title[0]'),
title: gettrim(v, 'title[0]._') || gettrim(v, 'title[0]'),
url: gettrim(v, 'link[0].$.href', ''),
content: gettrim(v, 'content[0]_', ''),
content: gettrim(v, 'content[0]._', ''),
pubTime: gettrim(v, 'published[0]') || gettrim(v, 'updated[0]'),
author: gettrim(v, 'author[0].name[0]') || gettrim(v, 'author[0]', '') || '',
})),
}
}
Expand Down
13 changes: 12 additions & 1 deletion src/main/reader/db.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { exec } from '@/services/db/electron-main/db'
import { exec, get } from '@/services/db/electron-main/db'
import { logger } from '@/services/logger/electron-main/logger'

const sql = `
Expand Down Expand Up @@ -26,9 +26,20 @@ const sql = `
);
`

const alterSql = `
ALTER TABLE articles
ADD COLUMN author NVARCHAR(50);
`

export const init = async () => {
try {
await exec(sql)

const row = await get('select * from sqlite_schema where name = "articles" and sql like "%author%"')

if (!row) {
await exec(alterSql)
}
} catch (e) {
logger.error('[Reader] Create Reader table error:', e)
}
Expand Down
2 changes: 1 addition & 1 deletion src/services/reader/electron-main/article.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Article, Tab } from '@/types/reader'
export const upsert = (articles: Article | Article[]) => new Promise<void>((resolve, reject) => {
const items = Array.isArray(articles) ? articles : [articles]

const cols = ['title', 'url', 'content', 'pubTime', 'feedId'] as const
const cols = ['title', 'url', 'content', 'pubTime', 'author', 'feedId'] as const
const keys = cols.map((k) => `$${k}`)
const sets = cols.map((k, index) => `${k}=${keys[index]}`)

Expand Down
1 change: 1 addition & 0 deletions src/types/reader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export type Article = {
url: string
content: string
pubTime?: string
author?: string
starred?: 0 | 1
read?: 0 | 1
feedId?: number
Expand Down
6 changes: 6 additions & 0 deletions src/ui/apps/reader/MainPanel/Article/content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ function Content() {
content,
feedId,
pubTime,
author,
} = activeArticle
const feed = feeds.find((v) => v.id === feedId)!

Expand Down Expand Up @@ -102,6 +103,11 @@ function Content() {
<div className="mr-7">
{feed.title}
</div>
{author !== feed.title && (
<div className="mr-7">
{author}
</div>
)}
<div>
{formatTime(pubTime!, 'MM/dd/yy hh:mm')}
</div>
Expand Down