修改新建订阅提示

This commit is contained in:
whyour 2022-09-21 14:54:45 +08:00
parent a75df03243
commit 23bfbeb995
2 changed files with 14 additions and 31 deletions

View File

@ -11,7 +11,7 @@ if (!process.env.QL_DIR) {
if (qlHomePath.endsWith('/static/')) { if (qlHomePath.endsWith('/static/')) {
qlHomePath = path.join(qlHomePath, '../'); qlHomePath = path.join(qlHomePath, '../');
} }
process.env.QL_DIR = qlHomePath; process.env.QL_DIR = qlHomePath.replace(/\/$/g, '');
} }
const lastVersionFile = `http://qn.whyour.cn/version.ts?v=${Date.now()}`; const lastVersionFile = `http://qn.whyour.cn/version.ts?v=${Date.now()}`;

View File

@ -190,8 +190,8 @@ const SubscriptionModal = ({
}; };
const onPaste = useCallback((e: any) => { const onPaste = useCallback((e: any) => {
const text = e.clipboardData.getData('text'); const text = e.clipboardData.getData('text') as string;
if (!subscription && text.includes('ql ')) { if (text.startsWith('ql ')) {
const [ const [
, ,
type, type,
@ -208,8 +208,8 @@ const SubscriptionModal = ({
type === 'raw' type === 'raw'
? 'file' ? 'file'
: url.startsWith('http') : url.startsWith('http')
? 'public-repo' ? 'public-repo'
: 'private-repo'; : 'private-repo';
form.setFieldsValue({ form.setFieldsValue({
type: _type, type: _type,
@ -225,6 +225,13 @@ const SubscriptionModal = ({
} }
}, []); }, []);
const onNamePaste = useCallback((e) => {
const text = e.clipboardData.getData('text') as string;
if (text.startsWith('ql ')) {
e.preventDefault();
}
}, []);
useEffect(() => { useEffect(() => {
if (visible) { if (visible) {
window.addEventListener('paste', onPaste); window.addEventListener('paste', onPaste);
@ -243,34 +250,10 @@ const SubscriptionModal = ({
} }
}, [subscription, visible]); }, [subscription, visible]);
const isFirefox = navigator.userAgent.includes('Firefox');
const isSafari =
navigator.userAgent.includes('Safari') &&
!navigator.userAgent.includes('Chrome');
const isQQBrowser = navigator.userAgent.includes('QQBrowser');
return ( return (
<Modal <Modal
title={ title={
subscription ? ( subscription ? '编辑订阅' : '新建订阅'
'编辑订阅'
) : (
<span>
<small
style={{
color: '#999',
fontWeight: 400,
fontSize: isFirefox ? 9 : 12,
marginLeft: 2,
zoom: isSafari ? 0.66 : 0.8,
letterSpacing: isQQBrowser ? -2 : 0,
}}
>
repo/raw命令
</small>
</span>
)
} }
open={visible} open={visible}
forceRender forceRender
@ -291,7 +274,7 @@ const SubscriptionModal = ({
> >
<Form form={form} name="form_in_modal" layout="vertical"> <Form form={form} name="form_in_modal" layout="vertical">
<Form.Item name="name" label="名称"> <Form.Item name="name" label="名称">
<Input placeholder="请输入订阅名" /> <Input placeholder="支持拷贝ql repo/raw命令粘贴导入" onPaste={onNamePaste} />
</Form.Item> </Form.Item>
<Form.Item <Form.Item
name="type" name="type"