Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -105,13 +105,140 @@ if os.path.exists(logo_path):
|
|
| 105 |
with open(logo_path, "rb") as f:
|
| 106 |
logo_base64 = base64.b64encode(f.read()).decode("utf-8")
|
| 107 |
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 113 |
|
| 114 |
-
|
|
|
|
| 115 |
<style>
|
| 116 |
/* ====== 桌機預設:單行顯示 ====== */
|
| 117 |
#main-title {
|
|
|
|
| 105 |
with open(logo_path, "rb") as f:
|
| 106 |
logo_base64 = base64.b64encode(f.read()).decode("utf-8")
|
| 107 |
|
| 108 |
+
with gr.Blocks(
|
| 109 |
+
theme="soft",
|
| 110 |
+
css="""
|
| 111 |
+
/* ====== logo 區塊 ====== */
|
| 112 |
+
#logo-top {
|
| 113 |
+
position: fixed;
|
| 114 |
+
top: 12px;
|
| 115 |
+
left: 18px;
|
| 116 |
+
z-index: 1000;
|
| 117 |
+
background-color: white;
|
| 118 |
+
border-radius: 10px;
|
| 119 |
+
padding: 6px 8px;
|
| 120 |
+
box-shadow: 0 0 8px rgba(0,0,0,0.15);
|
| 121 |
+
}
|
| 122 |
+
#logo-top img {
|
| 123 |
+
width: 120px;
|
| 124 |
+
height: auto;
|
| 125 |
+
display: block;
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
/* ====== 標題區 ====== */
|
| 129 |
+
#main-title-wrapper {
|
| 130 |
+
display: flex;
|
| 131 |
+
flex-direction: column;
|
| 132 |
+
align-items: center;
|
| 133 |
+
justify-content: center;
|
| 134 |
+
width: 100%;
|
| 135 |
+
text-align: center;
|
| 136 |
+
margin-top: 20px;
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
#main-title {
|
| 140 |
+
font-size: 28px;
|
| 141 |
+
font-weight: bold;
|
| 142 |
+
margin: 0;
|
| 143 |
+
text-align: center;
|
| 144 |
+
display: inline-block;
|
| 145 |
+
line-height: 1.4;
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
#sub-title {
|
| 149 |
+
margin-top: 10px;
|
| 150 |
+
font-size: 14px;
|
| 151 |
+
color: #666;
|
| 152 |
+
letter-spacing: 0.5px;
|
| 153 |
+
}
|
| 154 |
+
|
| 155 |
+
/* ====== 手機版:兩行置中 ====== */
|
| 156 |
+
@media (max-width: 768px) {
|
| 157 |
+
#main-title br { display: inline; }
|
| 158 |
+
#main-title {
|
| 159 |
+
display: block;
|
| 160 |
+
text-align: center;
|
| 161 |
+
white-space: pre-line;
|
| 162 |
+
}
|
| 163 |
+
}
|
| 164 |
+
@media (min-width: 769px) {
|
| 165 |
+
#main-title br { display: none; }
|
| 166 |
+
}
|
| 167 |
+
|
| 168 |
+
/* ====== footer 區 ====== */
|
| 169 |
+
#footer {
|
| 170 |
+
position: fixed;
|
| 171 |
+
bottom: 40px;
|
| 172 |
+
left: 0;
|
| 173 |
+
width: 100%;
|
| 174 |
+
text-align: center;
|
| 175 |
+
font-size: 13px;
|
| 176 |
+
color: #999;
|
| 177 |
+
font-family: "Segoe UI", "Noto Sans TC", sans-serif;
|
| 178 |
+
letter-spacing: 0.3px;
|
| 179 |
+
border-top: 1px solid #ddd;
|
| 180 |
+
padding-top: 8px;
|
| 181 |
+
}
|
| 182 |
+
|
| 183 |
+
/* ====== 手機 footer 修正 ====== */
|
| 184 |
+
@media (max-width: 768px) {
|
| 185 |
+
#logo-top {
|
| 186 |
+
position: static;
|
| 187 |
+
display: flex;
|
| 188 |
+
justify-content: center;
|
| 189 |
+
margin-bottom: 8px;
|
| 190 |
+
box-shadow: none;
|
| 191 |
+
background: transparent;
|
| 192 |
+
}
|
| 193 |
+
#footer {
|
| 194 |
+
position: relative;
|
| 195 |
+
margin-top: 40px;
|
| 196 |
+
border-top: 1px solid #ddd;
|
| 197 |
+
padding-top: 8px;
|
| 198 |
+
}
|
| 199 |
+
}
|
| 200 |
+
|
| 201 |
+
/* ====== LINE 風格輸入區 ====== */
|
| 202 |
+
#input-row {
|
| 203 |
+
display: flex;
|
| 204 |
+
align-items: center;
|
| 205 |
+
gap: 8px;
|
| 206 |
+
margin-top: 10px;
|
| 207 |
+
}
|
| 208 |
+
#user-input {
|
| 209 |
+
flex-grow: 1;
|
| 210 |
+
border-radius: 20px;
|
| 211 |
+
border: 1px solid #ccc;
|
| 212 |
+
padding: 3px 9px;
|
| 213 |
+
font-size: 15px;
|
| 214 |
+
background-color: #fff;
|
| 215 |
+
box-shadow: inset 0 1px 1px rgba(0,0,0,0.1);
|
| 216 |
+
}
|
| 217 |
+
#send-btn {
|
| 218 |
+
background-color: #00b900; /* LINE 綠 */
|
| 219 |
+
color: white;
|
| 220 |
+
border: none;
|
| 221 |
+
border-radius: 20px;
|
| 222 |
+
padding: 6px 6px;
|
| 223 |
+
font-weight: bold;
|
| 224 |
+
cursor: pointer;
|
| 225 |
+
transition: 0.2s ease;
|
| 226 |
+
}
|
| 227 |
+
#send-btn:hover {
|
| 228 |
+
background-color: #00a000;
|
| 229 |
+
}
|
| 230 |
+
"""
|
| 231 |
+
) as demo:
|
| 232 |
+
# 左上角 logo
|
| 233 |
+
if logo_base64:
|
| 234 |
+
gr.HTML(f"""
|
| 235 |
+
<div id="logo-top">
|
| 236 |
+
<img src="data:image/png;base64,{logo_base64}" alt="logo">
|
| 237 |
+
</div>
|
| 238 |
+
""")
|
| 239 |
|
| 240 |
+
# 主標題與副標題
|
| 241 |
+
gr.HTML("""
|
| 242 |
<style>
|
| 243 |
/* ====== 桌機預設:單行顯示 ====== */
|
| 244 |
#main-title {
|