Browse Source

Merge pull request #1401 from theasp/add-dynamic-manifest

feat: Allow overriding application name in manifest.json
Timothy Jaeryang Baek 1 năm trước cách đây
mục cha
commit
9404b6135a
3 tập tin đã thay đổi với 15 bổ sung18 xóa
  1. 1 1
      backend/config.py
  2. 14 1
      backend/main.py
  3. 0 16
      static/manifest.json

+ 1 - 1
backend/config.py

@@ -25,7 +25,7 @@ try:
 except ImportError:
     log.warning("dotenv not installed, skipping...")
 
-WEBUI_NAME = "Open WebUI"
+WEBUI_NAME = os.environ.get("WEBUI_NAME", "Open WebUI")
 WEBUI_FAVICON_URL = "https://openwebui.com/favicon.png"
 shutil.copyfile("../build/favicon.png", "./static/favicon.png")
 

+ 14 - 1
backend/main.py

@@ -84,7 +84,6 @@ app.state.MODEL_FILTER_LIST = MODEL_FILTER_LIST
 
 app.state.WEBHOOK_URL = WEBHOOK_URL
 
-
 origins = ["*"]
 
 
@@ -284,6 +283,20 @@ async def get_app_latest_release_version():
         )
 
 
+@app.get("/manifest.json")
+async def get_manifest_json():
+    return {
+        "name": WEBUI_NAME,
+        "short_name": WEBUI_NAME,
+        "start_url": "/",
+        "display": "standalone",
+        "background_color": "#343541",
+        "theme_color": "#343541",
+        "orientation": "portrait-primary",
+        "icons": [{"src": "/favicon.png", "type": "image/png", "sizes": "844x884"}],
+    }
+
+
 app.mount("/static", StaticFiles(directory="static"), name="static")
 app.mount("/cache", StaticFiles(directory="data/cache"), name="cache")
 

+ 0 - 16
static/manifest.json

@@ -1,16 +0,0 @@
-{
-	"name": "Open WebUI",
-	"short_name": "Open WebUI",
-	"start_url": "/",
-	"display": "standalone",
-	"background_color": "#343541",
-	"theme_color": "#343541",
-	"orientation": "portrait-primary",
-	"icons": [
-		{
-			"src": "/favicon.png",
-			"type": "image/png",
-			"sizes": "844x884"
-		}
-	]
-}