尝试修复webui一些bug (#726)
* Fix: 新增/修改配置时报错 * Fix: 不开始录制 * Fix: 更新LiveStreamer表时报错
This commit is contained in:
8 files changed
+43
-17
No files matched your search
@@ -0,0 +1 @@
|
||||
NEXT_PUBLIC_API_SERVER=http://localhost:19159
|
||||
+14
-5
@@ -14,6 +14,12 @@ const Dashboard: React.FC = () => {
|
||||
const { data: entity, error, isLoading } = useSWR("/v1/configuration", fetcher);
|
||||
const { trigger } = useSWRMutation("/v1/configuration", put);
|
||||
const formRef = useRef<FormApi>();
|
||||
const [formKey, setFormKey] = useState(0); // 初始化一个key
|
||||
|
||||
// 触发表单重新挂载
|
||||
const remountForm = () => {
|
||||
setFormKey(prevKey => prevKey + 1); // 更新key的值
|
||||
};
|
||||
|
||||
const [labelPosition, setLabelPosition] = useState<'top' | 'left' | 'inset'>('inset');
|
||||
useEffect(() => {
|
||||
@@ -27,6 +33,10 @@ const Dashboard: React.FC = () => {
|
||||
})
|
||||
return () => unRegister();
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
remountForm();
|
||||
}, [entity]);
|
||||
// const handleSelectChange = (value) => {
|
||||
// let text = value === 'male' ? 'Hi male' : 'Hi female!';
|
||||
// formRef.current?.setValue('Note', text);
|
||||
@@ -50,7 +60,8 @@ const Dashboard: React.FC = () => {
|
||||
></Nav>
|
||||
</Header>
|
||||
<Content>
|
||||
<Form initValues={entity}
|
||||
<Form key = {formKey}
|
||||
initValues={entity}
|
||||
onSubmit={async (values) => {
|
||||
await trigger(values)
|
||||
}}
|
||||
@@ -62,11 +73,11 @@ const Dashboard: React.FC = () => {
|
||||
label={{text: "分段大小"} }
|
||||
suffix={'MB'}
|
||||
/>
|
||||
<Form.InputNumber
|
||||
<Form.Input
|
||||
field='segment_time'
|
||||
extraText="录像单文件时间限制,格式'00:00:00'(时分秒),超过此大小分段下载,如需使用大小分段请注释此字段"
|
||||
label={{text: '分段时间'} }
|
||||
suffix={'分钟'}
|
||||
style={{width: 400}}
|
||||
/>
|
||||
<Form.InputNumber
|
||||
field="filtering_threshold"
|
||||
@@ -169,13 +180,11 @@ tctc-h5(备用线路4), tct-h5(备用线路5), ali-h5(备用线路6)
|
||||
例如录制https://www.youtube.com/@NeneAmanoCh/streams,关闭后将忽略直播回放
|
||||
'
|
||||
label="youtube_enable_download_playback"
|
||||
style={{width: 400}}
|
||||
/>
|
||||
<Form.Switch
|
||||
field="twitch_danmaku"
|
||||
extraText='录制Twitch弹幕,默认关闭【只有下载器为FFMPEG时才有效】'
|
||||
label="twitch_danmaku"
|
||||
style={{width: 400}}
|
||||
/>
|
||||
<Form.Switch
|
||||
field="twitch_disable_ads"
|
||||
|
||||
@@ -37,7 +37,7 @@ const TemplateFields: React.FC<FormFCChild> = ({ formState, formApi, values }) =
|
||||
const {biliUsers} = useBiliUsers();
|
||||
const list = biliUsers?.map((item) => {
|
||||
return {
|
||||
value: item.id, label: <>
|
||||
value: item.value, label: <>
|
||||
<Avatar size="extra-small" src={item.face} />
|
||||
<span style={{ marginLeft: 8 }}>
|
||||
{item.name}
|
||||
@@ -64,7 +64,7 @@ const TemplateFields: React.FC<FormFCChild> = ({ formState, formApi, values }) =
|
||||
field="copyright"
|
||||
label='类型'
|
||||
direction='vertical'
|
||||
initValue={1}
|
||||
// initValue={1}
|
||||
>
|
||||
<div onClick={()=>formApi.setValue('source', '')}>
|
||||
<Radio value={1}>自制</Radio>
|
||||
@@ -97,7 +97,7 @@ const TemplateFields: React.FC<FormFCChild> = ({ formState, formApi, values }) =
|
||||
style={{width: 560}}
|
||||
/>
|
||||
<TextArea style={{maxWidth: 560}}
|
||||
field="desc" label='简介' placeholder="填写更全面的相关信息,让更多的人能找到你的视频吧"
|
||||
field="description" label='简介' placeholder="填写更全面的相关信息,让更多的人能找到你的视频吧"
|
||||
autosize maxCount={2000} showClear/>
|
||||
|
||||
<div style={{display: 'flex', alignItems: 'center', color: 'var(--semi-color-tertiary)'}}>
|
||||
|
||||
@@ -56,7 +56,7 @@ const EditTemplate: React.FC = () => {
|
||||
tid: values?.tid[1],
|
||||
cover: values?.cover ?? '',
|
||||
title: values?.title ?? '',
|
||||
desc: values?.desc ?? '',
|
||||
description: values?.description ?? '',
|
||||
dynamic: values?.dynamic ?? '',
|
||||
tag: values?.tag ?? '',
|
||||
interactive: values?.interactive ?? 0,
|
||||
@@ -68,7 +68,8 @@ const EditTemplate: React.FC = () => {
|
||||
open_elec: values?.open_elec,
|
||||
no_reprint: values?.no_reprint,
|
||||
mission_id: values?.mission_id,
|
||||
dtime: values?.dtime
|
||||
dtime: values?.dtime,
|
||||
user_cookie: values?.user,
|
||||
}
|
||||
const result = await trigger(studioEntity);
|
||||
await mutate(result);
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ async def shot(event):
|
||||
from biliup.handler import CHECK
|
||||
index = 0
|
||||
while True:
|
||||
if len(event.url_list):
|
||||
if not len(event.url_list):
|
||||
logger.info(f"{event}没有任务,退出")
|
||||
return
|
||||
if index >= len(event.url_list):
|
||||
|
||||
+2
-1
@@ -25,7 +25,8 @@ class Config(UserDict):
|
||||
|
||||
def load_from_db(self):
|
||||
for con in Configuration.select().where(Configuration.key == 'config'):
|
||||
self.data = json.loads(con.value)
|
||||
# self.data = json.loads(con.value)
|
||||
self.data.update(json.loads(con.value))
|
||||
self['streamers'] = {}
|
||||
for ls in LiveStreamers.select():
|
||||
self['streamers'][ls.remark] = model_to_dict(ls)
|
||||
|
||||
+11
-1
@@ -142,12 +142,22 @@ class DB:
|
||||
# 创建新的临时表格
|
||||
TempStreamerInfo.create_table()
|
||||
# 将数据从原表格拷贝到新表格
|
||||
db.execute_sql('INSERT INTO temp_streamer_info (name, url, title, date, live_cover_path) SELECT name, url, title, date, live_cover_path FROM streamerinfo')
|
||||
db.execute_sql(
|
||||
'INSERT INTO temp_streamer_info (name, url, title, date, live_cover_path) SELECT name, url, title, date, live_cover_path FROM streamerinfo')
|
||||
# 删除原表格
|
||||
StreamerInfo.drop_table()
|
||||
# 将新表格重命名为原表格的名字
|
||||
db.execute_sql('ALTER TABLE temp_streamer_info RENAME TO streamerinfo')
|
||||
|
||||
@classmethod
|
||||
def update_live_streamer(cls, id, url, remark, filename_prefix=None, upload_streamers=None, **kwargs):
|
||||
""" 更新 LiveStreamers 表中的数据, 增加一层包装避免多余参数报错 """
|
||||
LiveStreamers.update(
|
||||
url=url,
|
||||
remark=remark,
|
||||
filename_prefix=filename_prefix,
|
||||
upload_streamers=upload_streamers).where(LiveStreamers.id == id).execute()
|
||||
|
||||
def backup(self):
|
||||
"""备份数据库"""
|
||||
pass
|
||||
@@ -12,7 +12,8 @@ import stream_gears
|
||||
import biliup.common.reload
|
||||
from biliup.config import config
|
||||
from biliup.plugins.bili_webup import BiliBili, Data
|
||||
from ..database.models import UploadStreamers, LiveStreamers, db, Configuration
|
||||
from ..database.models import UploadStreamers, LiveStreamers, Configuration
|
||||
from ..database.db import DB as db
|
||||
|
||||
BiliBili = BiliBili(Data())
|
||||
|
||||
@@ -76,7 +77,7 @@ async def set_streamer_config(request):
|
||||
return web.json_response({"status": 200}, status=200)
|
||||
|
||||
|
||||
async def save_config(reequest):
|
||||
async def save_config(request):
|
||||
config.save()
|
||||
biliup.common.reload.global_reloader.triggered = True
|
||||
import logging
|
||||
@@ -217,9 +218,11 @@ async def lives(request):
|
||||
try:
|
||||
if uid:
|
||||
us = UploadStreamers.get_by_id(json_data['upload_id'])
|
||||
LiveStreamers.update(**json_data, upload_streamers=us).where(LiveStreamers.id == old.id).execute()
|
||||
# LiveStreamers.update(**json_data, upload_streamers=us).where(LiveStreamers.id == old.id).execute()
|
||||
db.update_live_streamer(**{**json_data, "upload_streamers": us})
|
||||
else:
|
||||
LiveStreamers.update(**json_data).where(LiveStreamers.id == old.id).execute()
|
||||
# LiveStreamers.update(**json_data).where(LiveStreamers.id == old.id).execute()
|
||||
db.update_live_streamer(**json_data)
|
||||
except Exception as e:
|
||||
return web.HTTPBadRequest(text=str(e))
|
||||
config.load_from_db()
|
||||
@@ -270,6 +273,7 @@ async def streamers_put(request):
|
||||
|
||||
@routes.get('/v1/users')
|
||||
async def users(request):
|
||||
# Todo: 实现扫描当前目录下的cookie文件
|
||||
return web.json_response([{
|
||||
'id': 1,
|
||||
'name': 'cookies.json',
|
||||
|
||||
Reference in new issue
Block a user