Skip to content

Commit

Permalink
Merge pull request #434 from VirgilClyne/patch-1
Browse files Browse the repository at this point in the history
fix(BoxJs): done*() at ShadowRocket and Stash
  • Loading branch information
chavyleung authored Mar 18, 2023
2 parents 4212fa6 + 239adb2 commit 2806205
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 42 deletions.
30 changes: 9 additions & 21 deletions box/chavy.boxjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const $ = new Env('BoxJs')
// 为 eval 准备的上下文环境
const $eval_env = {}

$.version = '0.12.4'
$.version = '0.12.5'
$.versionType = 'beta'

// 发出的请求需要需要 Surge、QuanX 的 rewrite
Expand Down Expand Up @@ -872,40 +872,28 @@ function getJsonDoneHeaders() {

function doneOptions() {
const headers = getBaseDoneHeaders()
if ($.isSurge() || $.isLoon()) {
$.done({ response: { headers } })
} else if ($.isQuanX()) {
$.done({ headers })
}
if ($.isQuanX()) $.done({ headers })
else $.done({ response: { headers } })
}

function donePage() {
const headers = getHtmlDoneHeaders()
if ($.isSurge() || $.isLoon()) {
$.done({ response: { status: 200, headers, body: $.html } })
} else if ($.isQuanX()) {
$.done({ status: 'HTTP/1.1 200', headers, body: $.html })
}
if ($.isQuanX()) $.done({ status: 'HTTP/1.1 200', headers, body: $.html })
else $.done({ response: { status: 200, headers, body: $.html } })
}

function doneQuery() {
$.json = $.toStr($.json)
const headers = getJsonDoneHeaders()
if ($.isSurge() || $.isLoon()) {
$.done({ response: { status: 200, headers, body: $.json } })
} else if ($.isQuanX()) {
$.done({ status: 'HTTP/1.1 200', headers, body: $.json })
}
if ($.isQuanX()) $.done({ status: 'HTTP/1.1 200', headers, body: $.json })
else $.done({ response: { status: 200, headers, body: $.json } })
}

function doneApi() {
$.json = $.toStr($.json)
const headers = getJsonDoneHeaders()
if ($.isSurge() || $.isLoon()) {
$.done({ response: { status: 200, headers, body: $.json } })
} else if ($.isQuanX()) {
$.done({ status: 'HTTP/1.1 200', headers, body: $.json })
}
if ($.isQuanX()) $.done({ status: 'HTTP/1.1 200', headers, body: $.json })
else $.done({ response: { status: 200, headers, body: $.json } })
}

/**
Expand Down
16 changes: 16 additions & 0 deletions box/release/box.release.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
{
"releases": [
{
"version": "0.12.5",
"tags": ["beta"],
"author": "@VirgilClyne",
"msg": "fix(boxjs): 修复 Stash & ShadowRocket 报错问题",
"notes": [
{
"name": "修复",
"descs": ["修复 Stash & ShadowRocket 报错问题"]
},
{
"name": "感谢",
"descs": ["@VirgilClyne PR", "Stash 团队反馈及协助定位问题"]
}
]
},
{
"version": "0.12.4",
"tags": ["beta"],
Expand Down
16 changes: 16 additions & 0 deletions box/release/box.release.tf.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
{
"releases": [
{
"version": "0.12.5",
"tags": ["beta"],
"author": "@VirgilClyne",
"msg": "fix(boxjs): 修复 Stash & ShadowRocket 报错问题",
"notes": [
{
"name": "修复",
"descs": ["修复 Stash & ShadowRocket 报错问题"]
},
{
"name": "感谢",
"descs": ["@VirgilClyne PR", "Stash 团队反馈及协助定位问题"]
}
]
},
{
"version": "0.12.4",
"tags": ["beta"],
Expand Down
30 changes: 9 additions & 21 deletions chavy.box.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const $ = new Env('BoxJs')
// 为 eval 准备的上下文环境
const $eval_env = {}

$.version = '0.12.4'
$.version = '0.12.5'
$.versionType = 'beta'

// 发出的请求需要需要 Surge、QuanX 的 rewrite
Expand Down Expand Up @@ -872,40 +872,28 @@ function getJsonDoneHeaders() {

function doneOptions() {
const headers = getBaseDoneHeaders()
if ($.isSurge() || $.isLoon()) {
$.done({ response: { headers } })
} else if ($.isQuanX()) {
$.done({ headers })
}
if ($.isQuanX()) $.done({ headers })
else $.done({ response: { headers } })
}

function donePage() {
const headers = getHtmlDoneHeaders()
if ($.isSurge() || $.isLoon()) {
$.done({ response: { status: 200, headers, body: $.html } })
} else if ($.isQuanX()) {
$.done({ status: 'HTTP/1.1 200', headers, body: $.html })
}
if ($.isQuanX()) $.done({ status: 'HTTP/1.1 200', headers, body: $.html })
else $.done({ response: { status: 200, headers, body: $.html } })
}

function doneQuery() {
$.json = $.toStr($.json)
const headers = getJsonDoneHeaders()
if ($.isSurge() || $.isLoon()) {
$.done({ response: { status: 200, headers, body: $.json } })
} else if ($.isQuanX()) {
$.done({ status: 'HTTP/1.1 200', headers, body: $.json })
}
if ($.isQuanX()) $.done({ status: 'HTTP/1.1 200', headers, body: $.json })
else $.done({ response: { status: 200, headers, body: $.json } })
}

function doneApi() {
$.json = $.toStr($.json)
const headers = getJsonDoneHeaders()
if ($.isSurge() || $.isLoon()) {
$.done({ response: { status: 200, headers, body: $.json } })
} else if ($.isQuanX()) {
$.done({ status: 'HTTP/1.1 200', headers, body: $.json })
}
if ($.isQuanX()) $.done({ status: 'HTTP/1.1 200', headers, body: $.json })
else $.done({ response: { status: 200, headers, body: $.json } })
}

/**
Expand Down

0 comments on commit 2806205

Please sign in to comment.