{"record":{"id":"315ae672e1d057c7","repo":"yikart/AiToEarn","slug":"error-315ae6","errorCode":null,"errorMessage":"插件未安装或未就绪","messagePattern":"插件未安装或未就绪","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"project/aitoearn-web/src/store/plugin/plats/xhs/index.ts","lineNumber":41,"sourceCode":"  SubCommentListParams,\n} from '../types'\nimport type { XhsBaseResponse, XhsCommentResponse } from './types'\nimport { PlatType } from '@/app/config/platConfig'\nimport { getCommentList, getSubCommentList } from './comment'\nimport { getHomeFeedList, homeFeedCursor } from './homeFeed'\n\n/**\n * 小红书平台交互类\n */\nclass XhsPlatformInteraction implements IPlatformInteraction {\n  readonly platformType = PlatType.Xhs\n\n  /**\n   * 检查插件是否可用\n   */\n  private checkPlugin(): void {\n    if (!window.AIToEarnPlugin) {\n      throw new Error('插件未安装或未就绪')\n    }\n  }\n\n  /**\n   * 重置首页列表游标缓存\n   * 用于刷新列表时清除缓存\n   */\n  resetHomeFeedCursor(): void {\n    homeFeedCursor.reset()\n  }\n\n  /**\n   * 点赞/取消点赞作品\n   */\n  async likeWork(workId: string, isLike: boolean): Promise<LikeResult> {\n    this.checkPlugin()\n\n    if (window.AIToEarnPlugin!.unifiedInteraction) {","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/yikart/AiToEarn/blob/d3aa8bea5b146a8675607cf0144d891aad3e9683/project/aitoearn-web/src/store/plugin/plats/xhs/index.ts#L23-L59","documentation":"The Xiaohongshu (xhs) interaction adapter's private checkPlugin() throws '插件未安装或未就绪' when window.AIToEarnPlugin is missing. likeWork, commentWork and favoriteWork all funnel through this guard because their DOM automation requires the extension's injected bridge on xiaohongshu.com.","triggerScenarios":"Invoking any xhs interaction method while the Aitoearn extension is absent, disabled, not injected on the current tab, or the page is opened where extensions can't run (SSR, incognito without permission).","commonSituations":"User visits xiaohongshu.com without the extension; extension auto-updated requiring page reload; content-script injection blocked by site access settings; extension crashed after update.","solutions":["Install/enable the Aitoearn extension and reload the xiaohongshu.com tab to re-inject the content script.","Pre-check `!!window.AIToEarnPlugin` before calling actions and show an install/ready prompt instead of throwing.","Gate the interaction UI on the plugin store's Status.READY value rather than calling blindly.","Confirm extension site-access includes xiaohongshu.com and incognito access if applicable."],"exampleFix":"// before\nawait xhsPlugin.likeWork(workId)\n\n// after\nif (!window.AIToEarnPlugin)\n  return promptInstallPlugin()\nawait xhsPlugin.likeWork(workId)","handlingStrategy":"type-guard","validationCode":"if (typeof window === 'undefined' || !window.AIToEarnPlugin) {\n  showPluginInstallGuide('xhs')\n  return\n}","typeGuard":"function hasXhsPlugin(w: Window | undefined): w is Window & { AIToEarnPlugin: NonNullable<Window['AIToEarnPlugin']> } {\n  return !!w && !!(w as Window).AIToEarnPlugin\n}","tryCatchPattern":"try {\n  await xhsPlugin.favoriteWork(workId)\n}\ncatch (e) {\n  if (e.message === '插件未安装或未就绪') {\n    promptInstallOrReload()\n    return\n  }\n  throw e\n}","preventionTips":["Wrap plugin presence detection in a shared usePluginReady hook used by all xhs interaction entry points","Only render like/comment/favorite buttons when plugin status is READY","Reload the tab after extension install/update to re-inject the content script","Check extension permissions/site access for xiaohongshu.com"],"tags":["browser-extension","plugin","xhs","content-script"],"backgroundTag":"browser-extension-not-installed","analyzedSha":"d3aa8bea5b146a8675607cf0144d891aad3e9683","analyzedAt":"2026-08-31T14:19:24.185Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}