feat(admin): persist provider drafts in crm

This commit is contained in:
phamnazage-jpg
2026-05-27 21:49:12 +08:00
parent ebd86a4256
commit 8d7aa925df
18 changed files with 2687 additions and 3 deletions

View File

@@ -7,6 +7,7 @@ REMOTE="${REMOTE:-ubuntu@43.155.133.187}"
REMOTE_PORTAL_DIR="${REMOTE_PORTAL_DIR:-/var/www/sub2api-portal}"
REMOTE_NGINX_SITE="${REMOTE_NGINX_SITE:-/etc/nginx/sites-available/tksea}"
REMOTE_HOST_PORT="${REMOTE_HOST_PORT:-18169}"
REMOTE_CRM_PORT="${REMOTE_CRM_PORT:-18173}"
LOCAL_PORTAL_DIR="${LOCAL_PORTAL_DIR:-$ROOT_DIR/deploy/tksea-portal}"
REMOTE_STAGE_DIR="${REMOTE_STAGE_DIR:-/tmp/sub2api-portal-deploy}"
DRY_RUN="${DRY_RUN:-0}"
@@ -71,6 +72,10 @@ block = textwrap.dedent("""\
return 302 /portal/;
}
location = /portal/admin {
return 302 /portal/admin/;
}
location = /kimi-portal {
return 302 /portal/;
}
@@ -91,6 +96,15 @@ block = textwrap.dedent("""\
proxy_http_version 1.1;
}
location /portal-admin-api/ {
proxy_pass http://127.0.0.1:${REMOTE_CRM_PORT}/;
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_http_version 1.1;
}
location /kimi-portal/ {
return 302 /portal/;
}
@@ -154,6 +168,9 @@ EOF
tksea portal deployed
remote: ${REMOTE}
portal url: https://sub.tksea.top/portal/
portal admin home url: https://sub.tksea.top/portal/admin/
provider admin url: https://sub.tksea.top/portal/admin/providers.html
batch import admin url: https://sub.tksea.top/portal/admin/batch-import.html
batch import admin url: https://sub.tksea.top/portal/admin-batch-import.html
legacy url: https://sub.tksea.top/kimi-portal/
portal dir: ${REMOTE_PORTAL_DIR}

View File

@@ -4,6 +4,9 @@ set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
HTML_FILE="$ROOT_DIR/deploy/tksea-portal/index.html"
ADMIN_HTML_FILE="$ROOT_DIR/deploy/tksea-portal/admin-batch-import.html"
ADMIN_HOME_FILE="$ROOT_DIR/deploy/tksea-portal/admin/index.html"
ADMIN_PROVIDERS_FILE="$ROOT_DIR/deploy/tksea-portal/admin/providers.html"
ADMIN_BATCH_FILE="$ROOT_DIR/deploy/tksea-portal/admin/batch-import.html"
NGINX_FILE="$ROOT_DIR/deploy/tksea-portal/nginx.sub.tksea.top.conf.example"
DEPLOY_SCRIPT="$ROOT_DIR/scripts/deploy/deploy_tksea_portal.sh"
@@ -22,6 +25,9 @@ assert_contains_file() {
[[ -f "$HTML_FILE" ]] || fail "missing $HTML_FILE"
[[ -f "$ADMIN_HTML_FILE" ]] || fail "missing $ADMIN_HTML_FILE"
[[ -f "$ADMIN_HOME_FILE" ]] || fail "missing $ADMIN_HOME_FILE"
[[ -f "$ADMIN_PROVIDERS_FILE" ]] || fail "missing $ADMIN_PROVIDERS_FILE"
[[ -f "$ADMIN_BATCH_FILE" ]] || fail "missing $ADMIN_BATCH_FILE"
[[ -f "$NGINX_FILE" ]] || fail "missing $NGINX_FILE"
[[ -f "$DEPLOY_SCRIPT" ]] || fail "missing $DEPLOY_SCRIPT"
@@ -44,6 +50,10 @@ assert_contains_file "$HTML_FILE" "MiniMax-M2.7-highspeed"
assert_contains_file "$HTML_FILE" "deepseek-chat"
assert_contains_file "$ADMIN_HTML_FILE" "Batch Import Admin"
assert_contains_file "$ADMIN_HTML_FILE" "/portal/admin/"
assert_contains_file "$ADMIN_HTML_FILE" "/portal/admin/providers.html"
assert_contains_file "$ADMIN_HTML_FILE" "/portal/admin/batch-import.html"
assert_contains_file "$ADMIN_HTML_FILE" "/portal-admin-api"
assert_contains_file "$ADMIN_HTML_FILE" "matched_account_state"
assert_contains_file "$ADMIN_HTML_FILE" "account_resolution"
assert_contains_file "$ADMIN_HTML_FILE" "/api/batch-import/runs"
@@ -54,15 +64,43 @@ assert_contains_file "$ADMIN_HTML_FILE" "base_url|api_key|requested_model_1,requ
assert_contains_file "$ADMIN_HTML_FILE" "reused"
assert_contains_file "$ADMIN_HTML_FILE" "reactivated"
assert_contains_file "$ADMIN_HOME_FILE" "Admin Portal"
assert_contains_file "$ADMIN_HOME_FILE" "/portal/admin/providers.html"
assert_contains_file "$ADMIN_HOME_FILE" "/portal/admin/batch-import.html"
assert_contains_file "$ADMIN_HOME_FILE" "/portal-admin-api"
assert_contains_file "$ADMIN_HOME_FILE" "浏览器不直接写 pack 仓库"
assert_contains_file "$ADMIN_PROVIDERS_FILE" "Provider Admin"
assert_contains_file "$ADMIN_PROVIDERS_FILE" "/api/packs"
assert_contains_file "$ADMIN_PROVIDERS_FILE" "/api/hosts"
assert_contains_file "$ADMIN_PROVIDERS_FILE" "/api/providers/"
assert_contains_file "$ADMIN_PROVIDERS_FILE" "/preview-import"
assert_contains_file "$ADMIN_PROVIDERS_FILE" "/import"
assert_contains_file "$ADMIN_PROVIDERS_FILE" "/api/provider-drafts"
assert_contains_file "$ADMIN_PROVIDERS_FILE" "保存到服务端"
assert_contains_file "$ADMIN_PROVIDERS_FILE" "更新草稿"
assert_contains_file "$ADMIN_PROVIDERS_FILE" "删除草稿"
assert_contains_file "$ADMIN_PROVIDERS_FILE" "服务端草稿"
assert_contains_file "$ADMIN_PROVIDERS_FILE" "Provider Manifest 草稿"
assert_contains_file "$ADMIN_PROVIDERS_FILE" "/portal-admin-api"
assert_contains_file "$ADMIN_BATCH_FILE" "/portal/admin-batch-import.html"
assert_contains_file "$NGINX_FILE" "location = /portal"
assert_contains_file "$NGINX_FILE" "location = /portal/admin"
assert_contains_file "$NGINX_FILE" "location = /kimi-portal"
assert_contains_file "$NGINX_FILE" "location /portal/"
assert_contains_file "$NGINX_FILE" "location /portal-proxy/"
assert_contains_file "$NGINX_FILE" "location /portal-admin-api/"
assert_contains_file "$NGINX_FILE" "location /kimi-portal-proxy/"
assert_contains_file "$DEPLOY_SCRIPT" "portal url: https://sub.tksea.top/portal/"
assert_contains_file "$DEPLOY_SCRIPT" "portal admin home url: https://sub.tksea.top/portal/admin/"
assert_contains_file "$DEPLOY_SCRIPT" "provider admin url: https://sub.tksea.top/portal/admin/providers.html"
assert_contains_file "$DEPLOY_SCRIPT" "batch import admin url: https://sub.tksea.top/portal/admin/batch-import.html"
assert_contains_file "$DEPLOY_SCRIPT" "batch import admin url: https://sub.tksea.top/portal/admin-batch-import.html"
assert_contains_file "$DEPLOY_SCRIPT" "REMOTE_PORTAL_DIR"
assert_contains_file "$DEPLOY_SCRIPT" "REMOTE_CRM_PORT"
assert_contains_file "$DEPLOY_SCRIPT" "LOCAL_PORTAL_DIR"
assert_contains_file "$DEPLOY_SCRIPT" "patch_tksea_portal_nginx.py"