From 455610a76f5e3484ebc3f92e2601d5ba0d417093 Mon Sep 17 00:00:00 2001
From: 李曜臣
Date: Mon, 12 Oct 2026 11:38:57 +0800
Subject: [PATCH] 2026-10-12代码提交
---
.gitignore | 8 ++++++++
泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling/FoodLabeling.Th.Application/Services/ThTenantProvisioningAppService.cs | 8 ++------
泰额版/Food Labeling Management Code/Yi.Abp.Net8/src/Yi.Abp.Web/appsettings.json | 6 +++---
泰额版/Food Labeling Management Code/Yi.Vben5.Vue3/apps/web-antd/src/api/request.ts | 1 +
美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/Dashboard/DashboardOverviewOutputDto.cs | 3 ---
美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/AccountStructureCascadeDeleteHelper.cs | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/GroupListScopeHelper.cs | 11 +++++++++--
美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelEntityPartnerScopeHelper.cs | 7 +++++++
美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelTemplateLabelIdHelper.cs | 1 +
美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelTemplateScopeHelper.cs | 8 ++------
美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LocationScopeBindingHelper.cs | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------
美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/PartnerScopeHelper.cs | 9 ++++++++-
美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/DashboardAppService.cs | 7 -------
美国版/Food Labeling Management Code/Yi.Abp.Net8/src/Yi.Abp.Web/appsettings.json | 5 +++--
美国版/Food Labeling Management Platform/src/components/labels/LabelTemplateEditor/LabelCanvas.tsx | 28 ++++++++++++++--------------
美国版/scripts/.deploy-us-test.pub | 1 +
美国版/scripts/_deploy-us-ssh.ps1 | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
美国版/scripts/bt-register-net-project.py | 284 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
美国版/scripts/fix-cors-on-server.sh | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
美国版/scripts/nginx.flusapi-tetest.3flabeling.com.conf | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
美国版/scripts/nginx.flusapi-teustest.3flabeling.com.conf | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
美国版/scripts/nginx.flusapi-us.3flabeling.com.conf | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
美国版/scripts/nginx.flusapi-ustest.3flabeling.com.conf | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
美国版/scripts/泰鄂测试版部署.cmd | 5 +++++
美国版/scripts/泰鄂测试版部署.ps1 | 167 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
美国版/scripts/泰鄂美国测试版部署.cmd | 5 +++++
美国版/scripts/泰鄂美国测试版部署.ps1 | 150 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
美国版/scripts/美国版本正式环境部署.cmd | 5 +++++
美国版/scripts/美国版本正式环境部署.ps1 | 150 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
美国版/scripts/美国版本测试环境部署.cmd | 5 +++++
美国版/scripts/美国版本测试环境部署.ps1 | 150 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
31 files changed, 1464 insertions(+), 53 deletions(-)
create mode 100644 美国版/scripts/.deploy-us-test.pub
create mode 100644 美国版/scripts/_deploy-us-ssh.ps1
create mode 100644 美国版/scripts/bt-register-net-project.py
create mode 100644 美国版/scripts/fix-cors-on-server.sh
create mode 100644 美国版/scripts/nginx.flusapi-tetest.3flabeling.com.conf
create mode 100644 美国版/scripts/nginx.flusapi-teustest.3flabeling.com.conf
create mode 100644 美国版/scripts/nginx.flusapi-us.3flabeling.com.conf
create mode 100644 美国版/scripts/nginx.flusapi-ustest.3flabeling.com.conf
create mode 100644 美国版/scripts/泰鄂测试版部署.cmd
create mode 100644 美国版/scripts/泰鄂测试版部署.ps1
create mode 100644 美国版/scripts/泰鄂美国测试版部署.cmd
create mode 100644 美国版/scripts/泰鄂美国测试版部署.ps1
create mode 100644 美国版/scripts/美国版本正式环境部署.cmd
create mode 100644 美国版/scripts/美国版本正式环境部署.ps1
create mode 100644 美国版/scripts/美国版本测试环境部署.cmd
create mode 100644 美国版/scripts/美国版本测试环境部署.ps1
diff --git a/.gitignore b/.gitignore
index df1c0d3..5c3a3df 100644
--- a/.gitignore
+++ b/.gitignore
@@ -289,6 +289,14 @@ D//**/*
/D:/**
/D:/**/*
+# 美国版一键部署密钥、密码与本地发布目录
+美国版/scripts/.deploy-us-test
+美国版/scripts/.deploy-us-password
+美国版/Food Labeling Management Code/Yi.Abp.Net8/_publish-ustest/
+美国版/Food Labeling Management Code/Yi.Abp.Net8/_publish-usprod/
+美国版/Food Labeling Management Code/Yi.Abp.Net8/_publish-teustest/
+泰额版/Food Labeling Management Code/Yi.Abp.Net8/_publish-tetest/
+
# macOS 系统文件
.DS_Store
.DS_Store?
diff --git a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling/FoodLabeling.Th.Application/Services/ThTenantProvisioningAppService.cs b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling/FoodLabeling.Th.Application/Services/ThTenantProvisioningAppService.cs
index fa027c9..ba4c73a 100644
--- a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling/FoodLabeling.Th.Application/Services/ThTenantProvisioningAppService.cs
+++ b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling/FoodLabeling.Th.Application/Services/ThTenantProvisioningAppService.cs
@@ -159,12 +159,8 @@ public class ThTenantProvisioningAppService : ApplicationService, IThTenantProvi
var initializing = false;
if (input.InitializeDatabase)
{
- TenantDatabaseBootstrapper.EnsureDatabaseCreated(
- _dbConnOptions,
- dbType,
- connectionString,
- databaseName);
-
+ // 建库/CodeFirst/Seed 放到后台:HTTP 里同步 CREATE DATABASE 跨区会接近前端 10s 超时。
+ // InitAsync 内仍会 CREATE DATABASE + 建表。
_backgroundInitializer.Enqueue(created.Id);
initializing = true;
}
diff --git a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/src/Yi.Abp.Web/appsettings.json b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/src/Yi.Abp.Web/appsettings.json
index d42b098..bc00469 100644
--- a/泰额版/Food Labeling Management Code/Yi.Abp.Net8/src/Yi.Abp.Web/appsettings.json
+++ b/泰额版/Food Labeling Management Code/Yi.Abp.Net8/src/Yi.Abp.Web/appsettings.json
@@ -21,7 +21,7 @@
//应用启动:SelfUrl 供 Program.cs UseUrls 绑定;用 0.0.0.0 避免写成固定局域网 IP 在本机无该网卡时启动失败(WinError 10049)
"App": {
"SelfUrl": "http://192.168.31.87:19002",
- "CorsOrigins": "http://localhost:19002;http://localhost:18000;http://localhost:5666;http://localhost:5173;http://localhost:5174;http://localhost:3000;http://127.0.0.1:19002"
+ "CorsOrigins": "http://localhost:19002;http://localhost:18000;http://localhost:5666;http://localhost:5173;http://localhost:5174;http://localhost:3000;http://127.0.0.1:19002;http://flus-tetest.3flabeling.com;https://flus-tetest.3flabeling.com;http://flusapi-tetest.3flabeling.com;https://flusapi-tetest.3flabeling.com"
},
//配置
"Settings": {
@@ -67,9 +67,9 @@
"DbList": [ "Sqlite", "Mysql", "Sqlserver", "Oracle", "PostgreSQL" ],
"DbConnOptions": {
- "Url": "server=rm-bp19ohrgc6111ynzh1o.mysql.rds.aliyuncs.com;port=3306;database=antis-foodlabeling-host;uid=netteam;pwd=netteam;CharSet=utf8mb4;",
+ "Url": "server=rm-bp19ohrgc6111ynzh1o.mysql.rds.aliyuncs.com;port=3306;database=antis-foodlabeling-test-host;uid=netteam;pwd=netteam;CharSet=utf8mb4;",
// 高权限:仅建库/授权;租户连接串仍用 FoodLabeling:TenantDatabase 的 netteam
- "AdminConnectionString": "server=rm-bp19ohrgc6111ynzh1o.mysql.rds.aliyuncs.com;port=3306;database=antis-foodlabeling-host;uid=javateam;pwd=javateam2026;CharSet=utf8mb4;",
+ "AdminConnectionString": "server=rm-bp19ohrgc6111ynzh1o.mysql.rds.aliyuncs.com;port=3306;database=antis-foodlabeling-test-host;uid=javateam;pwd=javateam2026;CharSet=utf8mb4;",
"DbType": "MySql",
"EnabledReadWrite": false,
"EnabledCodeFirst": false,
diff --git a/泰额版/Food Labeling Management Code/Yi.Vben5.Vue3/apps/web-antd/src/api/request.ts b/泰额版/Food Labeling Management Code/Yi.Vben5.Vue3/apps/web-antd/src/api/request.ts
index 733800b..cc969e0 100644
--- a/泰额版/Food Labeling Management Code/Yi.Vben5.Vue3/apps/web-antd/src/api/request.ts
+++ b/泰额版/Food Labeling Management Code/Yi.Vben5.Vue3/apps/web-antd/src/api/request.ts
@@ -47,6 +47,7 @@ function createRequestClient(baseURL: string) {
const client = new RequestClient({
// 鍚庣鍦板潃
baseURL,
+ timeout: 60_000,
// 娑堟伅鎻愮ず绫诲瀷
errorMessageMode: 'message',
// 鏄惁杩斿洖鍘熺敓鍝嶅簲 姣斿锛氶渶瑕佽幏鍙栧搷搴斿ご鏃朵娇鐢ㄨ灞炴€?
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/Dashboard/DashboardOverviewOutputDto.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/Dashboard/DashboardOverviewOutputDto.cs
index 2b0e0e2..6abbfe0 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/Dashboard/DashboardOverviewOutputDto.cs
+++ b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application.Contracts/Dtos/Dashboard/DashboardOverviewOutputDto.cs
@@ -17,9 +17,6 @@ public class DashboardOverviewOutputDto
/// 活跃用户数
public DashboardMetricCardDto ActiveUsers { get; set; } = new();
- /// 标签数量
- public DashboardMetricCardDto Labels { get; set; } = new();
-
/// 公司数(fl_partner,按 Token 可见范围)
public DashboardMetricCardDto Companies { get; set; } = new();
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/AccountStructureCascadeDeleteHelper.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/AccountStructureCascadeDeleteHelper.cs
index 28ae1e0..7c17de0 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/AccountStructureCascadeDeleteHelper.cs
+++ b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/AccountStructureCascadeDeleteHelper.cs
@@ -278,15 +278,40 @@ public static class AccountStructureCascadeDeleteHelper
var bindings = await db.Queryable()
.Where(x => !x.IsDeleted)
- .Select(x => new { x.Id, x.LocationId })
+ .Select(x => new { x.Id, x.UserId, x.LocationId })
.ToListAsync();
- var bindingIds = bindings
+ var hitBindings = bindings
.Where(x =>
{
var key = TeamMemberListScopeHelper.NormalizeScopeKey(x.LocationId);
return !string.IsNullOrEmpty(key) && normalizedKeys.Contains(key);
})
+ .ToList();
+
+ if (hitBindings.Count == 0)
+ {
+ return;
+ }
+
+ var companyAdminUserIds = new HashSet(StringComparer.OrdinalIgnoreCase);
+ foreach (var userId in hitBindings.Select(x => x.UserId).Where(x => !string.IsNullOrWhiteSpace(x)).Distinct())
+ {
+ if (Guid.TryParse(userId.Trim(), out var userGuid)
+ && await TeamMemberRoleHelper.IsCompanyAdminUserAsync(db, userGuid))
+ {
+ companyAdminUserIds.Add(TeamMemberListScopeHelper.NormalizeScopeKey(userId));
+ }
+ }
+
+ if (companyAdminUserIds.Count > 0)
+ {
+ await RebindCompanyAdminsToRemainingLocationsAsync(
+ db, locationIds, companyAdminUserIds, now, modifierId);
+ }
+
+ var bindingIds = hitBindings
+ .Where(x => !companyAdminUserIds.Contains(TeamMemberListScopeHelper.NormalizeScopeKey(x.UserId)))
.Select(x => x.Id)
.Distinct(StringComparer.OrdinalIgnoreCase)
.ToList();
@@ -306,4 +331,73 @@ public static class AccountStructureCascadeDeleteHelper
.Where(x => bindingIds.Contains(x.Id))
.ExecuteCommandAsync();
}
+
+ ///
+ /// 删除门店时:Company Admin 改绑到该公司剩余门店,避免账号从范围里消失。
+ ///
+ private static async Task RebindCompanyAdminsToRemainingLocationsAsync(
+ ISqlSugarClient db,
+ IReadOnlyList deletedLocationIds,
+ HashSet companyAdminUserIds,
+ DateTime now,
+ string? modifierId)
+ {
+ var deletedLocs = await db.Queryable()
+ .Where(x => deletedLocationIds.Contains(x.Id))
+ .ToListAsync();
+ var partnerNames = deletedLocs
+ .Select(x => x.Partner?.Trim())
+ .Where(x => !string.IsNullOrWhiteSpace(x))
+ .Distinct(StringComparer.OrdinalIgnoreCase)
+ .ToList();
+ if (partnerNames.Count == 0)
+ {
+ return;
+ }
+
+ var remaining = await db.Queryable()
+ .Where(x => !x.IsDeleted && !deletedLocationIds.Contains(x.Id))
+ .ToListAsync();
+ var remainingIds = remaining
+ .Where(x => partnerNames.Any(n =>
+ string.Equals(n, x.Partner?.Trim(), StringComparison.OrdinalIgnoreCase)))
+ .Select(x => TeamMemberListScopeHelper.NormalizeScopeKey(x.Id.ToString("D")))
+ .Where(x => !string.IsNullOrEmpty(x))
+ .Distinct(StringComparer.OrdinalIgnoreCase)
+ .ToList();
+ if (remainingIds.Count == 0)
+ {
+ return;
+ }
+
+ foreach (var userKey in companyAdminUserIds)
+ {
+ if (!Guid.TryParse(userKey, out var userGuid))
+ {
+ continue;
+ }
+
+ var existing = await LocationScopeBindingHelper.ResolveBoundLocationIdsForUserAsync(db, userGuid);
+ var existingSet = new HashSet(existing, StringComparer.OrdinalIgnoreCase);
+ var toInsert = remainingIds.Where(id => !existingSet.Contains(id)).ToList();
+ if (toInsert.Count == 0)
+ {
+ continue;
+ }
+
+ var rows = toInsert.Select(locationId => new UserLocationDbEntity
+ {
+ Id = Guid.NewGuid().ToString("D"),
+ IsDeleted = false,
+ CreationTime = now,
+ CreatorId = modifierId,
+ LastModificationTime = now,
+ LastModifierId = modifierId,
+ UserId = TeamMemberListScopeHelper.UserKey(userGuid),
+ LocationId = locationId,
+ ConcurrencyStamp = string.Empty
+ }).ToList();
+ await db.Insertable(rows).ExecuteCommandAsync();
+ }
+ }
}
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/GroupListScopeHelper.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/GroupListScopeHelper.cs
index 80d8782..30f55f5 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/GroupListScopeHelper.cs
+++ b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/GroupListScopeHelper.cs
@@ -43,21 +43,28 @@ public static class GroupListScopeHelper
}
var db = dbContext.SqlSugarClient;
+ var isCompanyAdmin = await TeamMemberRoleHelper.IsCompanyAdminUserAsync(db, currentUser);
var locationIds = await LocationScopeBindingHelper.ResolveBoundLocationIdsForUserAsync(
db, currentUser.Id.Value);
+ if (locationIds.Count == 0 && isCompanyAdmin)
+ {
+ locationIds = await LocationScopeBindingHelper.ResolveSoftDeletedBoundLocationIdsForUserAsync(
+ db, currentUser.Id.Value);
+ }
+
if (locationIds.Count == 0)
{
return new GroupListScope();
}
var partnerIds = await LocationScopeBindingHelper.ResolvePartnerIdsFromLocationIdsAsync(
- db, locationIds);
+ db, locationIds, includeDeleted: isCompanyAdmin);
if (partnerIds.Count == 0)
{
return new GroupListScope();
}
- if (await TeamMemberRoleHelper.IsCompanyAdminUserAsync(db, currentUser))
+ if (isCompanyAdmin)
{
return new GroupListScope { AllowedPartnerIds = partnerIds };
}
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelEntityPartnerScopeHelper.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelEntityPartnerScopeHelper.cs
index b1bd4c6..ce9c6a6 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelEntityPartnerScopeHelper.cs
+++ b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelEntityPartnerScopeHelper.cs
@@ -540,6 +540,13 @@ public static class LabelEntityPartnerScopeHelper
string? groupId,
List? scopedLocationIds)
{
+ if (string.IsNullOrWhiteSpace(partnerId)
+ && string.IsNullOrWhiteSpace(groupId)
+ && scopedLocationIds is { Count: 0 })
+ {
+ return new List();
+ }
+
var pid = await ProductListScopeHelper.ResolveFilterPartnerIdAsync(
db, partnerId, groupId, scopedLocationIds);
return await ResolveScopedPartnerIdsForListAsync(db, pid);
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelTemplateLabelIdHelper.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelTemplateLabelIdHelper.cs
index 6112222..146577d 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelTemplateLabelIdHelper.cs
+++ b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelTemplateLabelIdHelper.cs
@@ -1,5 +1,6 @@
using System.Text.Json;
using System.Text.RegularExpressions;
+using FoodLabeling.Application.Contracts.Dtos.Label;
using FoodLabeling.Application.Contracts.Dtos.LabelTemplate;
namespace FoodLabeling.Application.Helpers;
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelTemplateScopeHelper.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelTemplateScopeHelper.cs
index 2373ffd..c655426 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelTemplateScopeHelper.cs
+++ b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelTemplateScopeHelper.cs
@@ -518,12 +518,8 @@ public static class LabelTemplateScopeHelper
if (scopedLocationIds.Count == 0)
{
- // 无可见门店:保留 Location=ALL(及无 location 关联)的模板
- return query.Where(t =>
- t.AppliedLocationType == ScopeAll
- || !SqlFunc.Subqueryable()
- .Where(l => l.TemplateId == t.Id)
- .Any());
+ // 非平台管理员且无可见门店:禁止漏出其它公司 Location=ALL 模板
+ return query.Where(_ => false);
}
if (!hasExtendedScope)
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LocationScopeBindingHelper.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LocationScopeBindingHelper.cs
index ade88f9..7d091be 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LocationScopeBindingHelper.cs
+++ b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LocationScopeBindingHelper.cs
@@ -56,6 +56,46 @@ public static class LocationScopeBindingHelper
}
///
+ /// Company Admin 活跃绑定被门店删除清掉后,用软删 userlocation 找回原公司门店 Id。
+ ///
+ public static async Task> ResolveSoftDeletedBoundLocationIdsForUserAsync(
+ ISqlSugarClient db,
+ Guid userId)
+ {
+ var userKey = TeamMemberListScopeHelper.UserKey(userId);
+ var userIdStr = userId.ToString("D");
+
+ var rows = await db.Ado.SqlQueryAsync(
+ """
+ SELECT LocationId
+ FROM userlocation
+ WHERE IsDeleted = 1
+ AND (
+ UserId = @UserIdD
+ OR UserId = @UserIdLower
+ OR LOWER(TRIM(UserId)) = @UserIdLower
+ )
+ """,
+ new
+ {
+ UserIdD = userIdStr,
+ UserIdLower = userKey
+ });
+
+ var locationIds = new HashSet(StringComparer.OrdinalIgnoreCase);
+ foreach (var locationId in rows)
+ {
+ var locKey = TeamMemberListScopeHelper.NormalizeScopeKey(locationId);
+ if (!string.IsNullOrEmpty(locKey))
+ {
+ locationIds.Add(locKey);
+ }
+ }
+
+ return locationIds.OrderBy(x => x, StringComparer.Ordinal).ToList();
+ }
+
+ ///
/// App 可选门店 Id:Company Admin 展开为绑定 Company 下全部门店;其它角色为 userlocation 绑定。
///
public static Task> ResolveAppAccessibleLocationIdsForUserAsync(
@@ -72,20 +112,29 @@ public static class LocationScopeBindingHelper
ICurrentUser? currentUser)
{
var locationIds = await ResolveBoundLocationIdsForUserAsync(db, userId);
+ var isCompanyAdmin = currentUser?.Id == userId
+ ? await TeamMemberRoleHelper.IsCompanyAdminUserAsync(db, currentUser)
+ : await TeamMemberRoleHelper.IsCompanyAdminUserAsync(db, userId);
if (locationIds.Count == 0)
{
- return locationIds;
+ if (!isCompanyAdmin)
+ {
+ return locationIds;
+ }
+
+ locationIds = await ResolveSoftDeletedBoundLocationIdsForUserAsync(db, userId);
+ if (locationIds.Count == 0)
+ {
+ return locationIds;
+ }
}
- var isCompanyAdmin = currentUser?.Id == userId
- ? await TeamMemberRoleHelper.IsCompanyAdminUserAsync(db, currentUser)
- : await TeamMemberRoleHelper.IsCompanyAdminUserAsync(db, userId);
if (!isCompanyAdmin)
{
return locationIds;
}
- var partnerIds = await ResolvePartnerIdsFromLocationIdsAsync(db, locationIds);
+ var partnerIds = await ResolvePartnerIdsFromLocationIdsAsync(db, locationIds, includeDeleted: true);
if (partnerIds.Count == 0)
{
return locationIds;
@@ -514,9 +563,18 @@ public static class LocationScopeBindingHelper
///
/// 根据已绑定门店反推适用的 Company Id(fl_partner.Id)。
///
+ public static Task> ResolvePartnerIdsFromLocationIdsAsync(
+ ISqlSugarClient db,
+ IReadOnlyList locationIds) =>
+ ResolvePartnerIdsFromLocationIdsAsync(db, locationIds, includeDeleted: false);
+
+ ///
+ /// 根据门店反推 Company Id; 用于门店已软删但仍需找回原公司。
+ ///
public static async Task> ResolvePartnerIdsFromLocationIdsAsync(
ISqlSugarClient db,
- IReadOnlyList locationIds)
+ IReadOnlyList locationIds,
+ bool includeDeleted)
{
var ids = NormalizeIds(locationIds);
if (ids.Count == 0)
@@ -531,7 +589,8 @@ public static class LocationScopeBindingHelper
}
var locs = await db.Queryable()
- .Where(x => !x.IsDeleted && guidList.Contains(x.Id))
+ .Where(x => guidList.Contains(x.Id))
+ .WhereIF(!includeDeleted, x => !x.IsDeleted)
.ToListAsync();
if (locs.Count == 0)
{
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/PartnerScopeHelper.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/PartnerScopeHelper.cs
index 3ec97d9..e7d37ac 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/PartnerScopeHelper.cs
+++ b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/PartnerScopeHelper.cs
@@ -41,13 +41,20 @@ public static class PartnerScopeHelper
var db = dbContext.SqlSugarClient;
var locationIds = await LocationScopeBindingHelper.ResolveBoundLocationIdsForUserAsync(
db, currentUser.Id.Value);
+ var isCompanyAdmin = await TeamMemberRoleHelper.IsCompanyAdminUserAsync(db, currentUser);
+ if (locationIds.Count == 0 && isCompanyAdmin)
+ {
+ locationIds = await LocationScopeBindingHelper.ResolveSoftDeletedBoundLocationIdsForUserAsync(
+ db, currentUser.Id.Value);
+ }
+
if (locationIds.Count == 0)
{
return new PartnerScopeFilter();
}
var allowedIds = await LocationScopeBindingHelper.ResolvePartnerIdsFromLocationIdsAsync(
- db, locationIds);
+ db, locationIds, includeDeleted: isCompanyAdmin);
return new PartnerScopeFilter { AllowedPartnerIds = allowedIds };
}
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/DashboardAppService.cs b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/DashboardAppService.cs
index 4d74358..d7dfbc7 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/DashboardAppService.cs
+++ b/美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Services/DashboardAppService.cs
@@ -92,11 +92,6 @@ public class DashboardAppService : ApplicationService, IDashboardAppService
var peoplePrevWeek = await DashboardScopeHelper.CountScopedRegisteredUsersAsync(
db, scopeLocationIds, activeOnly: false, createdBefore: weekStart);
- var labels = await DashboardScopeHelper.CountScopedLabelsAsync(
- db, _dbContext, CurrentUser, createdBefore: null);
- var labelsPrevWeek = await DashboardScopeHelper.CountScopedLabelsAsync(
- db, _dbContext, CurrentUser, createdBefore: weekStart);
-
var products = await DashboardScopeHelper.CountLocationListScopedProductsAsync(
db, CurrentUser, _dbContext);
// fl_product 当前实体未映射 CreationTime,无法按时间切分对比,先回退为同口径总量对比
@@ -243,7 +238,6 @@ public class DashboardAppService : ApplicationService, IDashboardAppService
var labelsCard = BuildMetricCard("labels", "Labels", labels, labelsPrevWeek);
var activeTemplatesCard = BuildMetricCard("activeTemplates", "Active Templates", activeTemplates, activeTemplatesPrevWeek);
var activeUsersCard = BuildMetricCard("activeUsers", "Active Users", activeUsers, activeUsersPrevWeek);
- var labelsCard = BuildMetricCard("labels", "Labels", labels, labelsPrevWeek);
var companiesCard = BuildMetricCard("companies", "Companies", companies, companiesPrevWeek);
var regionsCard = BuildMetricCard("regions", "Regions", regions, regionsPrevWeek);
var locationsCard = BuildMetricCard("locations", "Locations", locations, locationsPrevWeek);
@@ -256,7 +250,6 @@ public class DashboardAppService : ApplicationService, IDashboardAppService
Labels = labelsCard,
ActiveTemplates = activeTemplatesCard,
ActiveUsers = activeUsersCard,
- Labels = labelsCard,
Companies = companiesCard,
Regions = regionsCard,
Locations = locationsCard,
diff --git a/美国版/Food Labeling Management Code/Yi.Abp.Net8/src/Yi.Abp.Web/appsettings.json b/美国版/Food Labeling Management Code/Yi.Abp.Net8/src/Yi.Abp.Web/appsettings.json
index ac190b3..b316e9c 100644
--- a/美国版/Food Labeling Management Code/Yi.Abp.Net8/src/Yi.Abp.Web/appsettings.json
+++ b/美国版/Food Labeling Management Code/Yi.Abp.Net8/src/Yi.Abp.Web/appsettings.json
@@ -20,8 +20,8 @@
},
//应用启动:SelfUrl 供 Program.cs UseUrls 绑定;用 0.0.0.0 避免写成固定局域网 IP 在本机无该网卡时启动失败(WinError 10049)
"App": {
- "SelfUrl": "http://192.168.31.88:19003",
- "CorsOrigins": "http://localhost:19003;http://localhost:18000;http://localhost:5666;http://localhost:5174;http://localhost:5173;http://localhost:3000"
+ "SelfUrl": "http://localhost:19001",
+ "CorsOrigins": "http://localhost:19001;http://localhost:18000;http://localhost:5666;http://localhost:5174;http://localhost:5173;http://localhost:3000;http://flus-test.3flabeling.com;https://flus-test.3flabeling.com;http://flus.3flabeling.com;https://flus.3flabeling.com;http://flus-teustest.3flabeling.com;https://flus-teustest.3flabeling.com;http://flus-test.3ffoodsafety.com;https://flus-test.3ffoodsafety.com;http://flus.3ffoodsafety.com;https://flus.3ffoodsafety.com"
},
//配置
"Settings": {
@@ -31,6 +31,7 @@
"DbList": [ "Sqlite", "Mysql", "Sqlserver", "Oracle", "PostgreSQL" ],
"DbConnOptions": {
+ // 美国版数据库:本地/测试 antis-foodlabeling-test-us;正式 antis-foodlabeling-us(由正式环境部署脚本改写)
"Url": "server=rm-bp19ohrgc6111ynzh1o.mysql.rds.aliyuncs.com;port=3306;database=antis-foodlabeling-test-us;uid=netteam;pwd=netteam;CharSet=utf8mb4;",
"DbType": "Mysql",
"EnabledReadWrite": false,//是否启用读写分离
diff --git a/美国版/Food Labeling Management Platform/src/components/labels/LabelTemplateEditor/LabelCanvas.tsx b/美国版/Food Labeling Management Platform/src/components/labels/LabelTemplateEditor/LabelCanvas.tsx
index 70e87ed..b42beaa 100644
--- a/美国版/Food Labeling Management Platform/src/components/labels/LabelTemplateEditor/LabelCanvas.tsx
+++ b/美国版/Food Labeling Management Platform/src/components/labels/LabelTemplateEditor/LabelCanvas.tsx
@@ -1767,7 +1767,7 @@ function ElementContent({
commonStyle={commonStyle}
className="whitespace-nowrap"
>
- {previewFmt || '—'}
+ {previewFmt || '—'}
,
);
}
@@ -1818,7 +1818,7 @@ function ElementContent({
}
return wrapVertical(
- {example}
+ {example}
,
);
}
@@ -1833,7 +1833,7 @@ function ElementContent({
commonStyle={commonStyle}
className="whitespace-nowrap"
>
- {previewTime.trim() || '—'}
+ {previewTime.trim() || '—'}
,
);
}
@@ -1843,7 +1843,7 @@ function ElementContent({
const example = formatDateByPreset(timeFormat, d);
return wrapVertical(
- {example}
+ {example}
,
);
}
@@ -1857,7 +1857,7 @@ function ElementContent({
commonStyle={commonStyle}
className="whitespace-nowrap"
>
- {previewDur.trim() || '—'}
+ {previewDur.trim() || '—'}
,
);
}
@@ -1873,7 +1873,7 @@ function ElementContent({
const example = `${durationValue} ${unit}`;
return wrapVertical(
- {example}
+ {example}
,
);
}
@@ -2249,8 +2249,8 @@ export function LabelCanvas({
const dly = local.y - startLocalY;
if (Math.hypot(dlx, dly) < ELEMENT_DRAG_THRESHOLD_PX) return;
dragRef.current = { ...session, active: true };
- const domEl = document.getElementById(`element-${id}`);
- if (domEl) {
+ const domEl = document.getElementById(`element-${id}`);
+ if (domEl) {
domEl.classList.add(
'z-50',
'opacity-90',
@@ -2259,7 +2259,7 @@ export function LabelCanvas({
'ring-blue-400',
'ring-offset-2',
);
- domEl.style.cursor = 'grabbing';
+ domEl.style.cursor = 'grabbing';
}
}
@@ -3457,14 +3457,14 @@ export function LabelCanvas({
}
/>
) : null}
+
-
-
+
-
+
);
}
@@ -3543,8 +3543,8 @@ export function LabelPreviewOnly({
style={{
width: paperViewW,
height: paperViewH,
- }}
- >
+ }}
+ >
{template.elements.map((el) => {
const isPrintField = isPrintInputElement(el);
const isHighlighted = highlightElementId === el.id;
diff --git a/美国版/scripts/.deploy-us-test.pub b/美国版/scripts/.deploy-us-test.pub
new file mode 100644
index 0000000..dd13d12
--- /dev/null
+++ b/美国版/scripts/.deploy-us-test.pub
@@ -0,0 +1 @@
+ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDUdJucD71nTpfb0aGe4zOM4el8tiLB2bLi6x9UqGZvm flus-ustest-deploy
diff --git a/美国版/scripts/_deploy-us-ssh.ps1 b/美国版/scripts/_deploy-us-ssh.ps1
new file mode 100644
index 0000000..5f51bf9
--- /dev/null
+++ b/美国版/scripts/_deploy-us-ssh.ps1
@@ -0,0 +1,55 @@
+function Get-DeployPassword {
+ if ($env:FLUS_DEPLOY_SSH_PASSWORD) {
+ return $env:FLUS_DEPLOY_SSH_PASSWORD.Trim()
+ }
+ $passwordFile = Join-Path $ScriptDir ".deploy-us-password"
+ if (Test-Path $passwordFile) {
+ return (Get-Content $passwordFile -Raw -Encoding UTF8).Trim()
+ }
+ $sec = Read-Host "SSH root password" -AsSecureString
+ $bstr = [Runtime.InteropServices.Marshal]::SecureStringToBSTR($sec)
+ try {
+ return [Runtime.InteropServices.Marshal]::PtrToStringBSTR($bstr)
+ } finally {
+ [Runtime.InteropServices.Marshal]::ZeroFreeBSTR($bstr)
+ }
+}
+
+function Initialize-DeploySsh {
+ $pass = Get-DeployPassword
+ if ([string]::IsNullOrWhiteSpace($pass)) {
+ throw "Missing SSH password. Put it in .deploy-us-password"
+ }
+ $env:FLUS_DEPLOY_SSH_PASSWORD = $pass
+ $askPass = Join-Path $env:TEMP "flus-deploy-askpass.cmd"
+ $askBody = "@echo off" + [char]13 + [char]10 + "echo %FLUS_DEPLOY_SSH_PASSWORD%"
+ Set-Content -Path $askPass -Value $askBody -Encoding ASCII
+ $env:SSH_ASKPASS = $askPass
+ $env:SSH_ASKPASS_REQUIRE = "force"
+ $env:DISPLAY = "dummy:0"
+ $global:SshOpts = @(
+ "-o", "PreferredAuthentications=password",
+ "-o", "PubkeyAuthentication=no",
+ "-o", "KbdInteractiveAuthentication=no",
+ "-o", "NumberOfPasswordPrompts=1",
+ "-o", "StrictHostKeyChecking=accept-new"
+ )
+ Write-Host "== SSH password login check ==" -ForegroundColor Cyan
+ & ssh @global:SshOpts "${UserName}@${HostName}" "echo SSH_OK"
+ if ($LASTEXITCODE -ne 0) {
+ throw "SSH password login failed. Update .deploy-us-password"
+ }
+}
+
+function Invoke-Remote {
+ param(
+ [string]$Command,
+ [switch]$AllowFail
+ )
+ $Command = $Command -replace "`r", ""
+ $b64 = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($Command))
+ & ssh @global:SshOpts "${UserName}@${HostName}" "echo $b64 | base64 -d > /tmp/flus-deploy-run.sh && bash /tmp/flus-deploy-run.sh"
+ if (-not $AllowFail -and $LASTEXITCODE -ne 0) {
+ throw "Remote command failed"
+ }
+}
diff --git a/美国版/scripts/bt-register-net-project.py b/美国版/scripts/bt-register-net-project.py
new file mode 100644
index 0000000..ab7bbcd
--- /dev/null
+++ b/美国版/scripts/bt-register-net-project.py
@@ -0,0 +1,284 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+"""把 .NET 站点登记到宝塔 Net 项目,并写入域名 / Nginx 配置文件。"""
+import json
+import os
+import sqlite3
+import subprocess
+import sys
+import time
+
+DB_CANDIDATES = [
+ "/www/server/panel/data/db/site.db",
+ "/www/server/panel/data/default.db",
+ "/www/server/panel/data/db.db",
+]
+VHOST_NGINX = "/www/server/panel/vhost/nginx"
+VHOST_REWRITE = "/www/server/panel/vhost/rewrite"
+VHOST_CERT = "/www/server/panel/vhost/cert"
+
+
+def parse_args(argv):
+ data = {}
+ for item in argv:
+ if "=" not in item:
+ continue
+ k, v = item.split("=", 1)
+ data[k] = v
+ required = ("name", "path", "port", "cmd")
+ missing = [k for k in required if not data.get(k)]
+ if missing:
+ raise SystemExit("缺少参数: " + ",".join(missing))
+ data.setdefault("ps", data["name"])
+ data.setdefault("run_user", "root")
+ data.setdefault("dotnet_version", "8.0.100")
+ data.setdefault("domain", "")
+ return data
+
+
+def find_db():
+ for path in DB_CANDIDATES:
+ if os.path.isfile(path):
+ return path
+ raise SystemExit("找不到宝塔 site 数据库")
+
+
+def table_columns(conn, table):
+ return {row[1] for row in conn.execute("PRAGMA table_info(%s)" % table).fetchall()}
+
+
+def ensure_start_script(cfg):
+ scripts_dir = "/www/server/net_project/scripts"
+ pid_dir = "/var/tmp/net_project"
+ log_dir = "/www/wwwlogs/net"
+ os.makedirs(scripts_dir, exist_ok=True)
+ os.makedirs(pid_dir, exist_ok=True)
+ os.makedirs(log_dir, exist_ok=True)
+ os.chmod(pid_dir, 0o777)
+ script = os.path.join(scripts_dir, "%s.sh" % cfg["name"])
+ log_file = os.path.join(log_dir, "%s.log" % cfg["name"])
+ pid_file = os.path.join(pid_dir, "%s.pid" % cfg["name"])
+ body = """#!/bin/bash
+PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
+export PATH
+cd {path}
+nohup {cmd} &>> {log_file} &
+echo $! > {pid_file}
+""".format(path=cfg["path"], cmd=cfg["cmd"], log_file=log_file, pid_file=pid_file)
+ with open(script, "w", encoding="utf-8") as fh:
+ fh.write(body)
+ os.chmod(script, 0o755)
+ return script
+
+
+def insert_site(conn, cfg):
+ cols = table_columns(conn, "sites")
+ exists = conn.execute("SELECT id,name,path FROM sites WHERE name=?", (cfg["name"],)).fetchone()
+ domain = (cfg.get("domain") or "").strip()
+ domains = ["%s:80" % domain] if domain else []
+ project_config = json.dumps(
+ {
+ "ssl_path": "/www/wwwroot/net_node_ssl",
+ "project_name": cfg["name"],
+ "bind_extranet": 1 if domain else 0,
+ "domains": domains,
+ "project_path": cfg["path"],
+ "project_cmd": cfg["cmd"],
+ "is_power_on": 1,
+ "run_user": cfg["run_user"],
+ "port": int(cfg["port"]),
+ "log_path": "/www/wwwlogs/net",
+ "dotnet_version": cfg["dotnet_version"],
+ },
+ ensure_ascii=False,
+ )
+ now = time.strftime("%Y-%m-%d %H:%M:%S")
+ values = {
+ "name": cfg["name"],
+ "path": cfg["path"],
+ "ps": cfg["ps"],
+ "status": 1,
+ "type_id": 0,
+ "project_type": "net",
+ "project_config": project_config,
+ "addtime": now,
+ "edate": "0000-00-00",
+ }
+ values = {k: v for k, v in values.items() if k in cols}
+ if exists:
+ sets = ", ".join("%s=?" % k for k in values if k != "name")
+ params = [values[k] for k in values if k != "name"] + [cfg["name"]]
+ conn.execute("UPDATE sites SET %s WHERE name=?" % sets, params)
+ conn.commit()
+ print("UPDATED id=%s name=%s" % (exists[0], cfg["name"]))
+ return exists[0]
+ keys = list(values.keys())
+ sql = "INSERT INTO sites (%s) VALUES (%s)" % (",".join(keys), ",".join("?" * len(keys)))
+ cur = conn.execute(sql, [values[k] for k in keys])
+ conn.commit()
+ print("INSERTED id=%s name=%s" % (cur.lastrowid, cfg["name"]))
+ return cur.lastrowid
+
+
+def insert_domain(conn, site_id, cfg):
+ domain = (cfg.get("domain") or "").strip()
+ if not domain:
+ return
+ tables = [r[0] for r in conn.execute("SELECT name FROM sqlite_master WHERE type='table'").fetchall()]
+ if "domain" not in tables:
+ print("SKIP domain table missing")
+ return
+ cols = table_columns(conn, "domain")
+ conn.execute("DELETE FROM domain WHERE pid=?", (site_id,))
+ now = time.strftime("%Y-%m-%d %H:%M:%S")
+ row = {"name": domain, "pid": site_id, "port": 80, "addtime": now}
+ row = {k: v for k, v in row.items() if k in cols}
+ keys = list(row.keys())
+ conn.execute(
+ "INSERT INTO domain (%s) VALUES (%s)" % (",".join(keys), ",".join("?" * len(keys))),
+ [row[k] for k in keys],
+ )
+ conn.commit()
+ print("DOMAIN %s pid=%s" % (domain, site_id))
+
+
+def write_nginx_conf(cfg):
+ domain = (cfg.get("domain") or "").strip()
+ if not domain:
+ return
+ os.makedirs(VHOST_NGINX, exist_ok=True)
+ os.makedirs(VHOST_REWRITE, exist_ok=True)
+ name = cfg["name"]
+ port = cfg["port"]
+ conf_path = os.path.join(VHOST_NGINX, "net_%s.conf" % name)
+ rewrite_path = os.path.join(VHOST_REWRITE, "net_%s.conf" % name)
+ live = "/etc/letsencrypt/live/%s" % domain
+ cert_dir = os.path.join(VHOST_CERT, name)
+ os.makedirs(cert_dir, exist_ok=True)
+ if os.path.isfile(os.path.join(live, "fullchain.pem")):
+ for fname in ("fullchain.pem", "privkey.pem"):
+ src = os.path.join(live, fname)
+ dst = os.path.join(cert_dir, fname)
+ if os.path.islink(dst) or os.path.exists(dst):
+ try:
+ os.remove(dst)
+ except OSError:
+ pass
+ os.symlink(src, dst)
+ ssl_cert = os.path.join(live, "fullchain.pem")
+ ssl_key = os.path.join(live, "privkey.pem")
+ ssl_include = ""
+ if os.path.isfile("/etc/letsencrypt/options-ssl-nginx.conf"):
+ ssl_include = " include /etc/letsencrypt/options-ssl-nginx.conf;\n"
+ if os.path.isfile("/etc/letsencrypt/ssl-dhparams.pem"):
+ ssl_include += " ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;\n"
+ ssl_server = """
+server {{
+ listen 443 ssl;
+ listen [::]:443 ssl;
+ server_name {domain};
+ ssl_certificate {ssl_cert};
+ ssl_certificate_key {ssl_key};
+{ssl_include} access_log /www/wwwlogs/{domain}.access.log;
+ error_log /www/wwwlogs/{domain}.error.log;
+ client_max_body_size 50m;
+ include {rewrite};
+ location / {{
+ proxy_pass http://127.0.0.1:{port};
+ proxy_http_version 1.1;
+ proxy_set_header Host $host;
+ proxy_set_header X-Real-IP $remote_addr;
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+ proxy_set_header X-Forwarded-Proto $scheme;
+ proxy_set_header Upgrade $http_upgrade;
+ proxy_set_header Connection $connection_upgrade;
+ proxy_read_timeout 300s;
+ proxy_send_timeout 300s;
+ }}
+}}
+""".format(domain=domain, ssl_cert=ssl_cert, ssl_key=ssl_key, ssl_include=ssl_include,
+ rewrite=rewrite_path, port=port)
+ http_extra = """ client_max_body_size 50m;
+ location / {
+ proxy_pass http://127.0.0.1:%s;
+ proxy_http_version 1.1;
+ proxy_set_header Host $host;
+ proxy_set_header X-Real-IP $remote_addr;
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+ proxy_set_header X-Forwarded-Proto $scheme;
+ proxy_set_header Upgrade $http_upgrade;
+ proxy_set_header Connection $connection_upgrade;
+ proxy_read_timeout 300s;
+ proxy_send_timeout 300s;
+ }
+""" % port
+ else:
+ ssl_server = ""
+ http_extra = """ location / {
+ proxy_pass http://127.0.0.1:%s;
+ proxy_http_version 1.1;
+ proxy_set_header Host $host;
+ proxy_set_header X-Real-IP $remote_addr;
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+ proxy_set_header X-Forwarded-Proto $scheme;
+ proxy_read_timeout 300s;
+ proxy_send_timeout 300s;
+ }
+""" % port
+
+ body = """server {{
+ listen 80;
+ listen [::]:80;
+ server_name {domain};
+ location /.well-known/acme-challenge/ {{
+ root /www/wwwroot/letsencrypt;
+ allow all;
+ }}
+{http_extra}}}
+{ssl_server}
+""".format(domain=domain, http_extra=http_extra, ssl_server=ssl_server)
+
+ with open(conf_path, "w", encoding="utf-8") as fh:
+ fh.write(body)
+ if not os.path.isfile(rewrite_path):
+ with open(rewrite_path, "w", encoding="utf-8") as fh:
+ fh.write("# 请将伪静态规则或自定义NGINX配置填写到此处\n")
+ old = os.path.join(VHOST_NGINX, "%s.conf" % domain)
+ if os.path.isfile(old) and os.path.abspath(old) != os.path.abspath(conf_path):
+ os.rename(old, old + ".bak")
+ print("MOVED %s -> .bak" % old)
+ print("NGINX %s" % conf_path)
+
+
+def reload_nginx():
+ nginx = "/www/server/nginx/sbin/nginx"
+ conf = "/www/server/nginx/conf/nginx.conf"
+ if not os.path.isfile(nginx):
+ return
+ test = subprocess.run([nginx, "-t", "-c", conf], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ out = test.stdout.decode("utf-8", "ignore")
+ print(out)
+ if test.returncode != 0:
+ print("NGINX_TEST_FAIL skip reload")
+ return
+ subprocess.run([nginx, "-s", "reload"], check=False)
+ print("NGINX_RELOADED")
+
+
+def main():
+ cfg = parse_args(sys.argv[1:])
+ ensure_start_script(cfg)
+ db = find_db()
+ conn = sqlite3.connect(db)
+ try:
+ site_id = insert_site(conn, cfg)
+ insert_domain(conn, site_id, cfg)
+ finally:
+ conn.close()
+ write_nginx_conf(cfg)
+ reload_nginx()
+ print("BT_REGISTER_OK %s %s domain=%s" % (cfg["name"], cfg["path"], cfg.get("domain") or ""))
+
+
+if __name__ == "__main__":
+ main()
diff --git a/美国版/scripts/fix-cors-on-server.sh b/美国版/scripts/fix-cors-on-server.sh
new file mode 100644
index 0000000..6eab920
--- /dev/null
+++ b/美国版/scripts/fix-cors-on-server.sh
@@ -0,0 +1,71 @@
+#!/bin/bash
+# 在宝塔「终端」粘贴执行:补 CORS + HTTP 反代(不要 301 OPTIONS)
+set -e
+python3 - <<'PY'
+import re, pathlib
+
+cors_test = (
+ "http://0.0.0.0:19003;http://localhost:19003;"
+ "https://flusapi-ustest.3flabeling.com;http://flusapi-ustest.3flabeling.com;"
+ "http://flus-test.3flabeling.com;https://flus-test.3flabeling.com;"
+ "http://flus-test.3ffoodsafety.com;https://flus-test.3ffoodsafety.com;"
+ "http://localhost:18000;http://localhost:5666;http://localhost:5174;http://localhost:5173;http://localhost:3000"
+)
+cors_prod = (
+ "http://0.0.0.0:19001;http://localhost:19001;"
+ "https://flusapi-us.3flabeling.com;http://flusapi-us.3flabeling.com;"
+ "http://flus.3flabeling.com;https://flus.3flabeling.com;"
+ "http://flus.3ffoodsafety.com;https://flus.3ffoodsafety.com;"
+ "http://localhost:18000;http://localhost:5666;http://localhost:5174;http://localhost:5173;http://localhost:3000"
+)
+pairs = {
+ "/www/wwwroot/FoodLabelingManagementUsTest/appsettings.json": cors_test,
+ "/www/wwwroot/FoodLabelingManagementUs/appsettings.json": cors_prod,
+}
+for path, cors in pairs.items():
+ p = pathlib.Path(path)
+ if not p.is_file():
+ print("skip missing", path)
+ continue
+ text = p.read_text(encoding="utf-8")
+ text2, n = re.subn(r'"CorsOrigins"\s*:\s*"[^"]*"', '"CorsOrigins": "' + cors + '"', text, count=1)
+ p.write_text(text2, encoding="utf-8")
+ print("cors", path, n)
+
+proxy = r''' location / {
+ proxy_pass http://127.0.0.1:PORTNUM;
+ proxy_http_version 1.1;
+ proxy_set_header Host $host;
+ proxy_set_header X-Real-IP $remote_addr;
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+ proxy_set_header X-Forwarded-Proto $scheme;
+ proxy_set_header Upgrade $http_upgrade;
+ proxy_set_header Connection $connection_upgrade;
+ proxy_read_timeout 300s;
+ proxy_send_timeout 300s;
+ }
+'''
+import glob
+for conf in glob.glob("/www/server/panel/vhost/nginx/*.conf"):
+ t = pathlib.Path(conf).read_text(encoding="utf-8", errors="ignore")
+ if "flusapi-ustest.3flabeling.com" in t:
+ t2 = t.replace("return 301 https://$host$request_uri;", proxy.replace("PORTNUM", "19003"))
+ pathlib.Path(conf).write_text(t2, encoding="utf-8")
+ print("nginx http proxy", conf)
+ elif "flusapi-us.3flabeling.com" in t:
+ t2 = t.replace("return 301 https://$host$request_uri;", proxy.replace("PORTNUM", "19001"))
+ pathlib.Path(conf).write_text(t2, encoding="utf-8")
+ print("nginx http proxy", conf)
+PY
+/www/server/nginx/sbin/nginx -t -c /www/server/nginx/conf/nginx.conf
+/www/server/nginx/sbin/nginx -s reload
+pkill -f /www/wwwroot/FoodLabelingManagementUsTest/Yi.Abp.Web.dll || true
+pkill -f /www/wwwroot/FoodLabelingManagementUs/Yi.Abp.Web.dll || true
+sleep 1
+mkdir -p /www/wwwlogs/net /var/tmp/net_project
+nohup /www/server/dotnet/8.0.100/dotnet /www/wwwroot/FoodLabelingManagementUsTest/Yi.Abp.Web.dll --urls=http://0.0.0.0:19003 >> /www/wwwlogs/net/食品标签美国测试版.log 2>&1 &
+echo $! > /var/tmp/net_project/食品标签美国测试版.pid
+nohup /www/server/dotnet/8.0.100/dotnet /www/wwwroot/FoodLabelingManagementUs/Yi.Abp.Web.dll --urls=http://0.0.0.0:19001 >> /www/wwwlogs/net/食品标签美国正式版.log 2>&1 &
+echo $! > /var/tmp/net_project/食品标签美国正式版.pid
+sleep 4
+echo DONE
diff --git a/美国版/scripts/nginx.flusapi-tetest.3flabeling.com.conf b/美国版/scripts/nginx.flusapi-tetest.3flabeling.com.conf
new file mode 100644
index 0000000..45dbaae
--- /dev/null
+++ b/美国版/scripts/nginx.flusapi-tetest.3flabeling.com.conf
@@ -0,0 +1,49 @@
+# 食品标签泰鄂测试版 API 反代(宝塔 nginx vhost)
+# HTTP 也反代,避免前端走 http:// API 时 OPTIONS 预检被 301 导致 CORS 失败。
+server {
+ listen 80;
+ listen [::]:80;
+ server_name flusapi-tetest.3flabeling.com;
+ location /.well-known/acme-challenge/ {
+ root /www/wwwroot/letsencrypt;
+ allow all;
+ }
+ client_max_body_size 50m;
+ location / {
+ proxy_pass http://127.0.0.1:19002;
+ proxy_http_version 1.1;
+ proxy_set_header Host $host;
+ proxy_set_header X-Real-IP $remote_addr;
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+ proxy_set_header X-Forwarded-Proto $scheme;
+ proxy_set_header Upgrade $http_upgrade;
+ proxy_set_header Connection $connection_upgrade;
+ proxy_read_timeout 300s;
+ proxy_send_timeout 300s;
+ }
+}
+
+server {
+ listen 443 ssl;
+ listen [::]:443 ssl;
+ server_name flusapi-tetest.3flabeling.com;
+ ssl_certificate /etc/letsencrypt/live/flusapi-tetest.3flabeling.com/fullchain.pem;
+ ssl_certificate_key /etc/letsencrypt/live/flusapi-tetest.3flabeling.com/privkey.pem;
+ include /etc/letsencrypt/options-ssl-nginx.conf;
+ ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
+ access_log /www/wwwlogs/flusapi-tetest.3flabeling.com.access.log;
+ error_log /www/wwwlogs/flusapi-tetest.3flabeling.com.error.log;
+ client_max_body_size 50m;
+ location / {
+ proxy_pass http://127.0.0.1:19002;
+ proxy_http_version 1.1;
+ proxy_set_header Host $host;
+ proxy_set_header X-Real-IP $remote_addr;
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+ proxy_set_header X-Forwarded-Proto $scheme;
+ proxy_set_header Upgrade $http_upgrade;
+ proxy_set_header Connection $connection_upgrade;
+ proxy_read_timeout 300s;
+ proxy_send_timeout 300s;
+ }
+}
diff --git a/美国版/scripts/nginx.flusapi-teustest.3flabeling.com.conf b/美国版/scripts/nginx.flusapi-teustest.3flabeling.com.conf
new file mode 100644
index 0000000..1eb71d3
--- /dev/null
+++ b/美国版/scripts/nginx.flusapi-teustest.3flabeling.com.conf
@@ -0,0 +1,49 @@
+# 食品标签泰鄂美国测试版 API 反代(宝塔 nginx vhost)
+# HTTP 也反代,避免前端走 http:// API 时 OPTIONS 预检被 301 导致 CORS 失败。
+server {
+ listen 80;
+ listen [::]:80;
+ server_name flusapi-teustest.3flabeling.com;
+ location /.well-known/acme-challenge/ {
+ root /www/wwwroot/letsencrypt;
+ allow all;
+ }
+ client_max_body_size 50m;
+ location / {
+ proxy_pass http://127.0.0.1:19004;
+ proxy_http_version 1.1;
+ proxy_set_header Host $host;
+ proxy_set_header X-Real-IP $remote_addr;
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+ proxy_set_header X-Forwarded-Proto $scheme;
+ proxy_set_header Upgrade $http_upgrade;
+ proxy_set_header Connection $connection_upgrade;
+ proxy_read_timeout 300s;
+ proxy_send_timeout 300s;
+ }
+}
+
+server {
+ listen 443 ssl;
+ listen [::]:443 ssl;
+ server_name flusapi-teustest.3flabeling.com;
+ ssl_certificate /etc/letsencrypt/live/flusapi-teustest.3flabeling.com/fullchain.pem;
+ ssl_certificate_key /etc/letsencrypt/live/flusapi-teustest.3flabeling.com/privkey.pem;
+ include /etc/letsencrypt/options-ssl-nginx.conf;
+ ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
+ access_log /www/wwwlogs/flusapi-teustest.access.log;
+ error_log /www/wwwlogs/flusapi-teustest.error.log;
+ client_max_body_size 50m;
+ location / {
+ proxy_pass http://127.0.0.1:19004;
+ proxy_http_version 1.1;
+ proxy_set_header Host $host;
+ proxy_set_header X-Real-IP $remote_addr;
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+ proxy_set_header X-Forwarded-Proto $scheme;
+ proxy_set_header Upgrade $http_upgrade;
+ proxy_set_header Connection $connection_upgrade;
+ proxy_read_timeout 300s;
+ proxy_send_timeout 300s;
+ }
+}
diff --git a/美国版/scripts/nginx.flusapi-us.3flabeling.com.conf b/美国版/scripts/nginx.flusapi-us.3flabeling.com.conf
new file mode 100644
index 0000000..8e8db9e
--- /dev/null
+++ b/美国版/scripts/nginx.flusapi-us.3flabeling.com.conf
@@ -0,0 +1,49 @@
+# 美国版正式环境 API 反代(宝塔 nginx vhost)
+# HTTP 也反代,避免前端走 http:// API 时 OPTIONS 预检被 301 导致 CORS 失败。
+server {
+ listen 80;
+ listen [::]:80;
+ server_name flusapi-us.3flabeling.com;
+ location /.well-known/acme-challenge/ {
+ root /www/wwwroot/letsencrypt;
+ allow all;
+ }
+ client_max_body_size 50m;
+ location / {
+ proxy_pass http://127.0.0.1:19001;
+ proxy_http_version 1.1;
+ proxy_set_header Host $host;
+ proxy_set_header X-Real-IP $remote_addr;
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+ proxy_set_header X-Forwarded-Proto $scheme;
+ proxy_set_header Upgrade $http_upgrade;
+ proxy_set_header Connection $connection_upgrade;
+ proxy_read_timeout 300s;
+ proxy_send_timeout 300s;
+ }
+}
+
+server {
+ listen 443 ssl;
+ listen [::]:443 ssl;
+ server_name flusapi-us.3flabeling.com;
+ ssl_certificate /etc/letsencrypt/live/flusapi-us.3flabeling.com/fullchain.pem;
+ ssl_certificate_key /etc/letsencrypt/live/flusapi-us.3flabeling.com/privkey.pem;
+ include /etc/letsencrypt/options-ssl-nginx.conf;
+ ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
+ access_log /www/wwwlogs/flusapi-us.access.log;
+ error_log /www/wwwlogs/flusapi-us.error.log;
+ client_max_body_size 50m;
+ location / {
+ proxy_pass http://127.0.0.1:19001;
+ proxy_http_version 1.1;
+ proxy_set_header Host $host;
+ proxy_set_header X-Real-IP $remote_addr;
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+ proxy_set_header X-Forwarded-Proto $scheme;
+ proxy_set_header Upgrade $http_upgrade;
+ proxy_set_header Connection $connection_upgrade;
+ proxy_read_timeout 300s;
+ proxy_send_timeout 300s;
+ }
+}
diff --git a/美国版/scripts/nginx.flusapi-ustest.3flabeling.com.conf b/美国版/scripts/nginx.flusapi-ustest.3flabeling.com.conf
new file mode 100644
index 0000000..0d9a844
--- /dev/null
+++ b/美国版/scripts/nginx.flusapi-ustest.3flabeling.com.conf
@@ -0,0 +1,49 @@
+# 美国版测试环境 API 反代(宝塔 nginx vhost)
+# HTTP 也反代,避免前端走 http:// API 时 OPTIONS 预检被 301 导致 CORS 失败。
+server {
+ listen 80;
+ listen [::]:80;
+ server_name flusapi-ustest.3flabeling.com;
+ location /.well-known/acme-challenge/ {
+ root /www/wwwroot/letsencrypt;
+ allow all;
+ }
+ client_max_body_size 50m;
+ location / {
+ proxy_pass http://127.0.0.1:19003;
+ proxy_http_version 1.1;
+ proxy_set_header Host $host;
+ proxy_set_header X-Real-IP $remote_addr;
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+ proxy_set_header X-Forwarded-Proto $scheme;
+ proxy_set_header Upgrade $http_upgrade;
+ proxy_set_header Connection $connection_upgrade;
+ proxy_read_timeout 300s;
+ proxy_send_timeout 300s;
+ }
+}
+
+server {
+ listen 443 ssl;
+ listen [::]:443 ssl;
+ server_name flusapi-ustest.3flabeling.com;
+ ssl_certificate /etc/letsencrypt/live/flusapi-ustest.3flabeling.com/fullchain.pem;
+ ssl_certificate_key /etc/letsencrypt/live/flusapi-ustest.3flabeling.com/privkey.pem;
+ include /etc/letsencrypt/options-ssl-nginx.conf;
+ ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
+ access_log /www/wwwlogs/flusapi-ustest.access.log;
+ error_log /www/wwwlogs/flusapi-ustest.error.log;
+ client_max_body_size 50m;
+ location / {
+ proxy_pass http://127.0.0.1:19003;
+ proxy_http_version 1.1;
+ proxy_set_header Host $host;
+ proxy_set_header X-Real-IP $remote_addr;
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+ proxy_set_header X-Forwarded-Proto $scheme;
+ proxy_set_header Upgrade $http_upgrade;
+ proxy_set_header Connection $connection_upgrade;
+ proxy_read_timeout 300s;
+ proxy_send_timeout 300s;
+ }
+}
diff --git a/美国版/scripts/泰鄂测试版部署.cmd b/美国版/scripts/泰鄂测试版部署.cmd
new file mode 100644
index 0000000..f32f74d
--- /dev/null
+++ b/美国版/scripts/泰鄂测试版部署.cmd
@@ -0,0 +1,5 @@
+@echo off
+cd /d "%~dp0"
+powershell.exe -NoProfile -ExecutionPolicy Bypass -File "%~dp0%~n0.ps1" %*
+echo.
+pause
diff --git a/美国版/scripts/泰鄂测试版部署.ps1 b/美国版/scripts/泰鄂测试版部署.ps1
new file mode 100644
index 0000000..9511a5f
--- /dev/null
+++ b/美国版/scripts/泰鄂测试版部署.ps1
@@ -0,0 +1,167 @@
+#Requires -Version 5.1
+<#
+.SYNOPSIS
+ 食品标签泰鄂测试版 API 一键部署
+.DESCRIPTION
+ 发布泰鄂版 Yi.Abp.Web,上传到 47.253.11.59,重启 Kestrel 19002,健康检查 https://flusapi-tetest.3flabeling.com
+#>
+param(
+ [switch]$SkipBuild
+)
+
+$ErrorActionPreference = "Stop"
+$HostName = "47.253.11.59"
+$UserName = "root"
+$RemoteDir = "/www/wwwroot/FoodLabelingManagementTeTest"
+$Dotnet = "/www/server/dotnet/8.0.100/dotnet"
+$AppDll = "$RemoteDir/Yi.Abp.Web.dll"
+$HealthUrl = "https://flusapi-tetest.3flabeling.com/swagger/index.html"
+$ListenUrl = "http://0.0.0.0:19002"
+$Cors = "http://0.0.0.0:19002;http://localhost:19002;http://127.0.0.1:19002;https://flusapi-tetest.3flabeling.com;http://flusapi-tetest.3flabeling.com;http://flus-tetest.3flabeling.com;https://flus-tetest.3flabeling.com;http://localhost:18000;http://localhost:5666;http://localhost:5174;http://localhost:5173;http://localhost:3000"
+$DbHost = "rm-0xi95hpp522z6c62w.mysql.rds-aliyun-america.rds.aliyuncs.com"
+$ChinaDbHost = "rm-bp19ohrgc6111ynzh1o.mysql.rds.aliyuncs.com"
+$DbUser = "root"
+$DbPassword = 'Te2026@antis!'
+$TestDbName = "antis-foodlabeling-test-host"
+$BtName = "食品标签泰鄂测试版"
+$BtDomain = "flusapi-tetest.3flabeling.com"
+$BtCmd = "{0} {1} --urls={2}" -f $Dotnet, $AppDll, $ListenUrl
+
+$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
+$RepoRoot = Resolve-Path (Join-Path $ScriptDir "..\..")
+$WebCsproj = Join-Path $RepoRoot "泰额版\Food Labeling Management Code\Yi.Abp.Net8\src\Yi.Abp.Web\Yi.Abp.Web.csproj"
+$PublishDir = Join-Path $RepoRoot "泰额版\Food Labeling Management Code\Yi.Abp.Net8\_publish-tetest"
+. (Join-Path $ScriptDir "_deploy-us-ssh.ps1")
+Initialize-DeploySsh
+$SshOpts = $global:SshOpts
+
+Write-Host "== 食品标签泰鄂测试版部署 ==" -ForegroundColor Cyan
+Write-Host "目标: $HostName $RemoteDir"
+Write-Host "域名: $HealthUrl"
+Write-Host "数据库: $TestDbName @ $DbHost"
+
+if (-not $SkipBuild) {
+ if (-not (Test-Path $WebCsproj)) { throw "找不到工程: $WebCsproj" }
+ Write-Host "== 发布泰鄂版 Yi.Abp.Web ==" -ForegroundColor Cyan
+ if (Test-Path $PublishDir) { Remove-Item $PublishDir -Recurse -Force }
+ & dotnet publish $WebCsproj -c Release -o $PublishDir --nologo
+ if ($LASTEXITCODE -ne 0) { throw "dotnet publish 失败" }
+
+ $appsettings = Join-Path $PublishDir "appsettings.json"
+ if (Test-Path $appsettings) {
+ $json = Get-Content $appsettings -Raw -Encoding UTF8
+ $json = [regex]::Replace($json, '"SelfUrl"\s*:\s*"[^"]*"', '"SelfUrl": "' + $ListenUrl + '"')
+ $json = [regex]::Replace($json, '"CorsOrigins"\s*:\s*"[^"]*"', '"CorsOrigins": "' + $Cors + '"')
+ $json = $json.Replace($ChinaDbHost, $DbHost)
+ $json = [regex]::Replace($json, 'server=[^;]+', "server=$DbHost")
+ $json = [regex]::Replace($json, '"Server"\s*:\s*"rm-[^"]*"', '"Server": "' + $DbHost + '"')
+ $json = [regex]::Replace($json, 'database=antis-foodlabeling-[^;]+', "database=$TestDbName")
+ $json = [regex]::Replace($json, '"DatabaseName"\s*:\s*"antis-foodlabeling-host"', '"DatabaseName": "' + $TestDbName + '"')
+ $json = [regex]::Replace($json, 'uid=netteam', "uid=$DbUser")
+ $json = [regex]::Replace($json, 'pwd=netteam', "pwd=$DbPassword")
+ $json = [regex]::Replace($json, 'uid=javateam', "uid=$DbUser")
+ $json = [regex]::Replace($json, 'pwd=javateam2026', "pwd=$DbPassword")
+ $json = [regex]::Replace($json, '"UserId"\s*:\s*"netteam"', '"UserId": "' + $DbUser + '"')
+ $json = [regex]::Replace($json, '"Password"\s*:\s*"netteam"', '"Password": "' + $DbPassword + '"')
+ $json = [regex]::Replace($json, '"TemplateDirectory"\s*:\s*"[^"]*"', '"TemplateDirectory": "' + $RemoteDir + '/batchImportOfFiles"')
+ Set-Content -Path $appsettings -Value $json -Encoding UTF8
+ }
+}
+
+if (-not (Test-Path (Join-Path $PublishDir "Yi.Abp.Web.dll"))) {
+ throw "发布目录缺少 Yi.Abp.Web.dll: $PublishDir"
+}
+
+Write-Host "== 停止远程进程 ==" -ForegroundColor Cyan
+Invoke-Remote @'
+set -e
+if [ -f "/var/tmp/net_project/食品标签泰鄂测试版.pid" ]; then
+ pid=$(cat "/var/tmp/net_project/食品标签泰鄂测试版.pid" || true)
+ if [ -n "$pid" ]; then kill "$pid" 2>/dev/null || true; fi
+fi
+pkill -f "/www/wwwroot/FoodLabelingManagementTeTest/Yi.Abp.Web.dll" 2>/dev/null || true
+sleep 1
+echo stopped
+'@
+
+Write-Host "== 上传发布包 ==" -ForegroundColor Cyan
+$tar = Join-Path $env:TEMP "flus-tetest-publish.tgz"
+if (Test-Path $tar) { Remove-Item $tar -Force }
+Push-Location $PublishDir
+try {
+ & tar -czf $tar --exclude=logs --exclude=startup.log *
+ if ($LASTEXITCODE -ne 0) { throw "打包失败" }
+} finally {
+ Pop-Location
+}
+
+& scp @SshOpts $tar "${UserName}@${HostName}:/tmp/flus-tetest-publish.tgz"
+if ($LASTEXITCODE -ne 0) { throw "scp 失败" }
+
+Invoke-Remote @"
+set -e
+mkdir -p '$RemoteDir'
+cd '$RemoteDir'
+for x in *; do
+ case "`$x" in
+ logs|*.log) ;;
+ *) rm -rf "`$x" ;;
+ esac
+done
+tar --overwrite -xzf /tmp/flus-tetest-publish.tgz -C '$RemoteDir'
+rm -f /tmp/flus-tetest-publish.tgz
+chmod -R a+rX '$RemoteDir'
+ls -l '$RemoteDir/Yi.Abp.Web.dll'
+echo uploaded_to=$RemoteDir
+"@
+
+Write-Host "== 登记宝塔 Net 项目 ==" -ForegroundColor Cyan
+$btPyLocal = Join-Path $ScriptDir "bt-register-net-project.py"
+& scp @SshOpts $btPyLocal "${UserName}@${HostName}:/tmp/bt-register-net-project.py"
+if ($LASTEXITCODE -ne 0) { throw "上传宝塔登记脚本失败" }
+Invoke-Remote @"
+set -e
+sed -i 's/\r`$//' /tmp/bt-register-net-project.py
+python3 /tmp/bt-register-net-project.py name='$BtName' path='$RemoteDir' port='19002' ps='$BtName' domain='$BtDomain' cmd='$BtCmd' run_user='root' dotnet_version='8.0.100'
+"@
+
+Write-Host "== 启动 API ==" -ForegroundColor Cyan
+Invoke-Remote -AllowFail @"
+mkdir -p /www/wwwlogs/net /var/tmp/net_project
+if [ ! -f /swapfile ]; then
+ fallocate -l 2G /swapfile || dd if=/dev/zero of=/swapfile bs=1M count=2048
+ chmod 600 /swapfile
+ mkswap /swapfile
+ swapon /swapfile
+ grep -q '^/swapfile ' /etc/fstab || echo '/swapfile none swap sw 0 0' >> /etc/fstab
+fi
+swapon -a || true
+cd '$RemoteDir'
+setsid nohup $Dotnet '$AppDll' --urls=$ListenUrl >> /www/wwwlogs/net/食品标签泰鄂测试版.log 2>&1 < /dev/null &
+echo `$! > /var/tmp/net_project/食品标签泰鄂测试版.pid
+sleep 15
+ss -lntp | grep 19002 || true
+curl -s -o /dev/null -w 'local=%{http_code}\n' --max-time 15 http://127.0.0.1:19002/swagger/index.html || true
+tail -n 30 /www/wwwlogs/net/食品标签泰鄂测试版.log || true
+"@
+
+Write-Host "== 健康检查 ==" -ForegroundColor Cyan
+$ok = $false
+for ($i = 1; $i -le 10; $i++) {
+ try {
+ $resp = Invoke-WebRequest -Uri $HealthUrl -UseBasicParsing -TimeoutSec 15
+ if ($resp.StatusCode -eq 200) {
+ Write-Host "访问成功: $HealthUrl HTTP $($resp.StatusCode)" -ForegroundColor Green
+ $ok = $true
+ break
+ }
+ } catch {
+ Write-Host "等待服务就绪 ($i/10)..."
+ Start-Sleep -Seconds 3
+ }
+}
+
+if (-not $ok) { throw "部署后健康检查失败: $HealthUrl" }
+Write-Host "完成。API: https://flusapi-tetest.3flabeling.com" -ForegroundColor Green
+Write-Host "Swagger: $HealthUrl"
+Write-Host "登录: POST https://flusapi-tetest.3flabeling.com/api/app/th-web-auth/login"
diff --git a/美国版/scripts/泰鄂美国测试版部署.cmd b/美国版/scripts/泰鄂美国测试版部署.cmd
new file mode 100644
index 0000000..f32f74d
--- /dev/null
+++ b/美国版/scripts/泰鄂美国测试版部署.cmd
@@ -0,0 +1,5 @@
+@echo off
+cd /d "%~dp0"
+powershell.exe -NoProfile -ExecutionPolicy Bypass -File "%~dp0%~n0.ps1" %*
+echo.
+pause
diff --git a/美国版/scripts/泰鄂美国测试版部署.ps1 b/美国版/scripts/泰鄂美国测试版部署.ps1
new file mode 100644
index 0000000..6852799
--- /dev/null
+++ b/美国版/scripts/泰鄂美国测试版部署.ps1
@@ -0,0 +1,150 @@
+#Requires -Version 5.1
+<#
+.SYNOPSIS
+ 泰鄂美国测试版 API 一键部署
+.DESCRIPTION
+ 发布 Yi.Abp.Web,上传到 47.253.11.59,重启 Kestrel 19004,健康检查 https://flusapi-teustest.3flabeling.com
+#>
+param(
+ [switch]$SkipBuild
+)
+
+$ErrorActionPreference = "Stop"
+$HostName = "47.253.11.59"
+$UserName = "root"
+$RemoteDir = "/www/wwwroot/FoodLabelingManagementTeUsTest"
+$Dotnet = "/www/server/dotnet/8.0.100/dotnet"
+$AppDll = "$RemoteDir/Yi.Abp.Web.dll"
+$HealthUrl = "https://flusapi-teustest.3flabeling.com/swagger/index.html"
+$ListenUrl = "http://0.0.0.0:19004"
+$Cors = "http://0.0.0.0:19004;http://localhost:19004;https://flusapi-teustest.3flabeling.com;http://flusapi-teustest.3flabeling.com;http://flus-teustest.3flabeling.com;https://flus-teustest.3flabeling.com;http://localhost:18000;http://localhost:5666;http://localhost:5174;http://localhost:5173;http://localhost:3000"
+$DbHost = "rm-0xi95hpp522z6c62w.mysql.rds-aliyun-america.rds.aliyuncs.com"
+$DbUser = "root"
+$DbPassword = 'Te2026@antis!'
+$TestDbName = "antis-foodlabeling-teus"
+$BtName = "食品标签泰鄂美国测试版"
+$BtDomain = "flusapi-teustest.3flabeling.com"
+$BtCmd = "{0} {1} --urls={2}" -f $Dotnet, $AppDll, $ListenUrl
+
+$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
+$RepoRoot = Resolve-Path (Join-Path $ScriptDir "..\..")
+$WebCsproj = Join-Path $RepoRoot "美国版\Food Labeling Management Code\Yi.Abp.Net8\src\Yi.Abp.Web\Yi.Abp.Web.csproj"
+$PublishDir = Join-Path $RepoRoot "美国版\Food Labeling Management Code\Yi.Abp.Net8\_publish-teustest"
+. (Join-Path $ScriptDir "_deploy-us-ssh.ps1")
+Initialize-DeploySsh
+$SshOpts = $global:SshOpts
+
+Write-Host "== 泰鄂美国测试版部署 ==" -ForegroundColor Cyan
+Write-Host "目标: $HostName $RemoteDir"
+Write-Host "域名: $HealthUrl"
+Write-Host "数据库: $TestDbName @ $DbHost"
+
+if (-not $SkipBuild) {
+ if (-not (Test-Path $WebCsproj)) { throw "找不到工程: $WebCsproj" }
+ Write-Host "== 发布 Yi.Abp.Web ==" -ForegroundColor Cyan
+ if (Test-Path $PublishDir) { Remove-Item $PublishDir -Recurse -Force }
+ & dotnet publish $WebCsproj -c Release -o $PublishDir --nologo
+ if ($LASTEXITCODE -ne 0) { throw "dotnet publish 失败" }
+
+ $appsettings = Join-Path $PublishDir "appsettings.json"
+ if (Test-Path $appsettings) {
+ $json = Get-Content $appsettings -Raw -Encoding UTF8
+ $json = [regex]::Replace($json, '"SelfUrl"\s*:\s*"[^"]*"', '"SelfUrl": "' + $ListenUrl + '"')
+ $json = [regex]::Replace($json, '"CorsOrigins"\s*:\s*"[^"]*"', '"CorsOrigins": "' + $Cors + '"')
+ $json = [regex]::Replace($json, 'server=[^;]+', "server=$DbHost")
+ $json = [regex]::Replace($json, 'uid=[^;]+', "uid=$DbUser")
+ $json = [regex]::Replace($json, 'pwd=[^;]+', "pwd=$DbPassword")
+ $json = [regex]::Replace($json, 'database=antis-foodlabeling-[^;]+', "database=$TestDbName")
+ Set-Content -Path $appsettings -Value $json -Encoding UTF8
+ }
+}
+
+if (-not (Test-Path (Join-Path $PublishDir "Yi.Abp.Web.dll"))) {
+ throw "发布目录缺少 Yi.Abp.Web.dll: $PublishDir"
+}
+
+Write-Host "== 停止远程进程 ==" -ForegroundColor Cyan
+Invoke-Remote @'
+set -e
+if [ -f "/var/tmp/net_project/食品标签泰鄂美国测试版.pid" ]; then
+ pid=$(cat "/var/tmp/net_project/食品标签泰鄂美国测试版.pid" || true)
+ if [ -n "$pid" ]; then kill "$pid" 2>/dev/null || true; fi
+fi
+pkill -f "/www/wwwroot/FoodLabelingManagementTeUsTest/Yi.Abp.Web.dll" 2>/dev/null || true
+sleep 1
+echo stopped
+'@
+
+Write-Host "== 上传发布包 ==" -ForegroundColor Cyan
+$tar = Join-Path $env:TEMP "flus-teustest-publish.tgz"
+if (Test-Path $tar) { Remove-Item $tar -Force }
+Push-Location $PublishDir
+try {
+ & tar -czf $tar --exclude=logs --exclude=startup.log *
+ if ($LASTEXITCODE -ne 0) { throw "打包失败" }
+} finally {
+ Pop-Location
+}
+
+& scp @SshOpts $tar "${UserName}@${HostName}:/tmp/flus-teustest-publish.tgz"
+if ($LASTEXITCODE -ne 0) { throw "scp 失败" }
+
+Invoke-Remote @"
+set -e
+mkdir -p '$RemoteDir'
+cd '$RemoteDir'
+for x in *; do
+ case "`$x" in
+ logs|*.log) ;;
+ *) rm -rf "`$x" ;;
+ esac
+done
+tar --overwrite -xzf /tmp/flus-teustest-publish.tgz -C '$RemoteDir'
+rm -f /tmp/flus-teustest-publish.tgz
+chmod -R a+rX '$RemoteDir'
+ls -l '$RemoteDir/Yi.Abp.Web.dll'
+echo uploaded_to=$RemoteDir
+"@
+
+Write-Host "== 登记宝塔 Net 项目 ==" -ForegroundColor Cyan
+$btPyLocal = Join-Path $ScriptDir "bt-register-net-project.py"
+& scp @SshOpts $btPyLocal "${UserName}@${HostName}:/tmp/bt-register-net-project.py"
+if ($LASTEXITCODE -ne 0) { throw "上传宝塔登记脚本失败" }
+Invoke-Remote @"
+set -e
+sed -i 's/\r`$//' /tmp/bt-register-net-project.py
+python3 /tmp/bt-register-net-project.py name='$BtName' path='$RemoteDir' port='19004' ps='$BtName' domain='$BtDomain' cmd='$BtCmd' run_user='root' dotnet_version='8.0.100'
+"@
+
+Write-Host "== 启动 API ==" -ForegroundColor Cyan
+Invoke-Remote -AllowFail @"
+mkdir -p /www/wwwlogs/net /var/tmp/net_project
+cd '$RemoteDir'
+nohup $Dotnet '$AppDll' --urls=$ListenUrl >> /www/wwwlogs/net/食品标签泰鄂美国测试版.log 2>&1 &
+echo `$! > /var/tmp/net_project/食品标签泰鄂美国测试版.pid
+sleep 8
+ss -lntp | grep 19004 || true
+curl -s -o /dev/null -w 'local=%{http_code}\n' --max-time 15 http://127.0.0.1:19004/swagger/index.html || true
+tail -n 20 /www/wwwlogs/net/食品标签泰鄂美国测试版.log || true
+"@
+
+Write-Host "== 健康检查 ==" -ForegroundColor Cyan
+$ok = $false
+for ($i = 1; $i -le 8; $i++) {
+ try {
+ $resp = Invoke-WebRequest -Uri $HealthUrl -UseBasicParsing -TimeoutSec 15
+ if ($resp.StatusCode -eq 200) {
+ Write-Host "访问成功: $HealthUrl HTTP $($resp.StatusCode)" -ForegroundColor Green
+ $ok = $true
+ break
+ }
+ } catch {
+ Write-Host "等待服务就绪 ($i/8)..."
+ Start-Sleep -Seconds 3
+ }
+}
+
+if (-not $ok) { throw "部署后健康检查失败: $HealthUrl" }
+Write-Host "完成。API: https://flusapi-teustest.3flabeling.com" -ForegroundColor Green
+Write-Host "Swagger: $HealthUrl"
+Write-Host "登录: POST https://flusapi-teustest.3flabeling.com/api/app/account/login"
diff --git a/美国版/scripts/美国版本正式环境部署.cmd b/美国版/scripts/美国版本正式环境部署.cmd
new file mode 100644
index 0000000..f32f74d
--- /dev/null
+++ b/美国版/scripts/美国版本正式环境部署.cmd
@@ -0,0 +1,5 @@
+@echo off
+cd /d "%~dp0"
+powershell.exe -NoProfile -ExecutionPolicy Bypass -File "%~dp0%~n0.ps1" %*
+echo.
+pause
diff --git a/美国版/scripts/美国版本正式环境部署.ps1 b/美国版/scripts/美国版本正式环境部署.ps1
new file mode 100644
index 0000000..d857ae0
--- /dev/null
+++ b/美国版/scripts/美国版本正式环境部署.ps1
@@ -0,0 +1,150 @@
+#Requires -Version 5.1
+<#
+.SYNOPSIS
+ 美国版本正式环境 API 一键部署
+.DESCRIPTION
+ 发布 Yi.Abp.Web,上传到 47.253.11.59,重启 Kestrel 19001,健康检查 https://flusapi-us.3flabeling.com
+#>
+param(
+ [switch]$SkipBuild
+)
+
+$ErrorActionPreference = "Stop"
+$HostName = "47.253.11.59"
+$UserName = "root"
+$RemoteDir = "/www/wwwroot/FoodLabelingManagementUs"
+$Dotnet = "/www/server/dotnet/8.0.100/dotnet"
+$AppDll = "$RemoteDir/Yi.Abp.Web.dll"
+$HealthUrl = "https://flusapi-us.3flabeling.com/swagger/index.html"
+$ListenUrl = "http://0.0.0.0:19001"
+$Cors = "http://0.0.0.0:19001;http://localhost:19001;https://flusapi-us.3flabeling.com;http://flusapi-us.3flabeling.com;http://flus.3flabeling.com;https://flus.3flabeling.com;http://flus.3ffoodsafety.com;https://flus.3ffoodsafety.com;http://localhost:18000;http://localhost:5666;http://localhost:5174;http://localhost:5173;http://localhost:3000"
+$DbHost = "rm-0xi95hpp522z6c62w.mysql.rds-aliyun-america.rds.aliyuncs.com"
+$DbUser = "root"
+$DbPassword = "Te2026@antis!"
+$ProdDbName = "antis-foodlabeling-us"
+$BtName = "食品标签美国正式版"
+$BtDomain = "flusapi-us.3flabeling.com"
+$BtCmd = "{0} {1} --urls={2}" -f $Dotnet, $AppDll, $ListenUrl
+
+$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
+$RepoRoot = Resolve-Path (Join-Path $ScriptDir "..\..")
+$WebCsproj = Join-Path $RepoRoot "美国版\Food Labeling Management Code\Yi.Abp.Net8\src\Yi.Abp.Web\Yi.Abp.Web.csproj"
+$PublishDir = Join-Path $RepoRoot "美国版\Food Labeling Management Code\Yi.Abp.Net8\_publish-usprod"
+. (Join-Path $ScriptDir "_deploy-us-ssh.ps1")
+Initialize-DeploySsh
+$SshOpts = $global:SshOpts
+
+Write-Host "== 美国版本正式环境部署 ==" -ForegroundColor Cyan
+Write-Host "目标: $HostName $RemoteDir"
+Write-Host "域名: $HealthUrl"
+Write-Host "数据库: $ProdDbName @ $DbHost"
+
+if (-not $SkipBuild) {
+ if (-not (Test-Path $WebCsproj)) { throw "找不到工程: $WebCsproj" }
+ Write-Host "== 发布 Yi.Abp.Web ==" -ForegroundColor Cyan
+ if (Test-Path $PublishDir) { Remove-Item $PublishDir -Recurse -Force }
+ & dotnet publish $WebCsproj -c Release -o $PublishDir --nologo
+ if ($LASTEXITCODE -ne 0) { throw "dotnet publish 失败" }
+
+ $appsettings = Join-Path $PublishDir "appsettings.json"
+ if (Test-Path $appsettings) {
+ $json = Get-Content $appsettings -Raw -Encoding UTF8
+ $json = [regex]::Replace($json, '"SelfUrl"\s*:\s*"[^"]*"', '"SelfUrl": "' + $ListenUrl + '"')
+ $json = [regex]::Replace($json, '"CorsOrigins"\s*:\s*"[^"]*"', '"CorsOrigins": "' + $Cors + '"')
+ $json = [regex]::Replace($json, 'server=[^;]+', "server=$DbHost")
+ $json = [regex]::Replace($json, 'uid=[^;]+', "uid=$DbUser")
+ $json = [regex]::Replace($json, 'pwd=[^;]+', "pwd=$DbPassword")
+ $json = [regex]::Replace($json, 'database=antis-foodlabeling-[^;]+', "database=$ProdDbName")
+ Set-Content -Path $appsettings -Value $json -Encoding UTF8
+ }
+}
+
+if (-not (Test-Path (Join-Path $PublishDir "Yi.Abp.Web.dll"))) {
+ throw "发布目录缺少 Yi.Abp.Web.dll: $PublishDir"
+}
+
+Write-Host "== 停止远程正式环境进程 ==" -ForegroundColor Cyan
+Invoke-Remote @'
+set -e
+if [ -f "/var/tmp/net_project/食品标签美国正式版.pid" ]; then
+ pid=$(cat "/var/tmp/net_project/食品标签美国正式版.pid" || true)
+ if [ -n "$pid" ]; then kill "$pid" 2>/dev/null || true; fi
+fi
+pkill -f "/www/wwwroot/FoodLabelingManagementUs/Yi.Abp.Web.dll" 2>/dev/null || true
+sleep 1
+echo stopped
+'@
+
+Write-Host "== 上传发布包 ==" -ForegroundColor Cyan
+$tar = Join-Path $env:TEMP "flus-usprod-publish.tgz"
+if (Test-Path $tar) { Remove-Item $tar -Force }
+Push-Location $PublishDir
+try {
+ & tar -czf $tar --exclude=logs --exclude=startup.log *
+ if ($LASTEXITCODE -ne 0) { throw "打包失败" }
+} finally {
+ Pop-Location
+}
+
+& scp @SshOpts $tar "${UserName}@${HostName}:/tmp/flus-usprod-publish.tgz"
+if ($LASTEXITCODE -ne 0) { throw "scp 失败" }
+
+Invoke-Remote @"
+set -e
+mkdir -p '$RemoteDir'
+cd '$RemoteDir'
+for x in *; do
+ case "`$x" in
+ logs|*.log) ;;
+ *) rm -rf "`$x" ;;
+ esac
+done
+tar --overwrite -xzf /tmp/flus-usprod-publish.tgz -C '$RemoteDir'
+rm -f /tmp/flus-usprod-publish.tgz
+chmod -R a+rX '$RemoteDir'
+ls -l '$RemoteDir/Yi.Abp.Web.dll'
+echo uploaded_to=$RemoteDir
+"@
+
+Write-Host "== 登记宝塔 Net 项目 ==" -ForegroundColor Cyan
+$btPyLocal = Join-Path $ScriptDir "bt-register-net-project.py"
+& scp @SshOpts $btPyLocal "${UserName}@${HostName}:/tmp/bt-register-net-project.py"
+if ($LASTEXITCODE -ne 0) { throw "上传宝塔登记脚本失败" }
+Invoke-Remote @"
+set -e
+sed -i 's/\r`$//' /tmp/bt-register-net-project.py
+python3 /tmp/bt-register-net-project.py name='$BtName' path='$RemoteDir' port='19001' ps='$BtName' domain='$BtDomain' cmd='$BtCmd' run_user='root' dotnet_version='8.0.100'
+"@
+
+Write-Host "== 启动 API ==" -ForegroundColor Cyan
+Invoke-Remote -AllowFail @"
+mkdir -p /www/wwwlogs/net /var/tmp/net_project
+cd '$RemoteDir'
+nohup $Dotnet '$AppDll' --urls=$ListenUrl >> /www/wwwlogs/net/食品标签美国正式版.log 2>&1 &
+echo `$! > /var/tmp/net_project/食品标签美国正式版.pid
+sleep 8
+ss -lntp | grep 19001 || true
+curl -s -o /dev/null -w 'local=%{http_code}\n' --max-time 15 http://127.0.0.1:19001/swagger/index.html || true
+tail -n 20 /www/wwwlogs/net/食品标签美国正式版.log || true
+"@
+
+Write-Host "== 健康检查 ==" -ForegroundColor Cyan
+$ok = $false
+for ($i = 1; $i -le 8; $i++) {
+ try {
+ $resp = Invoke-WebRequest -Uri $HealthUrl -UseBasicParsing -TimeoutSec 15
+ if ($resp.StatusCode -eq 200) {
+ Write-Host "访问成功: $HealthUrl HTTP $($resp.StatusCode)" -ForegroundColor Green
+ $ok = $true
+ break
+ }
+ } catch {
+ Write-Host "等待服务就绪 ($i/8)..."
+ Start-Sleep -Seconds 3
+ }
+}
+
+if (-not $ok) { throw "部署后健康检查失败: $HealthUrl" }
+Write-Host "完成。API: https://flusapi-us.3flabeling.com" -ForegroundColor Green
+Write-Host "Swagger: $HealthUrl"
+Write-Host "登录: POST https://flusapi-us.3flabeling.com/api/app/account/login"
diff --git a/美国版/scripts/美国版本测试环境部署.cmd b/美国版/scripts/美国版本测试环境部署.cmd
new file mode 100644
index 0000000..ca6a732
--- /dev/null
+++ b/美国版/scripts/美国版本测试环境部署.cmd
@@ -0,0 +1,5 @@
+@echo off
+cd /d "%~dp0"
+powershell.exe -NoProfile -ExecutionPolicy Bypass -File "%~dp0%~n0.ps1" %*
+echo.
+pause
diff --git a/美国版/scripts/美国版本测试环境部署.ps1 b/美国版/scripts/美国版本测试环境部署.ps1
new file mode 100644
index 0000000..4ad9258
--- /dev/null
+++ b/美国版/scripts/美国版本测试环境部署.ps1
@@ -0,0 +1,150 @@
+#Requires -Version 5.1
+<#
+.SYNOPSIS
+ 美国版本测试环境 API 一键部署
+.DESCRIPTION
+ 发布 Yi.Abp.Web,上传到 47.253.11.59,重启 Kestrel,健康检查 https://flusapi-ustest.3flabeling.com
+#>
+param(
+ [switch]$SkipBuild
+)
+
+$ErrorActionPreference = "Stop"
+$HostName = "47.253.11.59"
+$UserName = "root"
+$RemoteDir = "/www/wwwroot/FoodLabelingManagementUsTest"
+$Dotnet = "/www/server/dotnet/8.0.100/dotnet"
+$AppDll = "$RemoteDir/Yi.Abp.Web.dll"
+$HealthUrl = "https://flusapi-ustest.3flabeling.com/swagger/index.html"
+$ListenUrl = "http://0.0.0.0:19003"
+$Cors = "http://0.0.0.0:19003;http://localhost:19003;https://flusapi-ustest.3flabeling.com;http://flusapi-ustest.3flabeling.com;http://flus-test.3flabeling.com;https://flus-test.3flabeling.com;http://flus-test.3ffoodsafety.com;https://flus-test.3ffoodsafety.com;http://localhost:18000;http://localhost:5666;http://localhost:5174;http://localhost:5173;http://localhost:3000"
+$DbHost = "rm-0xi95hpp522z6c62w.mysql.rds-aliyun-america.rds.aliyuncs.com"
+$DbUser = "root"
+$DbPassword = "Te2026@antis!"
+$TestDbName = "antis-foodlabeling-test-us"
+$BtName = "食品标签美国测试版"
+$BtDomain = "flusapi-ustest.3flabeling.com"
+$BtCmd = "{0} {1} --urls={2}" -f $Dotnet, $AppDll, $ListenUrl
+
+$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
+$RepoRoot = Resolve-Path (Join-Path $ScriptDir "..\..")
+$WebCsproj = Join-Path $RepoRoot "美国版\Food Labeling Management Code\Yi.Abp.Net8\src\Yi.Abp.Web\Yi.Abp.Web.csproj"
+$PublishDir = Join-Path $RepoRoot "美国版\Food Labeling Management Code\Yi.Abp.Net8\_publish-ustest"
+. (Join-Path $ScriptDir "_deploy-us-ssh.ps1")
+Initialize-DeploySsh
+$SshOpts = $global:SshOpts
+
+Write-Host "== 美国版本测试环境部署 ==" -ForegroundColor Cyan
+Write-Host "目标: $HostName $RemoteDir"
+Write-Host "域名: $HealthUrl"
+Write-Host "数据库: $TestDbName @ $DbHost"
+
+if (-not $SkipBuild) {
+ if (-not (Test-Path $WebCsproj)) { throw "找不到工程: $WebCsproj" }
+ Write-Host "== 发布 Yi.Abp.Web ==" -ForegroundColor Cyan
+ if (Test-Path $PublishDir) { Remove-Item $PublishDir -Recurse -Force }
+ & dotnet publish $WebCsproj -c Release -o $PublishDir --nologo
+ if ($LASTEXITCODE -ne 0) { throw "dotnet publish 失败" }
+
+ $appsettings = Join-Path $PublishDir "appsettings.json"
+ if (Test-Path $appsettings) {
+ $json = Get-Content $appsettings -Raw -Encoding UTF8
+ $json = [regex]::Replace($json, '"SelfUrl"\s*:\s*"[^"]*"', '"SelfUrl": "' + $ListenUrl + '"')
+ $json = [regex]::Replace($json, '"CorsOrigins"\s*:\s*"[^"]*"', '"CorsOrigins": "' + $Cors + '"')
+ $json = [regex]::Replace($json, 'server=[^;]+', "server=$DbHost")
+ $json = [regex]::Replace($json, 'uid=[^;]+', "uid=$DbUser")
+ $json = [regex]::Replace($json, 'pwd=[^;]+', "pwd=$DbPassword")
+ $json = [regex]::Replace($json, 'database=antis-foodlabeling-[^;]+', "database=$TestDbName")
+ Set-Content -Path $appsettings -Value $json -Encoding UTF8
+ }
+}
+
+if (-not (Test-Path (Join-Path $PublishDir "Yi.Abp.Web.dll"))) {
+ throw "发布目录缺少 Yi.Abp.Web.dll: $PublishDir"
+}
+
+Write-Host "== 停止远程进程 ==" -ForegroundColor Cyan
+Invoke-Remote @'
+set -e
+if [ -f "/var/tmp/net_project/食品标签美国测试版.pid" ]; then
+ pid=$(cat "/var/tmp/net_project/食品标签美国测试版.pid" || true)
+ if [ -n "$pid" ]; then kill "$pid" 2>/dev/null || true; fi
+fi
+pkill -f "/www/wwwroot/FoodLabelingManagementUsTest/Yi.Abp.Web.dll" 2>/dev/null || true
+sleep 1
+echo stopped
+'@
+
+Write-Host "== 上传发布包 ==" -ForegroundColor Cyan
+$tar = Join-Path $env:TEMP "flus-ustest-publish.tgz"
+if (Test-Path $tar) { Remove-Item $tar -Force }
+Push-Location $PublishDir
+try {
+ & tar -czf $tar --exclude=logs --exclude=startup.log *
+ if ($LASTEXITCODE -ne 0) { throw "打包失败" }
+} finally {
+ Pop-Location
+}
+
+& scp @SshOpts $tar "${UserName}@${HostName}:/tmp/flus-ustest-publish.tgz"
+if ($LASTEXITCODE -ne 0) { throw "scp 失败" }
+
+Invoke-Remote @"
+set -e
+mkdir -p '$RemoteDir'
+cd '$RemoteDir'
+for x in *; do
+ case "`$x" in
+ logs|*.log) ;;
+ *) rm -rf "`$x" ;;
+ esac
+done
+tar --overwrite -xzf /tmp/flus-ustest-publish.tgz -C '$RemoteDir'
+rm -f /tmp/flus-ustest-publish.tgz
+chmod -R a+rX '$RemoteDir'
+ls -l '$RemoteDir/Yi.Abp.Web.dll'
+echo uploaded_to=$RemoteDir
+"@
+
+Write-Host "== 登记宝塔 Net 项目 ==" -ForegroundColor Cyan
+$btPyLocal = Join-Path $ScriptDir "bt-register-net-project.py"
+& scp @SshOpts $btPyLocal "${UserName}@${HostName}:/tmp/bt-register-net-project.py"
+if ($LASTEXITCODE -ne 0) { throw "上传宝塔登记脚本失败" }
+Invoke-Remote @"
+set -e
+sed -i 's/\r`$//' /tmp/bt-register-net-project.py
+python3 /tmp/bt-register-net-project.py name='$BtName' path='$RemoteDir' port='19003' ps='$BtName' domain='$BtDomain' cmd='$BtCmd' run_user='root' dotnet_version='8.0.100'
+"@
+
+Write-Host "== 启动 API ==" -ForegroundColor Cyan
+Invoke-Remote -AllowFail @"
+mkdir -p /www/wwwlogs/net /var/tmp/net_project
+cd '$RemoteDir'
+nohup $Dotnet '$AppDll' --urls=$ListenUrl >> /www/wwwlogs/net/食品标签美国测试版.log 2>&1 &
+echo `$! > /var/tmp/net_project/食品标签美国测试版.pid
+sleep 8
+ss -lntp | grep 19003 || true
+curl -s -o /dev/null -w 'local=%{http_code}\n' --max-time 15 http://127.0.0.1:19003/swagger/index.html || true
+tail -n 20 /www/wwwlogs/net/食品标签美国测试版.log || true
+"@
+
+Write-Host "== 健康检查 ==" -ForegroundColor Cyan
+$ok = $false
+for ($i = 1; $i -le 8; $i++) {
+ try {
+ $resp = Invoke-WebRequest -Uri $HealthUrl -UseBasicParsing -TimeoutSec 15
+ if ($resp.StatusCode -eq 200) {
+ Write-Host "访问成功: $HealthUrl HTTP $($resp.StatusCode)" -ForegroundColor Green
+ $ok = $true
+ break
+ }
+ } catch {
+ Write-Host "等待服务就绪 ($i/8)..."
+ Start-Sleep -Seconds 3
+ }
+}
+
+if (-not $ok) { throw "部署后健康检查失败: $HealthUrl" }
+Write-Host "完成。API: https://flusapi-ustest.3flabeling.com" -ForegroundColor Green
+Write-Host "Swagger: $HealthUrl"
+Write-Host "登录: POST https://flusapi-ustest.3flabeling.com/api/app/account/login"
--
libgit2 0.21.4