type StudioOpts = { user: string, userAppKey?: string; appIds: string[] } export const createStudioAppListHtml = (opts: StudioOpts) => { const user = opts.user!; const userAppKey = opts?.userAppKey; let showUserAppKey = userAppKey; if (showUserAppKey && showUserAppKey.startsWith(user + '-')) { showUserAppKey = showUserAppKey.replace(user + '-', ''); } const pathApps = opts?.appIds?.map(appId => { const shortAppId = appId.replace(opts!.user + '-', '') return { appId, shortAppId, pathname: `/${user}/v1/${shortAppId}` }; }) || [] // 应用列表内容 const appListContent = `

Studio 应用列表

用户: ${user}

${pathApps.map((app, index) => `

${app.shortAppId}

${app.pathname}

`).join('')}
${pathApps.length === 0 ? `
📭

暂无应用

` : ''} ` return ` Studio - ${user} 的应用
${showUserAppKey ? `

应用不存在

抱歉,您访问的应用 ${showUserAppKey || ''} 不存在。

请检查应用 Key 是否正确,或联系管理员。

← 返回应用列表
` : ''} ${appListContent}
`; };