From 75ed2c6d12f7e9671c1fa3e4def7369745e8344e Mon Sep 17 00:00:00 2001 From: goddonebianu Date: Tue, 14 Oct 2025 21:15:25 +0800 Subject: [PATCH] ... --- .drone.yml | 75 ++++++++++++++++++++++++++++++++++++++++++++++---- .gitignore | 4 ++- next.config.ts | 1 + src/utils.ts | 3 +- 4 files changed, 75 insertions(+), 8 deletions(-) diff --git a/.drone.yml b/.drone.yml index 2553668..c971130 100644 --- a/.drone.yml +++ b/.drone.yml @@ -8,8 +8,73 @@ platform: arch: amd64 steps: -- name: build - image: node:23-alpine - commands: - - npm ci - - npm run build \ No newline at end of file + - name: build + image: node:23-alpine + commands: + - npm ci + - npm run build + + - name: package + image: node:23-alpine + environment: + ZHIPU_API_KEY: + from_secret: zhipu_api_key + commands: + - apk add zip + - cd .next/standalone + - echo "ZHIPU_API_KEY="$ZHIPU_API_KEY > .env + - zip -r /dist/learn-languages.zip * + volumes: + - name: debian-dist + path: /dist + + - name: transfer file + image: appleboy/drone-scp + settings: + host: + from_secret: SSH_HOST + username: + from_secret: SSH_USERNAME + key: + from_secret: SSH_KEY + port: 22 + target: /home/debian + source: + - /dist/learn-languages.zip + rm_target: true + strip_components: 1 + debug: true + volumes: + - name: debian-dist + path: /dist + + - name: deploy + image: appleboy/drone-ssh + settings: + host: + from_secret: ssh_host + username: + from_secret: ssh_username + key: + from_secret: ssh_key + port: 22 + script: + - cd ~/ + - unzip -d learn-languages -o learn-languages.zip + - rm learn-languages.zip + - cd learn-languages + - | + if pm2 list | grep -q learn-languages; then + echo "进程 learn-languages 已在pm2中运行,正在重启..." + pm2 restart "learn-languages" + else + echo "进程 learn-languages 未在pm2中运行,正在启动..." + pm2 start "./server.js" --name "learn-languages" + fi + - pm2 save + debug: true + +volumes: + - name: debian-dist + host: + path: /home/debian/dist diff --git a/.gitignore b/.gitignore index f752989..6fa3305 100644 --- a/.gitignore +++ b/.gitignore @@ -42,4 +42,6 @@ next-env.d.ts deploy.sh learn-languages.tar.gz -src/app/test \ No newline at end of file +src/app/test + +.env \ No newline at end of file diff --git a/next.config.ts b/next.config.ts index e9ffa30..e23d70d 100644 --- a/next.config.ts +++ b/next.config.ts @@ -2,6 +2,7 @@ import type { NextConfig } from "next"; const nextConfig: NextConfig = { /* config options here */ + output: "standalone" }; export default nextConfig; diff --git a/src/utils.ts b/src/utils.ts index 2f8df04..7653007 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,5 +1,4 @@ import { EdgeTTS, ProsodyOptions } from "edge-tts-universal/browser"; -import { env } from "process"; import { TextSpeakerArraySchema } from "./interfaces"; import z from "zod"; @@ -16,7 +15,7 @@ export function inspect(word: string) { export function urlGoto(url: string) { window.open(url, '_blank'); } -const API_KEY = env.ZHIPU_API_KEY; +const API_KEY = process.env.ZHIPU_API_KEY; export async function callZhipuAPI(messages: { role: string; content: string; }[], model = 'glm-4.5-flash') { const url = 'https://open.bigmodel.cn/api/paas/v4/chat/completions';