diff --git a/entry/src/main/ets/pages/view/Subscription/components/PreviewEffectImage.ets b/entry/src/main/ets/pages/view/Subscription/components/PreviewEffectImage.ets index 42c004b4..b38e6699 100644 --- a/entry/src/main/ets/pages/view/Subscription/components/PreviewEffectImage.ets +++ b/entry/src/main/ets/pages/view/Subscription/components/PreviewEffectImage.ets @@ -6,7 +6,6 @@ */ import CommonConstants from '../../../../common/constants/CommonConstants' import FontConstants from '../../../../common/constants/FontConstants' -import { showMessage } from '../../../../componets/common/promptShow' @Component export default struct PreviewEffectImage{ diff --git a/entry/src/main/ets/pages/view/Subscription/components/SubscriptionContent.ets b/entry/src/main/ets/pages/view/Subscription/components/SubscriptionContent.ets index 5a6dc9a7..c3c1c2f2 100644 --- a/entry/src/main/ets/pages/view/Subscription/components/SubscriptionContent.ets +++ b/entry/src/main/ets/pages/view/Subscription/components/SubscriptionContent.ets @@ -88,10 +88,14 @@ export default struct SubscriptionContent{ showMessage('置顶') break case 2: - showMessage('移动至') + this.isShowGroup = true break case 3: - showMessage('删除') + SubscriptionDao.deleteRssSourcesList(this.contentList) + setTimeout(()=>{ + this.refresh() + },200) + showMessage('删除成功') break } }), @@ -290,7 +294,7 @@ export default struct SubscriptionContent{ this.moveGroup = '' showMessage('移动成功') this.refresh() - },500) + },200) } else { showMessage('移动失败') } diff --git a/entry/src/main/ets/pages/view/Subscription/rssWebView.ets b/entry/src/main/ets/pages/view/Subscription/rssWebView.ets index 2ee0e7e9..49138ab8 100644 --- a/entry/src/main/ets/pages/view/Subscription/rssWebView.ets +++ b/entry/src/main/ets/pages/view/Subscription/rssWebView.ets @@ -1,6 +1,14 @@ import { webview } from '@kit.ArkWeb'; import { router } from '@kit.ArkUI'; import { showMessage } from '../../../componets/common/promptShow'; +import { loginComponentManager } from '@kit.AccountKit'; +import ImportCommon from '../../../componets/import/ImportCommon'; +import { BookSource } from '../../../database/entities/BookSource'; +import { getPasteDataSync, isNetworkUrl, sleep } from '../../../common/utils/utils'; +import axios, { AxiosResponse } from '@ohos/axios'; +import SubscriptionImport from '../../../componets/import/SubscriptionImport'; +import { rssListRule } from '../../../database/entities/rule/rssListRule'; +import { rssSources } from '../../../database/entities/rssSources'; interface RouteParams { url: string, @@ -13,6 +21,8 @@ struct RssWebView { @StorageLink('topRectHeight') topRectHeight: number = 0 @StorageLink('bottomRectHeight') bottomRectHeight: number = 0 webviewController: webview.WebviewController = new webview.WebviewController(); + regex:string = `/booksource/importonline\\?src=(http[s]?://[^/]+/[^\"']+)`; + regexRss:string = `/rsssource/importonline\\?src=(http[s]?://[^/]+/[^\"']+)`; aboutToAppear(): void { const params = router.getParams() as RouteParams; this.sourcesUrl = params.url @@ -33,12 +43,97 @@ struct RssWebView { .width("100%") Column(){ Web({ src: this.sourcesUrl, controller: this.webviewController }) - .onPageBegin(()=>{ - showMessage(this.webviewController.getUserAgent()) + .onLoadIntercept((event) => { + let url = event.data.getRequestUrl() + const match = url.match(this.regex); + if (match && match[1]) { + this.pasteAnalyzeBookSource(match[1]) + this.webviewController.loadUrl(this.sourcesUrl) + } + const matchRss = url.match(this.regexRss); + if (matchRss && matchRss[1]) { + this.pasteAnalyzeRssSource(matchRss[1]) + this.webviewController.loadUrl(this.sourcesUrl) + } + return false }) } + Flex() + .bindSheet($$this.isShowImportBookSource, this.dialogImportBookFunction(), { + detents: [SheetSize.FIT_CONTENT, SheetSize.LARGE, 200], + dragBar: true, + showClose: false, + onDisappear: () => { + this.isShowImportBookSource = false + } + }) + Flex() + .bindSheet($$this.isShowImportRssSources, this.dialogImportRssFunction(), { + detents: [SheetSize.FIT_CONTENT, SheetSize.LARGE, 200], + dragBar: true, + showClose: false, + onDisappear: () => { + this.isShowImportRssSources = false + } + }) + } + .padding({ top: this.topRectHeight, bottom: this.bottomRectHeight + 20 }) + } + @State isShowImportBookSource: boolean = false + @State sourceList: BookSource[] = [] + @Builder + dialogImportBookFunction() { + Flex() { + ImportCommon({ sourceList: this.sourceList, show: this.isShowImportBookSource }) + } + } + @State subscriptionList:rssSources[] = [] + @State isShowImportRssSources:boolean = false + @Builder dialogImportRssFunction() { + Flex() { + SubscriptionImport({ subscriptionList:this.subscriptionList,show: this.isShowImportRssSources}) + } + } + // 发现 + async pasteAnalyzeBookSource(url:string) { + try { + if (!url) { + showMessage('未获取到相关Url,请求默认数据') + url = 'https://node.wisdoms.xin/static/file/20240704/sy.json' + await sleep() + } + if (!isNetworkUrl(url ?? '')) { + showMessage('链接不正确') + return + } + const res: AxiosResponse = await axios + .get(url ?? 'https://node.wisdoms.xin/static/file/20240704/sy.json'); + this.sourceList = res.data; + this.isShowImportBookSource = true; + } catch (err) { + console.error('错误 ' + err); + } + } + // 订阅 + async pasteAnalyzeRssSource(url:string) { + try { + if (!url) { + showMessage('未获取到相关Url,请求默认数据') + url = 'http://yuedu.miaogongzi.net/shuyuan/miaogongziDY.json' + await sleep() + } + if (!isNetworkUrl(url ?? '')) { + showMessage('链接不正确') + return + } + const res: AxiosResponse = await axios + .get(url ?? 'http://yuedu.miaogongzi.net/shuyuan/miaogongziDY.json'); + console.log('res', JSON.stringify(res)) + this.subscriptionList = res.data; + this.isShowImportRssSources = true; + } catch (err) { + console.error('错误 ' + err); } - .padding({top:this.topRectHeight, bottom:this.bottomRectHeight + 20}) } } \ No newline at end of file