Spaces:
Sleeping
Sleeping
Junhui Ji
commited on
Commit
·
872249d
1
Parent(s):
77c3f55
update openai key management, update example loading status
Browse files- main.py +1 -1
- static/feedback.html +19 -0
- static/script.js +13 -3
main.py
CHANGED
@@ -25,7 +25,7 @@ from PIL import Image
|
|
25 |
app = FastAPI()
|
26 |
|
27 |
# 设置最大连接数
|
28 |
-
MAX_CONNECTIONS =
|
29 |
current_connections = 0
|
30 |
|
31 |
# 设置优化设计接口的访问限制
|
|
|
25 |
app = FastAPI()
|
26 |
|
27 |
# 设置最大连接数
|
28 |
+
MAX_CONNECTIONS = 100
|
29 |
current_connections = 0
|
30 |
|
31 |
# 设置优化设计接口的访问限制
|
static/feedback.html
CHANGED
@@ -67,6 +67,9 @@
|
|
67 |
|
68 |
<section class="feedback-section">
|
69 |
<h2 class="section-title">优化方案</h2>
|
|
|
|
|
|
|
70 |
<div class="optimization-container">
|
71 |
<div class="optimization-card">
|
72 |
<div class="optimization-header">
|
@@ -116,6 +119,22 @@
|
|
116 |
</main>
|
117 |
</div>
|
118 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
119 |
<script src="/static/script.js"></script>
|
120 |
</body>
|
121 |
</html>
|
|
|
67 |
|
68 |
<section class="feedback-section">
|
69 |
<h2 class="section-title">优化方案</h2>
|
70 |
+
<div class="api-key-link">
|
71 |
+
<a href="#" id="apiKeyLink">想使用自己的OpenAI API Key?</a>
|
72 |
+
</div>
|
73 |
<div class="optimization-container">
|
74 |
<div class="optimization-card">
|
75 |
<div class="optimization-header">
|
|
|
119 |
</main>
|
120 |
</div>
|
121 |
|
122 |
+
<!-- API Key Input Dialog -->
|
123 |
+
<div class="api-key-dialog" id="apiKeyDialog">
|
124 |
+
<div class="dialog-content">
|
125 |
+
<h3>输入OpenAI API Key</h3>
|
126 |
+
<p class="dialog-description">请输入您的OpenAI API Key,该Key需要有生图权限(Tier1以上)。</p>
|
127 |
+
<p class="dialog-help">
|
128 |
+
<a href="https://platform.openai.com/settings/organization/api-keys" target="_blank">如何获取API Key?</a>
|
129 |
+
</p>
|
130 |
+
<input type="password" id="apiKeyInput" placeholder="输入您的API Key">
|
131 |
+
<div class="dialog-buttons">
|
132 |
+
<button id="saveApiKey">保存</button>
|
133 |
+
<button id="cancelApiKey">取消</button>
|
134 |
+
</div>
|
135 |
+
</div>
|
136 |
+
</div>
|
137 |
+
|
138 |
<script src="/static/script.js"></script>
|
139 |
</body>
|
140 |
</html>
|
static/script.js
CHANGED
@@ -521,8 +521,17 @@ document.addEventListener('DOMContentLoaded', function() {
|
|
521 |
const desc = card.querySelector('.example-desc');
|
522 |
const sourceLink = card.querySelector('.example-source a');
|
523 |
|
524 |
-
if (img)
|
525 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
526 |
if (sourceLink) {
|
527 |
sourceLink.href = '#';
|
528 |
sourceLink.textContent = '加载中...';
|
@@ -602,12 +611,13 @@ document.addEventListener('DOMContentLoaded', function() {
|
|
602 |
const source = card.querySelector('.example-source');
|
603 |
|
604 |
if (img) {
|
|
|
605 |
img.src = example.image;
|
606 |
img.alt = example.title;
|
607 |
}
|
608 |
|
609 |
if (desc) {
|
610 |
-
desc.
|
611 |
}
|
612 |
|
613 |
if (source) {
|
|
|
521 |
const desc = card.querySelector('.example-desc');
|
522 |
const sourceLink = card.querySelector('.example-source a');
|
523 |
|
524 |
+
if (img) {
|
525 |
+
img.style.display = 'none';
|
526 |
+
}
|
527 |
+
if (desc) {
|
528 |
+
desc.innerHTML = `
|
529 |
+
<div class="optimization-loading">
|
530 |
+
<div class="loading-spinner"></div>
|
531 |
+
<div class="loading-text">正在搜索设计参考案例...</div>
|
532 |
+
</div>
|
533 |
+
`;
|
534 |
+
}
|
535 |
if (sourceLink) {
|
536 |
sourceLink.href = '#';
|
537 |
sourceLink.textContent = '加载中...';
|
|
|
611 |
const source = card.querySelector('.example-source');
|
612 |
|
613 |
if (img) {
|
614 |
+
img.style.display = 'block';
|
615 |
img.src = example.image;
|
616 |
img.alt = example.title;
|
617 |
}
|
618 |
|
619 |
if (desc) {
|
620 |
+
desc.innerHTML = example.description;
|
621 |
}
|
622 |
|
623 |
if (source) {
|