[
  {
    "path": ".gitignore",
    "content": "/node_modules\n/oh_modules\n/local.properties\n/.idea\n**/build\n/.hvigor\n.cxx\n/.clangd\n/.clang-format\n/.clang-tidy\n**/.test\n**/oh-package-lock.json5\n**/oh_modules\n**/.preview\n/Users"
  },
  {
    "path": "AppScope/app.json5",
    "content": "{\n  \"app\": {\n    \"bundleName\": \"top.wangchenyan.wanharmony\",\n    \"vendor\": \"wanharmony\",\n    \"versionCode\": 1000000,\n    \"versionName\": \"1.0.0\",\n    \"icon\": \"$media:app_icon\",\n    \"label\": \"$string:app_name\"\n  }\n}\n"
  },
  {
    "path": "AppScope/resources/base/element/string.json",
    "content": "{\n  \"string\": [\n    {\n      \"name\": \"app_name\",\n      \"value\": \"WanHarmony\"\n    }\n  ]\n}\n"
  },
  {
    "path": "LICENSE",
    "content": "                                 Apache License\n                           Version 2.0, January 2004\n                        http://www.apache.org/licenses/\n\n   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n   1. Definitions.\n\n      \"License\" shall mean the terms and conditions for use, reproduction,\n      and distribution as defined by Sections 1 through 9 of this document.\n\n      \"Licensor\" shall mean the copyright owner or entity authorized by\n      the copyright owner that is granting the License.\n\n      \"Legal Entity\" shall mean the union of the acting entity and all\n      other entities that control, are controlled by, or are under common\n      control with that entity. For the purposes of this definition,\n      \"control\" means (i) the power, direct or indirect, to cause the\n      direction or management of such entity, whether by contract or\n      otherwise, or (ii) ownership of fifty percent (50%) or more of the\n      outstanding shares, or (iii) beneficial ownership of such entity.\n\n      \"You\" (or \"Your\") shall mean an individual or Legal Entity\n      exercising permissions granted by this License.\n\n      \"Source\" form shall mean the preferred form for making modifications,\n      including but not limited to software source code, documentation\n      source, and configuration files.\n\n      \"Object\" form shall mean any form resulting from mechanical\n      transformation or translation of a Source form, including but\n      not limited to compiled object code, generated documentation,\n      and conversions to other media types.\n\n      \"Work\" shall mean the work of authorship, whether in Source or\n      Object form, made available under the License, as indicated by a\n      copyright notice that is included in or attached to the work\n      (an example is provided in the Appendix below).\n\n      \"Derivative Works\" shall mean any work, whether in Source or Object\n      form, that is based on (or derived from) the Work and for which the\n      editorial revisions, annotations, elaborations, or other modifications\n      represent, as a whole, an original work of authorship. For the purposes\n      of this License, Derivative Works shall not include works that remain\n      separable from, or merely link (or bind by name) to the interfaces of,\n      the Work and Derivative Works thereof.\n\n      \"Contribution\" shall mean any work of authorship, including\n      the original version of the Work and any modifications or additions\n      to that Work or Derivative Works thereof, that is intentionally\n      submitted to Licensor for inclusion in the Work by the copyright owner\n      or by an individual or Legal Entity authorized to submit on behalf of\n      the copyright owner. For the purposes of this definition, \"submitted\"\n      means any form of electronic, verbal, or written communication sent\n      to the Licensor or its representatives, including but not limited to\n      communication on electronic mailing lists, source code control systems,\n      and issue tracking systems that are managed by, or on behalf of, the\n      Licensor for the purpose of discussing and improving the Work, but\n      excluding communication that is conspicuously marked or otherwise\n      designated in writing by the copyright owner as \"Not a Contribution.\"\n\n      \"Contributor\" shall mean Licensor and any individual or Legal Entity\n      on behalf of whom a Contribution has been received by Licensor and\n      subsequently incorporated within the Work.\n\n   2. Grant of Copyright License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      copyright license to reproduce, prepare Derivative Works of,\n      publicly display, publicly perform, sublicense, and distribute the\n      Work and such Derivative Works in Source or Object form.\n\n   3. Grant of Patent License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      (except as stated in this section) patent license to make, have made,\n      use, offer to sell, sell, import, and otherwise transfer the Work,\n      where such license applies only to those patent claims licensable\n      by such Contributor that are necessarily infringed by their\n      Contribution(s) alone or by combination of their Contribution(s)\n      with the Work to which such Contribution(s) was submitted. If You\n      institute patent litigation against any entity (including a\n      cross-claim or counterclaim in a lawsuit) alleging that the Work\n      or a Contribution incorporated within the Work constitutes direct\n      or contributory patent infringement, then any patent licenses\n      granted to You under this License for that Work shall terminate\n      as of the date such litigation is filed.\n\n   4. Redistribution. You may reproduce and distribute copies of the\n      Work or Derivative Works thereof in any medium, with or without\n      modifications, and in Source or Object form, provided that You\n      meet the following conditions:\n\n      (a) You must give any other recipients of the Work or\n          Derivative Works a copy of this License; and\n\n      (b) You must cause any modified files to carry prominent notices\n          stating that You changed the files; and\n\n      (c) You must retain, in the Source form of any Derivative Works\n          that You distribute, all copyright, patent, trademark, and\n          attribution notices from the Source form of the Work,\n          excluding those notices that do not pertain to any part of\n          the Derivative Works; and\n\n      (d) If the Work includes a \"NOTICE\" text file as part of its\n          distribution, then any Derivative Works that You distribute must\n          include a readable copy of the attribution notices contained\n          within such NOTICE file, excluding those notices that do not\n          pertain to any part of the Derivative Works, in at least one\n          of the following places: within a NOTICE text file distributed\n          as part of the Derivative Works; within the Source form or\n          documentation, if provided along with the Derivative Works; or,\n          within a display generated by the Derivative Works, if and\n          wherever such third-party notices normally appear. The contents\n          of the NOTICE file are for informational purposes only and\n          do not modify the License. You may add Your own attribution\n          notices within Derivative Works that You distribute, alongside\n          or as an addendum to the NOTICE text from the Work, provided\n          that such additional attribution notices cannot be construed\n          as modifying the License.\n\n      You may add Your own copyright statement to Your modifications and\n      may provide additional or different license terms and conditions\n      for use, reproduction, or distribution of Your modifications, or\n      for any such Derivative Works as a whole, provided Your use,\n      reproduction, and distribution of the Work otherwise complies with\n      the conditions stated in this License.\n\n   5. Submission of Contributions. Unless You explicitly state otherwise,\n      any Contribution intentionally submitted for inclusion in the Work\n      by You to the Licensor shall be under the terms and conditions of\n      this License, without any additional terms or conditions.\n      Notwithstanding the above, nothing herein shall supersede or modify\n      the terms of any separate license agreement you may have executed\n      with Licensor regarding such Contributions.\n\n   6. Trademarks. This License does not grant permission to use the trade\n      names, trademarks, service marks, or product names of the Licensor,\n      except as required for reasonable and customary use in describing the\n      origin of the Work and reproducing the content of the NOTICE file.\n\n   7. Disclaimer of Warranty. Unless required by applicable law or\n      agreed to in writing, Licensor provides the Work (and each\n      Contributor provides its Contributions) on an \"AS IS\" BASIS,\n      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n      implied, including, without limitation, any warranties or conditions\n      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n      PARTICULAR PURPOSE. You are solely responsible for determining the\n      appropriateness of using or redistributing the Work and assume any\n      risks associated with Your exercise of permissions under this License.\n\n   8. Limitation of Liability. In no event and under no legal theory,\n      whether in tort (including negligence), contract, or otherwise,\n      unless required by applicable law (such as deliberate and grossly\n      negligent acts) or agreed to in writing, shall any Contributor be\n      liable to You for damages, including any direct, indirect, special,\n      incidental, or consequential damages of any character arising as a\n      result of this License or out of the use or inability to use the\n      Work (including but not limited to damages for loss of goodwill,\n      work stoppage, computer failure or malfunction, or any and all\n      other commercial damages or losses), even if such Contributor\n      has been advised of the possibility of such damages.\n\n   9. Accepting Warranty or Additional Liability. While redistributing\n      the Work or Derivative Works thereof, You may choose to offer,\n      and charge a fee for, acceptance of support, warranty, indemnity,\n      or other liability obligations and/or rights consistent with this\n      License. However, in accepting such obligations, You may act only\n      on Your own behalf and on Your sole responsibility, not on behalf\n      of any other Contributor, and only if You agree to indemnify,\n      defend, and hold each Contributor harmless for any liability\n      incurred by, or claims asserted against, such Contributor by reason\n      of your accepting any such warranty or additional liability.\n\n   END OF TERMS AND CONDITIONS\n\n   APPENDIX: How to apply the Apache License to your work.\n\n      To apply the Apache License to your work, attach the following\n      boilerplate notice, with the fields enclosed by brackets \"[]\"\n      replaced with your own identifying information. (Don't include\n      the brackets!)  The text should be enclosed in the appropriate\n      comment syntax for the file format. We also recommend that a\n      file or class name and description of purpose be included on the\n      same \"printed page\" as the copyright notice for easier\n      identification within third-party archives.\n\n   Copyright [yyyy] [name of copyright owner]\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n"
  },
  {
    "path": "README.md",
    "content": "# wan-harmony\n\n鸿蒙版玩 Android 客户端\n\n[鸿蒙即将抛弃Android，你还不来学习一下？](https://juejin.cn/post/7340307629891616808)\n\n**当前适配版本为 Harmony OS API 12**\n\n## 环境\n\n- DevEco Studio NEXT Developer Beta1\n  - Build Version: 5.0.3.403\n- Harmony OS Api 12\n- hvigor 5.0.0\n\n## 功能\n\n- 登录\n- 等级、排名、积分、收藏\n- 首页、搜索\n- 体系\n- 广场\n- 体系\n- 公众号\n\n## 截图\n\n![](https://raw.githubusercontent.com/wangchenyan/wan-harmony/master/art/screenshot.jpg)\n"
  },
  {
    "path": "build-profile.json5",
    "content": "{\n  \"app\": {\n    \"signingConfigs\": [],\n    \"products\": [\n      {\n        \"name\": \"default\",\n        \"signingConfig\": \"default\",\n        \"compatibleSdkVersion\": \"5.0.2(14)\",\n        \"runtimeOS\": \"HarmonyOS\",\n        \"buildOption\": {\n          \"strictMode\": {\n            \"caseSensitiveCheck\": true,\n            \"useNormalizedOHMUrl\": true\n          }\n        }\n      }\n    ],\n    \"buildModeSet\": [\n      {\n        \"name\": \"debug\",\n      },\n      {\n        \"name\": \"release\"\n      }\n    ]\n  },\n  \"modules\": [\n    {\n      \"name\": \"entry\",\n      \"srcPath\": \"./entry\",\n      \"targets\": [\n        {\n          \"name\": \"default\",\n          \"applyToProducts\": [\n            \"default\"\n          ]\n        }\n      ]\n    }\n  ]\n}"
  },
  {
    "path": "code-linter.json5",
    "content": "{\n  \"files\": [\n    \"**/*.ets\"\n  ],\n  \"ignore\": [\n    \"**/src/ohosTest/**/*\",\n    \"**/src/test/**/*\",\n    \"**/src/mock/**/*\",\n    \"**/node_modules/**/*\",\n    \"**/oh_modules/**/*\",\n    \"**/build/**/*\",\n    \"**/.preview/**/*\"\n  ],\n  \"ruleSet\": [\n    \"plugin:@performance/recommended\",\n    \"plugin:@typescript-eslint/recommended\"\n  ],\n  \"rules\": {\n    \"@security/no-unsafe-aes\": \"error\",\n    \"@security/no-unsafe-hash\": \"error\",\n    \"@security/no-unsafe-mac\": \"warn\",\n    \"@security/no-unsafe-dh\": \"error\",\n    \"@security/no-unsafe-dsa\": \"error\",\n    \"@security/no-unsafe-ecdsa\": \"error\",\n    \"@security/no-unsafe-rsa-encrypt\": \"error\",\n    \"@security/no-unsafe-rsa-sign\": \"error\",\n    \"@security/no-unsafe-rsa-key\": \"error\",\n    \"@security/no-unsafe-dsa-key\": \"error\",\n    \"@security/no-unsafe-dh-key\": \"error\",\n    \"@security/no-unsafe-3des\": \"error\"\n  }\n}"
  },
  {
    "path": "entry/.gitignore",
    "content": "/node_modules\n/oh_modules\n/.preview\n/build\n/.cxx\n/.test"
  },
  {
    "path": "entry/build-profile.json5",
    "content": "{\n  \"apiType\": \"stageMode\",\n  \"buildOption\": {\n  },\n  \"buildOptionSet\": [\n    {\n      \"name\": \"release\",\n      \"arkOptions\": {\n        \"obfuscation\": {\n          \"ruleOptions\": {\n            \"enable\": false,\n            \"files\": [\n              \"./obfuscation-rules.txt\"\n            ]\n          }\n        }\n      }\n    },\n  ],\n  \"targets\": [\n    {\n      \"name\": \"default\"\n    },\n    {\n      \"name\": \"ohosTest\",\n    }\n  ]\n}"
  },
  {
    "path": "entry/hvigorfile.ts",
    "content": "import { hapTasks } from '@ohos/hvigor-ohos-plugin';\n\nexport default {\n  system: hapTasks,  /* Built-in plugin of Hvigor. It cannot be modified. */\n  plugins:[]         /* Custom plugin to extend the functionality of Hvigor. */\n}\n"
  },
  {
    "path": "entry/obfuscation-rules.txt",
    "content": "# Define project specific obfuscation rules here.\n# You can include the obfuscation configuration files in the current module's build-profile.json5.\n#\n# For more details, see\n#   https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5\n\n# Obfuscation options:\n# -disable-obfuscation: disable all obfuscations\n# -enable-property-obfuscation: obfuscate the property names\n# -enable-toplevel-obfuscation: obfuscate the names in the global scope\n# -compact: remove unnecessary blank spaces and all line feeds\n# -remove-log: remove all console.* statements\n# -print-namecache: print the name cache that contains the mapping from the old names to new names\n# -apply-namecache: reuse the given cache file\n\n# Keep options:\n# -keep-property-name: specifies property names that you want to keep\n# -keep-global-name: specifies names that you want to keep in the global scope\n\n-enable-property-obfuscation\n-enable-toplevel-obfuscation\n-enable-filename-obfuscation\n-enable-export-obfuscation"
  },
  {
    "path": "entry/oh-package.json5",
    "content": "{\n  \"name\": \"entry\",\n  \"version\": \"1.0.0\",\n  \"description\": \"Please describe the basic information.\",\n  \"main\": \"\",\n  \"author\": \"\",\n  \"license\": \"\",\n  \"dependencies\": {\n    \"@ohos/pulltorefresh\": \"^2.0.5\",\n    \"@ohmos/json-bigint\": \"^1.0.0\"\n  }\n}\n"
  },
  {
    "path": "entry/src/main/ets/Routes.ets",
    "content": "import { collectListNavDesBuilder } from './pages/CollectList'\nimport { HarmonyNavDesBuilder } from './pages/Harmony'\nimport { loginNavDesBuilder } from './pages/Login'\nimport { RankingListNavDesBuilder } from './pages/RankingList'\nimport { searchEntryNavDesBuilder } from './pages/SearchEntry'\nimport { searchResultNavDesBuilder } from './pages/SearchResult'\nimport { webPageNavDesBuilder } from './pages/WebPage'\nimport { HRouter } from './router/HRouter'\n\n\nexport enum Routes {\n  Login = '/login',\n  Web = '/web',\n  SearchEntry = '/search_entry',\n  SearchResult = '/search_result',\n  CollectList = '/collect_list',\n  Harmony = '/Harmony',\n  RankingList = '/RankingList'\n}\n\nexport function registerRoutes() {\n  HRouter.register(Routes.Login, wrapBuilder(loginNavDesBuilder))\n  HRouter.register(Routes.Web, wrapBuilder(webPageNavDesBuilder))\n  HRouter.register(Routes.SearchEntry, wrapBuilder(searchEntryNavDesBuilder))\n  HRouter.register(Routes.SearchResult, wrapBuilder(searchResultNavDesBuilder))\n  HRouter.register(Routes.CollectList, wrapBuilder(collectListNavDesBuilder))\n  HRouter.register(Routes.Harmony, wrapBuilder(HarmonyNavDesBuilder))\n  HRouter.register(Routes.RankingList, wrapBuilder(RankingListNavDesBuilder))\n}"
  },
  {
    "path": "entry/src/main/ets/common/CollectUtils.ets",
    "content": "import Api from '../net/Api';\nimport { Article } from '../net/model/Article';\nimport UserService from '../service/UserService';\nimport { toast } from './Toast';\n\nexport default class CollectUtils {\n  static async collect(article: Article, id?: number): Promise<boolean> {\n    if (!UserService.get().isLogin()) {\n      UserService.get().checkLogin();\n      return Promise.resolve(false);\n    }\n\n    if (!id) {\n      id = article.id;\n    }\n    if (article.collect) {\n      const res = await Api.get().unCollect(id);\n      if (res.isSuccess()) {\n        article.collect = false;\n      } else {\n        toast(res.errorMsg);\n      }\n      return Promise.resolve(res.isSuccess());\n    } else {\n      const res = await Api.get().collect(id);\n      if (res.isSuccess()) {\n        article.collect = true;\n      } else {\n        toast(res.errorMsg);\n      }\n      return Promise.resolve(res.isSuccess());\n    }\n  }\n}"
  },
  {
    "path": "entry/src/main/ets/common/EntryContext.ets",
    "content": "export default class EntryContext {\n  private static context: Context\n\n  static setContext(context: Context) {\n    EntryContext.context = context\n  }\n\n  static getContext(): Context {\n    if (!EntryContext.context) {\n      throw Error(\"context is not init\")\n    }\n    return EntryContext.context\n  }\n}"
  },
  {
    "path": "entry/src/main/ets/common/OHPermission.ets",
    "content": "import abilityAccessCtrl, { Permissions } from '@ohos.abilityAccessCtrl';\nimport bundleManager from '@ohos.bundle.bundleManager';\nimport { BusinessError } from '@kit.BasicServicesKit';\n\nexport default class OHPermission {\n  static requestPermission(context: Context, permissionList: Permissions[]): Promise<void> {\n    return new Promise<void>((resolve, reject) => {\n      const atManager = abilityAccessCtrl.createAtManager();\n      // requestPermissionsFromUser会判断权限的授权状态来决定是否唤起弹窗\n      atManager.requestPermissionsFromUser(context, permissionList)\n        .then((data) => {\n          const grantStatus: number[] = data.authResults;\n          const length: number = grantStatus.length;\n          for (let i = 0; i < length; i++) {\n            if (grantStatus[i] !== 0) {\n              // 用户拒绝授权，提示用户必须授权才能访问当前页面的功能，并引导用户到系统设置中打开相应的权限\n              reject()\n            }\n          }\n          // 授权成功\n          resolve()\n        })\n        .catch((err: BusinessError) => {\n          console.error(`requestPermissionsFromUser failed, code is ${err.code}, message is ${err.message}`);\n          reject()\n        })\n    });\n  }\n\n  static async checkPermission(permission: Permissions): Promise<boolean> {\n    const grantStatus: abilityAccessCtrl.GrantStatus = await OHPermission.checkAccessToken(permission);\n    if (grantStatus === abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED) {\n      // 已经授权，可以继续访问目标操作\n      return true\n    } else {\n      return false\n    }\n  }\n\n  private static async checkAccessToken(permission: Permissions): Promise<abilityAccessCtrl.GrantStatus> {\n    const atManager: abilityAccessCtrl.AtManager = abilityAccessCtrl.createAtManager();\n    let grantStatus: abilityAccessCtrl.GrantStatus = abilityAccessCtrl.GrantStatus.PERMISSION_DENIED;\n\n    // 获取应用程序的accessTokenID\n    let tokenId: number = 0;\n    try {\n      const bundleInfo: bundleManager.BundleInfo =\n        await bundleManager.getBundleInfoForSelf(bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION);\n      const appInfo: bundleManager.ApplicationInfo = bundleInfo.appInfo;\n      tokenId = appInfo.accessTokenId;\n    } catch (error) {\n      const err: BusinessError = error as BusinessError;\n      console.error(`Failed to get bundle info for self. Code is ${err.code}, message is ${err.message}`);\n    }\n\n    // 校验应用是否被授予权限\n    try {\n      grantStatus = await atManager.checkAccessToken(tokenId, permission);\n    } catch (error) {\n      const err: BusinessError = error as BusinessError;\n      console.error(`Failed to check access token. Code is ${err.code}, message is ${err.message}`);\n    }\n\n    return grantStatus;\n  }\n}"
  },
  {
    "path": "entry/src/main/ets/common/Pair.ets",
    "content": "export class Pair<T, U> {\n  first: T;\n  second: U;\n\n  constructor(first: T, second: U) {\n    this.first = first;\n    this.second = second;\n  }\n}\n"
  },
  {
    "path": "entry/src/main/ets/common/Preferences.ets",
    "content": "import dataPreferences from '@ohos.data.preferences';\nimport JSON from '@ohmos/json-bigint';\nimport { User } from '../service/UserService';\nimport { Pair } from './Pair';\n\nconst PREFERENCES_NAME = \"top.wangchenyan.wanharmony\"\nconst KEY_USER_INFO = \"user_info\";\nconst KEY_SEARCH_HISTORY = \"search_history\";\nconst KEY_SELECTED_TREE_ID_1 = \"selected_tree_id_1\";\nconst KEY_SELECTED_TREE_ID_2 = \"selected_tree_id_2\";\n\nexport default class Preferences {\n  private static instance: Preferences;\n  private preferences: dataPreferences.Preferences;\n\n  private constructor(context: Context) {\n    this.preferences = dataPreferences.getPreferencesSync(context, {\n      name: PREFERENCES_NAME\n    });\n  }\n\n  getUser(): User | undefined {\n    const json = this.preferences.getSync(KEY_USER_INFO, \"\");\n    if (json) {\n      const user: User = JSON.parse(json)\n      return user;\n    } else {\n      return undefined;\n    }\n  }\n\n  putUser(user?: User) {\n    if (user) {\n      this.preferences.putSync(KEY_USER_INFO, JSON.stringify(user, undefined, undefined));\n    } else {\n      this.preferences.deleteSync(KEY_USER_INFO);\n    }\n    this.preferences.flush();\n  }\n\n  getSearchHistory(): string[] {\n    return this.preferences.getSync(KEY_SEARCH_HISTORY, []) as string[];\n  }\n\n  putSearchHistory(historyKeys: string[]) {\n    this.preferences.putSync(KEY_SEARCH_HISTORY, historyKeys)\n    this.preferences.flush()\n  }\n\n  getSelectedTreeId(): Pair<number, number> {\n    const id1 = this.preferences.getSync(KEY_SELECTED_TREE_ID_1, 0) as number;\n    const id2 = this.preferences.getSync(KEY_SELECTED_TREE_ID_2, 0) as number;\n    if (id1 > 0 && id2 > 0) {\n      return new Pair(id1, id2);\n    } else {\n      return new Pair(0, 0);\n    }\n  }\n\n  putSelectedTreeId(treeId1: number, treeId2: number) {\n    this.preferences.putSync(KEY_SELECTED_TREE_ID_1, treeId1);\n    this.preferences.putSync(KEY_SELECTED_TREE_ID_2, treeId2);\n    this.preferences.flush()\n  }\n\n  static get(context: Context): Preferences {\n    if (Preferences.instance === undefined) {\n      Preferences.instance = new Preferences(context);\n    }\n    return Preferences.instance;\n  }\n}"
  },
  {
    "path": "entry/src/main/ets/common/Toast.ets",
    "content": "import promptAction from '@ohos.promptAction';\nimport WindowUtils from './WindowUtils';\n\nexport function toast(message: ResourceStr | undefined) {\n  if (message) {\n    const bottom = WindowUtils.windowHeight > 0 ? (WindowUtils.windowHeight / 2 + 'px') : undefined;\n    promptAction.showToast({\n      message: message,\n      bottom: bottom\n    })\n  }\n}\n"
  },
  {
    "path": "entry/src/main/ets/common/WindowUtils.ets",
    "content": "import window from '@ohos.window'\n\nexport default class WindowUtils {\n  static statusBarHeight: number = 0\n  static navigationBarHeight: number = 0\n  static windowWidth: number = 0\n  static windowHeight: number = 0\n\n  static init(windowClass: window.Window) {\n    const windowRect = windowClass.getWindowProperties().windowRect;\n    WindowUtils.windowWidth = windowRect.width;\n    WindowUtils.windowHeight = windowRect.height;\n    const statusBarAvoidArea = windowClass.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM);\n    WindowUtils.statusBarHeight = statusBarAvoidArea.topRect.height;\n    const navigationBarAvoidArea = windowClass.getWindowAvoidArea(window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR);\n    WindowUtils.navigationBarHeight = navigationBarAvoidArea.bottomRect.height;\n  }\n}"
  },
  {
    "path": "entry/src/main/ets/entryability/EntryAbility.ets",
    "content": "import UIAbility from '@ohos.app.ability.UIAbility';\nimport hilog from '@ohos.hilog';\nimport window from '@ohos.window';\nimport EntryContext from '../common/EntryContext';\nimport WindowUtils from '../common/WindowUtils';\nimport { AbilityConstant, Want } from '@kit.AbilityKit';\n\nconst DOMAIN = 0x0000;\n\nexport default class EntryAbility extends UIAbility {\n  private static TAG: string = \"EntryAbility\"\n\n  onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {\n    hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate');\n    EntryContext.setContext(this.context)\n  }\n\n  async onWindowStageCreate(windowStage: window.WindowStage): Promise<void> {\n    // Main window is created, set main page for this ability\n    hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate');\n\n    const windowClass = await windowStage.getMainWindow();\n    hilog.info(0x0000, EntryAbility.TAG,\n      'Succeeded in obtaining the main window. Data: ' + JSON.stringify(windowClass));\n    windowClass.setWindowLayoutFullScreen(true);\n    WindowUtils.init(windowClass);\n\n    windowStage.loadContent('pages/Index', (err) => {\n      if (err.code) {\n        hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err));\n        return;\n      }\n      hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.');\n    });\n  }\n\n  onWindowStageDestroy(): void {\n    // Main window is destroyed, release UI related resources\n    hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');\n  }\n\n  onForeground(): void {\n    // Ability has brought to foreground\n    hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground');\n  }\n\n  onBackground(): void {\n    // Ability has back to background\n    hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground');\n  }\n\n  onDestroy(): void {\n    hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy');\n  }\n}\n"
  },
  {
    "path": "entry/src/main/ets/net/Api.ets",
    "content": "import { Article, ArticleList, HomeBannerData } from './model/Article';\nimport { User } from '../service/UserService';\nimport PersistentCookieJar from './cookie/PersistentCookieJar';\nimport CookieJar from './cookie/CookieJar';\nimport EntryContext from '../common/EntryContext';\nimport { Response } from './Response';\nimport { HotKey } from './model/Search';\nimport { WeChatAuthor } from './model/WeChat';\nimport { Tree } from './model/Tree';\nimport { Rank } from './model/RankingList';\nimport { Harmony } from './model/Harmony';\nimport { HttpClient } from './HttpClient';\n\nconst BASE_URL: string = \"https://www.wanandroid.com\";\n\nexport default class Api {\n  private static instance: Api;\n  private readonly cookieJar: CookieJar;\n  private readonly httpClient: HttpClient;\n\n  private constructor() {\n    this.cookieJar = new PersistentCookieJar(EntryContext.getContext());\n    this.httpClient = new HttpClient(BASE_URL, this.cookieJar);\n  }\n\n  static get(): Api {\n    if (Api.instance === undefined) {\n      Api.instance = new Api();\n    }\n    return Api.instance;\n  }\n\n  clearCookie() {\n    this.cookieJar.clear();\n  }\n\n  async getHomeArticleList(page: number): Promise<Response<ArticleList>> {\n    return this.httpClient.get(`/article/list/${page}/json`);\n  }\n\n  async getTopArticle(): Promise<Response<Article[]>> {\n    return this.httpClient.get(\"/article/top/json\");\n  }\n\n  async getHomeBanner(): Promise<Response<HomeBannerData[]>> {\n    return this.httpClient.get(\"/banner/json\");\n  }\n\n  async getSquareArticleList(page: number): Promise<Response<ArticleList>> {\n    return this.httpClient.get(`/user_article/list/${page}/json`);\n  }\n\n  async getWeChatAuthorList(): Promise<Response<WeChatAuthor[]>> {\n    return this.httpClient.get(\"/wxarticle/chapters/json\")\n  }\n\n  async getWeChatArticleList(id: number, page: number): Promise<Response<ArticleList>> {\n    return this.httpClient.get(`/wxarticle/list/${id}/${page}/json`);\n  }\n\n  async login(username: string, password: string): Promise<Response<User>> {\n    return this.httpClient.post(`/user/login?username=${username}&password=${password}`);\n  }\n\n  async logout(): Promise<Response<string>> {\n    return this.httpClient.get(\"/user/logout/json\");\n  }\n\n  async getUserInfo(): Promise<Response<User>> {\n    return this.httpClient.get(\"/lg/coin/userinfo/json\");\n  }\n\n  async getSearchHotKey(): Promise<Response<HotKey[]>> {\n    return this.httpClient.get(\"/hotkey/json\")\n  }\n\n  async search(keyword: string, page: number): Promise<Response<ArticleList>> {\n    return this.httpClient.post(`/article/query/${page}/json?k=${encodeURIComponent(keyword)}`)\n  }\n\n  async collect(id: number): Promise<Response<object>> {\n    return this.httpClient.post(`/lg/collect/${id}/json`)\n  }\n\n  async unCollect(id: number): Promise<Response<object>> {\n    return this.httpClient.post(`/lg/uncollect_originId/${id}/json`)\n  }\n\n  async getCollectList(page: number): Promise<Response<ArticleList>> {\n    return this.httpClient.get(`/lg/collect/list/${page}/json`)\n  }\n\n  async getTree(): Promise<Response<Tree[]>> {\n    return this.httpClient.get(`/tree/json`)\n  }\n\n  async getTreeArticleList(cid: number, page: number): Promise<Response<ArticleList>> {\n    return this.httpClient.get(`/article/list/${page}/json?cid=${cid}`)\n  }\n\n  async getHarmony(): Promise<Response<Harmony>> {\n    return this.httpClient.get(`/harmony/index/json`)\n  }\n\n  async getRankingList(page: number): Promise<Response<Rank>> {\n    const url = `/coin/rank/${page}/json`;\n    return this.httpClient.get(url);\n  }\n}"
  },
  {
    "path": "entry/src/main/ets/net/Headers.ets",
    "content": "export class Headers {\n  contentType?: string;\n  cookie?: string;\n}"
  },
  {
    "path": "entry/src/main/ets/net/HttpClient.ets",
    "content": "import CookieJar from './cookie/CookieJar'\nimport { http } from '@kit.NetworkKit'\nimport { Response } from './Response'\nimport { Headers } from './Headers'\nimport { uri } from '@kit.ArkTS'\nimport CookieUtils from './cookie/CookieUtils'\nimport { hilog } from '@kit.PerformanceAnalysisKit'\nimport UserService from '../service/UserService'\n\nconst TAG = \"HttpClient\";\nconst CODE_UNAUTH = -1001;\n\nexport class HttpClient {\n  readonly baseUrl: string\n  readonly cookieJar: CookieJar\n\n  constructor(baseUrl: string, cookieJar: CookieJar) {\n    this.baseUrl = baseUrl\n    this.cookieJar = cookieJar\n  }\n\n  async get<T>(path: string): Promise<Response<T>> {\n    return this.requestSync(path, http.RequestMethod.GET);\n  }\n\n  async post<T>(path: string, extraData?: object): Promise<Response<T>> {\n    return this.requestSync(path, http.RequestMethod.POST, extraData);\n  }\n\n  async requestSync<T>(\n    path: string,\n    method: http.RequestMethod,\n    extraData?: object\n  ): Promise<Response<T>> {\n    const headers = new Headers();\n    const url = this.baseUrl + path;\n    const uri = this.parseUri(url);\n    const cookies = this.cookieJar.loadForRequest(uri);\n    if (cookies.length > 0) {\n      headers.cookie = CookieUtils.cookieHeader(cookies);\n    }\n    if (method === http.RequestMethod.POST) {\n      headers.contentType = \"application/x-www-form-urlencoded\"\n      if (!extraData) {\n        // POST 必须有请求体，否则会报 Parameter error\n        extraData = new Object();\n      }\n    }\n    const httpRequest = http.createHttp();\n    hilog.info(0, TAG,\n      `start request, path: ${path}, method: ${method}, extraData: ` + JSON.stringify(extraData, undefined, undefined));\n\n    const res = new Response<T>()\n    let resp: http.HttpResponse\n\n    try {\n      resp = await httpRequest.request(\n        url,\n        {\n          method: method,\n          expectDataType: http.HttpDataType.OBJECT,\n          header: headers,\n          extraData: extraData\n        })\n    } catch (err) {\n      hilog.error(0, TAG, `request error, path: ${path}, error: ${JSON.stringify(err, undefined, undefined)}`)\n      res.errorCode = -1\n      res.errorMsg = err?.message ?? \"\"\n      return res;\n    }\n\n    if (resp.responseCode === 200) {\n      this.cookieJar.saveFromResponse(uri, CookieUtils.parseHttpRequestCookies(resp.cookies))\n      if (resp.resultType === http.HttpDataType.STRING) {\n        const result: Response<T> = JSON.parse(resp.result as string);\n        res.errorCode = result.errorCode;\n        res.errorMsg = result.errorMsg;\n        res.data = result.data;\n      } else if (resp.resultType === http.HttpDataType.OBJECT) {\n        const result = resp.result as Response<T>;\n        res.errorCode = result.errorCode;\n        res.errorMsg = result.errorMsg;\n        res.data = result.data;\n      } else {\n        res.errorCode = -1\n        res.errorMsg = `UnSupport data type: ${resp.resultType}`\n      }\n\n      hilog.info(0, TAG, `request success, path: ${path}, result: ${JSON.stringify(res, undefined, undefined)}`)\n\n      if (res.errorCode === CODE_UNAUTH) {\n        // token 失效\n        UserService.get().clearUser();\n      }\n    } else {\n      hilog.error(0, TAG, `request error, path: ${path}, http code: ${resp.responseCode}`)\n      res.errorCode = resp.responseCode\n    }\n\n    return res;\n  }\n\n  private parseUri(url: string): uri.URI {\n    return new uri.URI(url);\n  }\n}"
  },
  {
    "path": "entry/src/main/ets/net/Response.ets",
    "content": "export class Response<T> {\n  errorCode: number = 0\n  errorMsg: string = \"\"\n  data?: T = undefined\n\n  isSuccess(): boolean {\n    return this.errorCode === 0\n  }\n\n  isSuccessWithData(): boolean {\n    return this.errorCode === 0 && this.data !== undefined;\n  }\n\n  getDataOrThrow(): T {\n    return this.data!!\n  }\n}\n"
  },
  {
    "path": "entry/src/main/ets/net/cookie/Cookie.ets",
    "content": "/**\n * Cookie 对象，参考 OkHttp 中 Cookie 结构\n */\nexport default interface Cookie {\n  domain: string;\n  path: string;\n  expiresAt: number;\n  name: string;\n  value: string;\n  httpOnly: boolean;\n  persistent: boolean;\n}"
  },
  {
    "path": "entry/src/main/ets/net/cookie/CookieJar.ets",
    "content": "import uri from '@ohos.uri';\nimport Cookie from './Cookie';\n\nexport default interface CookieJar {\n  saveFromResponse(url: uri.URI, cookies: Cookie[]): void;\n\n  loadForRequest(url: uri.URI): Cookie[];\n\n  clear(): void;\n}\n"
  },
  {
    "path": "entry/src/main/ets/net/cookie/CookiePersistor.ets",
    "content": "import Cookie from './Cookie';\n\nexport default interface CookiePersistor {\n  loadAll(): Cookie[];\n\n  saveAll(cookies: Cookie[]): void;\n\n  removeAll(cookies: Cookie[]): void;\n\n  clear(): void;\n}"
  },
  {
    "path": "entry/src/main/ets/net/cookie/CookieUtils.ets",
    "content": "import Cookie from './Cookie';\nimport { uri } from '@kit.ArkTS';\n\nexport default class CookieUtils {\n  /**\n   * httpRequest 返回的 cookie 格式：\n   * ```\n   * #HttpOnly_www.wanandroid.com  FALSE  /  TRUE  0  JSESSIONID  564CB756D6C2F19456141DA377A0D692\n   * www.wanandroid.com  FALSE  /  FALSE  1705495544  loginUserName  chaywong\n   * www.wanandroid.com  FALSE  /  FALSE  1705495544  token_pass  d4fb1b1219a552003c5ec2e93221b0b0\n   * .wanandroid.com  TRUE  /  FALSE  1705495544  loginUserName_wanandroid_com  chaywong\n   * .wanandroid.com  TRUE  /  FALSE  1705495544  token_pass_wanandroid_com  d4fb1b1219a552003c5ec2e93221b0b0\n   * ```\n   */\n  static parseHttpRequestCookies(cookieString: string): Cookie[] {\n    if (!cookieString) {\n      return [];\n    }\n    const cookies: Cookie[] = [];\n    const lines = cookieString.split(\"\\r\\n\");\n    lines.forEach((line) => {\n      const attrs = line.split(\"\\t\");\n      if (attrs.length !== 7 || !attrs[0]) {\n        return;\n      }\n      let domain = attrs[0];\n      let httpOnly = false;\n      if (domain.startsWith(\"#HttpOnly_\")) {\n        domain = domain.substring(\"#HttpOnly_\".length);\n        httpOnly = true;\n      }\n      cookies.push({\n        domain: domain,\n        path: attrs[2],\n        expiresAt: parseInt(attrs[4]),\n        name: attrs[5],\n        value: attrs[6],\n        httpOnly: httpOnly,\n        persistent: true\n      });\n    })\n    return cookies;\n  }\n\n  static cookieHeader(cookies: Cookie[]): string {\n    let str = \"\";\n    cookies.forEach((cookie, index) => {\n      if (index > 0) {\n        str += \"; \";\n      }\n      str += cookie.name + \"=\" + cookie.value;\n    });\n    return str;\n  }\n\n  static matches(cookie: Cookie, url: uri.URI): boolean {\n    const domainMatch = CookieUtils.domainMatch(url.host, cookie.domain);\n    if (!domainMatch) {\n      return false;\n    }\n    if (!CookieUtils.pathMatch(url, cookie.path)) {\n      return false;\n    }\n    return true;\n  }\n\n  static createCookieKey(cookie: Cookie): string {\n    return `https://${cookie.domain}${cookie.path}|${cookie.name}`;\n  }\n\n  static isExpired(cookie: Cookie): boolean {\n    const nowTime = Date.now() / 1000;\n    return cookie.expiresAt < nowTime;\n  }\n\n  static fromJson(json: string): Cookie | undefined {\n    if (json.length === 0) {\n      return undefined;\n    }\n    const temp: Cookie | undefined = JSON.parse(json);\n    return temp;\n  }\n\n  private static domainMatch(urlHost: string, domain: string): boolean {\n    if (urlHost === domain) {\n      return true; // As in 'example.com' matching 'example.com'.\n    }\n\n    return urlHost.endsWith(domain) && urlHost[urlHost.length - domain.length - 1] === \".\";\n  }\n\n  private static pathMatch(url: uri.URI, path: string): boolean {\n    const urlPath = url.path;\n    if (urlPath === path) {\n      return true; // As in '/foo' matching '/foo'.\n    }\n    if (urlPath.startsWith(path)) {\n      if (path.endsWith(\"/\")) {\n        return true;\n      } // As in '/' matching '/foo'.\n      if (urlPath[path.length] === \"/\") {\n        return true;\n      } // As in '/foo' matching '/foo/bar'.\n    }\n    return false;\n  }\n}"
  },
  {
    "path": "entry/src/main/ets/net/cookie/KVCookiePersistor.ets",
    "content": "import Cookie from './Cookie';\nimport dataPreferences from '@ohos.data.preferences';\nimport CookiePersistor from './CookiePersistor';\nimport JSON from '@ohmos/json-bigint';\nimport CookieUtils from './CookieUtils';\n\nconst PREFERENCES_NAME = \"top.wangchenyan.cookie.persistor\"\nconst KEY_COOKIE_KEYS = \"COOKIE_KEYS\";\n\nexport default class KVCookiePersistor implements CookiePersistor {\n  private static TAG = \"KVCookiePersistor\";\n  private preferences: dataPreferences.Preferences;\n\n  constructor(context: Context) {\n    this.preferences = dataPreferences.getPreferencesSync(context, {\n      name: PREFERENCES_NAME\n    });\n  }\n\n  loadAll(): Cookie[] {\n    const cookies: Cookie[] = [];\n    const keys = this.preferences.getSync(KEY_COOKIE_KEYS, []) as string[]\n    keys.forEach((key) => {\n      const value = this.preferences.getSync(key, \"\") as string\n      if (value.length > 0) {\n        const cookie = CookieUtils.fromJson(value);\n        if (cookie) {\n          cookies.push(cookie);\n        }\n      }\n    })\n    return cookies;\n  }\n\n  saveAll(cookies: Cookie[]) {\n    cookies.forEach((cookie) => {\n      this.preferences.putSync(CookieUtils.createCookieKey(cookie), JSON.stringify(cookie, undefined, undefined));\n    });\n    const keys = this.preferences.getSync(KEY_COOKIE_KEYS, []) as string[]\n    cookies.forEach((cookie) => {\n      const key = CookieUtils.createCookieKey(cookie);\n      if (keys.indexOf(key) < 0) {\n        keys.push(key)\n      }\n    })\n    this.preferences.putSync(KEY_COOKIE_KEYS, keys);\n    this.preferences.flush();\n  }\n\n  removeAll(cookies: Cookie[]) {\n    const keys = this.preferences.getSync(KEY_COOKIE_KEYS, []) as string[]\n    cookies.forEach((cookie) => {\n      const key = CookieUtils.createCookieKey(cookie);\n      this.preferences.deleteSync(key);\n      const index = keys.indexOf(key);\n      if (index >= 0) {\n        keys.splice(index, 1);\n      }\n    });\n    this.preferences.putSync(KEY_COOKIE_KEYS, keys);\n    this.preferences.flush();\n  }\n\n  clear() {\n    this.preferences.clearSync();\n    this.preferences.flush();\n  }\n}"
  },
  {
    "path": "entry/src/main/ets/net/cookie/PersistentCookieJar.ets",
    "content": "import HashMap from '@ohos.util.HashMap';\nimport uri from '@ohos.uri';\nimport Cookie from './Cookie';\nimport CookieJar from './CookieJar';\nimport CookiePersistor from './CookiePersistor';\nimport KVCookiePersistor from './KVCookiePersistor';\nimport CookieUtils from './CookieUtils';\n\nexport default class PersistentCookieJar implements CookieJar {\n  private static TAG = \"PersistentCookieJar\";\n  private cache: HashMap<string, Cookie> = new HashMap();\n  private persistor: CookiePersistor;\n\n  constructor(context: Context) {\n    this.persistor = new KVCookiePersistor(context);\n    const cookies = this.persistor.loadAll();\n    cookies.forEach((cookie) => {\n      this.cache.set(CookieUtils.createCookieKey(cookie), cookie);\n    })\n  }\n\n  saveFromResponse(url: uri.URI, cookies: Cookie[]): void {\n    cookies.forEach((cookie) => {\n      this.cache.set(CookieUtils.createCookieKey(cookie), cookie);\n    })\n    this.persistor.saveAll(PersistentCookieJar.filterPersistentCookies(cookies));\n  }\n\n  private static filterPersistentCookies(cookies: Cookie[]): Cookie[] {\n    return cookies.filter((item) => {\n      return item.persistent;\n    })\n  }\n\n  loadForRequest(url: uri.URI): Cookie[] {\n    const cookiesToRemove: Cookie[] = [];\n    const validCookies: Cookie[] = [];\n\n    const iterator: IterableIterator<Cookie> = this.cache.values();\n    let result = iterator.next();\n    while (!result.done) {\n      const currentCookie: Cookie = result.value;\n      if (CookieUtils.isExpired(currentCookie)) {\n        cookiesToRemove.push(currentCookie);\n      } else if (CookieUtils.matches(currentCookie, url)) {\n        validCookies.push(currentCookie);\n      }\n      result = iterator.next();\n    }\n\n    cookiesToRemove.forEach((item) => {\n      this.cache.remove(CookieUtils.createCookieKey(item));\n    })\n\n    this.persistor.removeAll(cookiesToRemove);\n\n    return validCookies;\n  }\n\n  clear(): void {\n    this.cache.clear();\n    this.persistor.clear();\n  }\n}"
  },
  {
    "path": "entry/src/main/ets/net/model/Article.ets",
    "content": "export class ArticleList {\n  curPage: number = 0\n  datas: Article[] = []\n  offset: number = 0\n  over: boolean = false\n  pageCount: number = 0\n  size: number = 0\n  total: number = 0\n}\n\nexport class Article {\n  id: number = 0\n  apkLink: string = \"\"\n  audit: number = 0\n  author: string = \"\"\n  canEdit: boolean = false\n  chapterId: number = 0\n  chapterName: string = \"\"\n  collect: boolean = false\n  courseId: number = 0\n  desc: string = \"\"\n  descMd: string = \"\"\n  envelopePic: string = \"\"\n  fresh: boolean = false\n  host: string = \"\"\n  link: string = \"\"\n  niceDate: string = \"\"\n  niceShareDate: string = \"\"\n  origin: string = \"\"\n  prefix: string = \"\"\n  projectLink: string = \"\"\n  publishTime: number = 0\n  realSuperChapterId: number = 0\n  selfVisible: number = 0\n  shareDate: number = 0\n  shareUser: string = \"\"\n  superChapterId: number = 0\n  superChapterName: string = \"\"\n  title: string = \"\"\n  type: number = 0\n  userId: number = 0\n  visible: number = 0\n  zan: number = 0\n  adminAdd: boolean = false;\n  isAdminAdd: boolean = false;\n  originId: number = 0;\n  tags: ArticleTag[] = [];\n}\n\nexport function getArticleAuthor(article: Article): string {\n  return article.author ?? article.shareUser;\n}\n\nexport function getArticleChapter(article: Article): string {\n  let chapter = article.superChapterName ?? \"\";\n  if (chapter && article.chapterName) {\n    chapter = chapter + \" / \";\n  }\n  chapter = chapter + article.chapterName ?? \"\";\n  return chapter;\n}\n\nexport class ArticleTag {\n  name: string = \"\"\n  url: string = \"\"\n}\n\nexport function getTagColor(tag: ArticleTag): Resource {\n  switch (tag.name) {\n    case \"置顶\":\n      return $r(\"app.color.red\")\n    case \"本站发布\":\n      return $r(\"app.color.blue\")\n    case \"问答\":\n      return $r(\"app.color.cyan\")\n    case \"公众号\":\n      return $r(\"app.color.main\")\n    case \"项目\":\n      return $r(\"app.color.teal\")\n    default:\n      return $r(\"app.color.main\")\n  }\n}\n\nexport class HomeBannerData {\n  id: number = 0\n  desc: string = \"\"\n  imagePath: string = \"\"\n  isVisible: number = 0\n  order: number = 0\n  title: string = \"\"\n  type: number = 0\n  url: string = \"\"\n}"
  },
  {
    "path": "entry/src/main/ets/net/model/Harmony.ets",
    "content": "import { Article } from \"./Article\";\n\nexport  class  Links {\n  articleList: Article[] = []\n  author: string = \"\"\n  children: [] = []\n  courseId: number = 0\n  cover: string = \"\"\n  desc: string = \"\"\n  id: number = 0\n  lisense: string = \"\"\n  lisenseLink: string = \"\"\n  name: string = \"\"\n  order: number = 0\n  parentChapterId: number = 0\n  type: number = 0\n  userControlSetTop: boolean = false\n  visible: number = 0\n}\n\nexport class  Open_sources {\n  articleList: Article[] = []\n  author: string = \"\"\n  children: [] = []\n  courseId: number = 0\n  cover: string= \"\"\n  desc: string = \"\"\n  id: number = 0\n  lisense: string = \"\"\n  lisenseLink: string = \"\"\n  name: string = \"\"\n  order: number = 0\n  parentChapterId: number = 0\n  type: number = 0\n  userControlSetTop: boolean = false\n  visible: number = 0\n}\n\n\nexport class  Tools {\n  articleList: Article[] = []\n  author: string = \"\"\n  children: [] = []\n  courseId: number = 0\n  cover: string = \"\"\n  desc: string = \"\"\n  id: number = 0\n  lisense: string = \"\"\n  lisenseLink: string = \"\"\n  name: string = \"\"\n  order: number = 0\n  parentChapterId: number = 0\n  type: number = 0\n  userControlSetTop: boolean = false\n  visible: number = 0\n}\n\nexport class Harmony {\n  links: Links | null = new Links();\n  open_sources: Open_sources | null = new Open_sources();\n  tools: Tools | null = new Tools();\n}\n"
  },
  {
    "path": "entry/src/main/ets/net/model/RankingList.ets",
    "content": "\nexport class RankingList {\n  coinCount: number = 0\n  level: number = 0\n  nickname: string = \"\"\n  rank: string = \"\"\n  userId: number = 0\n  username: string = \"\"\n}\n\nexport class  Rank {\n  curPage: number = 0\n  datas: RankingList[] = []\n  offset: number = 0\n  over: boolean = false\n  pageCount: number = 0\n  size: number = 0\n  total: number = 0\n}"
  },
  {
    "path": "entry/src/main/ets/net/model/Search.ets",
    "content": "export class HotKey {\n  id: number = 0\n  name: string = \"\"\n}"
  },
  {
    "path": "entry/src/main/ets/net/model/Tree.ets",
    "content": "import { Article } from './Article'\n\nexport class Tree {\n  articleList: Article[] = []\n  author: string = \"\"\n  children: Tree[] = []\n  courseId: number = 0\n  cover: string = \"\"\n  desc: string = \"\"\n  id: number = 0\n  lisense: string = \"\"\n  lisenseLink: string = \"\"\n  name: string = \"\"\n  order: number = 0\n  parentChapterId: number = 0\n  type: number = 0\n  userControlSetTop: boolean = false\n  visible: number = 0\n}"
  },
  {
    "path": "entry/src/main/ets/net/model/WeChat.ets",
    "content": "export class WeChatAuthor {\n  id: number = 0\n  name: string = \"\"\n}"
  },
  {
    "path": "entry/src/main/ets/pages/CollectList.ets",
    "content": "import { PullToRefresh, PullToRefreshConfigurator } from '@ohos/pulltorefresh';\nimport hilog from '@ohos.hilog';\nimport Api from '../net/Api';\nimport { Article } from '../net/model/Article';\nimport { LoadState, PageLoading } from '../widgets/PageLoading';\nimport { TitleLayout } from '../widgets/TitleLayout';\nimport { ArticleItemComponent } from '../widgets/ArticleItemComponent';\nimport CollectUtils from '../common/CollectUtils';\nimport { RouteParams } from '../router/RouteInfo';\n\n@Component\nstruct CollectList {\n  @State loadState: LoadState = LoadState.LOADING;\n  @State showLoading: boolean = false;\n  @State title: string = \"我的收藏\";\n  @State data: Article[] = [];\n  private static TAG = \"CollectList\"\n  private scroller: Scroller = new Scroller();\n  private refreshConfig = new PullToRefreshConfigurator();\n  private nextPage: number = 1;\n  private hasMore: boolean = true;\n\n  aboutToAppear() {\n    this.loadData();\n  }\n\n  build() {\n    Column() {\n      TitleLayout({\n        title: this.title\n      })\n      PageLoading({\n        loadState: this.loadState,\n        showLoading: this.showLoading,\n        onReload: () => {\n          hilog.debug(0, CollectList.TAG, \"onReload\");\n          this.loadData();\n        }\n      }) {\n        Column() {\n          PullToRefresh({\n            data: $data,\n            scroller: this.scroller,\n            refreshConfigurator: this.refreshConfig,\n            customList: () => {\n              this.listViewBuilder();\n            },\n            onRefresh: () => {\n              return new Promise<string>((resolve, reject) => {\n                this.loadDataByPage(0).then(\n                  (data) => {\n                    this.nextPage = 1;\n                    this.data = data;\n                    resolve('刷新成功');\n                  },\n                  () => {\n                    resolve('刷新失败');\n                  }\n                )\n              });\n            },\n            onLoadMore: () => {\n              return new Promise<string>((resolve, reject) => {\n                if (this.hasMore) {\n                  this.loadDataByPage(this.nextPage).then(\n                    (data) => {\n                      if (data.length > 0) {\n                        this.nextPage++\n                        this.data = this.data.concat(data);\n                        resolve('加载成功');\n                      } else {\n                        this.hasMore = false;\n                        resolve('没有更多了');\n                      }\n                    },\n                    () => {\n                      resolve('加载失败');\n                    }\n                  )\n                } else {\n                  resolve('没有更多了');\n                }\n              });\n            },\n            customLoad: null,\n            customRefresh: null,\n          })\n        }\n        .width('100%')\n        .height('100%')\n      }\n    }\n    .width('100%')\n    .height('100%')\n  }\n\n  @Builder\n  private listViewBuilder() {\n    List({ scroller: this.scroller }) {\n      ForEach(this.data, (item: Article) => {\n        ListItem() {\n          ArticleItemComponent({\n            article: item,\n            onCollectClick: (article: Article) => {\n              CollectUtils.collect(article, article.originId)\n                .then((success) => {\n                  if (success) {\n                    this.data = this.data.map(item => item);\n                  }\n                })\n            }\n          })\n        }\n      })\n    }\n    .width('100%')\n    .height('100%')\n    .listDirection(Axis.Vertical)\n    .divider({\n      strokeWidth: 0.5,\n      color: $r(\"app.color.divider\"),\n      startMargin: 16,\n      endMargin: 16\n    })\n    .edgeEffect(EdgeEffect.None) // 必须设置列表为滑动到边缘无效果\n  }\n\n  private loadData() {\n    this.loadState = LoadState.LOADING\n    this.loadDataByPage(0).then(\n      (data) => {\n        this.data = data;\n        if (this.data.length === 0) {\n          this.loadState = LoadState.EMPTY;\n        } else {\n          this.loadState = LoadState.SUCCESS;\n        }\n      },\n      () => {\n        this.loadState = LoadState.FAIL;\n      })\n  }\n\n  private async loadDataByPage(page: number): Promise<Article[]> {\n    const res = await Api.get().getCollectList(page);\n    if (res.isSuccessWithData()) {\n      const list = res.getDataOrThrow().datas;\n      list.forEach((item) => {\n        item.collect = true;\n      })\n      return Promise.resolve(list);\n    } else {\n      return Promise.reject();\n    }\n  }\n}\n\n@Builder\nexport function collectListNavDesBuilder(params: RouteParams) {\n  NavDestination() {\n    CollectList()\n  }\n  .hideTitleBar(true)\n}\n"
  },
  {
    "path": "entry/src/main/ets/pages/Harmony.ets",
    "content": "import hilog from '@ohos.hilog';\nimport Api from '../net/Api';\nimport { LoadState, PageLoading } from '../widgets/PageLoading';\nimport { TitleLayout } from '../widgets/TitleLayout';\nimport { ArticleItemComponent } from '../widgets/ArticleItemComponent';\nimport CollectUtils from '../common/CollectUtils';\nimport { HRouter } from '../router/HRouter';\nimport { RouteMode, RouteParams } from '../router/RouteInfo';\nimport { Article } from '../net/model/Article';\nimport { Harmony, Links, Open_sources, Tools } from '../net/model/Harmony';\nimport { Response } from '../net/Response';\nimport { Routes } from '../Routes';\n\ninterface HarmonyCategory {\n  name: string;\n  key: 'links' | 'open_sources' | 'tools';\n}\n\ninterface GeneratedTypeLiteralInterface_1 {\n  categoryData: Links | Open_sources | Tools | null;\n}\n\n@Component\nstruct HarmonyTab {\n  @Prop categoryData: Links | Open_sources | Tools | null;\n  private static TAG = \"HarmonyTab\";\n  private scroller: Scroller = new Scroller();\n  @State articleList: Article[] = [];\n\n  onParameterChanged(params: GeneratedTypeLiteralInterface_1): void {\n    this.categoryData = params.categoryData;\n    this.updateArticleList();\n  }\n\n  aboutToAppear() {\n    this.updateArticleList();\n  }\n\n  private updateArticleList() {\n    this.articleList = this.categoryData?.articleList || [];\n    hilog.info(0, HarmonyTab.TAG, `加载分类文章数：${this.articleList.length}`);\n  }\n\n  private async handleCollectClick(article: Article) {\n    const success: boolean = await CollectUtils.collect(article);\n    if (success) {\n      this.articleList = this.articleList.map(item => item);\n    }\n  }\n\n  build() {\n    List({ scroller: this.scroller }) {\n      ForEach(this.articleList, (item: Article) => {\n        ListItem() {\n          ArticleItemComponent({\n            article: item,\n            clearTop: true,\n            onCollectClick: (article): Promise<void> => this.handleCollectClick(article)\n          })\n        }\n        .padding({ top: 8, bottom: 8 })\n      })\n\n      if (this.articleList.length === 0) {\n        ListItem() {\n          Column({ space: 8 }) {\n            Text('暂无相关文章')\n              .fontSize(14)\n              .fontColor($r(\"app.color.navi_bar_bg\")) // 确保资源存在\n          }\n          .width('100%')\n          .height(100)\n          .justifyContent(FlexAlign.Center)\n        }\n      }\n    }\n    .width('100%')\n    .height('100%')\n    .listDirection(Axis.Vertical)\n    .divider({\n      strokeWidth: 0.5,\n      color: $r(\"app.color.divider\"),\n      startMargin: 16,\n      endMargin: 16\n    })\n    .edgeEffect(EdgeEffect.None)\n  }\n}\n\n@Component\nexport struct HarmonyPage {\n  @State title: string = \"鸿蒙开发专栏\";\n  @State loadState: LoadState = LoadState.LOADING;\n  @State showLoading: boolean = false;\n  clearTop: boolean = false;\n  @State categories: HarmonyCategory[] = [\n    { name: '链接', key: 'links' },\n    { name: '开源项目', key: 'open_sources' },\n    { name: '工具', key: 'tools' }\n  ];\n  @State harmonyData: Harmony | null = null;\n  private static TAG = \"HarmonyPage\";\n\n  aboutToAppear() {\n    this.loadData();\n  }\n\n  private getTabData(categoryKey: 'links' | 'open_sources' | 'tools'): Links | Open_sources | Tools | null {\n    if (!this.harmonyData) {\n      return null;\n    }\n    switch (categoryKey) {\n      case 'links':\n        return this.harmonyData.links;\n      case 'open_sources':\n        return this.harmonyData.open_sources;\n      case 'tools':\n        return this.harmonyData.tools;\n      default:\n        return null;\n    }\n  }\n\n  build() {\n    Column() {\n      TitleLayout({\n        title: this.title,\n        showBack: false,\n        menuIcon: $r(\"app.media.ic_search\"),\n        onMenuClick: () => {\n          HRouter.with().url(Routes.Web).params('url', \"https://ohpm.openharmony.cn/#/cn/home\")\n            .mode(this.clearTop ? RouteMode.ClearTop : RouteMode.Standard)\n            .start();\n        }\n      })\n\n      PageLoading({\n        loadState: this.loadState,\n        showLoading: this.showLoading,\n        onReload: () => {\n          hilog.debug(0, HarmonyPage.TAG, \"重新加载数据\");\n          this.loadData();\n        }\n      }) {\n        if (this.categories.length > 0) {\n          Tabs({ barPosition: BarPosition.Start }) {\n            ForEach(this.categories, (category: HarmonyCategory) => {\n              TabContent() {\n                // 传递数据给子组件的@Prop属性（无private初始化问题）\n                HarmonyTab({\n                  categoryData: this.getTabData(category.key)\n                })\n              }\n              .tabBar(category.name)\n            })\n          }\n          .width('100%')\n          .height('100%')\n          .scrollable(true)\n          .barMode(BarMode.Scrollable)\n          .barHeight(44)\n        }\n      }\n    }\n    .width('100%')\n    .height('100%')\n  }\n\n  private loadData() {\n    this.loadState = LoadState.LOADING;\n    Api.get().getHarmony()\n      .then((res: Response<Harmony>) => {\n        if (res.errorCode === 0 && res.data) {\n          this.harmonyData = res.data;\n          this.loadState = LoadState.SUCCESS;\n          hilog.info(0, HarmonyPage.TAG, \"数据加载成功\");\n        } else {\n          this.loadState = LoadState.FAIL;\n          hilog.error(0, HarmonyPage.TAG, `加载失败：${res.errorMsg}`);\n        }\n      })\n      .catch((error: Error) => {\n        this.loadState = LoadState.FAIL;\n        hilog.error(0, HarmonyPage.TAG, `加载异常：${error.message}`);\n      });\n  }\n}\n\n@Builder\nexport function HarmonyNavDesBuilder(params: RouteParams) {\n  NavDestination() {\n    HarmonyPage()\n  }\n  .hideTitleBar(true)\n}\n\nexport { Harmony };\n"
  },
  {
    "path": "entry/src/main/ets/pages/Home.ets",
    "content": "import hilog from '@ohos.hilog'\nimport Api from '../net/Api'\nimport { Article, ArticleTag, HomeBannerData, } from '../net/model/Article'\nimport { LoadState, PageLoading } from '../widgets/PageLoading'\nimport { PullToRefresh } from '@ohos/pulltorefresh'\nimport { TitleLayout } from '../widgets/TitleLayout'\nimport { ArticleItemComponent } from '../widgets/ArticleItemComponent'\nimport CollectUtils from '../common/CollectUtils'\nimport { HRouter } from '../router/HRouter'\nimport { Routes } from '../Routes'\nimport { RouteMode } from '../router/RouteInfo'\n\ndeclare type HomeItemData = Article | HomeBannerData[];\n\n@Component\nexport struct Home {\n  @State data: HomeItemData[] = [];\n  @State loadState: LoadState = LoadState.LOADING;\n  @State showLoading: boolean = false;\n  @State bannerPosition: number = 0;\n  @State title: string = \"首页\";\n  private static TAG = \"Home\";\n  private scroller: Scroller = new Scroller();\n  private nextPage: number = 1;\n  private hasMore: boolean = true;\n\n  async aboutToAppear() {\n    hilog.info(0, Home.TAG, \"aboutToAppear\")\n    this.loadData();\n  }\n\n  build() {\n    PageLoading({\n      loadState: this.loadState,\n      showLoading: this.showLoading,\n      onReload: () => {\n        hilog.debug(0, Home.TAG, \"onReload\");\n        this.loadData();\n      }\n    }) {\n      Column() {\n        TitleLayout({\n          title: this.title,\n          showBack: false,\n\n          menuIcon: $r(\"app.media.ic_search\"),\n          onMenuClick: () => {\n            HRouter.with()\n              .url(Routes.SearchEntry)\n              .start();\n          }\n        });\n        PullToRefresh({\n          data: $data,\n          scroller: this.scroller,\n          customList: () => {\n            this.listViewBuilder();\n          },\n          onRefresh: () => {\n            return new Promise<string>((resolve, reject) => {\n              this.loadDataByPage(0).then(\n                (data) => {\n                  this.nextPage = 1;\n                  this.data = data;\n                  resolve('刷新成功');\n                },\n                () => {\n                  resolve('刷新失败');\n                }\n              )\n            });\n          },\n          onLoadMore: () => {\n            return new Promise<string>((resolve, reject) => {\n              if (this.hasMore) {\n                this.loadDataByPage(this.nextPage).then(\n                  (data) => {\n                    if (data.length > 0) {\n                      this.nextPage++\n                      this.data = this.data.concat(data);\n                      resolve('加载成功');\n                    } else {\n                      this.hasMore = false;\n                      resolve('没有更多了')\n                    }\n                  },\n                  () => {\n                    resolve('加载失败');\n                  }\n                )\n              } else {\n                resolve('没有更多了')\n              }\n            });\n          },\n          customLoad: null,\n          customRefresh: null,\n        })\n      }\n      .width('100%')\n      .height('100%')\n    }\n  }\n\n  @Builder\n  private listViewBuilder() {\n    List({ scroller: this.scroller }) {\n      ForEach(this.data, (item: HomeItemData) => {\n        ListItem() {\n          if (item instanceof Array) {\n            BannerComponent({\n              bannerList: item\n            })\n          } else {\n            ArticleItemComponent({\n              article: item as Article,\n              clearTop: true,\n              onCollectClick: async (article: Article) => {\n                const success = await CollectUtils.collect(article)\n                if (success) {\n                  this.data = this.data.map(item => item);\n                }\n              }\n            })\n          }\n        }\n      })\n    }\n    .width('100%')\n    .height('100%')\n    .listDirection(Axis.Vertical)\n    .divider({\n      strokeWidth: 0.5,\n      color: $r(\"app.color.divider\"),\n      startMargin: 16,\n      endMargin: 16\n    })\n    .edgeEffect(EdgeEffect.None) // 必须设置列表为滑动到边缘无效果\n  }\n\n  async loadData() {\n    this.loadState = LoadState.LOADING\n    this.loadDataByPage(0).then(\n      (data) => {\n        this.data = data;\n        if (this.data.length === 0) {\n          this.loadState = LoadState.EMPTY;\n        } else {\n          this.loadState = LoadState.SUCCESS;\n        }\n      },\n      () => {\n        this.loadState = LoadState.FAIL;\n      })\n  }\n\n  async loadDataByPage(page: number): Promise<HomeItemData[]> {\n    if (page === 0) {\n      const bannerRes = await Api.get().getHomeBanner();\n      const topRes = await Api.get().getTopArticle();\n      const articleRes = await Api.get().getHomeArticleList(page);\n\n      if (bannerRes.isSuccessWithData() && topRes.isSuccessWithData() && articleRes.isSuccessWithData()) {\n        const bannerList = bannerRes.getDataOrThrow();\n        let articleList: Article[] = [];\n        topRes.getDataOrThrow().forEach((item) => {\n          const tag = new ArticleTag();\n          tag.name = \"置顶\";\n          item.tags = [tag].concat(item.tags);\n          articleList.push(item);\n        })\n        articleList = articleList.concat(articleRes.getDataOrThrow().datas);\n        let dataList: HomeItemData[] = [];\n        dataList.push(bannerList);\n        dataList = dataList.concat(articleList);\n        return Promise.resolve(dataList);\n      } else {\n        return Promise.reject();\n      }\n    } else {\n      const articleRes = await Api.get().getHomeArticleList(page);\n      if (articleRes.isSuccessWithData()) {\n        return Promise.resolve(articleRes.getDataOrThrow().datas);\n      } else {\n        return Promise.reject();\n      }\n    }\n  }\n}\n\n@Component\nstruct BannerComponent {\n  private swiperController: SwiperController = new SwiperController()\n  @State private bannerPosition: number = 0\n  bannerList: HomeBannerData[] = []\n\n  build() {\n    Stack() {\n      Swiper(this.swiperController) {\n        ForEach(this.bannerList, (item: HomeBannerData) => {\n          this.bannerItemBuilder(item)\n        })\n      }\n      .autoPlay(true)\n      .index(this.bannerPosition)\n      .loop(true)\n      .indicatorStyle({\n        right: 16,\n        bottom: 0\n      })\n      .onChange((index) => {\n        this.bannerPosition = index;\n      })\n    }\n    .width('100%')\n    .height(220)\n  }\n\n  @Builder\n  private bannerItemBuilder(data: HomeBannerData) {\n    Stack({ alignContent: Alignment.Bottom }) {\n      Image(data.imagePath)\n        .objectFit(ImageFit.Cover)\n        .width('100%')\n        .height('100%')\n      Text(data.title)\n        .width('100%')\n        .padding({\n          left: 16,\n          top: 6,\n          right: 16,\n          bottom: 6\n        })\n        .fontColor($r(\"app.color.white\"))\n        .fontSize(15)\n        .maxLines(1)\n        .backgroundColor($r(\"app.color.translucent_black_40\"))\n    }\n    .width('100%')\n    .height('100%')\n    .onClick((event) => {\n      HRouter.with()\n        .url(Routes.Web)\n        .params('url', data.url)\n        .mode(RouteMode.ClearTop)\n        .start()\n    })\n  }\n}\n"
  },
  {
    "path": "entry/src/main/ets/pages/Index.ets",
    "content": "import { Home } from './Home'\nimport { Square } from './Square'\nimport { Mine } from './Mine'\nimport { Wechat } from './Wechat'\nimport OHPermission from '../common/OHPermission'\nimport { TreeTab } from './TreeTab'\nimport WindowUtils from '../common/WindowUtils'\nimport { HRouter } from '../router/HRouter'\nimport { registerRoutes } from '../Routes'\nimport { RouteParams } from '../router/RouteInfo'\nimport { HarmonyPage } from './Harmony'\n\n@Entry\n@Component\nstruct Index {\n  private static TAG = \"Index\"\n  private tabsController = new TabsController()\n  @State currentIndex: number = 0\n  @State isPermissionGrant: boolean = false\n\n  aboutToAppear() {\n    registerRoutes()\n    OHPermission.requestPermission(getContext(this), ['ohos.permission.INTERNET'])\n      .then((v) => {\n        this.isPermissionGrant = true;\n      })\n      .catch(() => {\n        this.isPermissionGrant = false;\n      })\n  }\n\n  build() {\n    Navigation(HRouter.pathStack) {\n      this.tabContainerBuilder()\n    }\n    .mode(NavigationMode.Auto)\n    .navBarWidth(360)\n    .navBarWidthRange([360, 640])\n    .minContentWidth(640)\n    .navDestination(this.navDestination)\n    .hideTitleBar(true)\n  }\n\n  @Builder\n  tabContainerBuilder() {\n    Column() {\n      if (this.isPermissionGrant) {\n        Tabs({ barPosition: BarPosition.End, controller: this.tabsController }) {\n          TabContent() {\n            Home()\n          }.tabBar(this.tabBuilder(\"首页\", 0, $r(\"app.media.ic_tab_home_fill\"), $r(\"app.media.ic_tab_home\")))\n\n          TabContent() {\n            HarmonyPage()\n          }.tabBar(this.tabBuilder(\"鸿蒙\", 1, $r(\"app.media.harmony_tab_fill\"), $r(\"app.media.harmony_tab\")))\n\n          TabContent() {\n            Square()\n          }.tabBar(this.tabBuilder(\"广场\", 2, $r(\"app.media.ic_tab_discover_fill\"), $r(\"app.media.ic_tab_discover\")))\n\n          TabContent() {\n            TreeTab()\n          }.tabBar(this.tabBuilder(\"体系\", 3, $r(\"app.media.ic_tab_tree_fill\"), $r(\"app.media.ic_tab_tree\")))\n\n          TabContent() {\n            Wechat()\n          }.tabBar(this.tabBuilder(\"公众号\", 4, $r(\"app.media.ic_tab_wechat_fill\"), $r(\"app.media.ic_tab_wechat\")))\n\n          TabContent() {\n            Mine()\n          }.tabBar(this.tabBuilder(\"我的\", 5, $r(\"app.media.ic_tab_my_fill\"), $r(\"app.media.ic_tab_my\")))\n        }\n        .layoutWeight(1)\n        .scrollable(false)\n        .animationDuration(0)\n        .onChange((index) => {\n          this.currentIndex = index\n        })\n        .backgroundColor($r(\"app.color.start_window_background\"))\n      } else {\n        Text(\"No Permission\")\n          .width('100%')\n          .layoutWeight(1)\n          .textAlign(TextAlign.Center)\n      }\n      Row()\n        .width('100%')\n        .height(WindowUtils.navigationBarHeight + 'px')\n        .backgroundColor($r(\"app.color.navi_bar_bg\"))\n    }\n    .width('100%')\n    .height('100%')\n  }\n\n  @Builder\n  tabBuilder(title: string, targetIndex: number, selectedImg: Resource, normalImg: Resource) {\n    Column() {\n      Image(this.currentIndex === targetIndex ? selectedImg : normalImg)\n        .size({ width: 24, height: 24 })\n        .fillColor(this.currentIndex === targetIndex ? $r(\"app.color.main\") : $r(\"app.color.navi_tab_unselect\"))\n      Text(title)\n        .fontColor(this.currentIndex === targetIndex ? $r(\"app.color.main\") : $r(\"app.color.navi_tab_unselect\"))\n        .fontSize(11)\n    }\n    .width('100%')\n    .height('100%')\n    .backgroundColor($r(\"app.color.navi_bar_bg\"))\n    .justifyContent(FlexAlign.Center)\n    .onClick(() => {\n      this.currentIndex = targetIndex\n      this.tabsController.changeIndex(targetIndex)\n    })\n  }\n\n  @Builder\n  navDestination(url: string, params: RouteParams) {\n    HRouter.getNavDesBuilder(url)!.builder(params)\n  }\n}"
  },
  {
    "path": "entry/src/main/ets/pages/Login.ets",
    "content": "import { toast } from '../common/Toast'\nimport Api from '../net/Api'\nimport { HRouter } from '../router/HRouter'\nimport { RouteParams } from '../router/RouteInfo'\nimport UserService from '../service/UserService'\nimport { LoadState, PageLoading } from '../widgets/PageLoading'\nimport { TitleLayout } from '../widgets/TitleLayout'\n\n@Component\nstruct Login {\n  @State loadState: LoadState = LoadState.SUCCESS;\n  @State showLoading: boolean = false;\n  @State title: string = \"登录\";\n  private account: string = \"\";\n  private password: string = \"\";\n\n  build() {\n    Stack() {\n      PageLoading({\n        loadState: this.loadState,\n        showLoading: this.showLoading\n      }) {\n        Column() {\n          TitleLayout({\n            title: this.title\n          })\n          Column() {\n            TextInput({\n              placeholder: \"请输入用户名\"\n            })\n              .fontSize(15)\n              .fontColor($r(\"app.color.text_h1\"))\n              .type(InputType.Email)\n              .onChange((value) => {\n                this.account = value\n              })\n            TextInput({\n              placeholder: \"请输入密码\"\n            })\n              .margin({ top: 16 })\n              .fontSize(15)\n              .fontColor($r(\"app.color.text_h1\"))\n              .type(InputType.Password)\n              .onChange((value) => {\n                this.password = value\n              })\n            Button(\"登录\", {\n              type: ButtonType.Capsule\n            })\n              .width('100%')\n              .margin({ top: 50 })\n              .fontSize(15)\n              .fontColor($r(\"app.color.white\"))\n              .backgroundColor($r(\"app.color.main\"))\n              .onClick((e) => {\n                this.login().catch();\n              })\n          }\n          .width('100%')\n          .margin({ top: 120 })\n          .padding({ left: 16, right: 16 })\n        }\n        .width('100%')\n        .height('100%')\n      }\n    }\n    .width('100%')\n    .height('100%')\n  }\n\n  async login() {\n    if (!this.account) {\n      toast(\"请输入用户名\");\n      return;\n    }\n    if (!this.password) {\n      toast(\"请输入密码\");\n      return;\n    }\n    this.showLoading = true;\n    const res = await Api.get().login(this.account, this.password);\n    this.showLoading = false;\n    if (res.isSuccessWithData()) {\n      toast(\"登录成功\");\n      UserService.get().setUser(res.data);\n      const user = await UserService.get().updateUser();\n      if (user) {\n        HRouter.with()\n          .params('success', true)\n          .back();\n      }\n    } else {\n      toast(res.errorMsg);\n    }\n  }\n}\n\n@Builder\nexport function loginNavDesBuilder(params: RouteParams) {\n  NavDestination() {\n    Login()\n  }\n  .hideTitleBar(true)\n}"
  },
  {
    "path": "entry/src/main/ets/pages/Mine.ets",
    "content": "import promptAction from '@ohos.promptAction'\nimport Api from '../net/Api'\nimport UserService, { User } from '../service/UserService'\nimport { LoadState, PageLoading } from '../widgets/PageLoading'\nimport { TitleLayout } from '../widgets/TitleLayout'\nimport { HRouter } from '../router/HRouter'\nimport { Routes } from '../Routes'\n\nclass UserInfo {\n  name: string = \"\"\n  level: string = \"\"\n  rank: string = \"\"\n  point: string = \"\"\n}\n\n@Component\nexport struct Mine {\n  @State loadState: LoadState = LoadState.SUCCESS;\n  @State showLoading: boolean = false;\n  @State title: string = \"\";\n  private unLoginInfo: UserInfo = {\n    name: \"未登录\",\n    level: \"\",\n    rank: \"\",\n    point: \"\"\n  }\n  @State userInfo: UserInfo = this.unLoginInfo;\n  @State isLogin: boolean = false;\n  private userObserver = (user?: User) => {\n    if (user) {\n      this.isLogin = true;\n      this.userInfo = {\n        name: user.nickname,\n        level: user.level,\n        rank: user.rank,\n        point: user.coinCount.toString()\n      }\n    } else {\n      this.isLogin = false;\n      this.userInfo = this.unLoginInfo\n    }\n  }\n\n  aboutToAppear() {\n    UserService.get().addUserObserver(this.userObserver);\n    const user = UserService.get().getUser();\n    this.userObserver(user);\n  }\n\n  aboutToDisappear() {\n    UserService.get().removeUserObserver(this.userObserver);\n  }\n\n  build() {\n    PageLoading({\n      loadState: this.loadState,\n      showLoading: this.showLoading\n    }) {\n      Column() {\n        TitleLayout({\n          title: this.title,\n          isJustShowStatusBar: true\n        })\n        Column() {\n          Image($r(\"app.media.harmony_os\"))\n            .width(100)\n            .height(100)\n          Text(this.userInfo.name)\n            .fontColor($r(\"app.color.text_h1\"))\n            .fontSize(17)\n            .margin({ top: 16 })\n          Row({ space: 5 }) {\n            Text(\"LV\" + this.userInfo.level)\n              .fontColor($r(\"app.color.white\"))\n              .fontSize(15)\n              .backgroundColor($r(\"app.color.green\"))\n              .padding({\n                left: 4,\n                top: 2,\n                right: 4,\n                bottom: 2\n              })\n            Text(\"排名\" + this.userInfo.rank)\n              .fontColor($r(\"app.color.white\"))\n              .fontSize(15)\n              .backgroundColor($r(\"app.color.blue\"))\n              .padding({\n                left: 4,\n                top: 2,\n                right: 4,\n                bottom: 2\n              })\n          }\n          .margin({ top: 16 })\n        }\n        .margin({ top: 30 })\n        .alignItems(HorizontalAlign.Center)\n        .onClick((e) => {\n          UserService.get().checkLogin()\n        })\n\n        Row() {\n          Text(\"我的积分\")\n            .layoutWeight(1)\n            .fontSize(15)\n            .fontColor($r(\"app.color.text_h1\"))\n          Text(this.userInfo.point)\n            .fontSize(15)\n            .fontColor($r(\"app.color.text_h1\"))\n        }\n        .width('100%')\n        .height(50)\n        .margin({ top: 50 })\n        .alignItems(VerticalAlign.Center)\n        .padding({ left: 16, right: 16 })\n        .backgroundColor($r(\"app.color.white\"))\n        .onClick((e) => {\n          UserService.get().checkLogin()\n        })\n\n        Row()\n          .width('100%')\n          .height(0.5)\n          .backgroundColor($r(\"app.color.divider\"))\n        Row() {\n          Text(\"我的收藏\")\n            .layoutWeight(1)\n            .fontSize(15)\n            .fontColor($r(\"app.color.text_h1\"))\n          Image($r(\"app.media.ic_arrow_right\"))\n            .fillColor($r(\"app.color.text_h1\"))\n            .width(20)\n            .height(20)\n        }\n        .width('100%')\n        .height(50)\n        .alignItems(VerticalAlign.Center)\n        .padding({ left: 16, right: 16 })\n        .backgroundColor($r(\"app.color.white\"))\n        .onClick((event) => {\n          UserService.get().checkLogin(() => {\n            HRouter.with()\n              .url(Routes.CollectList)\n              .start()\n          })\n        })\n        Row()\n          .width('100%')\n          .height(0.5)\n          .backgroundColor($r(\"app.color.divider\"))\n        Row() {\n          Text(\"积分排行榜\")\n            .layoutWeight(1)\n            .fontSize(15)\n            .fontColor($r(\"app.color.text_h1\"))\n          Image($r(\"app.media.ic_arrow_right\"))\n            .fillColor($r(\"app.color.text_h1\"))\n            .width(20)\n            .height(20)\n        }\n        .width('100%')\n        .height(50)\n        .alignItems(VerticalAlign.Center)\n        .padding({ left: 16, right: 16 })\n        .backgroundColor($r(\"app.color.white\"))\n        .onClick((event) => {\n          UserService.get().checkLogin(() => {\n            HRouter.with()\n              .url(Routes.RankingList)\n              .start()\n          })\n        })\n\n        if (this.isLogin) {\n          Column() {\n            Button(\"退出登录\", {\n              type: ButtonType.Capsule\n            })\n              .width('100%')\n              .fontSize(15)\n              .fontColor($r(\"app.color.white\"))\n              .backgroundColor($r(\"app.color.red\"))\n              .onClick((e) => {\n                this.logout();\n              })\n          }\n          .width('100%')\n          .margin({ top: 50 })\n          .padding({ left: 16, right: 16 })\n        }\n      }\n      .width('100%')\n      .height('100%')\n    }\n  }\n\n  async logout() {\n    const res = await promptAction.showDialog({\n      title: \"提示\",\n      message: \"确认退出登录？\",\n      buttons: [\n        {\n          text: \"确认\",\n          color: $r(\"app.color.main\")\n        },\n        {\n          text: \"取消\",\n          color: $r(\"app.color.text_h2\")\n        }\n      ]\n    })\n    if (res.index === 0) {\n      await Api.get().logout();\n      UserService.get().clearUser();\n    }\n  }\n}"
  },
  {
    "path": "entry/src/main/ets/pages/RankingList.ets",
    "content": "import hilog from '@ohos.hilog';\nimport Api from '../net/Api';\nimport { LoadState, PageLoading } from '../widgets/PageLoading';\nimport { PullToRefresh } from '@ohos/pulltorefresh';\nimport { TitleLayout } from '../widgets/TitleLayout';\nimport { HRouter } from '../router/HRouter';\nimport { RouteParams } from '../router/RouteInfo';\nimport { RankingList, Rank } from '../net/model/RankingList';\nimport { Response } from '../net/Response';\n\n@Component\nexport struct RankingListPage {\n  @State title: string = \"积分排行榜\";\n  @State loadState: LoadState = LoadState.LOADING;\n  @State showLoading: boolean = false;\n  @State rankingList: RankingList[] = [];\n  private static TAG = \"RankingListPage\";\n  private scroller: Scroller = new Scroller();\n  private currentPage: number = 1;\n  private hasMore: boolean = true;\n\n  async aboutToAppear() {\n    hilog.info(0, RankingListPage.TAG, \"aboutToAppear：开始加载排行榜数据\");\n    this.loadData();\n  }\n\n  build() {\n    PageLoading({\n      loadState: this.loadState,\n      showLoading: this.showLoading,\n      onReload: () => {\n        hilog.debug(0, RankingListPage.TAG, \"onReload：重新加载排行榜\");\n        this.loadData();\n      }\n    }) {\n      Column() {\n        TitleLayout({\n          title: this.title,\n          showBack: true,\n          onBack: () => {\n            HRouter.with().back();\n          },\n          menuIcon: undefined,\n          onMenuClick: undefined\n        });\n\n        PullToRefresh({\n          data: $rankingList,\n          scroller: this.scroller,\n          customList: () => {\n            this.listViewBuilder();\n          },\n          onRefresh: () => {\n            return new Promise<string>((resolve) => {\n              this.loadDataByPage(1).then(\n                (rankData) => {\n                  this.currentPage = 1;\n                  this.rankingList = rankData.datas;\n                  this.hasMore = !rankData.over;\n                  resolve('刷新成功');\n                },\n                () => {\n                  resolve('刷新失败');\n                }\n              );\n            });\n          },\n          onLoadMore: () => {\n            return new Promise<string>((resolve) => {\n              if (this.hasMore) {\n                this.loadDataByPage(this.currentPage + 1).then(\n                  (rankData) => {\n                    if (rankData.datas.length > 0) {\n                      this.currentPage++;\n                      this.rankingList = this.rankingList.concat(rankData.datas);\n                      this.hasMore = !rankData.over;\n                      resolve('加载成功');\n                    } else {\n                      this.hasMore = false;\n                      resolve('没有更多数据了');\n                    }\n                  },\n                  () => {\n                    resolve('加载失败');\n                  }\n                );\n              } else {\n                resolve('没有更多数据了');\n              }\n            });\n          },\n          customLoad: null,\n          customRefresh: null,\n        })\n      }\n      .width('100%')\n      .height('100%')\n    }\n  }\n\n  @Builder\n  private listViewBuilder() {\n    List({ scroller: this.scroller }) {\n      ForEach(this.rankingList, (item: RankingList, index: number) => {\n        ListItem() {\n          this.rankItemBuilder(item, index + 1);\n        }\n        .padding({ top: 12, bottom: 12 })\n      });\n\n      if (this.rankingList.length === 0 && this.loadState === LoadState.SUCCESS) {\n        ListItem() {\n          Column({ space: 8 }) {\n            Text('暂无排行榜数据')\n              .fontSize(14)\n              .fontColor($r(\"app.color.gray600\"))\n          }\n          .width('100%')\n          .height(100)\n          .justifyContent(FlexAlign.Center)\n        }\n      }\n    }\n    .width('100%')\n    .height('100%')\n    .listDirection(Axis.Vertical)\n    .divider({\n      strokeWidth: 0.5,\n      color: $r(\"app.color.divider\"),\n      startMargin: 16,\n      endMargin: 16\n    })\n    .edgeEffect(EdgeEffect.None);\n  }\n\n  @Builder\n  private rankItemBuilder(item: RankingList, actualRank: number) {\n    Row({ space: 16 }) {\n      Text(actualRank.toString())\n        .width(24)\n        .textAlign(TextAlign.Center)\n        .fontSize(16)\n        .fontWeight(FontWeight.Bold)\n        .fontColor(this.getRankColor(actualRank));\n\n      Column({ space: 4 }) {\n        Text(item.username)\n          .fontSize(15)\n          .fontColor($r(\"app.color.text_h1\"))\n          .maxLines(1)\n          .textOverflow({ overflow: TextOverflow.Ellipsis })\n          .flexGrow(1);\n\n        Text(`等级：${item.level}`)\n          .fontSize(12)\n          .fontColor($r(\"app.color.gray600\"));\n      }\n      .flexGrow(1);\n\n      Text(`积分：${item.coinCount}`)\n        .fontSize(15)\n        .fontColor($r(\"app.color.main\"))\n        .fontWeight(FontWeight.Medium);\n    }\n    .width('100%')\n    .padding({ left: 16, right: 16 });\n  }\n\n  private getRankColor(rank: number): Resource {\n    switch (rank) {\n      case 1:\n        return $r(\"app.color.rank_gold\");\n      case 2:\n        return $r(\"app.color.rank_silver\");\n      case 3:\n        return $r(\"app.color.rank_bronze\");\n      default:\n        return $r(\"app.color.gray600\");\n    }\n  }\n\n  private async loadData() {\n    this.loadState = LoadState.LOADING;\n    try {\n      const rankData = await this.loadDataByPage(1);\n      this.rankingList = rankData.datas;\n      this.currentPage = 1;\n      this.hasMore = !rankData.over;\n      this.loadState = this.rankingList.length === 0 ? LoadState.EMPTY : LoadState.SUCCESS;\n    } catch (error) {\n      this.loadState = LoadState.FAIL;\n      // 确保catch中打印的是Error实例的message（避免类型问题）\n      const errorMsg = error instanceof Error ? error.message : '未知加载错误';\n      hilog.error(0, RankingListPage.TAG, `初始加载失败：${errorMsg}`);\n    }\n  }\n\n  private async loadDataByPage(page: number): Promise<Rank> {\n    try {\n      hilog.info(0, RankingListPage.TAG, `加载第${page}页排行榜数据`);\n      const response: Response<Rank> = await Api.get().getRankingList(page);\n\n      if (response.errorCode === 0 && response.data) {\n        return response.data;\n      } else {\n        // 2. 修复throw错误：将内容封装成Error实例（原错误位置）\n        const errorMsg = `接口返回异常：${response.errorMsg || '未知错误'}`;\n        throw new Error(errorMsg); // 仅抛出Error类型，符合ArkTS规范\n      }\n    } catch (error) {\n      const errorMsg = error instanceof Error ? error.message : '网络请求失败';\n      hilog.error(0, RankingListPage.TAG, `第${page}页加载失败：${errorMsg}`);\n      // 再次抛出时也确保是Error实例（若上层需要处理）\n      throw error instanceof Error ? error : new Error(errorMsg);\n    }\n  }\n}\n\n@Builder\nexport function RankingListNavDesBuilder(params: RouteParams) {\n  NavDestination() {\n    RankingListPage()\n  }\n  .hideTitleBar(true);\n}"
  },
  {
    "path": "entry/src/main/ets/pages/SearchEntry.ets",
    "content": "import WindowUtils from '../common/WindowUtils'\nimport Api from '../net/Api'\nimport { HotKey } from '../net/model/Search'\nimport Preferences from '../common/Preferences'\nimport { toast } from '../common/Toast'\nimport { HRouter } from '../router/HRouter'\nimport { Routes } from '../Routes'\nimport { RouteParams } from '../router/RouteInfo'\n\n@Component\nstruct SearchEntry {\n  @State showKeyword: string = \"\"\n  @State hotKeys: HotKey[] = []\n  @State historyKeys: string[] = []\n  private keyword: string = \"\"\n\n  async aboutToAppear() {\n    this.historyKeys = Preferences.get(getContext()).getSearchHistory()\n    const res = await Api.get().getSearchHotKey()\n    if (res.isSuccessWithData()) {\n      this.hotKeys = res.getDataOrThrow();\n    }\n  }\n\n  build() {\n    Column() {\n      Row()\n        .width('100%')\n        .height(WindowUtils.statusBarHeight + 'px')\n      Row() {\n        Image($r(\"app.media.ic_back\"))\n          .width(48)\n          .height(48)\n          .padding(14)\n          .fillColor($r(\"app.color.text_h1\"))\n          .objectFit(ImageFit.Contain)\n          .onClick((event) => {\n            HRouter.with().back();\n          })\n        TextInput({\n          placeholder: \"关键词以空格隔开\",\n          text: this.showKeyword\n        })\n          .layoutWeight(1)\n          .fontSize(17)\n          .fontColor($r(\"app.color.text_h1\"))\n          .padding({ left: 16, right: 16 })\n          .onChange((value) => {\n            this.keyword = value;\n          })\n          .onSubmit((keyType) => {\n            this.search();\n          })\n        Image($r(\"app.media.ic_search\"))\n          .width(48)\n          .height(48)\n          .padding(14)\n          .fillColor($r(\"app.color.text_h1\"))\n          .objectFit(ImageFit.Contain)\n          .onClick((event) => {\n            this.search();\n          })\n      }\n      .width('100%')\n      .height(48)\n      .alignItems(VerticalAlign.Center)\n\n      Column() {\n        Text(\"热门搜索\")\n          .fontColor($r(\"app.color.text_h1\"))\n          .fontSize(16)\n          .width('100%')\n          .margin({ top: 16 })\n          .padding({ left: 16, right: 16 })\n        Flex({\n          direction: FlexDirection.Row,\n          wrap: FlexWrap.Wrap\n        }) {\n          ForEach(this.hotKeys, (key: HotKey) => {\n            Text(key.name)\n              .fontColor($r(\"app.color.text_h1\"))\n              .fontSize(14)\n              .padding({\n                left: 12,\n                top: 6,\n                right: 12,\n                bottom: 6\n              })\n              .maxLines(1)\n              .backgroundColor($r(\"app.color.hot_key_bg\"))\n              .borderRadius(50)\n              .margin({ top: 8, right: 8 })\n              .onClick((event) => {\n                this.showKeyword = key.name;\n                this.keyword = key.name;\n                this.search();\n              })\n          })\n        }\n        .width('100%')\n        .margin({ top: 8 })\n        .padding({ left: 16, right: 16 })\n\n        Text(\"搜索历史\")\n          .fontColor($r(\"app.color.text_h1\"))\n          .fontSize(16)\n          .width('100%')\n          .margin({ top: 16 })\n          .padding({ left: 16, right: 16 })\n        List() {\n          ForEach(this.historyKeys, (item: string, index: number) => {\n            ListItem() {\n              Row() {\n                Text(item)\n                  .fontColor($r(\"app.color.text_h2\"))\n                  .fontSize(14)\n                  .layoutWeight(1)\n                  .maxLines(1)\n                Image($r(\"app.media.ic_close\"))\n                  .width(20)\n                  .height(20)\n                  .fillColor($r(\"app.color.text_h2\"))\n                  .onClick((event) => {\n                    this.deleteHistory(index);\n                  })\n              }\n              .width('100%')\n              .padding({\n                left: 16,\n                top: 12,\n                right: 16,\n                bottom: 12\n              })\n              .onClick((event) => {\n                this.showKeyword = item;\n                this.keyword = item;\n                this.search();\n              })\n            }\n          })\n        }\n        .listDirection(Axis.Vertical)\n        .width('100%')\n        .height('100%')\n        .margin({ top: 16 })\n      }\n      .width('100%')\n    }\n    .width('100%')\n    .height('100%')\n  }\n\n  search() {\n    if (!this.keyword) {\n      toast(\"请输入关键词\");\n      return;\n    }\n    let historyKeys: string[] = [];\n    historyKeys = historyKeys.concat(this.historyKeys)\n    const existIndex = historyKeys.findIndex((value) => {\n      return this.keyword === value;\n    })\n    if (existIndex >= 0) {\n      historyKeys.splice(existIndex, 1);\n    }\n    historyKeys.unshift(this.keyword);\n    this.historyKeys = historyKeys;\n    Preferences.get(getContext()).putSearchHistory(historyKeys);\n    HRouter.with()\n      .url(Routes.SearchResult)\n      .params('keyword', this.keyword)\n      .start()\n  }\n\n  deleteHistory(index: number) {\n    let historyKeys: string[] = [];\n    historyKeys = historyKeys.concat(this.historyKeys)\n    historyKeys.splice(index, 1);\n    this.historyKeys = historyKeys;\n    Preferences.get(getContext()).putSearchHistory(historyKeys);\n  }\n}\n\n@Builder\nexport function searchEntryNavDesBuilder(params: RouteParams) {\n  NavDestination() {\n    SearchEntry()\n  }\n  .hideTitleBar(true)\n}"
  },
  {
    "path": "entry/src/main/ets/pages/SearchResult.ets",
    "content": "import hilog from '@ohos.hilog';\nimport { PullToRefresh, PullToRefreshConfigurator } from '@ohos/pulltorefresh';\nimport CollectUtils from '../common/CollectUtils';\nimport Api from '../net/Api';\nimport { Article } from '../net/model/Article';\nimport { HRouter } from '../router/HRouter';\nimport { RouteParams } from '../router/RouteInfo';\nimport { ArticleItemComponent } from '../widgets/ArticleItemComponent';\nimport { LoadState, PageLoading } from '../widgets/PageLoading';\nimport { TitleLayout } from '../widgets/TitleLayout';\n\n@Component\nstruct SearchResult {\n  @State loadState: LoadState = LoadState.LOADING;\n  @State showLoading: boolean = false;\n  @State title: string = \"\";\n  @State data: Article[] = [];\n  private static TAG = \"SearchResult\"\n  private keyword: string = \"\"\n  private scroller: Scroller = new Scroller();\n  private refreshConfig = new PullToRefreshConfigurator();\n  private nextPage: number = 1;\n  private hasMore: boolean = true;\n\n  aboutToAppear() {\n    let routeParams = HRouter.with(this.queryNavDestinationInfo()).getCurrentParams()\n    this.keyword = routeParams.get('keyword') as string;\n    this.title = this.keyword;\n    this.refreshConfig.setHasRefresh(false);\n    this.loadData();\n  }\n\n  build() {\n    Column() {\n      TitleLayout({\n        title: this.title\n      })\n      PageLoading({\n        loadState: this.loadState,\n        showLoading: this.showLoading,\n        onReload: () => {\n          hilog.debug(0, SearchResult.TAG, \"onReload\");\n          this.loadData();\n        }\n      }) {\n        Column() {\n          PullToRefresh({\n            data: $data,\n            scroller: this.scroller,\n            refreshConfigurator: this.refreshConfig,\n            customList: () => {\n              this.listViewBuilder();\n            },\n            onLoadMore: () => {\n              return new Promise<string>((resolve, reject) => {\n                if (this.hasMore) {\n                  this.loadDataByPage(this.nextPage).then(\n                    (data) => {\n                      if (data.length > 0) {\n                        this.nextPage++\n                        this.data = this.data.concat(data);\n                        resolve('加载成功');\n                      } else {\n                        this.hasMore = false;\n                        resolve('没有更多了');\n                      }\n                    },\n                    () => {\n                      resolve('加载失败');\n                    }\n                  )\n                } else {\n                  resolve('没有更多了');\n                }\n              });\n            },\n            customLoad: null,\n            customRefresh: null,\n          })\n        }\n        .width('100%')\n        .height('100%')\n      }\n    }\n    .width('100%')\n    .height('100%')\n  }\n\n  @Builder\n  private listViewBuilder() {\n    List({ scroller: this.scroller }) {\n      ForEach(this.data, (item: Article) => {\n        ListItem() {\n          ArticleItemComponent({\n            article: item,\n            onCollectClick: (article: Article) => {\n              CollectUtils.collect(article)\n                .then((success) => {\n                  if (success) {\n                    this.data = this.data.map(item => item);\n                  }\n                })\n            }\n          })\n        }\n      })\n    }\n    .width('100%')\n    .height('100%')\n    .listDirection(Axis.Vertical)\n    .divider({\n      strokeWidth: 0.5,\n      color: $r(\"app.color.divider\"),\n      startMargin: 16,\n      endMargin: 16\n    })\n    .edgeEffect(EdgeEffect.None) // 必须设置列表为滑动到边缘无效果\n  }\n\n  private loadData() {\n    this.loadState = LoadState.LOADING\n    this.loadDataByPage(0).then(\n      (data) => {\n        this.data = data;\n        if (this.data.length === 0) {\n          this.loadState = LoadState.EMPTY;\n        } else {\n          this.loadState = LoadState.SUCCESS;\n        }\n      },\n      () => {\n        this.loadState = LoadState.FAIL;\n      })\n  }\n\n  private async loadDataByPage(page: number): Promise<Article[]> {\n    const res = await Api.get().search(this.keyword, page);\n    if (res.isSuccessWithData()) {\n      const list = res.getDataOrThrow().datas;\n      list.forEach((item) => {\n        item.title = this.removeHtmlTags(item.title);\n      })\n      return Promise.resolve(list);\n    } else {\n      return Promise.reject();\n    }\n  }\n\n  private removeHtmlTags(text: string): string {\n    // 使用正则表达式将 < 开头到 > 结尾之间的部分全部替换成空字符串\n    return text.replace(/<[^>]+>/g, '')\n      .replace('&gt;', '>')\n      .replace('&lt;', '<');\n  }\n}\n\n@Builder\nexport function searchResultNavDesBuilder(params: RouteParams) {\n  NavDestination() {\n    SearchResult()\n  }\n  .hideTitleBar(true)\n}"
  },
  {
    "path": "entry/src/main/ets/pages/Square.ets",
    "content": "import hilog from '@ohos.hilog';\nimport { PullToRefresh, PullToRefreshConfigurator } from '@ohos/pulltorefresh';\nimport CollectUtils from '../common/CollectUtils';\nimport Api from '../net/Api';\nimport { Article } from '../net/model/Article';\nimport { ArticleItemComponent } from '../widgets/ArticleItemComponent';\nimport { LoadState, PageLoading } from '../widgets/PageLoading';\nimport { TitleLayout } from '../widgets/TitleLayout';\n\n@Component\nexport struct Square {\n  @State loadState: LoadState = LoadState.LOADING;\n  @State showLoading: boolean = false;\n  @State title: string = \"广场\";\n  @State data: Article[] = [];\n  private static TAG = \"Square\"\n  private scroller: Scroller = new Scroller();\n  private refreshConfig = new PullToRefreshConfigurator();\n  private nextPage: number = 1;\n  private hasMore: boolean = true;\n\n  aboutToAppear() {\n    this.loadData();\n  }\n\n  build() {\n    Column() {\n      TitleLayout({\n        title: this.title,\n        showBack: false,\n      })\n      PageLoading({\n        loadState: this.loadState,\n        showLoading: this.showLoading,\n        onReload: () => {\n          hilog.debug(0, Square.TAG, \"onReload\");\n          this.loadData();\n        }\n      }) {\n        Column() {\n          PullToRefresh({\n            data: $data,\n            scroller: this.scroller,\n            refreshConfigurator: this.refreshConfig,\n            customList: () => {\n              this.listViewBuilder();\n            },\n            onRefresh: () => {\n              return new Promise<string>((resolve, reject) => {\n                this.loadDataByPage(0).then(\n                  (data) => {\n                    this.nextPage = 1;\n                    this.data = data;\n                    resolve('刷新成功');\n                  },\n                  () => {\n                    resolve('刷新失败');\n                  }\n                )\n              });\n            },\n            onLoadMore: () => {\n              return new Promise<string>((resolve, reject) => {\n                if (this.hasMore) {\n                  this.loadDataByPage(this.nextPage).then(\n                    (data) => {\n                      if (data.length > 0) {\n                        this.nextPage++\n                        this.data = this.data.concat(data);\n                        resolve('加载成功');\n                      } else {\n                        this.hasMore = false;\n                        resolve('没有更多了');\n                      }\n                    },\n                    () => {\n                      resolve('加载失败');\n                    }\n                  )\n                } else {\n                  resolve('没有更多了');\n                }\n              });\n            },\n            customLoad: null,\n            customRefresh: null,\n          })\n        }\n        .width('100%')\n        .height('100%')\n      }\n    }\n    .width('100%')\n    .height('100%')\n  }\n\n  @Builder\n  private listViewBuilder() {\n    List({ scroller: this.scroller }) {\n      ForEach(this.data, (item: Article) => {\n        ListItem() {\n          ArticleItemComponent({\n            article: item,\n            clearTop: true,\n            onCollectClick: (article: Article) => {\n              CollectUtils.collect(article)\n                .then((success) => {\n                  if (success) {\n                    this.data = this.data.map(item => item);\n                  }\n                })\n            }\n          })\n        }\n      })\n    }\n    .width('100%')\n    .height('100%')\n    .listDirection(Axis.Vertical)\n    .divider({\n      strokeWidth: 0.5,\n      color: $r(\"app.color.divider\"),\n      startMargin: 16,\n      endMargin: 16\n    })\n    .edgeEffect(EdgeEffect.None) // 必须设置列表为滑动到边缘无效果\n  }\n\n  private loadData() {\n    this.loadState = LoadState.LOADING\n    this.loadDataByPage(0).then(\n      (data) => {\n        this.data = data;\n        if (this.data.length === 0) {\n          this.loadState = LoadState.EMPTY;\n        } else {\n          this.loadState = LoadState.SUCCESS;\n        }\n      },\n      () => {\n        this.loadState = LoadState.FAIL;\n      })\n  }\n\n  private async loadDataByPage(page: number): Promise<Article[]> {\n    const res = await Api.get().getSquareArticleList(page);\n    if (res.isSuccessWithData()) {\n      const list = res.getDataOrThrow().datas;\n      return Promise.resolve(list);\n    } else {\n      return Promise.reject();\n    }\n  }\n}"
  },
  {
    "path": "entry/src/main/ets/pages/TreeTab.ets",
    "content": "import { PullToRefresh, PullToRefreshConfigurator } from '@ohos/pulltorefresh';\nimport hilog from '@ohos.hilog';\nimport { Pair } from '../common/Pair';\nimport Api from '../net/Api';\nimport { Article } from '../net/model/Article';\nimport { Tree } from '../net/model/Tree';\nimport { LoadState, PageLoading } from '../widgets/PageLoading';\nimport { TitleLayout } from '../widgets/TitleLayout';\nimport { ArticleItemComponent } from '../widgets/ArticleItemComponent';\nimport CollectUtils from '../common/CollectUtils';\nimport Preferences from '../common/Preferences';\n\n@Component\nexport struct TreeTab {\n  @State loadStateTree: LoadState = LoadState.LOADING;\n  @State loadStateArticle: LoadState = LoadState.LOADING;\n  @State showLoading: boolean = false;\n  @State title: string = \"体系\";\n  @State treeList: Tree[] = [];\n  @State data: Article[] = [];\n  @State selectTrees: Pair<Tree | undefined, Tree | undefined> = new Pair(undefined, undefined);\n  @State selectTreeTemp?: Tree = undefined;\n  @State showSelectLayer: boolean = false;\n  private static TAG = \"Tree\"\n  private treeScroll1: Scroller = new Scroller();\n  private treeScroll2: Scroller = new Scroller();\n  private articleScroller: Scroller = new Scroller();\n  private refreshConfig = new PullToRefreshConfigurator();\n  private nextPage: number = 1;\n  private hasMore: boolean = true;\n\n  aboutToAppear() {\n    this.refreshConfig.setHasRefresh(false);\n    this.loadTreeData();\n  }\n\n  build() {\n    Column() {\n      TitleLayout({\n        title: this.title,\n        isJustShowStatusBar: true\n      })\n      PageLoading({\n        loadState: this.loadStateTree,\n        showLoading: this.showLoading,\n        onReload: () => {\n          hilog.debug(0, TreeTab.TAG, \"onReloadTree\");\n          this.loadTreeData();\n        }\n      }) {\n        Column() {\n          if (this.selectTrees.first && this.selectTrees.second) {\n            Row() {\n              Text(`${this.selectTrees.first.name} > ${this.selectTrees.second.name}`)\n                .fontColor($r(\"app.color.text_h1\"))\n                .fontSize(17)\n                .layoutWeight(1)\n              Text(`更换 ${this.showSelectLayer ? \"🔼\" : \"🔽\"}`)\n                .margin({ left: 12 })\n                .fontColor($r(\"app.color.main\"))\n                .fontSize(16)\n            }\n            .width('100%')\n            .height(48)\n            .padding({ left: 16, right: 16 })\n            .alignItems(VerticalAlign.Center)\n            .onClick((event) => {\n              if (this.showSelectLayer) {\n                this.showSelectLayer = false;\n                this.selectTreeTemp = this.selectTrees.first;\n              } else {\n                this.showSelectLayer = true;\n                setTimeout(() => {\n                  // 滚动到选中位置的前一个\n                  const selectedIndex1 = this.treeList.findIndex(item => item.id === this.selectTrees.first!.id);\n                  if (selectedIndex1 >= 0) {\n                    this.treeScroll1.scrollToIndex(Math.max(selectedIndex1 - 1, 0));\n                  }\n                  const selectedIndex2 =\n                    this.selectTrees.first!.children.findIndex(item => item.id === this.selectTrees.second!.id);\n                  if (selectedIndex2 >= 0) {\n                    this.treeScroll2.scrollToIndex(Math.max(selectedIndex2 - 1, 0));\n                  }\n                }, 16)\n              }\n            })\n          }\n          Stack() {\n            PageLoading({\n              loadState: this.loadStateArticle,\n              showLoading: this.showLoading,\n              onReload: () => {\n                hilog.debug(0, TreeTab.TAG, \"onReloadArticle\");\n                this.loadArticleData();\n              }\n            }) {\n              Column() {\n                PullToRefresh({\n                  data: $data,\n                  scroller: this.articleScroller,\n                  refreshConfigurator: this.refreshConfig,\n                  customList: () => {\n                    this.listViewBuilder();\n                  },\n                  onLoadMore: () => {\n                    return new Promise<string>((resolve, reject) => {\n                      if (this.hasMore) {\n                        this.loadArticleDataByPage(this.nextPage).then(\n                          (data) => {\n                            if (data.length > 0) {\n                              this.nextPage++\n                              this.data = this.data.concat(data);\n                              resolve('加载成功');\n                            } else {\n                              this.hasMore = false;\n                              resolve('没有更多了');\n                            }\n                          },\n                          () => {\n                            resolve('加载失败');\n                          }\n                        )\n                      } else {\n                        resolve('没有更多了');\n                      }\n                    });\n                  },\n                  customLoad: null,\n                  customRefresh: null,\n                })\n              }\n              .width('100%')\n              .height('100%')\n            }\n\n            if (this.showSelectLayer) {\n              Column() {\n                Row() {\n                  List({ scroller: this.treeScroll1 }) {\n                    ForEach(this.treeList, (tree: Tree, index: number) => {\n                      ListItem() {\n                        Text(tree.name)\n                          .width('100%')\n                          .padding({\n                            left: 12,\n                            top: 8,\n                            right: 12,\n                            bottom: 8\n                          })\n                          .fontColor((this.selectTreeTemp!.id === tree.id) ? $r(\"app.color.main\") :\n                          $r(\"app.color.text_h1\"))\n                          .fontSize(14)\n                          .textAlign(TextAlign.Center)\n                          .backgroundColor((index % 2 === 0) ? Color.Transparent : $r(\"app.color.hot_key_bg\"))\n                          .onClick((event) => {\n                            this.selectTreeTemp = tree;\n                          })\n                      }\n                    })\n                  }\n                  .width('50%')\n                  .height('100%')\n                  .onClick((event) => {\n                  })\n\n                  Line()\n                    .width(0.5)\n                    .height('100%')\n                    .backgroundColor($r(\"app.color.divider\"))\n\n                  List({ scroller: this.treeScroll2 }) {\n                    ForEach(this.selectTreeTemp!.children, (tree: Tree, index: number) => {\n                      ListItem() {\n                        Text(tree.name)\n                          .width('100%')\n                          .padding({\n                            left: 12,\n                            top: 8,\n                            right: 12,\n                            bottom: 8\n                          })\n                          .fontColor((this.selectTrees.second!.id === tree.id) ? $r(\"app.color.main\") :\n                          $r(\"app.color.text_h1\"))\n                          .fontSize(14)\n                          .textAlign(TextAlign.Center)\n                          .backgroundColor((index % 2 === 1) ? Color.Transparent : $r(\"app.color.hot_key_bg\"))\n                          .onClick((event) => {\n                            this.selectTrees = new Pair(this.selectTreeTemp, tree);\n                            Preferences.get(getContext())\n                              .putSelectedTreeId(this.selectTrees.first!.id, this.selectTrees.second!.id)\n                            this.showSelectLayer = false;\n                            this.hasMore = true;\n                            this.loadArticleData();\n                          })\n                      }\n                    })\n                  }\n                  .width('50%')\n                  .height('100%')\n                  .onClick((event) => {\n                  })\n                }\n                .width('100%')\n                .height('70%')\n                .backgroundColor($r(\"app.color.start_window_background\"))\n              }\n              .width('100%')\n              .height('100%')\n              .backgroundColor($r(\"app.color.translucent_black_50\"))\n              .onClick((event) => {\n                this.showSelectLayer = false;\n                this.selectTreeTemp = this.selectTrees.first;\n              })\n            }\n          }\n          .width('100%')\n          .height('100%')\n        }\n        .width('100%')\n        .height('100%')\n      }\n    }\n    .width('100%')\n    .height('100%')\n  }\n\n  @Builder\n  private listViewBuilder() {\n    List({ scroller: this.articleScroller }) {\n      ForEach(this.data, (item: Article) => {\n        ListItem() {\n          ArticleItemComponent({\n            article: item,\n            clearTop: true,\n            onCollectClick: (article: Article) => {\n              CollectUtils.collect(article)\n                .then((success) => {\n                  if (success) {\n                    this.data = this.data.map(item => item);\n                  }\n                })\n            }\n          })\n        }\n      })\n    }\n    .width('100%')\n    .height('100%')\n    .listDirection(Axis.Vertical)\n    .divider({\n      strokeWidth: 0.5,\n      color: $r(\"app.color.divider\"),\n      startMargin: 16,\n      endMargin: 16\n    })\n    .edgeEffect(EdgeEffect.None) // 必须设置列表为滑动到边缘无效果\n  }\n\n  private async loadTreeData() {\n    this.loadStateTree = LoadState.LOADING\n    const res = await Api.get().getTree();\n    if (res.isSuccessWithData()) {\n      if (res.getDataOrThrow().length > 0) {\n        this.treeList = res.getDataOrThrow();\n        const selectedIds = Preferences.get(getContext()).getSelectedTreeId();\n        const selectedTree1 = this.treeList.find((item) => item.id === selectedIds.first);\n        const selectedTree2 = selectedTree1?.children?.find((item) => item.id === selectedIds.second);\n        if (selectedTree1 !== undefined && selectedTree2 !== undefined) {\n          this.selectTreeTemp = selectedTree1;\n          this.selectTrees = new Pair(selectedTree1, selectedTree2);\n        } else {\n          this.selectTreeTemp = this.treeList[0];\n          this.selectTrees = new Pair(this.treeList[0], this.treeList[0].children[0]);\n        }\n        this.loadStateTree = LoadState.SUCCESS;\n        this.loadArticleData();\n      } else {\n        this.loadStateTree = LoadState.EMPTY;\n      }\n    } else {\n      this.loadStateTree = LoadState.FAIL;\n    }\n  }\n\n  private loadArticleData() {\n    this.loadStateArticle = LoadState.LOADING;\n    this.nextPage = 1;\n    this.loadArticleDataByPage(0).then(\n      (data) => {\n        this.data = data;\n        if (this.data.length === 0) {\n          this.loadStateArticle = LoadState.EMPTY;\n        } else {\n          this.loadStateArticle = LoadState.SUCCESS;\n        }\n      },\n      () => {\n        this.loadStateArticle = LoadState.FAIL;\n      })\n  }\n\n  private async loadArticleDataByPage(page: number): Promise<Article[]> {\n    const res = await Api.get().getTreeArticleList(this.selectTrees.second!.id, page);\n    if (res.isSuccessWithData()) {\n      const list = res.getDataOrThrow().datas;\n      return Promise.resolve(list);\n    } else {\n      return Promise.reject();\n    }\n  }\n}"
  },
  {
    "path": "entry/src/main/ets/pages/WebPage.ets",
    "content": "import web_webview from '@ohos.web.webview';\nimport { TitleLayout } from '../widgets/TitleLayout';\nimport { HRouter } from '../router/HRouter';\nimport { RouteParams } from '../router/RouteInfo';\n\n@Component\nexport struct WebPage {\n  private webController: web_webview.WebviewController = new web_webview.WebviewController()\n  url: string = ''\n  @State title: string = \"加载中…\"\n  @State progress: number = 0\n\n  build() {\n    NavDestination() {\n      Column() {\n        TitleLayout({\n          title: this.title,\n          onBack: () => {\n            if (this.webController.accessBackward()) {\n              this.webController.backward()\n            } else {\n              HRouter.with().back();\n            }\n          }\n        })\n        Stack({ alignContent: Alignment.Top }) {\n          Web({\n            src: this.url,\n            controller: this.webController\n          })\n            .width('100%')\n            .height('100%')\n            .onlineImageAccess(true)\n            .javaScriptAccess(true)\n            .domStorageAccess(true)\n            .databaseAccess(true)\n            .mixedMode(MixedMode.All)\n            .onTitleReceive((event) => {\n              this.title = event?.title ?? \"\"\n            })\n            .onProgressChange((event) => {\n              this.progress = event?.newProgress ?? 0\n            })\n          if (this.progress !== 100) {\n            Progress({ value: this.progress, total: 100, type: ProgressType.Linear })\n              .width('100%')\n          }\n        }\n        .width('100%')\n        .layoutWeight(1)\n      }\n      .width('100%')\n      .height('100%')\n    }\n    .hideTitleBar(true)\n    .onBackPressed(() => {\n      if (this.webController.accessBackward()) {\n        this.webController.backward()\n        return true;\n      }\n      return false;\n    })\n  }\n}\n\n@Builder\nexport function webPageNavDesBuilder(params: RouteParams) {\n  WebPage({\n    url: params.get('url') as string\n  })\n}"
  },
  {
    "path": "entry/src/main/ets/pages/Wechat.ets",
    "content": "import hilog from '@ohos.hilog';\nimport Api from '../net/Api';\nimport { WeChatAuthor } from '../net/model/WeChat';\nimport { LoadState, PageLoading } from '../widgets/PageLoading';\nimport { TitleLayout } from '../widgets/TitleLayout';\nimport { WechatTab } from './WechatTab';\n\n@Component\nexport struct Wechat {\n  @State title: string = \"公众号\";\n  @State loadState: LoadState = LoadState.LOADING;\n  @State showLoading: boolean = false;\n  @State authors: WeChatAuthor[] = []\n  private static TAG = \"Square\"\n\n  aboutToAppear() {\n    this.loadData();\n  }\n\n  build() {\n    Column() {\n      TitleLayout({\n        title: this.title,\n        showBack: false,\n      })\n      PageLoading({\n        loadState: this.loadState,\n        showLoading: this.showLoading,\n        onReload: () => {\n          hilog.debug(0, Wechat.TAG, \"onReload\");\n          this.loadData();\n        }\n      }) {\n        if (this.authors.length > 0) {\n          Tabs({\n            barPosition: BarPosition.Start\n          }) {\n            ForEach(this.authors, (author: WeChatAuthor) => {\n              TabContent() {\n                WechatTab({\n                  authorId: author.id\n                })\n              }\n              .tabBar(author.name)\n            })\n          }\n          .width('100%')\n          .height('100%')\n          .scrollable(true)\n          .barMode(BarMode.Scrollable)\n          .barHeight(44)\n        }\n      }\n    }\n    .width('100%')\n    .height('100%')\n  }\n\n  private loadData() {\n    this.loadState = LoadState.LOADING\n    Api.get().getWeChatAuthorList()\n      .then((res) => {\n        if (res.isSuccessWithData()) {\n          this.authors = res.getDataOrThrow();\n          if (this.authors.length === 0) {\n            this.loadState = LoadState.EMPTY;\n          } else {\n            this.loadState = LoadState.SUCCESS;\n          }\n        } else {\n          this.loadState = LoadState.FAIL;\n        }\n      })\n  }\n}"
  },
  {
    "path": "entry/src/main/ets/pages/WechatTab.ets",
    "content": "import hilog from '@ohos.hilog';\nimport { PullToRefresh, PullToRefreshConfigurator } from '@ohos/pulltorefresh';\nimport CollectUtils from '../common/CollectUtils';\nimport Api from '../net/Api';\nimport { Article } from '../net/model/Article';\nimport { ArticleItemComponent } from '../widgets/ArticleItemComponent';\nimport { LoadState, PageLoading } from '../widgets/PageLoading';\n\n@Component\nexport struct WechatTab {\n  authorId: number = 0;\n  @State loadState: LoadState = LoadState.LOADING;\n  @State showLoading: boolean = false;\n  @State data: Article[] = [];\n  private static TAG = \"WechatTab\"\n  private scroller: Scroller = new Scroller();\n  private refreshConfig = new PullToRefreshConfigurator();\n  private nextPage: number = 1;\n  private hasMore: boolean = true;\n\n  aboutToAppear() {\n    this.refreshConfig.setHasRefresh(false);\n    this.loadData();\n  }\n\n  build() {\n    Column() {\n      PageLoading({\n        loadState: this.loadState,\n        showLoading: this.showLoading,\n        onReload: () => {\n          hilog.debug(0, WechatTab.TAG, \"onReload\");\n          this.loadData();\n        }\n      }) {\n        Column() {\n          PullToRefresh({\n            data: $data,\n            scroller: this.scroller,\n            refreshConfigurator: this.refreshConfig,\n            customList: () => {\n              this.listViewBuilder();\n            },\n            onLoadMore: () => {\n              return new Promise<string>((resolve, reject) => {\n                if (this.hasMore) {\n                  this.loadDataByPage(this.nextPage).then(\n                    (data) => {\n                      if (data.length > 0) {\n                        this.nextPage++\n                        this.data = this.data.concat(data);\n                        resolve('加载成功');\n                      } else {\n                        this.hasMore = false;\n                        resolve('没有更多了');\n                      }\n                    },\n                    () => {\n                      resolve('加载失败');\n                    }\n                  )\n                } else {\n                  resolve('没有更多了');\n                }\n              });\n            },\n            customLoad: null,\n            customRefresh: null,\n          })\n        }\n        .width('100%')\n        .height('100%')\n      }\n    }\n    .width('100%')\n    .height('100%')\n  }\n\n  @Builder\n  private listViewBuilder() {\n    List({ scroller: this.scroller }) {\n      ForEach(this.data, (item: Article) => {\n        ListItem() {\n          ArticleItemComponent({\n            article: item,\n            clearTop: true,\n            onCollectClick: (article: Article) => {\n              CollectUtils.collect(article)\n                .then((success) => {\n                  if (success) {\n                    this.data = this.data.map(item => item);\n                  }\n                })\n            }\n          })\n        }\n      })\n    }\n    .width('100%')\n    .height('100%')\n    .listDirection(Axis.Vertical)\n    .divider({\n      strokeWidth: 0.5,\n      color: $r(\"app.color.divider\"),\n      startMargin: 16,\n      endMargin: 16\n    })\n    .edgeEffect(EdgeEffect.None) // 必须设置列表为滑动到边缘无效果\n  }\n\n  private loadData() {\n    if (this.authorId) {\n      this.loadState = LoadState.LOADING\n      this.loadDataByPage(0).then(\n        (data) => {\n          this.data = data;\n          if (this.data.length === 0) {\n            this.loadState = LoadState.EMPTY;\n          } else {\n            this.loadState = LoadState.SUCCESS;\n          }\n        },\n        () => {\n          this.loadState = LoadState.FAIL;\n        })\n    } else {\n      this.loadState = LoadState.FAIL;\n    }\n  }\n\n  private async loadDataByPage(page: number): Promise<Article[]> {\n    const res = await Api.get().getWeChatArticleList(this.authorId, page);\n    if (res.isSuccessWithData()) {\n      const list = res.getDataOrThrow().datas;\n      return Promise.resolve(list);\n    } else {\n      return Promise.reject();\n    }\n  }\n}"
  },
  {
    "path": "entry/src/main/ets/router/HRouter.ets",
    "content": "import { RouteRequest } from './RouteRequest'\nimport { RouteParams } from './RouteInfo'\n\nclass _HRouter {\n  readonly pathStack: NavPathStack = new NavPathStack()\n  private readonly navDesBuilderMap: Map<string, WrappedBuilder<[RouteParams]>> = new Map()\n\n  register(url: string, builder: WrappedBuilder<[RouteParams]>) {\n    this.navDesBuilderMap.set(url, builder)\n  }\n\n  getNavDesBuilder(url: string): WrappedBuilder<[RouteParams]> | undefined {\n    return this.navDesBuilderMap.get(url)\n  }\n\n  with(info?: NavDestinationInfo): RouteRequest {\n    return new RouteRequest(info)\n  }\n\n  clearStack() {\n    this.pathStack.clear(false)\n  }\n}\n\nexport const HRouter: _HRouter = new _HRouter()\n"
  },
  {
    "path": "entry/src/main/ets/router/RouteExecutor.ets",
    "content": "import { HRouter } from './HRouter'\nimport { RouteInfo, RouteMode, RouteParams } from './RouteInfo'\n\nclass _RouteExecutor {\n  start(info: RouteInfo) {\n    let builder = HRouter.getNavDesBuilder(info.targetUrl)\n    if (!builder) {\n      return\n    }\n    switch (info.mode) {\n      case RouteMode.ClearTop:\n        this.startWithClearTop(info)\n        break;\n      case RouteMode.MoveToTop:\n        this.startWithMoveToTop(info)\n        break;\n      case RouteMode.Standard:\n      default:\n        this.startWithStandardMode(info)\n        break;\n    }\n  }\n\n  back(info: RouteInfo) {\n    HRouter.pathStack.pop(info.targetParams, info.animated)\n  }\n\n  private startWithStandardMode(info: RouteInfo) {\n    if (info.onPop) {\n      let onPopListener = info.onPop\n      HRouter.pathStack.pushPathByName(info.targetUrl, info.targetParams, (popInfo) => {\n        onPopListener(popInfo.result as RouteParams)\n      }, info.animated)\n    } else {\n      HRouter.pathStack.pushPathByName(info.targetUrl, info.targetParams, info.animated)\n    }\n  }\n\n  private startWithClearTop(info: RouteInfo) {\n    let indices = HRouter.pathStack.getIndexByName(info.targetUrl)\n    if (indices.length) {\n      let lastIndex = indices[indices.length - 1]\n      while (lastIndex <= HRouter.pathStack.size() - 1) {\n        HRouter.pathStack.pop(false)\n      }\n      setTimeout(() => {\n        this.startWithStandardMode(info)\n      }, 16)\n    } else {\n      this.startWithStandardMode(info)\n    }\n  }\n\n  private startWithMoveToTop(info: RouteInfo) {\n    let indices = HRouter.pathStack.getIndexByName(info.targetUrl)\n    if (indices.length) {\n      HRouter.pathStack.moveIndexToTop(indices[indices.length - 1], info.animated)\n    } else {\n      this.startWithStandardMode(info)\n    }\n  }\n}\n\nexport const RouteExecutor: _RouteExecutor = new _RouteExecutor();"
  },
  {
    "path": "entry/src/main/ets/router/RouteInfo.ets",
    "content": "export class RouteInfo {\n  targetUrl: string = ''\n  currentParams: RouteParams = new Map()\n  targetParams: RouteParams = new Map()\n  mode: RouteMode = RouteMode.Standard\n  animated: boolean = true\n  onPop?: (params: RouteParams) => void\n}\n\nexport type RouteParams = Map<string, Object>\n\nexport enum RouteMode {\n  Standard = 'Standard',\n  MoveToTop = 'MoveToTop',\n  ClearTop = 'ClearTop',\n}\n"
  },
  {
    "path": "entry/src/main/ets/router/RouteRequest.ets",
    "content": "import { RouteExecutor } from './RouteExecutor'\nimport { RouteInfo, RouteMode, RouteParams } from './RouteInfo'\n\nexport class RouteRequest {\n  private readonly routeInfo: RouteInfo = new RouteInfo()\n\n  constructor(navDesInfo?: NavDestinationInfo) {\n    if (navDesInfo) {\n      this.routeInfo.currentParams = (navDesInfo.param ?? new Map()) as RouteParams\n    }\n  }\n\n  getRouteInfo(): RouteInfo {\n    return this.routeInfo\n  }\n\n  getCurrentParams(): RouteParams {\n    return this.routeInfo.currentParams\n  }\n\n  url(url: string): RouteRequest {\n    this.routeInfo.targetUrl = url\n    return this\n  }\n\n  params(key: string, value: Object): RouteRequest {\n    this.routeInfo.targetParams.set(key, value)\n    return this\n  }\n\n  mode(value: RouteMode): RouteRequest {\n    this.routeInfo.mode = value\n    return this\n  }\n\n  animated(value: boolean): RouteRequest {\n    this.routeInfo.animated = value\n    return this\n  }\n\n  start(onPop?: (params: RouteParams) => void) {\n    this.routeInfo.onPop = onPop\n    RouteExecutor.start(this.routeInfo)\n  }\n\n  back() {\n    RouteExecutor.back(this.routeInfo)\n  }\n}"
  },
  {
    "path": "entry/src/main/ets/service/UserService.ets",
    "content": "import promptAction from '@ohos.promptAction';\nimport EntryContext from '../common/EntryContext';\nimport Api from '../net/Api';\nimport Preferences from '../common/Preferences';\nimport { HRouter } from '../router/HRouter';\nimport { Routes } from '../Routes';\n\nexport default class UserService {\n  private static instance: UserService\n  private static TAG = \"UserService\"\n  private user?: User\n  private userObservers: ((user?: User) => void)[] = []\n\n  static get(): UserService {\n    if (UserService.instance === undefined) {\n      UserService.instance = new UserService()\n    }\n    return UserService.instance\n  }\n\n  private constructor() {\n    const context = EntryContext.getContext();\n    const user = Preferences.get(context).getUser()\n    if (user) {\n      this.user = user;\n      this.notifyObserver();\n      this.updateUser().catch();\n    }\n  }\n\n  isLogin(): boolean {\n    if (this.user) {\n      return true;\n    }\n    return false;\n  }\n\n  checkLogin(onLogin?: () => void) {\n    if (this.isLogin()) {\n      if (onLogin) {\n        onLogin()\n      }\n    } else {\n      promptAction.showDialog({\n        title: \"提示\",\n        message: \"当前操作需要登录\",\n        buttons: [\n          {\n            text: \"立即登录\",\n            color: $r(\"app.color.main\")\n          },\n          {\n            text: \"取消\",\n            color: $r(\"app.color.text_h2\")\n          }\n        ]\n      }).then((resp) => {\n        if (resp.index === 0) {\n          HRouter.with()\n            .url(Routes.Login)\n            .start((params) => {\n              if (params.get('success') && onLogin) {\n                onLogin()\n              }\n            })\n        }\n      })\n    }\n  }\n\n  getUser(): User | undefined {\n    return this.user;\n  }\n\n  setUser(user?: User) {\n    this.user = user;\n    this.notifyObserver();\n    const context = EntryContext.getContext();\n    Preferences.get(context).putUser(user);\n  }\n\n  async updateUser(): Promise<User> {\n    if (this.isLogin()) {\n      const res = await Api.get().getUserInfo()\n      if (res.isSuccessWithData()) {\n        const user = this.user!!;\n        user.coinCount = res.getDataOrThrow().coinCount;\n        user.level = res.getDataOrThrow().level;\n        user.rank = res.getDataOrThrow().rank;\n        this.setUser(user);\n        return Promise.resolve(user);\n      } else {\n        return Promise.reject(res.errorMsg);\n      }\n    } else {\n      return Promise.reject()\n    }\n  }\n\n  addUserObserver(observer: (user?: User) => void) {\n    if (!this.userObservers.includes(observer)) {\n      this.userObservers.push(observer);\n    }\n  }\n\n  removeUserObserver(observer: (user?: User) => void) {\n    const index = this.userObservers.indexOf(observer);\n    if (index >= 0) {\n      this.userObservers.splice(index, 1);\n    }\n  }\n\n  private notifyObserver() {\n    this.userObservers.forEach((observer) => {\n      if (observer) {\n        observer(this.user);\n      }\n    });\n  }\n\n  clearUser() {\n    this.setUser(undefined);\n    Api.get().clearCookie();\n  }\n}\n\nexport class User {\n  id: number = 0\n  username: string = \"\"\n  nickname: string = \"\"\n  chapterTops: object[] = []\n  coinCount: number = 0\n  collectIds: number[] = []\n  email: string = \"\"\n  icon: string = \"\"\n  level: string = \"\"\n  rank: string = \"\"\n}\n"
  },
  {
    "path": "entry/src/main/ets/widgets/ArticleItemComponent.ets",
    "content": "import { Article, ArticleTag, getArticleAuthor, getArticleChapter, getTagColor } from '../net/model/Article';\nimport { HRouter } from '../router/HRouter';\nimport { RouteMode } from '../router/RouteInfo';\nimport { Routes } from '../Routes';\n\n@Component\nexport struct ArticleItemComponent {\n  article: Article = new Article();\n  clearTop: boolean = false\n  onCollectClick?: (article: Article) => void;\n\n  build() {\n    Column() {\n      Row() {\n        ForEach(this.article.tags, (item: ArticleTag) => {\n          Text(item.name)\n            .fontColor(getTagColor(item))\n            .fontSize(10)\n            .textAlign(TextAlign.Center)\n            .borderWidth(0.5)\n            .border({\n              width: 0.5,\n              color: getTagColor(item),\n              radius: 3\n            })\n            .padding({\n              left: 2,\n              top: 1,\n              right: 2,\n              bottom: 1\n            })\n          Divider()\n            .width(8)\n            .height(0)\n            .color(Color.Transparent)\n        })\n        Text(getArticleAuthor(this.article))\n          .layoutWeight(1)\n          .fontColor($r(\"app.color.text_h1\"))\n          .fontSize(12)\n        Divider()\n          .width(8)\n          .height(0)\n          .color(Color.Transparent)\n        Text(this.article.niceDate)\n          .fontColor($r(\"app.color.text_h2\"))\n          .fontSize(12)\n      }\n\n      Divider()\n        .width('100%')\n        .height(4)\n        .color(Color.Transparent)\n      Text(this.article.title)\n        .width('100%')\n        .fontColor($r(\"app.color.text_h1\"))\n        .fontSize(15)\n        .maxLines(2)\n        .textOverflow({ overflow: TextOverflow.Ellipsis })\n      Divider()\n        .width('100%')\n        .height(5)\n        .color(Color.Transparent)\n      Row() {\n        Text(getArticleChapter(this.article))\n          .fontColor($r(\"app.color.text_h2\"))\n          .fontSize(12)\n        Blank()\n        Image(this.article.collect ? $r(\"app.media.ic_like_fill\") : $r(\"app.media.ic_like\"))\n          .fillColor(this.article.collect ? $r(\"app.color.red\") : $r(\"app.color.text_h2\"))\n          .width(24)\n          .height(24)\n          .onClick((event) => {\n            if (this.onCollectClick !== undefined) {\n              this.onCollectClick(this.article);\n            }\n          })\n      }\n      .justifyContent(FlexAlign.Center)\n      .width('100%')\n    }\n    .width('100%')\n    .padding({\n      left: 16,\n      top: 10,\n      right: 16,\n      bottom: 10\n    })\n    .onClick((e) => {\n      HRouter.with()\n        .url(Routes.Web)\n        .params('url', this.article.link)\n        .mode(this.clearTop ? RouteMode.ClearTop : RouteMode.Standard)\n        .start()\n    })\n  }\n}"
  },
  {
    "path": "entry/src/main/ets/widgets/PageLoading.ets",
    "content": "export enum LoadState {\n  LOADING,\n  SUCCESS,\n  FAIL,\n  EMPTY\n}\n\n@Component\nexport struct PageLoading {\n  @Prop loadState: LoadState;\n  onReload?: () => void;\n  @Prop showLoading: boolean;\n  @BuilderParam content: () => void;\n\n  build() {\n    Stack() {\n      if (this.loadState === LoadState.LOADING) {\n        LoadingProgress()\n          .width(50)\n          .height(50)\n          .color($r(\"app.color.main\"))\n      } else if (this.loadState === LoadState.SUCCESS) {\n        this.content();\n        if (this.showLoading) {\n          Stack() {\n            Stack() {\n              LoadingProgress()\n                .width(50)\n                .height(50)\n                .color($r(\"app.color.white\"))\n            }\n            .width(100)\n            .height(100)\n            .backgroundColor($r(\"app.color.translucent_black_50\"))\n            .borderRadius(8)\n          }\n          .width('100%')\n          .height('100%')\n        }\n      } else if (this.loadState === LoadState.FAIL) {\n        Stack() {\n          Text(\"加载失败，点击重试\")\n        }\n        .width('100%')\n        .height('100%')\n        .onClick(() => {\n          if (this.onReload) {\n            this.onReload();\n          }\n        })\n      } else {\n        Stack() {\n          Text(\"这里什么都没有\")\n        }\n        .width('100%')\n        .height('100%')\n        .onClick(() => {\n          if (this.onReload) {\n            this.onReload();\n          }\n        })\n      }\n    }\n    .width('100%')\n    .height('100%')\n  }\n}\n"
  },
  {
    "path": "entry/src/main/ets/widgets/TitleLayout.ets",
    "content": "import WindowUtils from '../common/WindowUtils';\nimport { HRouter } from '../router/HRouter';\n\n@Component\nexport struct TitleLayout {\n  @Prop\n  title: string;\n  isJustShowStatusBar: boolean = false;\n  showBack: boolean = true;\n  onBack: () => void = () => {\n    HRouter.with().back();\n  }\n  menuIcon?: Resource;\n  onMenuClick?: () => void;\n\n  build() {\n    Column() {\n      Row()\n        .width('100%')\n        .height(WindowUtils.statusBarHeight + 'px')\n      if (this.isJustShowStatusBar === false) {\n        Row() {\n          if (this.showBack) {\n            Image($r(\"app.media.ic_back\"))\n              .width(48)\n              .height(48)\n              .padding(14)\n              .fillColor($r(\"app.color.text_h1\"))\n              .objectFit(ImageFit.Contain)\n              .onClick((event) => {\n                if (this.onBack !== undefined) {\n                  this.onBack();\n                }\n              })\n          }\n          Text(this.title)\n            .layoutWeight(1)\n            .fontSize(17)\n            .fontColor($r(\"app.color.text_h1\"))\n            .maxLines(1)\n            .textOverflow({ overflow: TextOverflow.Ellipsis })\n            .padding({ left: 16, right: 16 })\n          if (this.menuIcon !== undefined) {\n            Image(this.menuIcon)\n              .width(48)\n              .height(48)\n              .padding(14)\n              .fillColor($r(\"app.color.text_h1\"))\n              .objectFit(ImageFit.Contain)\n              .onClick((event) => {\n                if (this.onMenuClick !== undefined) {\n                  this.onMenuClick();\n                }\n              })\n          }\n        }\n        .width('100%')\n        .height(48)\n        .alignItems(VerticalAlign.Center)\n      }\n    }\n    .width('100%')\n    .backgroundColor($r(\"app.color.title_bar_bg\"))\n  }\n}"
  },
  {
    "path": "entry/src/main/module.json5",
    "content": "{\n  \"module\": {\n    \"name\": \"entry\",\n    \"type\": \"entry\",\n    \"description\": \"$string:module_desc\",\n    \"mainElement\": \"EntryAbility\",\n    \"deviceTypes\": [\n      \"phone\",\n      \"tablet\"\n    ],\n    \"deliveryWithInstall\": true,\n    \"installationFree\": false,\n    \"pages\": \"$profile:main_pages\",\n    \"requestPermissions\": [\n      {\n        \"name\": \"ohos.permission.INTERNET\",\n        \"reason\": \"$string:internet_permission_reason\",\n        \"usedScene\": {\n          \"abilities\": [\n            \"EntryAbility\"\n          ],\n          \"when\": \"inuse\"\n        }\n      }\n    ],\n    \"abilities\": [\n      {\n        \"name\": \"EntryAbility\",\n        \"srcEntry\": \"./ets/entryability/EntryAbility.ets\",\n        \"description\": \"$string:EntryAbility_desc\",\n        \"icon\": \"$media:icon\",\n        \"label\": \"$string:EntryAbility_label\",\n        \"startWindowIcon\": \"$media:icon\",\n        \"startWindowBackground\": \"$color:start_window_background\",\n        \"exported\": true,\n        \"skills\": [\n          {\n            \"entities\": [\n              \"entity.system.home\"\n            ],\n            \"actions\": [\n              \"action.system.home\"\n            ]\n          }\n        ]\n      }\n    ]\n  }\n}"
  },
  {
    "path": "entry/src/main/resources/base/element/color.json",
    "content": "{\n  \"color\": [\n    {\n      \"name\": \"start_window_background\",\n      \"value\": \"#FAFAFA\"\n    },\n    {\n      \"name\": \"white\",\n      \"value\": \"#FFFFFF\"\n    },\n    {\n      \"name\": \"translucent_black_40\",\n      \"value\": \"#66000000\"\n    },\n    {\n      \"name\": \"translucent_black_50\",\n      \"value\": \"#80000000\"\n    },\n    {\n      \"name\": \"main\",\n      \"value\": \"#4CAF50\"\n    },\n    {\n      \"name\": \"text_h1\",\n      \"value\": \"#212121\"\n    },\n    {\n      \"name\": \"text_h2\",\n      \"value\": \"#757575\"\n    },\n    {\n      \"name\": \"divider\",\n      \"value\": \"#EEEEEE\"\n    },\n    {\n      \"name\": \"navi_tab_unselect\",\n      \"value\": \"#424242\"\n    },\n    {\n      \"name\": \"navi_bar_bg\",\n      \"value\": \"#FFFFFF\"\n    },\n    {\n      \"name\": \"title_bar_bg\",\n      \"value\": \"#FAFAFA\"\n    },\n    {\n      \"name\": \"red\",\n      \"value\": \"#F44336\"\n    },\n    {\n      \"name\": \"blue\",\n      \"value\": \"#2196F3\"\n    },\n    {\n      \"name\": \"green\",\n      \"value\": \"#4CAF50\"\n    },\n    {\n      \"name\": \"cyan\",\n      \"value\": \"#00BCD4\"\n    },\n    {\n      \"name\": \"teal\",\n      \"value\": \"#009688\"\n    },\n    {\n      \"name\": \"hot_key_bg\",\n      \"value\": \"#DDDDDD\"\n    },\n    {\n      \"name\": \"rank_gold\",\n      \"value\": \"#FFD700\"\n    },\n    {\n      \"name\": \"rank_silver\",\n      \"value\": \"#C0C0C0\"\n    },\n    {\n      \"name\": \"rank_bronze\",\n      \"value\": \"#CD7F32\"\n    },\n    {\n      \"name\": \"gray600\",\n      \"value\": \"#999999\"\n    }\n  ]\n}"
  },
  {
    "path": "entry/src/main/resources/base/element/string.json",
    "content": "{\n  \"string\": [\n    {\n      \"name\": \"module_desc\",\n      \"value\": \"module description\"\n    },\n    {\n      \"name\": \"EntryAbility_desc\",\n      \"value\": \"description\"\n    },\n    {\n      \"name\": \"EntryAbility_label\",\n      \"value\": \"WanHarmony\"\n    },\n    {\n      \"name\": \"internet_permission_reason\",\n      \"value\": \"获取网络数据\"\n    }\n  ]\n}"
  },
  {
    "path": "entry/src/main/resources/base/profile/main_pages.json",
    "content": "{\n  \"src\": [\n    \"pages/Index\"\n  ]\n}\n"
  },
  {
    "path": "entry/src/main/resources/en_US/element/string.json",
    "content": "{\n  \"string\": [\n    {\n      \"name\": \"module_desc\",\n      \"value\": \"module description\"\n    },\n    {\n      \"name\": \"EntryAbility_desc\",\n      \"value\": \"description\"\n    },\n    {\n      \"name\": \"EntryAbility_label\",\n      \"value\": \"WanHarmony\"\n    }\n  ]\n}"
  },
  {
    "path": "entry/src/main/resources/zh_CN/element/string.json",
    "content": "{\n  \"string\": [\n    {\n      \"name\": \"module_desc\",\n      \"value\": \"模块描述\"\n    },\n    {\n      \"name\": \"EntryAbility_desc\",\n      \"value\": \"description\"\n    },\n    {\n      \"name\": \"EntryAbility_label\",\n      \"value\": \"玩Harmony\"\n    }\n  ]\n}"
  },
  {
    "path": "entry/src/ohosTest/ets/test/Ability.test.ets",
    "content": "import hilog from '@ohos.hilog';\nimport { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'\n\nexport default function abilityTest() {\n  describe('ActsAbilityTest', function () {\n    // Defines a test suite. Two parameters are supported: test suite name and test suite function.\n    beforeAll(function () {\n      // Presets an action, which is performed only once before all test cases of the test suite start.\n      // This API supports only one parameter: preset action function.\n    })\n    beforeEach(function () {\n      // Presets an action, which is performed before each unit test case starts.\n      // The number of execution times is the same as the number of test cases defined by **it**.\n      // This API supports only one parameter: preset action function.\n    })\n    afterEach(function () {\n      // Presets a clear action, which is performed after each unit test case ends.\n      // The number of execution times is the same as the number of test cases defined by **it**.\n      // This API supports only one parameter: clear action function.\n    })\n    afterAll(function () {\n      // Presets a clear action, which is performed after all test cases of the test suite end.\n      // This API supports only one parameter: clear action function.\n    })\n    it('assertContain',0, function () {\n      // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.\n      hilog.info(0x0000, 'testTag', '%{public}s', 'it begin');\n      const a = 'abc'\n      const b = 'b'\n      // Defines a variety of assertion methods, which are used to declare expected boolean conditions.\n      expect(a).assertContain(b)\n      expect(a).assertEqual(a)\n    })\n  })\n}"
  },
  {
    "path": "entry/src/ohosTest/ets/test/List.test.ets",
    "content": "import abilityTest from './Ability.test'\n\nexport default function testsuite() {\n  abilityTest()\n}"
  },
  {
    "path": "entry/src/ohosTest/ets/testability/TestAbility.ets",
    "content": "import UIAbility from '@ohos.app.ability.UIAbility';\nimport AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';\nimport hilog from '@ohos.hilog';\nimport { Hypium } from '@ohos/hypium';\nimport testsuite from '../test/List.test';\nimport window from '@ohos.window';\n\nexport default class TestAbility extends UIAbility {\n    onCreate(want, launchParam) {\n        hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onCreate');\n        hilog.info(0x0000, 'testTag', '%{public}s', 'want param:' + JSON.stringify(want) ?? '');\n        hilog.info(0x0000, 'testTag', '%{public}s', 'launchParam:'+ JSON.stringify(launchParam) ?? '');\n        var abilityDelegator: any\n        abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()\n        var abilityDelegatorArguments: any\n        abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()\n        hilog.info(0x0000, 'testTag', '%{public}s', 'start run testcase!!!');\n        Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)\n    }\n\n    onDestroy() {\n        hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onDestroy');\n    }\n\n    onWindowStageCreate(windowStage: window.WindowStage) {\n        hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageCreate');\n        windowStage.loadContent('testability/pages/Index', (err, data) => {\n            if (err.code) {\n                hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');\n                return;\n            }\n            hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s',\n                JSON.stringify(data) ?? '');\n        });\n    }\n\n    onWindowStageDestroy() {\n        hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageDestroy');\n    }\n\n    onForeground() {\n        hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onForeground');\n    }\n\n    onBackground() {\n        hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onBackground');\n    }\n}"
  },
  {
    "path": "entry/src/ohosTest/ets/testability/pages/Index.ets",
    "content": "import hilog from '@ohos.hilog';\n\n@Entry\n@Component\nstruct Index {\n  aboutToAppear() {\n    hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility index aboutToAppear');\n  }\n @State message: string = 'Hello World'\n   build() {\n         Row() {\n           Column() {\n             Text(this.message)\n               .fontSize(50)\n               .fontWeight(FontWeight.Bold)\n             Button() {\n               Text('next page')\n                 .fontSize(20)\n                 .fontWeight(FontWeight.Bold)\n             }.type(ButtonType.Capsule)\n             .margin({\n               top: 20\n             })\n             .backgroundColor('#0D9FFB')\n             .width('35%')\n             .height('5%')\n             .onClick(()=>{\n             })\n           }\n             .width('100%')\n         }\n             .height('100%')\n   }\n }"
  },
  {
    "path": "entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts",
    "content": "import hilog from '@ohos.hilog';\nimport TestRunner from '@ohos.application.testRunner';\nimport AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';\n\nvar abilityDelegator = undefined\nvar abilityDelegatorArguments = undefined\n\nasync function onAbilityCreateCallback() {\n    hilog.info(0x0000, 'testTag', '%{public}s', 'onAbilityCreateCallback');\n}\n\nasync function addAbilityMonitorCallback(err: any) {\n    hilog.info(0x0000, 'testTag', 'addAbilityMonitorCallback : %{public}s', JSON.stringify(err) ?? '');\n}\n\nexport default class OpenHarmonyTestRunner implements TestRunner {\n    constructor() {\n    }\n\n    onPrepare() {\n        hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner OnPrepare ');\n    }\n\n    async onRun() {\n        hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun run');\n        abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()\n        abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()\n        var testAbilityName = abilityDelegatorArguments.bundleName + '.TestAbility'\n        const lMonitor = {\n            abilityName: testAbilityName,\n            onAbilityCreate: onAbilityCreateCallback,\n        };\n        abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)\n        var cmd = 'aa start -d 0 -a TestAbility' + ' -b ' + abilityDelegatorArguments.bundleName\n        var debug = abilityDelegatorArguments.parameters['-D']\n        if (debug == 'true')\n        {\n            cmd += ' -D'\n        }\n        hilog.info(0x0000, 'testTag', 'cmd : %{public}s', cmd);\n        abilityDelegator.executeShellCommand(cmd,\n            (err: any, d: any) => {\n                hilog.info(0x0000, 'testTag', 'executeShellCommand : err : %{public}s', JSON.stringify(err) ?? '');\n                hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.stdResult ?? '');\n                hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.exitCode ?? '');\n            })\n        hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun end');\n    }\n}"
  },
  {
    "path": "entry/src/ohosTest/module.json5",
    "content": "{\n  \"module\": {\n    \"name\": \"entry_test\",\n    \"type\": \"feature\",\n    \"description\": \"$string:module_test_desc\",\n    \"mainElement\": \"TestAbility\",\n    \"deviceTypes\": [\n      \"phone\",\n      \"tablet\"\n    ],\n    \"deliveryWithInstall\": true,\n    \"installationFree\": false,\n    \"pages\": \"$profile:test_pages\",\n    \"abilities\": [\n      {\n        \"name\": \"TestAbility\",\n        \"srcEntry\": \"./ets/testability/TestAbility.ets\",\n        \"description\": \"$string:TestAbility_desc\",\n        \"icon\": \"$media:icon\",\n        \"label\": \"$string:TestAbility_label\",\n        \"exported\": true,\n        \"startWindowIcon\": \"$media:icon\",\n        \"startWindowBackground\": \"$color:start_window_background\",\n        \"skills\": [\n          {\n            \"actions\": [\n              \"action.system.home\"\n            ],\n            \"entities\": [\n              \"entity.system.home\"\n            ]\n          }\n        ]\n      }\n    ]\n  }\n}\n"
  },
  {
    "path": "entry/src/ohosTest/resources/base/element/color.json",
    "content": "{\n  \"color\": [\n    {\n      \"name\": \"start_window_background\",\n      \"value\": \"#FFFFFF\"\n    }\n  ]\n}"
  },
  {
    "path": "entry/src/ohosTest/resources/base/element/string.json",
    "content": "{\n  \"string\": [\n    {\n      \"name\": \"module_test_desc\",\n      \"value\": \"test ability description\"\n    },\n    {\n      \"name\": \"TestAbility_desc\",\n      \"value\": \"the test ability\"\n    },\n    {\n      \"name\": \"TestAbility_label\",\n      \"value\": \"test label\"\n    }\n  ]\n}"
  },
  {
    "path": "entry/src/ohosTest/resources/base/profile/test_pages.json",
    "content": "{\n  \"src\": [\n    \"testability/pages/Index\"\n  ]\n}\n"
  },
  {
    "path": "hvigor/hvigor-config.json5",
    "content": "{\n  \"modelVersion\": \"5.0.2\",\n  \"dependencies\": {\n  },\n  \"execution\": {\n    // \"analyze\": \"normal\",                     /* Define the build analyze mode. Value: [ \"normal\" | \"advanced\" | false ]. Default: \"normal\" */\n    // \"daemon\": true,                          /* Enable daemon compilation. Value: [ true | false ]. Default: true */\n    // \"incremental\": true,                     /* Enable incremental compilation. Value: [ true | false ]. Default: true */\n    // \"parallel\": true,                        /* Enable parallel compilation. Value: [ true | false ]. Default: true */\n    // \"typeCheck\": false,                      /* Enable typeCheck. Value: [ true | false ]. Default: false */\n  },\n  \"logging\": {\n    // \"level\": \"info\"                          /* Define the log level. Value: [ \"debug\" | \"info\" | \"warn\" | \"error\" ]. Default: \"info\" */\n  },\n  \"debugging\": {\n    // \"stacktrace\": false                      /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */\n  },\n  \"nodeOptions\": {\n    // \"maxOldSpaceSize\": 8192                  /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/\n    // \"exposeGC\": true                         /* Enable to trigger garbage collection explicitly. Default: true*/\n  }\n}\n"
  },
  {
    "path": "hvigorfile.ts",
    "content": "import { appTasks } from '@ohos/hvigor-ohos-plugin';\n\nexport default {\n  system: appTasks,  /* Built-in plugin of Hvigor. It cannot be modified. */\n  plugins:[]         /* Custom plugin to extend the functionality of Hvigor. */\n}\n"
  },
  {
    "path": "oh-package.json5",
    "content": "{\n  \"modelVersion\": \"5.0.2\",\n  \"license\": \"\",\n  \"devDependencies\": {\n    \"@ohos/hypium\": \"1.0.21\",\n    \"@ohos/hamock\": \"1.0.0\"\n  },\n  \"author\": \"wangchenyan.top\",\n  \"name\": \"myapplication\",\n  \"description\": \"Please describe the basic information.\",\n  \"main\": \"\",\n  \"version\": \"1.0.0\",\n  \"dependencies\": {\n  },\n  \"dynamicDependencies\": {}\n}"
  }
]