@@ -0,0 +1 @@
|
||||
import{q as e,o as a,c as t,w as o,d as s,x as n,U as r,X as c}from"./index-440fed29.js";const f=e({__name:"BlankLayout",setup(p){return(u,_)=>(a(),t(r,null,{default:o(()=>[s(n(c))]),_:1}))}});export{f as default};
|
||||
@@ -1 +0,0 @@
|
||||
import{q as e,o as a,b as t,w as o,c as s,x as n,X as r,Z as c}from"./index-7e5a38e4.js";const f=e({__name:"BlankLayout",setup(p){return(u,_)=>(a(),t(r,null,{default:o(()=>[s(n(c))]),_:1}))}});export{f as default};
|
||||
@@ -1 +0,0 @@
|
||||
import{q as C,o as l,b as n,w as t,c as o,a0 as k,u as i,H as x,a as U,t as m,a1 as v,A as f,I as w,G as N,l as s,n as _,Q as S,R as B,F as r,a4 as D,M as y,a5 as T,e as $,m as F,g as b}from"./index-7e5a38e4.js";const A={class:"d-sm-flex align-center justify-space-between"},I=C({__name:"UiParentCard",props:{title:String},setup(d){const c=d;return(p,u)=>(l(),n(N,{variant:"outlined",elevation:"0",class:"withbg"},{default:t(()=>[o(k,null,{default:t(()=>[i("div",A,[o(x,null,{default:t(()=>[U(m(c.title),1)]),_:1}),v(p.$slots,"action")])]),_:3}),o(f),o(w,null,{default:t(()=>[v(p.$slots,"default")]),_:3})]),_:3}))}}),q={__name:"ConfigDetailCard",props:{config:Array},setup(d){return(c,p)=>(l(!0),s(r,null,_(d.config,u=>(l(),n(I,{key:u.name,title:u.name,style:{"margin-bottom":"16px"}},{default:t(()=>[S(i("a",null,"No data",512),[[B,d.config.length===0]]),(l(!0),s(r,null,_(u.body,e=>(l(),s(r,null,[e.config_type==="item"?(l(),s(r,{key:0},[e.val_type==="bool"?(l(),n(D,{key:0,modelValue:e.value,"onUpdate:modelValue":a=>e.value=a,label:e.name,hint:e.description,color:"primary",inset:""},null,8,["modelValue","onUpdate:modelValue","label","hint"])):e.val_type==="str"?(l(),n(y,{key:1,modelValue:e.value,"onUpdate:modelValue":a=>e.value=a,label:e.name,hint:e.description,style:{"margin-bottom":"8px"},variant:"outlined"},null,8,["modelValue","onUpdate:modelValue","label","hint"])):e.val_type==="int"?(l(),n(y,{key:2,modelValue:e.value,"onUpdate:modelValue":a=>e.value=a,label:e.name,hint:e.description,style:{"margin-bottom":"8px"},variant:"outlined"},null,8,["modelValue","onUpdate:modelValue","label","hint"])):e.val_type==="list"?(l(),s(r,{key:3},[i("span",null,m(e.name),1),o(T,{modelValue:e.value,"onUpdate:modelValue":a=>e.value=a,chips:"",clearable:"",label:"请添加",multiple:"","prepend-icon":"mdi-tag-multiple-outline"},{selection:t(({attrs:a,item:V,select:g,selected:h})=>[o($,F(a,{"model-value":h,closable:"",onClick:g,"onClick:close":P=>c.remove(V)}),{default:t(()=>[i("strong",null,m(V),1)]),_:2},1040,["model-value","onClick","onClick:close"])]),_:2},1032,["modelValue","onUpdate:modelValue"])],64)):b("",!0)],64)):e.config_type==="divider"?(l(),n(f,{key:1,style:{"margin-top":"8px","margin-bottom":"8px"}})):b("",!0)],64))),256))]),_:2},1032,["title"]))),128))}};export{q as _};
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Vendored
+1
-1
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
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
File diff suppressed because one or more lines are too long
+2
-2
File diff suppressed because one or more lines are too long
+2
-2
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
@@ -1,4 +1,4 @@
|
||||
import{aj as L,q as $,B as J,o as q,l as X,c as G,w as Q,Q as R,R as O,x as S,u as m,ak as Z,al as t0,am as r0,an as e0}from"./index-7e5a38e4.js";const E={Sidebar_drawer:!0,Customizer_drawer:!1,mini_sidebar:!1,fontTheme:"Roboto",inputBg:!1},i0=L({id:"customizer",state:()=>({Sidebar_drawer:E.Sidebar_drawer,Customizer_drawer:E.Customizer_drawer,mini_sidebar:E.mini_sidebar,fontTheme:"Poppins",inputBg:E.inputBg}),getters:{},actions:{SET_SIDEBAR_DRAWER(){this.Sidebar_drawer=!this.Sidebar_drawer},SET_MINI_SIDEBAR(p){this.mini_sidebar=p},SET_FONT(p){this.fontTheme=p}}}),s0={class:"logo",style:{display:"flex","align-items":"center"}},a0={style:{"font-size":"24px","font-weight":"1000"}},f0={style:{"font-size":"20px","font-weight":"1000"}},o0={style:{"font-size":"20px"}},l0=$({__name:"LogoDark",setup(p){J("rgb(var(--v-theme-primary))"),J("rgb(var(--v-theme-secondary))");const d=i0();return(M,y)=>(q(),X("div",s0,[G(S(Z),{to:"/",style:{"text-decoration":"none",color:"black"}},{default:Q(()=>[R(m("span",a0,"AstrBot 仪表盘",512),[[O,!S(d).mini_sidebar]]),R(m("span",f0,"Astr",512),[[O,S(d).mini_sidebar]]),R(m("span",o0,"Bot",512),[[O,S(d).mini_sidebar]])]),_:1})]))}});var P={exports:{}};const n0={},h0=Object.freeze(Object.defineProperty({__proto__:null,default:n0},Symbol.toStringTag,{value:"Module"})),H=t0(h0);/**
|
||||
import{aj as L,q as $,B as J,o as q,l as X,d as G,w as Z,a0 as O,a1 as R,x as S,u as m,ak as Q,al as t0,am as r0,an as e0}from"./index-440fed29.js";const E={Sidebar_drawer:!0,Customizer_drawer:!1,mini_sidebar:!1,fontTheme:"Roboto",inputBg:!1},i0=L({id:"customizer",state:()=>({Sidebar_drawer:E.Sidebar_drawer,Customizer_drawer:E.Customizer_drawer,mini_sidebar:E.mini_sidebar,fontTheme:"Poppins",inputBg:E.inputBg}),getters:{},actions:{SET_SIDEBAR_DRAWER(){this.Sidebar_drawer=!this.Sidebar_drawer},SET_MINI_SIDEBAR(p){this.mini_sidebar=p},SET_FONT(p){this.fontTheme=p}}}),s0={class:"logo",style:{display:"flex","align-items":"center"}},a0={style:{"font-size":"24px","font-weight":"1000"}},f0={style:{"font-size":"20px","font-weight":"1000"}},o0={style:{"font-size":"20px"}},l0=$({__name:"LogoDark",setup(p){J("rgb(var(--v-theme-primary))"),J("rgb(var(--v-theme-secondary))");const d=i0();return(M,y)=>(q(),X("div",s0,[G(S(Q),{to:"/",style:{"text-decoration":"none",color:"black"}},{default:Z(()=>[O(m("span",a0,"AstrBot 仪表盘",512),[[R,!S(d).mini_sidebar]]),O(m("span",f0,"Astr",512),[[R,S(d).mini_sidebar]]),O(m("span",o0,"Bot",512),[[R,S(d).mini_sidebar]])]),_:1})]))}});var P={exports:{}};const n0={},h0=Object.freeze(Object.defineProperty({__proto__:null,default:n0},Symbol.toStringTag,{value:"Module"})),H=t0(h0);/**
|
||||
* [js-md5]{@link https://github.com/emn178/js-md5}
|
||||
*
|
||||
* @namespace md5
|
||||
Vendored
+2
-2
@@ -11,8 +11,8 @@
|
||||
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-7e5a38e4.js"></script>
|
||||
<link rel="stylesheet" href="/assets/index-0f1523f3.css">
|
||||
<script type="module" crossorigin src="/assets/index-440fed29.js"></script>
|
||||
<link rel="stylesheet" href="/assets/index-86dd25ba.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
|
||||
+1
-74
@@ -1,80 +1,6 @@
|
||||
VERSION = '3.3.16'
|
||||
DB_PATH = 'data/data_v2.db'
|
||||
|
||||
DEFAULT_CONFIG = {
|
||||
"qqbot": {
|
||||
"enable": False,
|
||||
"appid": "",
|
||||
"token": "",
|
||||
},
|
||||
"gocqbot": {
|
||||
"enable": False,
|
||||
},
|
||||
"uniqueSessionMode": False,
|
||||
"dump_history_interval": 10,
|
||||
"limit": {
|
||||
"time": 60,
|
||||
"count": 30,
|
||||
},
|
||||
"notice": "",
|
||||
"direct_message_mode": True,
|
||||
"reply_prefix": "",
|
||||
"baidu_aip": {
|
||||
"enable": False,
|
||||
"app_id": "",
|
||||
"api_key": "",
|
||||
"secret_key": ""
|
||||
},
|
||||
"openai": {
|
||||
"key": [],
|
||||
"api_base": "",
|
||||
"chatGPTConfigs": {
|
||||
"model": "gpt-4o",
|
||||
"max_tokens": 6000,
|
||||
"temperature": 0.9,
|
||||
"top_p": 1,
|
||||
"frequency_penalty": 0,
|
||||
"presence_penalty": 0,
|
||||
},
|
||||
"total_tokens_limit": 10000,
|
||||
},
|
||||
"qq_forward_threshold": 200,
|
||||
"qq_welcome": "",
|
||||
"qq_pic_mode": True,
|
||||
"gocq_host": "127.0.0.1",
|
||||
"gocq_http_port": 5700,
|
||||
"gocq_websocket_port": 6700,
|
||||
"gocq_react_group": True,
|
||||
"gocq_react_guild": True,
|
||||
"gocq_react_friend": True,
|
||||
"gocq_react_group_increase": True,
|
||||
"other_admins": [],
|
||||
"CHATGPT_BASE_URL": "",
|
||||
"qqbot_secret": "",
|
||||
"qqofficial_enable_group_message": False,
|
||||
"admin_qq": "",
|
||||
"nick_qq": ["/", "!"],
|
||||
"admin_qqchan": "",
|
||||
"llm_env_prompt": "",
|
||||
"llm_wake_prefix": "",
|
||||
"default_personality_str": "",
|
||||
"openai_image_generate": {
|
||||
"model": "dall-e-3",
|
||||
"size": "1024x1024",
|
||||
"style": "vivid",
|
||||
"quality": "standard",
|
||||
},
|
||||
"http_proxy": "",
|
||||
"https_proxy": "",
|
||||
"dashboard_username": "",
|
||||
"dashboard_password": "",
|
||||
"aiocqhttp": {
|
||||
"enable": False,
|
||||
"ws_reverse_host": "",
|
||||
"ws_reverse_port": 0,
|
||||
}
|
||||
}
|
||||
|
||||
# 新版本配置文件,摈弃旧版本令人困惑的配置项 :D
|
||||
DEFAULT_CONFIG_VERSION_2 = {
|
||||
"config_version": 2,
|
||||
@@ -232,6 +158,7 @@ MAPPINGS_1_2 = [
|
||||
[["nick_qq"], ["wake_prefix"]],
|
||||
]
|
||||
|
||||
# 配置项的中文描述、值类型
|
||||
CONFIG_METADATA_2 = {
|
||||
"config_version": {"description": "配置版本", "type": "int"},
|
||||
"platform": {
|
||||
|
||||
+9
-43
@@ -3,7 +3,7 @@ import json
|
||||
import shutil
|
||||
import logging
|
||||
from util.io import on_error
|
||||
from type.config import DEFAULT_CONFIG, DEFAULT_CONFIG_VERSION_2, MAPPINGS_1_2
|
||||
from type.config import DEFAULT_CONFIG_VERSION_2, MAPPINGS_1_2
|
||||
from dataclasses import dataclass, field, asdict
|
||||
from typing import List, Dict, Optional
|
||||
|
||||
@@ -176,7 +176,7 @@ class AstrBotConfig():
|
||||
self.https_proxy=data.get("https_proxy", "")
|
||||
self.http_proxy=data.get("http_proxy", "")
|
||||
self.dashboard=DashboardConfig(**data.get("dashboard", {}))
|
||||
self.wake_prefix=data.get("wake_prefix", [])
|
||||
self.wake_prefix=data.get("wake_prefix", ["/"])
|
||||
self.log_level=data.get("log_level", "INFO")
|
||||
self.t2i_endpoint=data.get("t2i_endpoint", "")
|
||||
|
||||
@@ -229,22 +229,15 @@ class AstrBotConfig():
|
||||
config = self.migrate_config_1_2(config)
|
||||
self.flush_config(config)
|
||||
|
||||
_tag = False
|
||||
for key, val in DEFAULT_CONFIG_VERSION_2.items():
|
||||
if key not in config:
|
||||
config[key] = val
|
||||
_tag = True
|
||||
if _tag:
|
||||
with open(ASTRBOT_CONFIG_PATH, "w", encoding="utf-8-sig") as f:
|
||||
json.dump(config, f, indent=2, ensure_ascii=False)
|
||||
f.flush()
|
||||
|
||||
# 加载配置到对象
|
||||
self.load_from_dict(config)
|
||||
# 保存到文件
|
||||
# 这一步操作是为了保证配置文件中的字段的完整性。
|
||||
# 在版本变动新增配置项时,将对象中新增的配置项的默认值写入文件。
|
||||
self.save_config()
|
||||
|
||||
def get(self, key: str, default=None):
|
||||
'''
|
||||
从文件系统中直接获取配置
|
||||
'''
|
||||
'''从文件系统中直接获取配置'''
|
||||
with open(ASTRBOT_CONFIG_PATH, "r", encoding="utf-8-sig") as f:
|
||||
d = json.load(f)
|
||||
if key in d:
|
||||
@@ -253,9 +246,7 @@ class AstrBotConfig():
|
||||
return default
|
||||
|
||||
def get_all(self):
|
||||
'''
|
||||
从文件系统中获取所有配置
|
||||
'''
|
||||
'''从文件系统中获取所有配置'''
|
||||
with open(ASTRBOT_CONFIG_PATH, "r", encoding="utf-8-sig") as f:
|
||||
conf_str = f.read()
|
||||
if conf_str.startswith(u'/ufeff'): # remove BOM
|
||||
@@ -275,31 +266,6 @@ class AstrBotConfig():
|
||||
|
||||
def to_dict(self) -> Dict:
|
||||
return asdict(self)
|
||||
|
||||
def put_by_dot_str(self, key: str, value):
|
||||
'''根据点分割的字符串,将值写入配置文件'''
|
||||
with open(ASTRBOT_CONFIG_PATH, "r", encoding="utf-8-sig") as f:
|
||||
d = json.load(f)
|
||||
_d = d
|
||||
_ks = key.split(".")
|
||||
for i in range(len(_ks)):
|
||||
if i == len(_ks) - 1:
|
||||
_d[_ks[i]] = value
|
||||
else:
|
||||
_d = _d[_ks[i]]
|
||||
with open(ASTRBOT_CONFIG_PATH, "w", encoding="utf-8-sig") as f:
|
||||
json.dump(d, f, indent=2, ensure_ascii=False)
|
||||
f.flush()
|
||||
|
||||
def update_by_path(self, path: List):
|
||||
'''根据路径更新配置文件。
|
||||
|
||||
这个方法首先会更新缓存在内存中的配置,然后再写入文件。
|
||||
'''
|
||||
|
||||
for key in path:
|
||||
if key not in self:
|
||||
raise KeyError(f"Key {key} not found in config.")
|
||||
|
||||
def check_exist(self) -> bool:
|
||||
return os.path.exists(ASTRBOT_CONFIG_PATH)
|
||||
|
||||
@@ -58,14 +58,19 @@ class AstrBotUpdator(RepoZipUpdator):
|
||||
if self.compare_version(VERSION, latest_version) >= 0:
|
||||
raise Exception("当前已经是最新版本。")
|
||||
file_url = update_data[0]['zipball_url']
|
||||
else:
|
||||
elif str(version).startswith("v"):
|
||||
# 更新到指定版本
|
||||
print(f"请求更新到指定版本: {version}")
|
||||
logger.info(f"正在更新到指定版本: {version}")
|
||||
for data in update_data:
|
||||
if data['tag_name'] == version:
|
||||
file_url = data['zipball_url']
|
||||
if not file_url:
|
||||
raise Exception(f"未找到版本号为 {version} 的更新文件。")
|
||||
else:
|
||||
if len(str(version)) != 40:
|
||||
raise Exception("commit hash 长度不正确,应为 40")
|
||||
logger.info(f"正在尝试更新到指定 commit: {version}")
|
||||
file_url = "https://github.com/Soulter/AstrBot/archive/" + version + ".zip"
|
||||
|
||||
try:
|
||||
await download_file(file_url, "temp.zip")
|
||||
|
||||
Reference in New Issue
Block a user