yikart/AiToEarn · error · Error

请先安装 Aitoearn 浏览器插件

Error message

请先安装 Aitoearn 浏览器插件

What it means

The plugin store's login(platform) throws ERROR_MESSAGES.PLUGIN_NOT_INSTALLED ('请先安装 Aitoearn 浏览器插件') when the tracked status is Status.NOT_INSTALLED. The store detects extension presence at startup; login is refused up front because window.AIToEarnPlugin cannot be invoked without the extension.

Solutions

  1. Install the Aitoearn browser extension from the official download page, then reload the page so the store re-detects it.
  2. Trigger a status re-check (store's detection/init method) after installation before calling login().
  3. Gate the login button on status === Status.READY and render an install guide when NOT_INSTALLED.
  4. Catch this error by message and route the user to the plugin install flow instead of a generic error toast.

Example fix

// before
await usePluginStore.getState().login('douyin')

// after
const { status } = usePluginStore.getState()
if (status === Status.NOT_INSTALLED) {
  openPluginInstallGuide()
  return
}
await usePluginStore.getState().login('douyin')
Defensive patterns

Strategy: validation

Validate before calling

const { status } = usePluginStore.getState()
if (status === Status.NOT_INSTALLED) {
  openPluginInstallGuide()
  return
}
if (status !== Status.READY) await waitForPluginReady()
await login(platform)

Type guard

function isPluginReady(status: Status): status is Status.READY {
  return status === Status.READY
}

Try / catch

try {
  await login(platform)
}
catch (e) {
  if (e.message === ERROR_MESSAGES.PLUGIN_NOT_INSTALLED)
    return showInstallDialog()
  throw e
}

Prevention

When it happens

Trigger: Calling the store's login() action while usePluginStore status === Status.NOT_INSTALLED — the extension is not detected in the browser (absent window.AIToEarnPlugin at detection time).

Common situations: Fresh browser without the extension; user disabled the extension; page not reloaded after installing the extension so the store never re-detected it; browser profile where the extension isn't installed.

Related errors


AI-assisted analysis of yikart/AiToEarn@d3aa8bea5b (2026-08-31). Data as JSON: /api/errors/2e0152c192f05a60. Report an issue: GitHub.

Appendix: source

Thrown at project/aitoearn-web/src/store/plugin/store.ts:732

            return result.data || null
          }
          else {
            console.error('同步账号失败:', result?.message)
            return null
          }
        }
        catch (error) {
          console.error('同步账号到数据库失败:', error)
          return null
        }
      },

      /** 登录到指定平台 */
      async login(platform: PluginPlatformType) {
        const { status, platformAccounts } = get()

        if (status === Status.NOT_INSTALLED)
          throw new Error(ERROR_MESSAGES.PLUGIN_NOT_INSTALLED)

        if (status !== Status.READY)
          throw new Error(ERROR_MESSAGES.PLUGIN_NOT_READY)

        try {
          const result = await window.AIToEarnPlugin!.login(platform)
          set({
            platformAccounts: { ...platformAccounts, [platform]: result },
          })
          await methods.syncAccountToDatabase(platform)
          return result
        }
        catch (error) {
          console.error('登录失败:', error)
          throw error
        }
      },

View on GitHub (pinned to d3aa8bea5b)