优化一键部署脚本, 增加cloudtentacles
This commit is contained in:
@@ -30,7 +30,6 @@ import { formatAdminDateTime } from '@/utils/admin-time'
|
|||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const sidebarStorageKey = 'admin-sidebar-collapsed'
|
const sidebarStorageKey = 'admin-sidebar-collapsed'
|
||||||
const isDevMode = import.meta.env.DEV
|
|
||||||
const isSidebarCollapsed = ref(
|
const isSidebarCollapsed = ref(
|
||||||
typeof window !== 'undefined' && window.localStorage.getItem(sidebarStorageKey) === '1',
|
typeof window !== 'undefined' && window.localStorage.getItem(sidebarStorageKey) === '1',
|
||||||
)
|
)
|
||||||
@@ -52,21 +51,16 @@ type AdminNavItem = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const platformConfigNavItems = computed<AdminNavItem[]>(() => {
|
const platformConfigNavItems = computed<AdminNavItem[]>(() => {
|
||||||
const items: AdminNavItem[] = [
|
return [
|
||||||
{ to: '/admin/platform-shops?tab=ninetyone', label: '91卡券', icon: Connection },
|
{ to: '/admin/platform-shops?tab=ninetyone', label: '91卡券', icon: Connection },
|
||||||
{ to: '/admin/platform-shops?tab=notifications', label: '内部通知', icon: Bell },
|
{ to: '/admin/platform-shops?tab=notifications', label: '内部通知', icon: Bell },
|
||||||
{ to: '/admin/platform-shops?tab=kuaishouEticket', label: '快手小店核销', icon: Tickets },
|
{ to: '/admin/platform-shops?tab=kuaishouEticket', label: '快手小店核销', icon: Tickets },
|
||||||
]
|
{
|
||||||
|
|
||||||
if (isDevMode) {
|
|
||||||
items.push({
|
|
||||||
to: '/admin/platform-shops?tab=cloudtentacles',
|
to: '/admin/platform-shops?tab=cloudtentacles',
|
||||||
label: 'cloudtentacles',
|
label: 'cloudtentacles',
|
||||||
icon: Setting,
|
icon: Setting,
|
||||||
})
|
},
|
||||||
}
|
]
|
||||||
|
|
||||||
return items
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const navItems = computed(() => {
|
const navItems = computed(() => {
|
||||||
|
|||||||
@@ -22,15 +22,10 @@ import { useAdminKuaishouEticketPlatform } from './composables/useAdminKuaishouE
|
|||||||
import type { PlatformTab } from './composables/types'
|
import type { PlatformTab } from './composables/types'
|
||||||
|
|
||||||
const loading = ref(true)
|
const loading = ref(true)
|
||||||
const isDevMode = import.meta.env.DEV
|
|
||||||
const errorMessage = ref('')
|
const errorMessage = ref('')
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
|
|
||||||
const platformTabs: PlatformTab[] = ['ninetyone', 'notifications', 'kuaishouEticket']
|
const platformTabs: PlatformTab[] = ['ninetyone', 'notifications', 'kuaishouEticket', 'cloudtentacles']
|
||||||
|
|
||||||
if (isDevMode) {
|
|
||||||
platformTabs.push('cloudtentacles')
|
|
||||||
}
|
|
||||||
|
|
||||||
function normalizePlatformTab(value: unknown): PlatformTab {
|
function normalizePlatformTab(value: unknown): PlatformTab {
|
||||||
return typeof value === 'string' && platformTabs.includes(value as PlatformTab)
|
return typeof value === 'string' && platformTabs.includes(value as PlatformTab)
|
||||||
@@ -186,21 +181,17 @@ const overviewCards = computed(() => {
|
|||||||
}`,
|
}`,
|
||||||
status: kuaishouEticketStats.value.cookieReadyCount > 0 ? '已就绪' : '待配置',
|
status: kuaishouEticketStats.value.cookieReadyCount > 0 ? '已就绪' : '待配置',
|
||||||
},
|
},
|
||||||
...(isDevMode
|
{
|
||||||
? [
|
key: 'cloudtentacles',
|
||||||
{
|
label: 'cloudtentacles',
|
||||||
key: 'cloudtentacles',
|
tag: '履约账号',
|
||||||
label: 'cloudtentacles',
|
value: cloudtentaclesStats.value.hasCredential ? '已配置' : '未配置',
|
||||||
tag: '履约账号',
|
unit: '履约凭据',
|
||||||
value: cloudtentaclesStats.value.hasCredential ? '已配置' : '未配置',
|
meta: `短信 ${cloudtentaclesStats.value.smsSent ? '已发送' : '未发送'} · 会话 ${
|
||||||
unit: '履约凭据',
|
cloudtentaclesStats.value.validated ? '已验证' : '未验证'
|
||||||
meta: `短信 ${cloudtentaclesStats.value.smsSent ? '已发送' : '未发送'} · 会话 ${
|
}`,
|
||||||
cloudtentaclesStats.value.validated ? '已验证' : '未验证'
|
status: cloudtentaclesStats.value.validated ? '已验证' : '待验证',
|
||||||
}`,
|
},
|
||||||
status: cloudtentaclesStats.value.validated ? '已验证' : '待验证',
|
|
||||||
},
|
|
||||||
]
|
|
||||||
: []),
|
|
||||||
]
|
]
|
||||||
|
|
||||||
return cards
|
return cards
|
||||||
@@ -367,7 +358,7 @@ onMounted(loadConfigs)
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<AdminPlatformCloudtentaclesSection
|
<AdminPlatformCloudtentaclesSection
|
||||||
v-else-if="isDevMode && activePlatform === 'cloudtentacles'"
|
v-else-if="activePlatform === 'cloudtentacles'"
|
||||||
:cloudtentacles-file-path="cloudtentaclesFilePath"
|
:cloudtentacles-file-path="cloudtentaclesFilePath"
|
||||||
:cloudtentacles-session-file-path="cloudtentaclesSessionFilePath"
|
:cloudtentacles-session-file-path="cloudtentaclesSessionFilePath"
|
||||||
:cloudtentacles-form="cloudtentaclesForm"
|
:cloudtentacles-form="cloudtentaclesForm"
|
||||||
|
|||||||
+26
-4
@@ -88,7 +88,12 @@ deploy_stack() {
|
|||||||
docker compose pull --ignore-buildable
|
docker compose pull --ignore-buildable
|
||||||
|
|
||||||
log "构建并启动服务"
|
log "构建并启动服务"
|
||||||
docker compose up -d --build
|
if docker compose up -d --build; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
print_diagnostics
|
||||||
|
fail "docker compose 启动失败,请根据上面的日志排查。"
|
||||||
}
|
}
|
||||||
|
|
||||||
wait_for_health() {
|
wait_for_health() {
|
||||||
@@ -102,12 +107,29 @@ wait_for_health() {
|
|||||||
sleep 2
|
sleep 2
|
||||||
done
|
done
|
||||||
|
|
||||||
docker compose ps
|
print_diagnostics
|
||||||
warn "健康检查暂未通过,最近后端日志如下:"
|
|
||||||
docker compose logs --tail=80 backend
|
|
||||||
fail "部署已启动但健康检查未通过,请根据日志排查。"
|
fail "部署已启动但健康检查未通过,请根据日志排查。"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
print_diagnostics() {
|
||||||
|
warn "当前容器状态:"
|
||||||
|
docker compose ps || true
|
||||||
|
|
||||||
|
warn "后端最近日志:"
|
||||||
|
local backend_logs
|
||||||
|
backend_logs="$(docker compose logs --tail=120 backend 2>&1 || true)"
|
||||||
|
printf '%s\n' "${backend_logs}"
|
||||||
|
|
||||||
|
if printf '%s\n' "${backend_logs}" | grep -q 'password authentication failed for user "postgres"'; then
|
||||||
|
warn "检测到 PostgreSQL 密码认证失败。通常是 postgres_data 已用旧密码初始化,而 .env 改成了新密码。"
|
||||||
|
warn "无生产数据时可执行:docker compose down -v && bash deploy/ubuntu-deploy.sh"
|
||||||
|
warn "需要保留数据时,请进入 postgres 容器用当前 .env 的 POSTGRES_PASSWORD 修改数据库用户密码。"
|
||||||
|
fi
|
||||||
|
|
||||||
|
warn "后端 ready 接口:"
|
||||||
|
docker compose exec -T backend sh -lc 'curl -fsS http://127.0.0.1:3000/health/ready || true' || true
|
||||||
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
cd "${PROJECT_ROOT}"
|
cd "${PROJECT_ROOT}"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user