feat: 更新部署配置和API类型定义
将部署配置更改为生产环境服务器设置 将AxiosRequestConfig替换为InternalAxiosRequestConfig
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import axios, { type AxiosRequestConfig, type AxiosError } from 'axios';
|
import axios, { type InternalAxiosRequestConfig, type AxiosError } from 'axios';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API配置
|
* API配置
|
||||||
@@ -12,7 +12,7 @@ const api = axios.create({
|
|||||||
|
|
||||||
// 请求拦截器
|
// 请求拦截器
|
||||||
api.interceptors.request.use(
|
api.interceptors.request.use(
|
||||||
(config: AxiosRequestConfig) => {
|
(config: InternalAxiosRequestConfig) => {
|
||||||
// 如果 baseURL 不是 localhost,自动添加 API Key
|
// 如果 baseURL 不是 localhost,自动添加 API Key
|
||||||
const baseURL =
|
const baseURL =
|
||||||
(config.baseURL as string) ||
|
(config.baseURL as string) ||
|
||||||
|
|||||||
@@ -1,73 +0,0 @@
|
|||||||
# Deploy script - Upload files to remote server using scp
|
|
||||||
|
|
||||||
# Configuration
|
|
||||||
$remoteHost = "127.0.0.1"
|
|
||||||
$remotePort = "1122"
|
|
||||||
$remoteUser = "cubie"
|
|
||||||
$keyPath = "d:\163"
|
|
||||||
$serverDest = "/home/cubie/down/document/bidding/publish/server"
|
|
||||||
$frontendDest = "/home/cubie/down/document/bidding/publish/frontend"
|
|
||||||
$srcDest = "/home/cubie/down/document/bidding/"
|
|
||||||
|
|
||||||
# Check if key file exists
|
|
||||||
if (-not (Test-Path $keyPath)) {
|
|
||||||
Write-Error "Private key file not found: $keyPath"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
# Check if dist directory exists
|
|
||||||
if (-not (Test-Path "dist")) {
|
|
||||||
Write-Error "dist directory not found, please run npm run build first"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
# Check if frontend directory exists
|
|
||||||
if (-not (Test-Path "frontend")) {
|
|
||||||
Write-Error "frontend directory not found"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
# Check if src directory exists
|
|
||||||
if (-not (Test-Path "src")) {
|
|
||||||
Write-Error "src directory not found"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
Write-Host "Starting deployment..." -ForegroundColor Green
|
|
||||||
Write-Host "Remote server: ${remoteHost}:${remotePort}" -ForegroundColor Cyan
|
|
||||||
Write-Host "Private key: $keyPath" -ForegroundColor Cyan
|
|
||||||
|
|
||||||
# Upload dist directory contents to server directory
|
|
||||||
Write-Host "`nUploading dist directory to ${serverDest}..." -ForegroundColor Yellow
|
|
||||||
scp -i $keyPath -P $remotePort -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -r dist/* "${remoteUser}@${remoteHost}:${serverDest}"
|
|
||||||
|
|
||||||
if ($LASTEXITCODE -ne 0) {
|
|
||||||
Write-Error "Failed to upload dist directory"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
Write-Host "dist directory uploaded successfully" -ForegroundColor Green
|
|
||||||
|
|
||||||
# Upload entire frontend directory to publish directory
|
|
||||||
Write-Host "`nUploading frontend directory to ${frontendDest}..." -ForegroundColor Yellow
|
|
||||||
scp -i $keyPath -P $remotePort -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -r frontend/dist "${remoteUser}@${remoteHost}:${frontendDest}"
|
|
||||||
|
|
||||||
if ($LASTEXITCODE -ne 0) {
|
|
||||||
Write-Error "Failed to upload frontend directory"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
Write-Host "frontend directory uploaded successfully" -ForegroundColor Green
|
|
||||||
|
|
||||||
# Upload entire src directory to bidding directory
|
|
||||||
Write-Host "`nUploading src directory to ${srcDest}..." -ForegroundColor Yellow
|
|
||||||
scp -i $keyPath -P $remotePort -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -r src "${remoteUser}@${remoteHost}:${srcDest}"
|
|
||||||
|
|
||||||
if ($LASTEXITCODE -ne 0) {
|
|
||||||
Write-Error "Failed to upload src directory"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
Write-Host "src directory uploaded successfully" -ForegroundColor Green
|
|
||||||
|
|
||||||
Write-Host "`nDeployment completed!" -ForegroundColor Green
|
|
||||||
@@ -12,21 +12,36 @@ import * as dotenv from 'dotenv';
|
|||||||
dotenv.config();
|
dotenv.config();
|
||||||
|
|
||||||
// Configuration
|
// Configuration
|
||||||
|
// const config = {
|
||||||
|
// host: '127.0.0.1',
|
||||||
|
// port: 1122,
|
||||||
|
// username: 'cubie',
|
||||||
|
// privateKey: fs.readFileSync('d:\\163'),
|
||||||
|
// passphrase: process.env.SSH_PASSPHRASE || '',
|
||||||
|
// };
|
||||||
|
|
||||||
|
|
||||||
const config = {
|
const config = {
|
||||||
host: '127.0.0.1',
|
host: '139.180.190.142',
|
||||||
port: 1122,
|
port: 2211,
|
||||||
username: 'cubie',
|
username: 'root',
|
||||||
privateKey: fs.readFileSync('d:\\163'),
|
privateKey: fs.readFileSync('d:\\163'),
|
||||||
passphrase: process.env.SSH_PASSPHRASE || '',
|
passphrase: process.env.SSH_PASSPHRASE || '',
|
||||||
};
|
};
|
||||||
|
|
||||||
const destinations = {
|
// const destinations = {
|
||||||
server: '/home/cubie/down/document/bidding/publish/server',
|
// server: '/home/cubie/down/document/bidding/publish/server',
|
||||||
frontend: '/home/cubie/down/document/bidding/publish/frontend',
|
// frontend: '/home/cubie/down/document/bidding/publish/frontend',
|
||||||
src: '/home/cubie/down/document/bidding/',
|
// src: '/home/cubie/down/document/bidding/',
|
||||||
};
|
// };
|
||||||
|
|
||||||
|
|
||||||
|
const destinations = {
|
||||||
|
server: '/root/bidding/publish/server',
|
||||||
|
frontend: '/root/bidding/publish/frontend',
|
||||||
|
src: '/root/bidding/',
|
||||||
|
};
|
||||||
|
|
||||||
async function uploadDirectory(
|
async function uploadDirectory(
|
||||||
sftp: SftpClient,
|
sftp: SftpClient,
|
||||||
localPath: string,
|
localPath: string,
|
||||||
|
|||||||
Reference in New Issue
Block a user