Compare commits
2 Commits
5024477b74
...
9d32874e1e
| Author | SHA1 | Date | |
|---|---|---|---|
| 9d32874e1e | |||
| fab2b34a03 |
@@ -48,6 +48,7 @@ RUN apt-get update && apt-get install -y \
|
|||||||
potrace \
|
potrace \
|
||||||
imagemagick \
|
imagemagick \
|
||||||
zsh \
|
zsh \
|
||||||
|
vim \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# 安装 Python 3.12
|
# 安装 Python 3.12
|
||||||
@@ -112,7 +113,8 @@ RUN code-server --install-extension ms-ceintl.vscode-language-pack-zh-hans \
|
|||||||
&& code-server --install-extension dbaeumer.vscode-eslint \
|
&& code-server --install-extension dbaeumer.vscode-eslint \
|
||||||
&& code-server --install-extension prisma.prisma \
|
&& code-server --install-extension prisma.prisma \
|
||||||
&& code-server --install-extension ecmel.vscode-html-css \
|
&& code-server --install-extension ecmel.vscode-html-css \
|
||||||
&& code-server --install-extension cweijan.vscode-redis-client
|
&& code-server --install-extension cweijan.vscode-redis-client \
|
||||||
|
&& code-server --install-extension anthropic.claude-code
|
||||||
|
|
||||||
# 配置 code-server (密码将在启动时设置)
|
# 配置 code-server (密码将在启动时设置)
|
||||||
RUN mkdir -p /root/.config/code-server && \
|
RUN mkdir -p /root/.config/code-server && \
|
||||||
|
|||||||
@@ -17,6 +17,12 @@ services:
|
|||||||
- code-server-config:/root/.config/code-server
|
- code-server-config:/root/.config/code-server
|
||||||
# Code Server 数据(插件、用户设置、扩展数据)
|
# Code Server 数据(插件、用户设置、扩展数据)
|
||||||
- code-server-data:/root/.local/share/code-server
|
- code-server-data:/root/.local/share/code-server
|
||||||
|
# Claude Code 配置和保存数据
|
||||||
|
- claude:/root/.claude
|
||||||
|
# Claude Code Router 配置和保存数据
|
||||||
|
- claude-code-router:/root/.claude-code-router
|
||||||
|
# SSH 配置
|
||||||
|
- ssh:/root/.ssh
|
||||||
environment:
|
environment:
|
||||||
- NODE_ENV=development
|
- NODE_ENV=development
|
||||||
- TZ=Asia/Shanghai
|
- TZ=Asia/Shanghai
|
||||||
|
|||||||
@@ -219,7 +219,7 @@ main() {
|
|||||||
print_info "配置 AI API..."
|
print_info "配置 AI API..."
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
PKUAI_API_KEY=$(read_input "PKU AI API Key" "" "true")
|
PKUAI_API_KEY=$(read_password "PKU AI API Key" "true")
|
||||||
PKUAI_API_BASE=$(read_input "PKU AI API Base URL" "https://chat.noc.pku.edu.cn/")
|
PKUAI_API_BASE=$(read_input "PKU AI API Base URL" "https://chat.noc.pku.edu.cn/")
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
@@ -232,6 +232,7 @@ main() {
|
|||||||
|
|
||||||
DEV_PORT=$(read_input "开发服务器端口" "3000")
|
DEV_PORT=$(read_input "开发服务器端口" "3000")
|
||||||
DEV_TERMINAL_PORT=$(read_input "开发终端默认端口" "7681")
|
DEV_TERMINAL_PORT=$(read_input "开发终端默认端口" "7681")
|
||||||
|
DEV_TERMINAL_URL=$(read_input "开发终端 URL" "" "true")
|
||||||
DEV_TERMINAL=$(read_input "开发终端 tmux session 名称" "nextdev")
|
DEV_TERMINAL=$(read_input "开发终端 tmux session 名称" "nextdev")
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
@@ -284,6 +285,7 @@ EOF
|
|||||||
# 仅在开发环境加载
|
# 仅在开发环境加载
|
||||||
PORT=${DEV_PORT}
|
PORT=${DEV_PORT}
|
||||||
NEXT_PUBLIC_DEV_TERMINAL_DEFAULT_PORT=${DEV_TERMINAL_PORT}
|
NEXT_PUBLIC_DEV_TERMINAL_DEFAULT_PORT=${DEV_TERMINAL_PORT}
|
||||||
|
NEXT_PUBLIC_DEV_TERMINAL_URL=${DEV_TERMINAL_URL}
|
||||||
DEV_TERMINAL=${DEV_TERMINAL}
|
DEV_TERMINAL=${DEV_TERMINAL}
|
||||||
EOF
|
EOF
|
||||||
print_success ".env.development 文件已创建"
|
print_success ".env.development 文件已创建"
|
||||||
@@ -318,6 +320,11 @@ EOF
|
|||||||
EOF
|
EOF
|
||||||
print_success "新的 CLAUDE.md 已创建"
|
print_success "新的 CLAUDE.md 已创建"
|
||||||
|
|
||||||
|
# 清空 README.md
|
||||||
|
print_info "清空 README.md..."
|
||||||
|
> README.md
|
||||||
|
print_success "README.md 已清空"
|
||||||
|
|
||||||
# 创建 Claude Code Router 配置
|
# 创建 Claude Code Router 配置
|
||||||
print_info "配置 Claude Code Router..."
|
print_info "配置 Claude Code Router..."
|
||||||
mkdir -p ~/.claude-code-router
|
mkdir -p ~/.claude-code-router
|
||||||
@@ -392,17 +399,31 @@ EOF
|
|||||||
GIT_USER_NAME=$(read_input "Git 用户名" "")
|
GIT_USER_NAME=$(read_input "Git 用户名" "")
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
print_info "设置 Git 全局配置..."
|
git init
|
||||||
git config --global user.email "$GIT_USER_EMAIL"
|
git config init.defaultBranch main
|
||||||
git config --global user.name "$GIT_USER_NAME"
|
print_info "设置 Git 用户配置..."
|
||||||
print_success "Git 全局配置已设置"
|
git config user.email "$GIT_USER_EMAIL"
|
||||||
|
git config user.name "$GIT_USER_NAME"
|
||||||
|
print_success "Git 用户配置已设置"
|
||||||
|
|
||||||
# 初始化新的 git 仓库
|
# 初始化新的 git 仓库
|
||||||
print_info "初始化 Git 仓库..."
|
print_info "初始化 Git 仓库..."
|
||||||
git init
|
|
||||||
git add .
|
git add .
|
||||||
git commit -m "init"
|
git commit -m "init"
|
||||||
print_success "Git 仓库已初始化并完成首次提交"
|
git branch -M main
|
||||||
|
print_success "Git 仓库已初始化并完成首次提交 (主分支: main)"
|
||||||
|
|
||||||
|
# 配置远程仓库
|
||||||
|
echo ""
|
||||||
|
print_info "配置远程仓库 (格式: https://用户名:密码@gitea.example.com/用户名/仓库名.git)"
|
||||||
|
GIT_REMOTE_URL=$(read_input "远程仓库链接" "" "true")
|
||||||
|
|
||||||
|
if [ -n "$GIT_REMOTE_URL" ]; then
|
||||||
|
git remote add origin "$GIT_REMOTE_URL"
|
||||||
|
print_success "远程仓库已配置: $GIT_REMOTE_URL"
|
||||||
|
else
|
||||||
|
print_info "跳过远程仓库配置"
|
||||||
|
fi
|
||||||
|
|
||||||
# ==================== 完成提示 ====================
|
# ==================== 完成提示 ====================
|
||||||
print_header "配置完成!"
|
print_header "配置完成!"
|
||||||
|
|||||||
@@ -126,8 +126,7 @@ export function DevTools() {
|
|||||||
variant="outline"
|
variant="outline"
|
||||||
size="sm"
|
size="sm"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
const port = process.env.NEXT_PUBLIC_DEV_TERMINAL_DEFAULT_PORT || '7681'
|
window.open(process.env.NEXT_PUBLIC_DEV_TERMINAL_URL || `http://localhost:${process.env.NEXT_PUBLIC_DEV_TERMINAL_DEFAULT_PORT || '7681'}`, '_blank')
|
||||||
window.open(`http://localhost:${port}`, '_blank')
|
|
||||||
}}
|
}}
|
||||||
disabled={!terminalLoaded}
|
disabled={!terminalLoaded}
|
||||||
className="gap-1.5"
|
className="gap-1.5"
|
||||||
|
|||||||
@@ -12,6 +12,33 @@ export const minioClient = new Client({
|
|||||||
|
|
||||||
export const BUCKET_NAME = process.env.MINIO_BUCKET || 'app-files';
|
export const BUCKET_NAME = process.env.MINIO_BUCKET || 'app-files';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取客户端访问的基础 URL
|
||||||
|
* 优先使用 MINIO_SERVER_URL(公网地址),否则使用内部地址
|
||||||
|
*/
|
||||||
|
function getClientBaseUrl(): string {
|
||||||
|
if (process.env.MINIO_SERVER_URL) {
|
||||||
|
return process.env.MINIO_SERVER_URL;
|
||||||
|
}
|
||||||
|
const protocol = process.env.MINIO_USE_SSL === 'true' ? 'https' : 'http';
|
||||||
|
const endpoint = process.env.MINIO_ENDPOINT || 'localhost';
|
||||||
|
const port = process.env.MINIO_API_PORT || '9000';
|
||||||
|
return `${protocol}://${endpoint}:${port}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 替换预签名 URL 中的内部地址为客户端可访问的地址
|
||||||
|
*/
|
||||||
|
function replaceUrlBase(originalUrl: string): string {
|
||||||
|
const clientBase = getClientBaseUrl();
|
||||||
|
const url = new URL(originalUrl);
|
||||||
|
const clientUrl = new URL(clientBase);
|
||||||
|
url.protocol = clientUrl.protocol;
|
||||||
|
url.hostname = clientUrl.hostname;
|
||||||
|
url.port = clientUrl.port; // 空字符串表示使用协议默认端口
|
||||||
|
return url.toString();
|
||||||
|
}
|
||||||
|
|
||||||
// 桶初始化标志
|
// 桶初始化标志
|
||||||
let bucketInitialized = false;
|
let bucketInitialized = false;
|
||||||
|
|
||||||
@@ -150,7 +177,7 @@ export async function generatePresignedPostPolicy(
|
|||||||
const presignedData = await minioClient.presignedPostPolicy(policy);
|
const presignedData = await minioClient.presignedPostPolicy(policy);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
postURL: presignedData.postURL,
|
postURL: replaceUrlBase(presignedData.postURL),
|
||||||
formData: presignedData.formData,
|
formData: presignedData.formData,
|
||||||
objectName,
|
objectName,
|
||||||
};
|
};
|
||||||
@@ -237,7 +264,7 @@ export async function generatePresignedGetObject(
|
|||||||
);
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
url,
|
url: replaceUrlBase(url),
|
||||||
expiresIn: expirySeconds,
|
expiresIn: expirySeconds,
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -343,9 +370,5 @@ export async function getObjectMetadata(objectName: string) {
|
|||||||
* @returns 公开访问 URL
|
* @returns 公开访问 URL
|
||||||
*/
|
*/
|
||||||
export function getPublicUrl(objectName: string): string {
|
export function getPublicUrl(objectName: string): string {
|
||||||
const protocol = process.env.MINIO_USE_SSL === 'true' ? 'https' : 'http';
|
return `${getClientBaseUrl()}/${BUCKET_NAME}/${objectName}`;
|
||||||
const endpoint = process.env.MINIO_ENDPOINT || 'localhost';
|
|
||||||
const port = process.env.MINIO_API_PORT || '9000';
|
|
||||||
|
|
||||||
return `${protocol}://${endpoint}:${port}/${BUCKET_NAME}/${objectName}`;
|
|
||||||
}
|
}
|
||||||
@@ -46,7 +46,8 @@ export function startTerminalService() {
|
|||||||
'-p', port,
|
'-p', port,
|
||||||
'-t', 'titleFixed=开发终端',
|
'-t', 'titleFixed=开发终端',
|
||||||
'-t', 'fontSize=14',
|
'-t', 'fontSize=14',
|
||||||
'-i', '127.0.0.1',
|
'-c', `super_admin:${process.env.SUPER_ADMIN_PASSWORD}`,
|
||||||
|
'-i', process.env.SUPER_ADMIN_PASSWORD ? '0.0.0.0' : "127.0.0.1",
|
||||||
'--writable',
|
'--writable',
|
||||||
'tmux', 'new', '-A',
|
'tmux', 'new', '-A',
|
||||||
'-s', process.env.DEV_TERMINAL || 'nextdev',
|
'-s', process.env.DEV_TERMINAL || 'nextdev',
|
||||||
|
|||||||
Reference in New Issue
Block a user