mirror of
https://github.com/algerkong/AlgerMusicPlayer.git
synced 2026-04-28 10:57:23 +08:00
✨ feat: 添加额外资源配置,优化远程控制页面HTML路径获取逻辑
This commit is contained in:
@@ -99,6 +99,13 @@
|
|||||||
"repo": "AlgerMusicPlayer"
|
"repo": "AlgerMusicPlayer"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"extraResources": [
|
||||||
|
{
|
||||||
|
"from": "resources/html",
|
||||||
|
"to": "html",
|
||||||
|
"filter": ["**/*"]
|
||||||
|
}
|
||||||
|
],
|
||||||
"mac": {
|
"mac": {
|
||||||
"icon": "resources/icon.icns",
|
"icon": "resources/icon.icns",
|
||||||
"target": [
|
"target": [
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { ipcMain, app as electronApp } from 'electron';
|
import { ipcMain } from 'electron';
|
||||||
import express from 'express';
|
import express from 'express';
|
||||||
import cors from 'cors';
|
import cors from 'cors';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
@@ -212,16 +212,8 @@ function setupRoutes(app: express.Application) {
|
|||||||
// 提供远程控制界面HTML
|
// 提供远程控制界面HTML
|
||||||
app.get('/', (_, res) => {
|
app.get('/', (_, res) => {
|
||||||
try {
|
try {
|
||||||
// 使用electronApp.getAppPath()获取应用根目录
|
const resourcesPath = process.resourcesPath || '';
|
||||||
const appPath = electronApp.getAppPath();
|
const finalPath = path.join(resourcesPath, 'html', 'remote-control.html');
|
||||||
|
|
||||||
// 在开发环境下可能需要不同的路径
|
|
||||||
const isPacked = electronApp.isPackaged;
|
|
||||||
const finalPath = isPacked
|
|
||||||
? path.join(path.dirname(appPath), 'resources', 'html', 'remote-control.html')
|
|
||||||
: path.join(appPath, 'resources', 'html', 'remote-control.html');
|
|
||||||
|
|
||||||
console.log('远程控制HTML路径:', finalPath);
|
|
||||||
|
|
||||||
if (fs.existsSync(finalPath)) {
|
if (fs.existsSync(finalPath)) {
|
||||||
res.sendFile(finalPath);
|
res.sendFile(finalPath);
|
||||||
|
|||||||
Reference in New Issue
Block a user