Merge pull request #2051 from xinnan-tech/hot-fix

update:引导测试页面启动
This commit is contained in:
欣南科技
2025-08-16 14:37:04 +08:00
committed by GitHub
2 changed files with 1625 additions and 1550 deletions
@@ -9,7 +9,7 @@ logger = setup_logging()
class DefaultTTS(TTSProviderBase): class DefaultTTS(TTSProviderBase):
def __init__(self, config, delete_audio_file=True): def __init__(self, config, delete_audio_file=True):
super().__init__(config, delete_audio_file) super().__init__(config, delete_audio_file)
self.output_dir = config.get("output_dir", "output") self.output_dir = config.get("output_dir", "tmp")
if not os.path.exists(self.output_dir): if not os.path.exists(self.output_dir):
os.makedirs(self.output_dir) os.makedirs(self.output_dir)
+75
View File
@@ -6,7 +6,82 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>小智服务器测试页面</title> <title>小智服务器测试页面</title>
<link rel="stylesheet" href="test_page.css"> <link rel="stylesheet" href="test_page.css">
<style>
#fileProtocolWarning {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.8);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
z-index: 9999;
color: white;
padding: 20px;
box-sizing: border-box;
}
#fileProtocolWarning h2 {
color: #ff4d4d;
margin-bottom: 20px;
}
#fileProtocolWarning pre {
background-color: green;
font-size: 18px;
padding: 15px;
border-radius: 5px;
font-family: monospace;
overflow-x: auto;
margin: 15px 0;
}
#fileProtocolWarning button {
background-color: #4CAF50;
color: white;
border: none;
padding: 10px 20px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 10px 2px;
cursor: pointer;
border-radius: 4px;
}
#fileProtocolWarning button:hover {
background-color: #45a049;
}
</style>
<script>
// 检测是否使用file://协议打开
if (window.location.protocol === 'file:') {
document.addEventListener('DOMContentLoaded', function () {
// 创建警告框
const warningDiv = document.createElement('div');
warningDiv.id = 'fileProtocolWarning';
warningDiv.innerHTML = `
<h2>⚠️ 警告:请使用HTTP服务器打开此页面</h2>
<p>您当前使用的是本地文件方式打开页面(file://协议),这可能导致页面功能异常。</p>
<p>您可以使用nginx映射启动测试页面,也可以请按照以下步骤使用python启动测试http服务:</p>
<ol>
<li>打开命令行终端</li>
<li>命令行进入到 xiaozhi-server/test 目录</li>
<li>执行以下命令启动HTTP服务器:</li>
</ol>
<pre>python -m http.server 8006</pre>
<p>然后在浏览器中访问:<strong>http://localhost:8006/test_page.html</strong></p>
`;
document.body.appendChild(warningDiv);
});
}
</script>
</head> </head>
<body> <body>
<div class="container"> <div class="container">
<h1>小智服务器测试页面</h1> <h1>小智服务器测试页面</h1>