{"record":{"id":"1dfa75d9fe49cd4a","repo":"lyswhut/lx-music-desktop","slug":"api-name","errorCode":null,"errorMessage":"导入失败，脚本内容与已有的源「${api.name}」相同","messagePattern":"导入失败，脚本内容与已有的源「(.+?)」相同","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/main/modules/userApi/utils.ts","lineNumber":117,"sourceCode":"const inflateScript = async(script: string) => new Promise<string>((resolve, reject) => {\n  if (script.startsWith('gz_')) {\n    zlib.inflate(Buffer.from(script.substring(3), 'base64'), (err, buf) => {\n      if (err) {\n        reject(err)\n        return\n      }\n      resolve(buf.toString('utf8'))\n    })\n  } else resolve(script)\n})\nexport const importApi = async(scriptRaw: string): Promise<LX.UserApi.UserApiInfo> => {\n  let scriptInfo = parseScriptInfo(scriptRaw)\n  const script = await deflateScript(scriptRaw)\n  userApis ??= []\n  for (const api of userApis) {\n    const existingScript = scripts.get(api.id)\n    if (existingScript === script) {\n      throw new Error(`导入失败，脚本内容与已有的源「${api.name}」相同`)\n    }\n  }\n  const apiInfo = {\n    id: `user_api_${Math.random().toString().substring(2, 5)}_${Date.now()}`,\n    ...scriptInfo,\n    allowShowUpdateAlert: true,\n  }\n  userApis.push(apiInfo)\n  scripts.set(apiInfo.id, script)\n  saveData()\n  return apiInfo\n}\n\nexport const removeApi = (ids: string[]) => {\n  if (!userApis) return\n  for (let index = userApis.length - 1; index > -1; index--) {\n    if (ids.includes(userApis[index].id)) {\n      scripts.delete(userApis[index].id)","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/lyswhut/lx-music-desktop/blob/9c364b482e5621a1d38b50e8610d2fb974457e6e/src/main/modules/userApi/utils.ts#L99-L135","documentation":"Error \"导入失败，脚本内容与已有的源「${api.name}」相同\" thrown in lyswhut/lx-music-desktop.","triggerScenarios":"Thrown at src/main/modules/userApi/utils.ts:117 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"9c364b482e5621a1d38b50e8610d2fb974457e6e","analyzedAt":"2026-08-12T15:14:48.244Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}