AI Outpainting (AI扩图)网站源码
网站首页
价格页面
博客列表
图片编辑
1.基于nextjs 14 和 tailwindcss3 开发的AI扩图网站,网站地址:https://www.ai-outpainting.com/
2.网站需要配合后端AI模型使用。后端模型需要自行搭建。
3.国际化采用lingui实现,这个对比next-intl 的好处是不需要为每个文案生成一个key,它会通过命令提取文案生成多语言文件。之后基于多语言文件去做翻译
4.项目编写了一些自动化脚本,如自动翻译国际化内容,自动翻译博客内容。这些都需要在有需要的时候手动运行
5.项目依赖数据库、cloudfare r2 存储、Google登录所需要的参数、paypal支付参数,这些参数都配置在.env和.env.production文件当中。
6.使用next-auth 集成google登录。本地开发时如果需要google登录,需要修改一些源码才可以,不然会报错。具体修改内容见下方说明
7.集成了paypal、stripe支付。本地开发使用的时沙盒环境,正式环境需要配置正式的paypal参数到.env.production文件当中
8.当前项目调用AI模型使用的方式大致如下:
9.整体架构图如下:
10.另外一种实现方案
11.如果有预算的也可以考虑直接使用runpod 的API服务,就不用自己实现MQ队列管理器服务器了,集成它的SDK就可以。
参考代码
import runpodSdk, { EndpointCompletedOutput, EndpointIncompleteOutput } from 'runpod-sdk'
async function fetchProcessByRunPod(data: any): Promise {
// const serverUrl = `${UE_PROCESS_API}/create_docker`
// https://docs.runpod.io/serverless/endpoints/job-operations
const runpod = runpodSdk("N5Jxxxxxxxxxxxxx");
const endpoint = runpod.endpoint("1zgk5xi3ew77pv");
console.log("start invoke runpod endpoint,data:",data)
return endpoint?.run({
"input": data,
})
}yarn extract 命令,将新的文案提取到国际化文件当中,并执行 yarn translate 命令将文案翻译为对应语言yarn translate 命令新将增的博客内容翻译为对应语言 // 网站关键词
const keyword = 'extend image ai'
// 网站该要描述
const description = '利用AI技术实现对图片进行扩展,在保证原始图片不变的前提下,扩展四周的内容,且能与原图片保持内容延续性
// 这个命令会根据表结构声明生成数据库表,并初始化表数据。如果有新的表字段更新都需要执行当前命令
yarn pg:migrate
// 其他操作命令建议直接看prisma官方文档
Error: ENOENT: no such file or directory xxx/.next/fallback-build-manifest.json 问题,通过固定"@lingui/swc-plugin": "4.0.8",版本解决。删除本地node_modules目录,重新安装依赖解决。Error: Cannot find module 'canvas' 问题,通过添加webpack ignore plugin 解决。优化多语言文件加载方式。可以从网站上直接复制某些现成的组件代码完全基于 tw实现
提供基于封装好的组件直接使用
提供多套默认 icon图标可以直接用
shipixen
动态生成国际化文件
基于MDX生成博客内容
配置Google登录需要的参数
https://www.prisma.io/docs/orm/more/help-and-troubleshooting/help-articles/vercel-caching-issue
There is a problem with the server configuration.,后端提示[auth][error] OperationProcessingError: "response" body "issuer" property does not match the expected value 错误,按如下方式修改
function validateIssuer(expected, result) {
if (result.claims.iss !== expected) {
// throw new OPE('unexpected JWT "iss" (issuer) claim value');
}
return result;
} if (new URL(json.issuer).href !== expectedIssuerIdentifier.href) {
// throw new OPE('"response" body "issuer" does not match "expectedIssuer"');
}bun run add-word-locale.js 或者 node add-word-locale.jsNo open issues yet, or sync has not completed.