mirror of
https://github.com/GSManagerXZ/GameServerManager.git
synced 2026-05-23 03:40:54 +08:00
修复音频和python
This commit is contained in:
28
.github/workflows/build.yml
vendored
28
.github/workflows/build.yml
vendored
@@ -61,34 +61,6 @@ jobs:
|
||||
with:
|
||||
node-version: '22.16.0'
|
||||
cache: 'npm'
|
||||
- name: Download Windows Node.js
|
||||
shell: pwsh
|
||||
run: |
|
||||
$nodeVersion = "22.16.0"
|
||||
$nodeUrl = "https://nodejs.org/dist/v$nodeVersion/node-v$nodeVersion-win-x64.zip"
|
||||
Write-Host "Downloading Node.js for Windows..."
|
||||
Invoke-WebRequest -Uri $nodeUrl -OutFile "node-windows.zip"
|
||||
|
||||
# 解压到临时目录
|
||||
Write-Host "Extracting Node.js..."
|
||||
Expand-Archive -Path "node-windows.zip" -DestinationPath "temp-node" -Force
|
||||
|
||||
# 移动到server目录
|
||||
if (Test-Path "temp-node/node-v$nodeVersion-win-x64") {
|
||||
if (Test-Path "server/node") {
|
||||
Remove-Item "server/node" -Recurse -Force
|
||||
}
|
||||
Move-Item "temp-node/node-v$nodeVersion-win-x64" "server/node"
|
||||
Remove-Item "temp-node" -Recurse -Force
|
||||
}
|
||||
|
||||
# 验证文件结构
|
||||
if (Test-Path "server/node/node.exe") {
|
||||
Write-Host "Node.js for Windows downloaded and placed in server directory successfully"
|
||||
} else {
|
||||
Write-Error "Failed to place Node.js in server directory"
|
||||
exit 1
|
||||
}
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
npm install
|
||||
|
||||
@@ -18,6 +18,17 @@ import LoadingSpinner from '@/components/LoadingSpinner'
|
||||
import NotificationContainer from '@/components/NotificationContainer'
|
||||
import GlobalMusicPlayer from '@/components/GlobalMusicPlayer'
|
||||
|
||||
// GlobalMusicPlayer包装器组件 - 只在已登录时显示
|
||||
const GlobalMusicPlayerWrapper: React.FC = () => {
|
||||
const { isAuthenticated } = useAuthStore()
|
||||
|
||||
if (!isAuthenticated) {
|
||||
return null
|
||||
}
|
||||
|
||||
return <GlobalMusicPlayer />
|
||||
}
|
||||
|
||||
// 受保护的路由组件
|
||||
const ProtectedRoute: React.FC<{ children: React.ReactNode }> = ({ children }) => {
|
||||
const { isAuthenticated, loading } = useAuthStore()
|
||||
@@ -137,8 +148,8 @@ function App() {
|
||||
{/* 全局通知容器 */}
|
||||
<NotificationContainer />
|
||||
|
||||
{/* 全局音乐播放器 */}
|
||||
<GlobalMusicPlayer />
|
||||
{/* 全局音乐播放器 - 只在已登录时显示 */}
|
||||
<GlobalMusicPlayerWrapper />
|
||||
</div>
|
||||
</AntdApp>
|
||||
</ConfigProvider>
|
||||
|
||||
@@ -487,10 +487,29 @@ const __dirname = path.dirname(__filename)
|
||||
// Python脚本路径
|
||||
const PYTHON_SCRIPT_PATH = path.join(__dirname, '..', 'Python', 'game_config_manager.py')
|
||||
|
||||
// Python依赖安装状态
|
||||
// Python依赖是否已安装的标志
|
||||
let pythonDepsInstalled = false
|
||||
|
||||
// 安装Python依赖
|
||||
// 获取正确的Python命令
|
||||
function getPythonCommand(): string {
|
||||
const platform = os.platform()
|
||||
if (platform === 'win32') {
|
||||
return 'python'
|
||||
} else {
|
||||
return 'python3'
|
||||
}
|
||||
}
|
||||
|
||||
// 获取正确的pip命令
|
||||
function getPipCommand(): string {
|
||||
const platform = os.platform()
|
||||
if (platform === 'win32') {
|
||||
return 'pip'
|
||||
} else {
|
||||
return 'pip3'
|
||||
}
|
||||
}
|
||||
|
||||
function installPythonDependencies(): Promise<void> {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (pythonDepsInstalled) {
|
||||
@@ -531,7 +550,7 @@ function installPythonDependencies(): Promise<void> {
|
||||
const mirror = mirrors[currentMirrorIndex]
|
||||
logger.info(`尝试使用${mirror.name}安装Python依赖`)
|
||||
|
||||
const installProcess = spawn('pip', [
|
||||
const installProcess = spawn(getPipCommand(), [
|
||||
'install',
|
||||
'-r',
|
||||
requirementsPath,
|
||||
@@ -581,7 +600,7 @@ function callPythonScript(method: string, args: any[] = []): Promise<any> {
|
||||
await installPythonDependencies()
|
||||
|
||||
const pythonArgs = [PYTHON_SCRIPT_PATH, method, ...args.map(arg => JSON.stringify(arg))]
|
||||
const pythonProcess = spawn('python', pythonArgs, {
|
||||
const pythonProcess = spawn(getPythonCommand(), pythonArgs, {
|
||||
stdio: ['pipe', 'pipe', 'pipe'],
|
||||
env: {
|
||||
...process.env,
|
||||
@@ -808,12 +827,7 @@ router.post('/:instanceId/configs/:configId', authenticateToken, async (req: Req
|
||||
router.get('/python/check', authenticateToken, async (req: Request, res: Response) => {
|
||||
try {
|
||||
const platform = os.platform()
|
||||
let pythonCommand = 'python'
|
||||
|
||||
// Linux和macOS系统优先使用python3
|
||||
if (platform === 'linux' || platform === 'darwin') {
|
||||
pythonCommand = 'python3'
|
||||
}
|
||||
const pythonCommand = getPythonCommand()
|
||||
|
||||
logger.info(`检测Python环境,平台: ${platform},使用命令: ${pythonCommand}`)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user