Skip to content

Commit 99194bd

Browse files
committed
0.1.8
1 parent 4c4516a commit 99194bd

File tree

5 files changed

+28
-10
lines changed

5 files changed

+28
-10
lines changed

RoboFile.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,5 @@ public function extDev()
4848
{
4949
$this->_exec("cd extension && pnpm dev");
5050
}
51+
5152
}

extension/background/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ browser.alarms.onAlarm.addListener( async a =>
3535
const config = await load_data("COOKIE_SYNC_SETTING") ;
3636
if( config )
3737
{
38+
if( config.type && config.type == 'pause')
39+
{
40+
console.log("暂停模式,不同步");
41+
return true;
42+
}
43+
3844
// 获得当前的分钟数
3945
const now = new Date();
4046
const minute = now.getMinutes();

extension/function.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ export async function upload_cookie( payload )
159159
console.log( "sha256", sha256 );
160160
const last_uploaded_info = await load_data( 'LAST_UPLOADED_COOKIE' );
161161
// 如果24小时内已经上传过同样内容的数据,则不再上传
162-
if( last_uploaded_info && last_uploaded_info.sha256 === sha256 && new Date().getTime() - last_uploaded_info.timestamp < 1000*60*60*24 )
162+
if( ( !payload['no_cache'] || parseInt(payload['no_cache']) < 1 ) && last_uploaded_info && last_uploaded_info.sha256 === sha256 && new Date().getTime() - last_uploaded_info.timestamp < 1000*60*60*24 )
163163
{
164164
console.log("same data in 24 hours, skip1");
165165
return {action:'done',note:'本地Cookie数据无变动,不再上传'};

extension/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "cookie-cloud",
33
"displayName": "CookieCloud",
44
"description": "__MSG_appDesc__",
5-
"version": "0.1.7",
5+
"version": "0.1.8",
66
"default_locale": "zh_CN",
77
"author": "[email protected]",
88
"license": "GPLv3",

extension/popup.tsx

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,30 @@ function IndexPopup() {
1313
let init: Object={"endpoint":"http://127.0.0.1:8088","password":"","interval":10,"domains":"","uuid":String(short_uid.generate()),"type":"up","keep_live":""};
1414
const [data, setData] = useState(init);
1515

16-
async function test()
16+
async function test(action='测试')
1717
{
18-
// console.log("request,begin");
18+
console.log("request,begin");
1919
if( !data['endpoint'] || !data['password'] || !data['uuid'] || !data['type'] )
2020
{
2121
alert('请填写完整的信息');
2222
return;
2323
}
24-
const ret = await sendToBackground<RequestBody, ResponseBody>({name:"config",body:{payload:data}});
25-
console.log("ret888...",ret);
24+
if( data['type'] == 'pause' )
25+
{
26+
alert('暂停状态不能'+action);
27+
return;
28+
}
29+
const ret = await sendToBackground<RequestBody, ResponseBody>({name:"config",body:{payload:{...data,no_cache:1}}});
30+
console.log(action+"返回",ret);
2631
if( ret && ret['message'] == 'done' )
2732
{
2833
if( ret['note'] )
2934
alert(ret['note']);
3035
else
31-
alert('测试成功');
36+
alert(action+'成功');
3237
}else
3338
{
34-
alert('测试失败,请检查填写的信息是否正确');
39+
alert(action+'失败,请检查填写的信息是否正确');
3540
}
3641
}
3742

@@ -85,14 +90,15 @@ function IndexPopup() {
8590
<Radio.Group onChange={e=>onChange('type',e)} value={data['type']}>
8691
<Radio value={'up'}>上传到服务器</Radio>
8792
<Radio value={'down'}>覆盖到浏览器</Radio>
93+
<Radio value={'pause'}>暂停</Radio>
8894
</Radio.Group>
8995
</div>
9096

9197
{data['type'] && data['type'] == 'down' && <div className="bg-red-600 text-white p-2 my-2 rounded">
9298
覆盖模式主要用于云端和只读用的浏览器,Cookie和Local Storage覆盖可能导致当前浏览器的登录和修改操作失效;另外部分网站不允许同一个cookie在多个浏览器同时登录,可能导致其他浏览器上账号退出。
9399
</div>}
94100

95-
101+
{data['type'] && data['type'] != 'pause' && <>
96102
<div className="">服务器地址</div>
97103
<input type="text" className="border-1 my-2 p-2 rounded w-full" placeholder="请输入服务器地址" value={data['endpoint']} onChange={e=>onChange('endpoint',e)} />
98104
<div className="">用户KEY</div>
@@ -121,9 +127,14 @@ function IndexPopup() {
121127
<div className="">Cookie保活·选填</div>
122128
<textarea className="border-1 my-2 p-2 rounded w-full" style={{"height":"60px"}} placeholder="定时后台刷新URL,模拟用户活跃。一行一个URL,默认60分钟,可用 URL|分钟数 的方式指定刷新时间" onChange={e=>onChange('keep_live',e)} value={data['keep_live']}/>
123129
</>}
130+
</>}
131+
132+
{data['type'] && data['type'] == 'pause' && <>
133+
<div className="bg-blue-400 text-white p-2 my-2 rounded">暂停同步和保活</div>
134+
</>}
124135
<div className="flex flex-row justify-between mt-2">
125136
<div className="left text-gray-400">
126-
<Button className="hover:bg-blue-100" onClick={()=>test()}>测试</Button>
137+
{data['type'] && data['type'] != 'pause' && <><Button className="hover:bg-blue-100 mr-2" onClick={()=>test('手动同步')}>手动同步</Button><Button className="hover:bg-blue-100" onClick={()=>test('测试')}>测试</Button></>}
127138

128139
</div>
129140
<div className="right">

0 commit comments

Comments
 (0)