From b0816816ad7ff0eb3048c17e78f5ee3066c18bfc Mon Sep 17 00:00:00 2001 From: Marvin <63292605+yi-boide@users.noreply.github.com> Date: Wed, 4 Sep 2024 15:55:21 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=94=B9=E8=A7=A3=E6=9E=90?= =?UTF-8?q?=E8=AF=B7=E6=B1=82=E5=9C=B0=E5=9D=80=20(#271)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/ets/common/constants/CommonConstants.ets | 5 +++++ entry/src/main/ets/common/model/XmlAnalysis.ets | 3 ++- entry/src/main/ets/pages/view/Find/CategoryList/Index.ets | 3 ++- .../main/ets/pages/view/Find/components/BookFindContent.ets | 3 ++- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/entry/src/main/ets/common/constants/CommonConstants.ets b/entry/src/main/ets/common/constants/CommonConstants.ets index 2c42ecb4..643a7307 100644 --- a/entry/src/main/ets/common/constants/CommonConstants.ets +++ b/entry/src/main/ets/common/constants/CommonConstants.ets @@ -274,4 +274,9 @@ export default class CommonConstants { static readonly COMMON_HEIGHT_21_6: number = 21.6; static readonly COMMON_WIDTH_40: number = 40; static readonly COMMON_HEIGHT_40: number = 40; + + /* + * 接口请求域名 + * */ + static readonly BASE_URL: string = 'https://legado.miaogongzi.cc/api/LegadoServer'; } \ No newline at end of file diff --git a/entry/src/main/ets/common/model/XmlAnalysis.ets b/entry/src/main/ets/common/model/XmlAnalysis.ets index bc9684db..aee96759 100644 --- a/entry/src/main/ets/common/model/XmlAnalysis.ets +++ b/entry/src/main/ets/common/model/XmlAnalysis.ets @@ -4,6 +4,7 @@ import { BookSource } from '../../database/entities/BookSource'; import { ExploreQuery } from '../../database/types/BookSourceType'; import axios, { AxiosError, AxiosResponse } from '@ohos/axios'; import { isNetworkUrl } from '../utils/utils'; +import CommonConstants from '../constants/CommonConstants'; export interface IXmlAnalysis { @@ -53,7 +54,7 @@ export class XmlAnalysis { searchUrl: this.searchUrl } axios.defaults.timeout = 5000 - let response: AxiosResponse = await axios.post('http://legado.wisdoms.xin/analysisBook', data) + let response: AxiosResponse = await axios.post(CommonConstants.BASE_URL + '/search/analysisBook', data) if (response.data){ bookList = (response.data as SearchBook[]).map(item => { item.bookType = this.xmlDate.bookSource?.bookSourceType ?? 0 diff --git a/entry/src/main/ets/pages/view/Find/CategoryList/Index.ets b/entry/src/main/ets/pages/view/Find/CategoryList/Index.ets index 85825f0e..478318cd 100644 --- a/entry/src/main/ets/pages/view/Find/CategoryList/Index.ets +++ b/entry/src/main/ets/pages/view/Find/CategoryList/Index.ets @@ -7,6 +7,7 @@ import { isNetworkUrl } from '../../../../common/utils/utils'; import axios, { AxiosResponse } from '@ohos/axios'; import noFind from '../../../../componets/common/noFind'; import { CardItem } from '../components/CardItem'; +import CommonConstants from '../../../../common/constants/CommonConstants'; interface RouteParams { bookSourceUrl: string, @@ -67,7 +68,7 @@ struct CateGoryListPage { } this.loading = true try { - const res: AxiosResponse = await axios.post('http://legado.wisdoms.xin/analysisRules', exploreQuery) + const res: AxiosResponse = await axios.post(CommonConstants.BASE_URL + '/common/analysisRules', exploreQuery) console.info('TagInfo, 解析内容:', JSON.stringify(res.data)) const bookList = (res.data as ExploreRule[]).map(item => { if (item.coverUrl && !isNetworkUrl(item.coverUrl)) { diff --git a/entry/src/main/ets/pages/view/Find/components/BookFindContent.ets b/entry/src/main/ets/pages/view/Find/components/BookFindContent.ets index f59f7eaa..7ce1ee11 100644 --- a/entry/src/main/ets/pages/view/Find/components/BookFindContent.ets +++ b/entry/src/main/ets/pages/view/Find/components/BookFindContent.ets @@ -12,6 +12,7 @@ import { ExploreItem, ExploreQuery } from '../../../../database/types/BookSource import mayAlsoLike from '../mayAlsoLike' import { CardItem } from './CardItem' import { router } from '@kit.ArkUI' +import CommonConstants from '../../../../common/constants/CommonConstants'; @Component export default struct BookFindContent { @@ -49,7 +50,7 @@ export default struct BookFindContent { coverUrl: this.exploreRule.coverUrl, wordCount: this.exploreRule.wordCount } - axios.post('http://legado.wisdoms.xin/analysisRules', exploreQuery).then((res: AxiosResponse) => { + axios.post(CommonConstants.BASE_URL + '/common/analysisRules', exploreQuery).then((res: AxiosResponse) => { console.info('TagInfo, 解析内容:', JSON.stringify(res.data)) this.bookList = (res.data as ExploreRule[]).map(item => { if (item.coverUrl && !isNetworkUrl(item.coverUrl)) {