Skip to content

Commit

Permalink
订阅源自定义源列表、WEB VIEW 可以新增/修改
Browse files Browse the repository at this point in the history
订阅源自定义源列表、WEB VIEW 可以新增/修改
  • Loading branch information
MaoXiaoone committed Jul 19, 2024
1 parent 0d923b8 commit ab5e7a2
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 21 deletions.
20 changes: 18 additions & 2 deletions entry/src/main/ets/database/AppDatabase/index.ets
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,7 @@ export default {
},
{
"tableName": "rssSources",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`sourceType` INTEGER NOT NULL ,`sourceUrl` TEXT NOT NULL, `sourceName` TEXT NOT NULL, `sourceIcon` TEXT NOT NULL, `sourceGroup` TEXT, `sourceComment` TEXT, `enabled` INTEGER NOT NULL, `variableComment` TEXT, `jsLib` TEXT, `enabledCookieJar` INTEGER DEFAULT 0, `concurrentRate` TEXT, `header` TEXT, `loginUrl` TEXT, `loginUi` TEXT, `loginCheckJs` TEXT, `coverDecodeJs` TEXT, `sortUrl` TEXT, `singleUrl` INTEGER NOT NULL, `articleStyle` INTEGER NOT NULL DEFAULT 0, `ruleArticles` TEXT, `ruleNextPage` TEXT, `ruleTitle` TEXT, `rulePubDate` TEXT, `ruleDescription` TEXT, `ruleImage` TEXT, `ruleLink` TEXT, `ruleContent` TEXT, `contentWhitelist` TEXT, `contentBlacklist` TEXT, `shouldOverrideUrlLoading` TEXT, `style` TEXT, `enableJs` INTEGER NOT NULL DEFAULT 1, `loadWithBaseUrl` INTEGER NOT NULL DEFAULT 1, `injectJs` TEXT, `lastUpdateTime` INTEGER NOT NULL DEFAULT 0,`variable` TEXT, `sourceIconIsUrl` INTEGER ,`showRecentIcon` INTEGER NOT NULL DEFAULT 1, `customOrder` INTEGER NOT NULL DEFAULT 0, PRIMARY KEY(`sourceUrl`))",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`sourceType` INTEGER NOT NULL ,`sourceUrl` TEXT NOT NULL, `sourceName` TEXT NOT NULL, `sourceIcon` TEXT NOT NULL, `sourceGroup` TEXT, `sourceComment` TEXT, `enabled` INTEGER NOT NULL, `variableComment` TEXT, `jsLib` TEXT, `enabledCookieJar` INTEGER DEFAULT 0, `concurrentRate` TEXT, `header` TEXT, `loginUrl` TEXT, `loginUi` TEXT, `loginCheckJs` TEXT, `coverDecodeJs` TEXT, `sortUrl` TEXT, `singleUrl` INTEGER NOT NULL, `articleStyle` INTEGER NOT NULL DEFAULT 0, `ruleArticles` TEXT, `ruleNextPage` TEXT, `ruleTitle` TEXT, `rulePubDate` TEXT, `ruleDescription` TEXT, `ruleImage` TEXT, `ruleLink` TEXT, `ruleContent` TEXT, `contentWhitelist` TEXT, `contentBlacklist` TEXT, `shouldOverrideUrlLoading` TEXT, `style` TEXT, `enableJs` INTEGER NOT NULL DEFAULT 1, `loadWithBaseUrl` INTEGER NOT NULL DEFAULT 1, `injectJs` TEXT, `lastUpdateTime` INTEGER NOT NULL DEFAULT 0,`variable` TEXT, `rssListRule` TEXT,`rssWebViewRule` TEXT,`sourceIconIsUrl` INTEGER ,`showRecentIcon` INTEGER NOT NULL DEFAULT 1, `customOrder` INTEGER NOT NULL DEFAULT 0, PRIMARY KEY(`sourceUrl`))",
"fields": [
{
"fieldPath": "sourceType",
Expand Down Expand Up @@ -1062,6 +1062,7 @@ export default {
"fieldPath": "enabledCookieJar",
"columnName": "enabledCookieJar",
"affinity": "INTEGER",
"boolean": true,
"notNull": false,
"defaultValue": "0"
},
Expand Down Expand Up @@ -1215,14 +1216,29 @@ export default {
{
"fieldPath": "sourceIconIsUrl",
"columnName": "sourceIconIsUrl",
"affinity": "INTEGER"
"affinity": "INTEGER",
"boolean": true,
"notNull": false,
"defaultValue": "0"
},
{
"fieldPath": "variable",
"columnName": "variable",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "rssListRule",
"columnName": "rssListRule",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "rssWebViewRule",
"columnName": "rssWebViewRule",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "showRecentIcon",
"columnName": "showRecentIcon",
Expand Down
24 changes: 8 additions & 16 deletions entry/src/main/ets/database/dao/SubscriptionDao.ets
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import DbUtil from '../../common/utils/DbUtil';
import { showMessage } from '../../componets/common/promptShow';
import AppDatabaseUtil from '../AppDatabaseUtil';
import { rssSourceDb, rssSources, ToRssSources, ToRssSourcesDb } from '../entities/rssSources';
import { rssSourcesPart } from '../entities/rssSourcesPart';
import { ColumnInfo, ColumnType } from '../types/ColumnInfo';
import { rssSourcesTypeParams } from '../types/rssSourcesType';

Expand Down Expand Up @@ -94,9 +93,9 @@ class SubscriptionDao {
this.update(rssSource)
return true
}
const bookSourceDb = ToRssSourcesDb(rssSource)
bookSourceDb.lastUpdateTime = Date.now()
await DbUtil.insert(this.TABLE_NAME, bookSourceDb, column)
const rssSourceDb = ToRssSourcesDb(rssSource)
rssSourceDb.lastUpdateTime = Date.now()
await DbUtil.insert(this.TABLE_NAME, rssSourceDb, column)
console.log('TagInfo', '创建成功')
return true
} catch (err) {
Expand All @@ -105,7 +104,7 @@ class SubscriptionDao {
}
}

async update(rssSource: rssSources | rssSourcesPart) {
async update(rssSource: rssSources) {
try {
const column: ColumnInfo[] = AppDatabaseUtil.getColumn(this.TABLE_NAME);
const predicates = DbUtil.getPredicates(this.TABLE_NAME);
Expand All @@ -115,17 +114,10 @@ class SubscriptionDao {
this.insert(rssSource)
return true
}
if (rssSource instanceof rssSources) {
const rssSourceDb = ToRssSourcesDb(rssSource)
rssSourceDb.lastUpdateTime = Date.now()
rssSourceDb.showRecentIcon = true
await DbUtil.update(predicates, rssSourceDb, column)
return true
}
rssSource.lastUpdateTime = Date.now()
rssSource.showRecentIcon = true
const columnPart: ColumnInfo[] = this.getFlowColumn().slice(0, -2)
await DbUtil.update(predicates, rssSource, columnPart)
const rssSourceDb = ToRssSourcesDb(rssSource)
rssSourceDb.lastUpdateTime = Date.now()
rssSourceDb.showRecentIcon = true
await DbUtil.update(predicates, rssSourceDb, column)
return true
} catch (err) {
console.log('TagInfo, Error, ', JSON.stringify(err))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ export default struct newSources{
sourceGroup: SUBSCRIPTION_GROUP_TYPE[0],
enabled: true,
singleUrl: true,
showRecentIcon: true
showRecentIcon: true,
rssListRule: new rssListRule(),
rssWebViewRule: new rssWebViewRule(),
}

@State sourceGroupList:SelectOption[] = []
Expand Down Expand Up @@ -171,8 +173,9 @@ export default struct newSources{
customRightBuilder: () => {
this.cookieJar(
this.formModel.enabledCookieJar ?? false,
(val) => {
(val:boolean) => {
this.formModel.enabledCookieJar = val
showMessage('已开启CookieJar' + JSON.stringify(this.formModel.enabledCookieJar))
})
}
});
Expand Down Expand Up @@ -219,8 +222,9 @@ export default struct newSources{
Row(){
this.sourceIconIsUrl(
this.formModel.sourceIconIsUrl ?? false,
(val) => {
(val:boolean) => {
this.formModel.sourceIconIsUrl = val
showMessage(JSON.stringify(this.formModel.sourceIconIsUrl))
})
}
}
Expand Down Expand Up @@ -429,6 +433,7 @@ export default struct newSources{
.onChange((val: boolean) => {
if ( this.formModel.rssWebViewRule) {
this.formModel.rssWebViewRule.enableJs = val
showMessage(JSON.stringify(this.formModel.rssWebViewRule.enableJs ))
}
})
}
Expand Down

0 comments on commit ab5e7a2

Please sign in to comment.