Files
SoonDesign/docker/sync-config.ps1
T
24kycj 152228d41f 前端配置迁至 config/local.js,完善支付、模板库与部署脚本
- 页面直接引用 local.js 设置 SOON_DEPLOY_CONFIG,移除 deploy-config
- Docker sync-config 生成 local.js;更新 README 与 agent-core 说明
- 模板库自动扫描 .soon;新增后端部署/种子/排查脚本
- 完善支付配置、订阅弹窗与后台支付管理页

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-08 20:48:51 +08:00

72 lines
2.7 KiB
PowerShell

param([string]$EnvFile = "$PSScriptRoot\.env", [string]$Root = (Split-Path $PSScriptRoot -Parent))
if (-not (Test-Path $EnvFile)) { Copy-Item "$PSScriptRoot\.env.example" $EnvFile }
$ports = @{ WEB_PORT = '8100'; ELECTRON_PORT = '8101'; BACKEND_PORT = '8102' }
Get-Content $EnvFile -Encoding UTF8 | ForEach-Object {
if ($_ -match '^\s*(WEB_PORT|ELECTRON_PORT|BACKEND_PORT)\s*=\s*(\d+)') { $ports[$matches[1]] = $matches[2] }
}
$w, $e, $b = $ports.WEB_PORT, $ports.ELECTRON_PORT, $ports.BACKEND_PORT
$localJs = @"
window.SOON_DEPLOY_CONFIG = {
api_v1_base: 'http://localhost:$b/api/v1',
api_admin_base: 'http://localhost:$b/api/admin',
front_base_url: 'http://localhost:$w',
web_base: 'http://localhost:$w',
version: 'local-dev'
};
"@
$localPhp = @"
<?php
return [
'app' => [
'env' => 'development',
'debug' => true,
'timezone' => 'Asia/Shanghai',
'jwt_secret' => 'local-dev-jwt-secret-minimum-32-chars',
'jwt_ttl' => 3600,
'jwt_refresh_ttl' => 2592000,
'cors_origins' => [
'http://localhost:$w', 'http://127.0.0.1:$w',
'http://localhost:$e', 'http://127.0.0.1:$e',
],
],
'db' => [
'host' => 'mysql', 'port' => 3306, 'name' => 'soondesign',
'user' => 'soondesign', 'pass' => 'soondesign', 'charset' => 'utf8mb4',
],
'site' => [
'base_url' => 'http://localhost:$b',
'front_base_url' => 'http://localhost:$w',
],
'storage' => [
'users_dir' => '/var/www/storage/users',
'models_dir' => '/var/soonModels',
],
'limits' => ['free_quota_mb' => 20, 'preview_require_membership' => false],
'rate_limits' => [
'admin/*' => ['capacity' => 120, 'window' => 60],
'POST /api/v1/auth/login' => ['capacity' => 10, 'window' => 60],
'POST /api/v1/auth/register' => ['capacity' => 5, 'window' => 60],
'POST /api/v1/files' => ['capacity' => 30, 'window' => 60],
],
'alipay' => ['app_id' => '', 'private_key' => '', 'public_key' => '', 'sandbox' => true],
'wechat' => [
'app_id' => '', 'mch_id' => '', 'mch_serial_no' => '',
'mch_private_key' => '', 'api_v3_key' => '', 'sandbox' => true,
],
];
"@
$dir = Join-Path $PSScriptRoot 'config'
New-Item -ItemType Directory -Force -Path $dir | Out-Null
$enc = [Text.UTF8Encoding]::new($false)
[IO.File]::WriteAllText((Join-Path $dir 'local.js'), $localJs.Trim() + "`n", $enc)
[IO.File]::WriteAllText((Join-Path $dir 'local.php'), $localPhp.Trim() + "`n", $enc)
$webLocal = Join-Path $Root 'frontend-web\config\local.js'
New-Item -ItemType Directory -Force -Path (Split-Path $webLocal -Parent) | Out-Null
[IO.File]::WriteAllText($webLocal, $localJs.Trim() + "`n", $enc)