{"record":{"id":"51d730ab8cecce46","repo":"yikart/AiToEarn","slug":"error-51d730","errorCode":null,"errorMessage":"该平台在当前区域不可用","messagePattern":"该平台在当前区域不可用","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"project/aitoearn-web/src/store/plugin/store.ts","lineNumber":757,"sourceCode":"          set({\n            platformAccounts: { ...platformAccounts, [platform]: result },\n          })\n          await methods.syncAccountToDatabase(platform)\n          return result\n        }\n        catch (error) {\n          console.error('登录失败:', error)\n          throw error\n        }\n      },\n\n      /** 发布内容到指定平台 */\n      async publish(params: PublishParams, onProgress?: ProgressCallback) {\n        const { status, publishingPlatforms, platformProgress } = get()\n        const platform = params.platform\n\n        if (!isPlatformEnabledSync(platform))\n          throw new Error(ERROR_MESSAGES.PLATFORM_REGION_RESTRICTED)\n\n        // 解析话题\n        const { topics, cleanedString } = parseTopicString(params.desc || '')\n        params.topics = [...new Set(params.topics?.concat(topics))]\n        params.desc = cleanedString\n\n        const accountId = params.accountId\n        // 使用 platform + accountId 作为唯一标识，支持同一平台多账号同时发布\n        const publishKey = getPublishKey(platform, accountId)\n\n        if (status === Status.NOT_INSTALLED)\n          throw new Error(ERROR_MESSAGES.PLUGIN_NOT_INSTALLED)\n\n        if (status !== Status.READY)\n          throw new Error(ERROR_MESSAGES.PLUGIN_NOT_READY)\n\n        // 检查该账号是否正在发布（同一平台不同账号可以同时发布）\n        if (publishingPlatforms.has(publishKey))","sourceCodeStart":739,"sourceCodeEnd":775,"githubUrl":"https://github.com/yikart/AiToEarn/blob/d3aa8bea5b146a8675607cf0144d891aad3e9683/project/aitoearn-web/src/store/plugin/store.ts#L739-L775","documentation":"The web app's plugin publish flow refuses to publish to a platform that is disabled for the user's current region. Before doing any work, publish() checks isPlatformEnabledSync(platform); if the platform is region-restricted it throws PLATFORM_REGION_RESTRICTED (\"该平台在当前区域不可用\"). This is a deliberate policy guard, typically reflecting compliance/licensing restrictions (e.g. 中国版 vs 国际版 environments).","triggerScenarios":"Calling publish({ platform, ... }) from project/aitoearn-web/src/store/plugin/store.ts with a platform for which isPlatformEnabledSync returns false — i.e. the platform is not enabled in the current region/environment build.","commonSituations":"Users of the international build (aitoearn.ai) trying to publish to China-only platforms (or vice versa with aitoearn.cn), or a platform gated behind a feature flag/region config that hasn't been enabled for the deployed environment.","solutions":["Check isPlatformEnabledSync(params.platform) in the UI before offering/enabling the publish action, and hide or disable restricted platforms","Verify the current environment/region build (aitoearn.cn vs aitoearn.ai) matches the platforms the user expects; switch environment or platform accordingly","If the platform should be available, update the region/platform enablement config so isPlatformEnabledSync returns true"],"exampleFix":"// before\nawait publish({ platform: 'xiaohongshu', accountId }) // throws if restricted\n// after\nif (isPlatformEnabledSync('xiaohongshu')) {\n  await publish({ platform: 'xiaohongshu', accountId })\n} else {\n  toast.error('该平台在当前区域不可用')\n}","handlingStrategy":"validation","validationCode":"import { isPlatformEnabledSync } from '@/lib/platforms'\nconst { publish } = usePluginStore.getState()\nif (!isPlatformEnabledSync(platform)) {\n  toast.error('该平台在当前区域不可用'); return\n}\nawait publish({ platform, accountId })","typeGuard":"function isPublishablePlatform(p: string): boolean {\n  return isPlatformEnabledSync(p)\n}","tryCatchPattern":"try {\n  await publish({ platform, accountId })\n} catch (e) {\n  if (e.message === '该平台在当前区域不可用') {\n    toast.error('该平台在当前区域不可用'); return\n  }\n  throw e\n}","preventionTips":["Gate platform selection UI on isPlatformEnabledSync so restricted platforms are never selectable","Keep region/platform config in sync between environments (cn vs ai)","Test publish flows in each deployed environment before release"],"tags":["region-restriction","publish","platform"],"backgroundTag":"platform-region-restricted","analyzedSha":"d3aa8bea5b146a8675607cf0144d891aad3e9683","analyzedAt":"2026-08-31T14:19:24.185Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}