Skip to content

Commit b405879

Browse files
committed
更新[BoxJs]: 处理由于链接地址发生变更导致的全屏失效问题 (更新>重启代理>无痕访问>添加桌面)
1 parent 372d9af commit b405879

3 files changed

Lines changed: 55 additions & 13 deletions

File tree

box/release/box.release.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"releases": [
3+
{
4+
"version": "1.0.0",
5+
"tags": ["beta"],
6+
"author": "@chavyleung",
7+
"icon": "https://avatars3.githubusercontent.com/u/29748519",
8+
"repo": "https://github.com/chavyleung",
9+
"note": [
10+
{
11+
"name": "新增",
12+
"list": ["增加版本时间线"]
13+
}
14+
]
15+
}
16+
]
17+
}

chavy.box.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,25 +1175,32 @@ function printHtml(data, curapp = null, curview = 'app') {
11751175
'ui.curview': {
11761176
handler(newval, oldval) {
11771177
this.ui.bfview = oldval
1178+
const isFullScreen = window.navigator.standalone
11781179
if (newval === 'app') {
11791180
this.ui.curapp = null
11801181
this.ui.curappSessions = null
11811182
var state = { title: 'BoxJs' }
11821183
document.title = state.title
1183-
history.pushState(state, '', '/home')
1184+
if (!isFullScreen) {
1185+
history.pushState(state, '', '/home')
1186+
}
11841187
this.$vuetify.goTo(this.ui.scrollY, { duration: 0, offset: 0 })
11851188
} else if (newval === 'sub') {
11861189
this.ui.curapp = null
11871190
this.ui.curappSessions = null
11881191
var state = { title: 'BoxJs' }
11891192
document.title = state.title
1190-
history.pushState(state, '', '/sub')
1193+
if (!isFullScreen) {
1194+
history.pushState(state, '', '/sub')
1195+
}
11911196
} else if (newval === 'my') {
11921197
this.ui.curapp = null
11931198
this.ui.curappSessions = null
11941199
var state = { title: 'BoxJs' }
11951200
document.title = state.title
1196-
history.pushState(state, '', '/my')
1201+
if (!isFullScreen) {
1202+
history.pushState(state, '', '/my')
1203+
}
11971204
}
11981205
}
11991206
}
@@ -1241,7 +1248,10 @@ function printHtml(data, curapp = null, curview = 'app') {
12411248
this.ui.curappSessions = this.box.sessions.filter((s) => s.appId === this.ui.curapp.id)
12421249
this.ui.curview = 'appsession'
12431250
var state = { title: 'BoxJs - ' + this.ui.curapp.name, url: window.location.href }
1244-
history.pushState(state, '', '/app/' + this.ui.curapp.id)
1251+
const isFullScreen = window.navigator.standalone
1252+
if (!isFullScreen) {
1253+
history.pushState(state, '', '/app/' + this.ui.curapp.id)
1254+
}
12451255
document.title = state.title
12461256
},
12471257
onClearCurAppSessionData(app, datas, data) {

noteyoudao/noteyoudao.js

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,38 @@
11
const $ = new Env('有道云笔记')
2+
$.VAL_login = $.getdata('chavy_login_noteyoudao')
23
$.VAL_sign_url = $.getdata('chavy_signurl_noteyoudao')
34
$.VAL_sign_body = $.getdata('chavy_signbody_noteyoudao')
45
$.VAL_sign_headers = $.getdata('chavy_signheaders_noteyoudao')
56

67
!(async () => {
7-
$.log('', `🔔 ${$.name}, 开始!`, '')
8+
await loginapp()
89
await signinapp()
910
await logindaily()
1011
await showmsg()
1112
})()
12-
.catch((e) => {
13-
$.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '')
14-
})
15-
.finally(() => {
16-
$.msg($.name, $.subt, $.desc), $.log('', `🔔 ${$.name}, 结束!`, ''), $.done()
13+
.catch((e) => $.logErr(e))
14+
.finally(() => $.done())
15+
16+
function loginapp() {
17+
return new Promise((resove) => {
18+
const { url, body, headers } = JSON.parse($.VAL_login)
19+
$.post({ url, body, headers: JSON.parse(headers) }, (error, response, data) => {
20+
try {
21+
if (error) throw new Error(error)
22+
$.log(`❕ ${$.name}, 登录: ${JSON.stringify(response)}`)
23+
} catch (e) {
24+
$.log(`❗️ ${$.name}, 每日登录: 失败!`, ` error = ${error || e}`, `response = ${JSON.stringify(response)}`, `data = ${data}`, '')
25+
} finally {
26+
resove()
27+
}
28+
})
1729
})
30+
}
1831

1932
function logindaily() {
20-
const url = { url: 'https://note.youdao.com/yws/api/daupromotion?method=sync', headers: JSON.parse($.VAL_sign_headers) }
2133
return new Promise((resove) => {
34+
const url = { url: 'https://note.youdao.com/yws/api/daupromotion?method=sync', headers: JSON.parse($.VAL_sign_headers) }
35+
delete url.headers.Cookie
2236
$.post(url, (error, response, data) => {
2337
try {
2438
if (error) throw new Error(error)
@@ -34,8 +48,9 @@ function logindaily() {
3448
}
3549

3650
function signinapp() {
37-
const url = { url: $.VAL_sign_url, body: $.VAL_sign_body, headers: JSON.parse($.VAL_sign_headers) }
3851
return new Promise((resove) => {
52+
const url = { url: $.VAL_sign_url, body: $.VAL_sign_body, headers: JSON.parse($.VAL_sign_headers) }
53+
delete url.headers.Cookie
3954
$.post(url, (error, response, data) => {
4055
try {
4156
if (error) throw new Error(error)
@@ -64,4 +79,4 @@ function showmsg() {
6479
}
6580

6681
// prettier-ignore
67-
function Env(t){this.name=t,this.logs=[],this.isSurge=(()=>"undefined"!=typeof $httpClient),this.isQuanX=(()=>"undefined"!=typeof $task),this.log=((...t)=>{this.logs=[...this.logs,...t],t?console.log(t.join("\n")):console.log(this.logs.join("\n"))}),this.msg=((t=this.name,s="",i="")=>{this.isSurge()&&$notification.post(t,s,i),this.isQuanX()&&$notify(t,s,i),this.log("==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============="),t&&this.log(t),s&&this.log(s),i&&this.log(i)}),this.getdata=(t=>this.isSurge()?$persistentStore.read(t):this.isQuanX()?$prefs.valueForKey(t):void 0),this.setdata=((t,s)=>this.isSurge()?$persistentStore.write(t,s):this.isQuanX()?$prefs.setValueForKey(t,s):void 0),this.get=((t,s)=>this.send(t,"GET",s)),this.wait=((t,s=t)=>i=>setTimeout(()=>i(),Math.floor(Math.random()*(s-t+1)+t))),this.post=((t,s)=>this.send(t,"POST",s)),this.send=((t,s,i)=>{if(this.isSurge()){const e="POST"==s?$httpClient.post:$httpClient.get;e(t,(t,s,e)=>{s&&(s.body=e,s.statusCode=s.status),i(t,s,e)})}this.isQuanX()&&(t.method=s,$task.fetch(t).then(t=>{t.status=t.statusCode,i(null,t,t.body)},t=>i(t.error,t,t)))}),this.done=((t={})=>$done(t))}
82+
function Env(t,s){return new class{constructor(t,s){this.name=t,this.data=null,this.dataFile="box.dat",this.logs=[],this.logSeparator="\n",this.startTime=(new Date).getTime(),Object.assign(this,s),this.log("",`\ud83d\udd14${this.name}, \u5f00\u59cb!`)}isNode(){return"undefined"!=typeof module&&!!module.exports}isQuanX(){return"undefined"!=typeof $task}isSurge(){return"undefined"!=typeof $httpClient}isLoon(){return"undefined"!=typeof $loon}loaddata(){if(!this.isNode)return{};{this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),s=this.path.resolve(process.cwd(),this.dataFile),e=this.fs.existsSync(t),i=!e&&this.fs.existsSync(s);if(!e&&!i)return{};{const i=e?t:s;try{return JSON.parse(this.fs.readFileSync(i))}catch{return{}}}}}writedata(){if(this.isNode){this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),s=this.path.resolve(process.cwd(),this.dataFile),e=this.fs.existsSync(t),i=!e&&this.fs.existsSync(s),h=JSON.stringify(this.data);e?this.fs.writeFileSync(t,h):i?this.fs.writeFileSync(s,h):this.fs.writeFileSync(t,h)}}getdata(t){return this.isSurge()||this.isLoon()?$persistentStore.read(t):this.isQuanX()?$prefs.valueForKey(t):this.isNode()?(this.data=this.loaddata(),this.data[t]):this.data&&this.data[t]||null}setdata(t,s){return this.isSurge()||this.isLoon()?$persistentStore.write(t,s):this.isQuanX()?$prefs.setValueForKey(t,s):this.isNode()?(this.data=this.loaddata(),this.data[s]=t,this.writedata(),!0):this.data&&this.data[s]||null}initGotEnv(t){this.got=this.got?this.got:require("got"),this.cktough=this.cktough?this.cktough:require("tough-cookie"),this.ckjar=this.ckjar?this.ckjar:new this.cktough.CookieJar,t&&(t.headers=t.headers?t.headers:{},void 0===t.headers.Cookie&&void 0===t.cookieJar&&(t.cookieJar=this.ckjar))}get(t,s=(()=>{})){t.headers&&(delete t.headers["Content-Type"],delete t.headers["Content-Length"]),this.isSurge()||this.isLoon()?$httpClient.get(t,(t,e,i)=>{!t&&e&&(e.body=i,e.statusCode=e.status,s(t,e,i))}):this.isQuanX()?$task.fetch(t).then(t=>{const{statusCode:e,statusCode:i,headers:h,body:o}=t;s(null,{status:e,statusCode:i,headers:h,body:o},o)},t=>s(t)):this.isNode()&&(this.initGotEnv(t),this.got(t).on("redirect",(t,s)=>{try{const e=t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString();this.ckjar.setCookieSync(e,null),s.cookieJar=this.ckjar}catch(t){this.logErr(t)}}).then(t=>{const{statusCode:e,statusCode:i,headers:h,body:o}=t;s(null,{status:e,statusCode:i,headers:h,body:o},o)},t=>s(t)))}post(t,s=(()=>{})){if(t.body&&t.headers&&!t.headers["Content-Type"]&&(t.headers["Content-Type"]="application/x-www-form-urlencoded"),delete t.headers["Content-Length"],this.isSurge()||this.isLoon())$httpClient.post(t,(t,e,i)=>{!t&&e&&(e.body=i,e.statusCode=e.status,s(t,e,i))});else if(this.isQuanX())t.method="POST",$task.fetch(t).then(t=>{const{statusCode:e,statusCode:i,headers:h,body:o}=t;s(null,{status:e,statusCode:i,headers:h,body:o},o)},t=>s(t));else if(this.isNode()){this.initGotEnv(t);const{url:e,...i}=t;this.got.post(e,i).then(t=>{const{statusCode:e,statusCode:i,headers:h,body:o}=t;s(null,{status:e,statusCode:i,headers:h,body:o},o)},t=>s(t))}}msg(s=t,e="",i="",h){this.isSurge()||this.isLoon()?$notification.post(s,e,i):this.isQuanX()&&$notify(s,e,i),this.logs.push("","==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============="),this.logs.push(s),e&&this.logs.push(e),i&&this.logs.push(i)}log(...t){t.length>0?this.logs=[...this.logs,...t]:console.log(this.logs.join(this.logSeparator))}logErr(t,s){const e=!this.isSurge()&&!this.isQuanX()&&!this.isLoon();e?$.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t.stack):$.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t.message)}wait(t){return new Promise(s=>setTimeout(s,t))}done(t=null){const s=(new Date).getTime(),e=(s-this.startTime)/1e3;this.log("",`\ud83d\udd14${this.name}, \u7ed3\u675f! \ud83d\udd5b ${e} \u79d2`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,s)}

0 commit comments

Comments
 (0)