perf: 不再内嵌管理面板构建文件

This commit is contained in:
Soulter
2024-11-29 17:09:04 +08:00
parent bd40404f58
commit ba12d65792
27 changed files with 50 additions and 785 deletions
-1
View File
@@ -1 +0,0 @@
/* /index.html 200
-1
View File
@@ -1 +0,0 @@
import{k as e,o as a,c as t,w as o,b as s,u as n,R as r,T as c}from"./index-d089162b.js";const f=e({__name:"BlankLayout",setup(u){return(p,_)=>(a(),t(r,null,{default:o(()=>[s(n(c))]),_:1}))}});export{f as default};
File diff suppressed because one or more lines are too long
-1
View File
@@ -1 +0,0 @@
.v-tab{text-transform:none!important}
@@ -1 +0,0 @@
import{u as s}from"./common-40607810.js";import{o as i,l as n}from"./index-d089162b.js";const a={id:"term",style:{"background-color":"#1e1e1e",padding:"16px","border-radius":"8px","overflow-y":"scroll"}},h={name:"ConsoleDisplayer",data(){return{logColorAnsiMap:{"\x1B[1;34m":"color: #0000FF; font-weight: bold;","\x1B[1;36m":"color: #00FFFF; font-weight: bold;","\x1B[1;33m":"color: #FFFF00; font-weight: bold;","\x1B[31m":"color: #FF0000;","\x1B[1;31m":"color: #FF0000; font-weight: bold;","\x1B[0m":"color: inherit; font-weight: normal;","\x1B[32m":"color: #00FF00;",default:"color: #FFFFFF;"},logCache:s().getLogCache(),historyNum_:-1}},props:{historyNum:{type:String,default:-1}},watch:{logCache:{handler(o){this.printLog(o[this.logCache.length-1])},deep:!0}},mounted(){this.historyNum_=parseInt(this.historyNum);let o=0;for(let t of this.logCache)this.historyNum_!=-1&&o>=this.logCache.length-this.historyNum_?(this.printLog(t),++o):this.historyNum_==-1&&this.printLog(t)},methods:{printLog(o){let t=document.getElementById("term"),e=document.createElement("span"),r=this.logColorAnsiMap.default;for(let l in this.logColorAnsiMap)if(o.startsWith(l)){r=this.logColorAnsiMap[l],o=o.replace(l,"").replace("\x1B[0m","");break}e.style=r+"display: block; font-size: 12px; font-family: Consolas, monospace;",e.classList.add("fade-in"),e.innerText=o,t.appendChild(e),t.scrollTop=t.scrollHeight}}},p=Object.assign(h,{setup(o){return(t,e)=>(i(),n("div",a))}});export{p as _};
-1
View File
@@ -1 +0,0 @@
import{_ as t}from"./ConsoleDisplayer-721c13f2.js";import{o,l as s,b as n,n as e}from"./index-d089162b.js";import"./common-40607810.js";const a={style:{height:"100%"}},c=e("div",{style:{"background-color":"white",padding:"8px","padding-left":"16px","border-radius":"8px","margin-bottom":"16px",display:"flex","flex-direction":"row","align-items":"center","justify-content":"space-between"}},[e("h4",null,"控制台")],-1),i={name:"ConsolePage",components:{ConsoleDisplayer:t}},g=Object.assign(i,{setup(l){return(r,_)=>(o(),s("div",a,[c,n(t,{style:{height:"calc(100vh - 160px)"}})]))}});export{g as default};
@@ -1 +0,0 @@
@keyframes fadeIn{0%{opacity:0}to{opacity:1}}.fade-in{animation:fadeIn .2s ease-in-out}
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1 +0,0 @@
import{_ as n}from"./_plugin-vue_export-helper-c27b6911.js";import{o as t,c as a,w as l,B as o,b as s,D as c,n as e}from"./index-d089162b.js";const r={},u=e("div",{style:{display:"flex","flex-direction":"column","justify-content":"center",padding:"24px"}},[e("h3",null,"即将支持。"),e("p",null,"AstrBot 将会支持使用消息记录微调 LLM,并强化人格功能,包括但不限于:"),e("ul",null,[e("li",null,"更像人类的回答"),e("li",null,"长期记忆"),e("li",null,"表情包理解与回复"),e("li",null,"基于兴趣的主动话题展开")])],-1);function i(d,_){return t(),a(o,null,{default:l(()=>[s(c,null,{default:l(()=>[u]),_:1})]),_:1})}const x=n(r,[["render",i]]);export{x as default};
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
-1
View File
@@ -1 +0,0 @@
.custom-devider{border-color:#00000014!important}.googleBtn{border-color:#00000014;margin:30px 0 20px}.outlinedInput .v-field{border:1px solid rgba(0,0,0,.08);box-shadow:none}.orbtn{padding:2px 40px;border-color:#00000014;margin:20px 15px}.pwdInput{position:relative}.pwdInput .v-input__append{position:absolute;right:10px;top:50%;transform:translateY(-50%)}.loginForm .v-text-field .v-field--active input{font-weight:500}.loginBox{max-width:475px;margin:0 auto}
@@ -1 +0,0 @@
import{v as m,o as e,c as u,w as a,b as s,B as d,C as T,e as _,D as p,a5 as w,n,l as r,f,g as o,t as l,K as y}from"./index-d089162b.js";import{_ as S}from"./_plugin-vue_export-helper-c27b6911.js";const k={name:"WaitingForRestart",data(){return{visible:!1,startTime:-1,newStartTime:-1,status:"",cnt:0}},methods:{async check(){this.newStartTime=-1,this.startTime=-1,this.visible=!0,this.status="",console.log("start wfr"),await this.getStartTime(),setTimeout(()=>{this.timeoutInternal()},1e3)},timeoutInternal(){console.log("wfr: timeoutInternal",this.newStartTime,this.startTime),this.newStartTime===-1&&this.cnt<15&&this.visible?(this.checkStartTime(),this.cnt++,setTimeout(()=>{this.timeoutInternal()},1e3)):(this.cnt==10&&(this.status="拉取状态达到最大次数,请手动检查。"),this.cnt=0,setTimeout(()=>{this.visible=!1},1e3))},async getStartTime(){m.get("/api/stat/start-time",{timeout:3e3}).then(i=>{this.startTime=i.data.data.start_time})},async checkStartTime(){let i=await m.get("/api/stat/start-time",{timeout:3e3});return this.newStartTime=i.data.data.start_time,console.log("wfr: checkStartTime",this.newStartTime,this.startTime),this.newStartTime!==this.startTime&&(console.log("wfr: restarted"),setTimeout(()=>{this.visible=!1,window.location.reload()},2e3)),this.newStartTime}}},g={style:{"margin-top":"16px"}},b={key:0,class:"py-12 text-center"},V=n("p",null,"重启成功!",-1),v={key:1,style:{display:"block"}},x={key:2,style:{display:"block"}},B={key:3,style:{display:"block"}},C={style:{display:"block"}};function I(i,c,N,D,t,W){return e(),u(y,{modelValue:t.visible,"onUpdate:modelValue":c[0]||(c[0]=h=>t.visible=h),persistent:"","max-width":"400"},{default:a(()=>[s(d,null,{default:a(()=>[s(T,null,{default:a(()=>[_("正在等待 AstrBot 重启...")]),_:1}),s(p,null,{default:a(()=>[s(w,{indeterminate:"",color:"primary"}),n("div",g,[t.newStartTime!=-1?(e(),r("div",b,[s(f,{class:"mb-6",color:"success",icon:"mdi-check-circle-outline",size:"128"}),V])):o("",!0),t.startTime!=-1?(e(),r("small",v,"当前实例标识:"+l(t.startTime),1)):o("",!0),t.newStartTime!=-1?(e(),r("small",x,"检查到新实例:"+l(t.newStartTime)+",即将自动刷新页面",1)):o("",!0),t.status?(e(),r("small",B,l(t.status),1)):o("",!0),n("small",C,"次数:"+l(t.cnt)+" / 15",1)])]),_:1})]),_:1})]),_:1},8,["modelValue"])}const z=S(k,[["render",I]]);export{z as W};
@@ -1 +0,0 @@
const s=(t,r)=>{const o=t.__vccOpts||t;for(const[c,e]of r)o[c]=e;return o};export{s as _};
-1
View File
@@ -1 +0,0 @@
import{d as l}from"./index-d089162b.js";const i=l({id:"common",state:()=>({websocket:null,log_cache:[],log_cache_max_len:1e3}),actions:{createWebSocket(){if(this.websocket)return;let e=window.location.protocol==="https:"?"wss":"ws",t="/api/live-log",c=window.location.port,o=`${e}://${window.location.hostname}:${c}${t}`;console.log("websocket url:",o),this.websocket=new WebSocket(o),this.websocket.onmessage=s=>{this.log_cache.push(s.data),this.log_cache.length>this.log_cache_max_len&&this.log_cache.shift()}},getLogCache(){return this.log_cache}}});export{i as u};
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
-1
View File
@@ -1 +0,0 @@
<svg t="1702013028016" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1541" width="200" height="200"><path d="M0 0m204.8 0l614.4 0q204.8 0 204.8 204.8l0 614.4q0 204.8-204.8 204.8l-614.4 0q-204.8 0-204.8-204.8l0-614.4q0-204.8 204.8-204.8Z" fill="#FFEC9C" p-id="1542"></path><path d="M819.2 0H534.272A756.48 756.48 0 0 0 0 483.584V819.2a204.8 204.8 0 0 0 204.8 204.8h614.4a204.8 204.8 0 0 0 204.8-204.8V204.8a204.8 204.8 0 0 0-204.8-204.8z" fill="#FFE98A" p-id="1543"></path><path d="M819.2 0h-3.84a755.2 755.2 0 0 0-539.392 1024H819.2a204.8 204.8 0 0 0 204.8-204.8V204.8a204.8 204.8 0 0 0-204.8-204.8z" fill="#FFE471" p-id="1544"></path><path d="M497.152 721.152A752.384 752.384 0 0 0 560.384 1024H819.2a204.8 204.8 0 0 0 204.8-204.8V204.8a204.8 204.8 0 0 0-89.088-168.96 755.2 755.2 0 0 0-437.76 685.312z" fill="#FFE161" p-id="1545"></path><path d="M526.08 140.032l98.304 199.168L844.8 371.2a15.616 15.616 0 0 1 8.704 25.6l-159.744 156.16 37.632 219.136a15.616 15.616 0 0 1-22.528 16.384l-196.608-102.4-196.608 102.4a15.616 15.616 0 0 1-22.528-16.384l37.12-219.136-159.232-155.136a15.616 15.616 0 0 1 8.704-25.6l219.904-32 98.304-199.168a15.616 15.616 0 0 1 28.16-1.024z" fill="#FFF5CC" p-id="1546"></path><path d="M665.6 409.6a444.16 444.16 0 0 0 25.6-61.44l-65.536-9.472-99.584-198.656a15.616 15.616 0 0 0-27.904 0l-98.304 199.168L179.2 371.2a15.616 15.616 0 0 0-8.704 25.6l159.744 156.16-15.104 87.04A407.808 407.808 0 0 0 665.6 409.6z" fill="#FFFFFF" p-id="1547"></path></svg>

Before

Width:  |  Height:  |  Size: 1.5 KiB

-21
View File
@@ -1,21 +0,0 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="keywords" content="AstrBot Soulter" />
<meta name="description" content="AstrBot Dashboard" />
<link
rel="stylesheet"
href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Poppins:wght@400;500;600;700&family=Roboto:wght@400;500;700&display=swap"
/>
<title>AstrBot - 仪表盘</title>
<script type="module" crossorigin src="/assets/index-d089162b.js"></script>
<link rel="stylesheet" href="/assets/index-d7da5bd1.css">
</head>
<body>
<div id="app"></div>
</body>
</html>
+2 -1
View File
@@ -1,5 +1,5 @@
import logging
import asyncio
import asyncio, os
from quart import Quart
from quart.logging import default_handler
from core.core_lifecycle import AstrBotCoreLifecycle
@@ -16,6 +16,7 @@ class AstrBotDashboard():
def __init__(self, core_lifecycle: AstrBotCoreLifecycle, db: BaseDatabase) -> None:
self.core_lifecycle = core_lifecycle
self.config = core_lifecycle.astrbot_config
self.data_path = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../data/dist"))
self.app = Quart("dashboard", static_folder="dist", static_url_path="/")
self.app.json.sort_keys = False
+48 -1
View File
@@ -3,7 +3,9 @@ import os
import asyncio
import sys
import mimetypes
import aiohttp
import zipfile
from typing import List
from core.core_lifecycle import AstrBotCoreLifecycle
from core.db.sqlite import SQLiteDatabase
from core.config import DB_PATH
@@ -37,6 +39,48 @@ def check_env():
mimetypes.add_type("text/javascript", ".js")
mimetypes.add_type("text/javascript", ".mjs")
mimetypes.add_type("application/json", ".json")
async def check_dashboard_files():
'''下载管理面板文件'''
if os.path.exists("data/dist"):
return
dashboard_release_url = "https://api.github.com/repos/Soulter/AstrBot-Dashboard/releases/latest"
logger.info("正在获取管理面板最新版本信息,请稍等片刻...")
async with aiohttp.ClientSession() as session:
async with session.get(dashboard_release_url) as resp:
if resp.status != 200:
logger.error(f"获取管理面板最新版本信息失败: {resp.status}")
return
release_info = await resp.json()
download_url = release_info["assets"][0]["browser_download_url"]
mirrors = ["https://ghp.ci/"]
for i in range(len(mirrors)):
mirrors[i] += download_url
mirrors.append(download_url)
ok = False
for mirror in mirrors:
logger.info(f"正在从 GitHub 下载管理面板文件: {mirror}")
async with aiohttp.ClientSession() as session:
async with session.get(mirror) as resp:
if resp.status != 200:
logger.error(f"下载管理面板文件失败: {resp.status}")
continue
with open("data/dashboard.zip", "wb") as f:
f.write(await resp.read())
logger.info("管理面板文件下载完成。")
ok = True
break
if not ok:
logger.fatal(f"下载管理面板文件失败,请手动前往 {download_url} 下载,并将其中的 dist 文件夹解压到 data 目录下。")
return
# unzip
with zipfile.ZipFile("data/dashboard.zip", "r") as z:
z.extractall("data")
logger.info("管理面板下载完成。")
if __name__ == "__main__":
check_env()
@@ -45,6 +89,9 @@ if __name__ == "__main__":
log_broker = LogBroker()
LogManager.set_queue_handler(logger, log_broker)
# check dashboard files
asyncio.run(check_dashboard_files())
# start db
db = SQLiteDatabase(DB_PATH)