-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
添加网络扩展 #208
Open
WP-Studio01
wants to merge
21
commits into
Gandi-IDE:main
Choose a base branch
from
WP-Studio01:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
添加网络扩展 #208
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
9135d51
Create HelloWorldExt.js
WP-Studio01 70776f2
Merge branch 'Gandi-IDE:main' into main
WP-Studio01 efecc20
编写network扩展前两个函数
WP-Studio01 7149ac6
Helloworld提交
WP-Studio01 ab0af3a
.
WP-Studio01 9ff793d
.
WP-Studio01 13aa25a
.
WP-Studio01 584c94e
.
WP-Studio01 9babb2e
.
WP-Studio01 eceb1c0
Merge branch 'Gandi-IDE:main' into main
WP-Studio01 b6b187d
.
WP-Studio01 8023a48
.
WP-Studio01 32c9dae
.
WP-Studio01 e93df2e
.
WP-Studio01 37d2313
.
WP-Studio01 17682c9
删除不必要的东西
WP-Studio01 a490c45
.
WP-Studio01 e3eb6e9
.
WP-Studio01 0223e48
.
WP-Studio01 7e23edc
.
WP-Studio01 3f3bcee
Merge branch 'Gandi-IDE:main' into main
WP-Studio01 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
git add . | ||
git commit -m "." | ||
git push origin main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,169 @@ | ||
class Network { | ||
constructor(runtime) { | ||
this.runtime = runtime; | ||
this._formatMessage = runtime.getFormatMessage({ | ||
'zh-cn': { | ||
'NetworkExt.ExtName': '网络扩展', | ||
'NetworkExt.description': '让你的作品可以访问网络', | ||
'NetworkExt.httpget': 'GET方法同步请求[url]查询字符串[query]没有则留空', | ||
'NetworkExt.httppost': 'POST方法同步请求[url]请求主体[body]', | ||
'NetworkExt.encoding': 'json转换uri编码字符串[json]', | ||
'NetworkExt.decoding': 'uri编码字符串转换json[uri]', | ||
// 'NetworkExt.content': '异步请求返回内容', | ||
// 'NetworkExt.setheader': '设置异步请求头部[key]=[value]', | ||
// 'NetworkExt.status': '异步请求状态码', | ||
// 'NetworkExt.setmethod': '设置异步请求方法为[method]', | ||
// 'NetworkExt.sendasyncreq': '发送异步请求,方法为[method],主体为(没有填null)[body],url为[url]', | ||
// 'NetworkExt.seturl': '设置异步请求url[url]', | ||
// 'NetworkExt.whenasync': '当异步请求结束', | ||
}, | ||
|
||
en: { | ||
'NetworkExt.ExtName': 'Network extension', | ||
'NetworkExt.httpget': 'GET method synchronization request [url]', | ||
'NetworkExt.httppost': 'POST method synchronization request [url] request body [body]', | ||
'NetworkExt.encoding': 'json转换uri编码字符串[json]', | ||
'NetworkExt.decoding': 'uri编码字符串转换json[uri]', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are there some English translations in Chinese? |
||
// 'NetworkExt.content': '异步请求返回内容', | ||
// 'NetworkExt.setheader': 'Set asynchronous request header [key] = [value]', | ||
// 'NetworkExt.status': 'Asynchronous request status code', | ||
// 'NetworkExt.setmethod': 'Set the asynchronous request method to [method]', | ||
// 'NetworkExt.sendasyncreq': '发送异步请求,方法为[method],主体为(没有填null)[body],url为[url]', | ||
// 'NetworkExt.seturl': 'Set asynchronous request url[url]', | ||
// 'NetworkExt.whenasync': 'When the asynchronous request ends.', | ||
}, | ||
}) | ||
} | ||
|
||
formatMessage(id) { | ||
return this._formatMessage({ | ||
id, | ||
default: id, | ||
description: id, | ||
}) | ||
} | ||
|
||
getInfo() { | ||
return { | ||
id: 'HelloworldNetworkExt', | ||
name: this.formatMessage('NetworkExt.ExtName'), | ||
color1: '#e000ff', | ||
blocks: [ | ||
{ | ||
opcode: 'httpget', | ||
blockType: 'reporter', | ||
text: this.formatMessage('NetworkExt.httpget'), | ||
arguments: { | ||
url: { | ||
type: 'string', | ||
defaultValue: 'https://extensions.turbowarp.org/hello.txt', | ||
}, | ||
query: { | ||
type: 'string', | ||
defaultValue: undefined, | ||
}, | ||
}, | ||
}, | ||
{ | ||
opcode: 'httppost', | ||
blockType: 'reporter', | ||
text: this.formatMessage('NetworkExt.httppost'), | ||
arguments: { | ||
url: { | ||
type: 'string', | ||
defaultValue: 'https://extensions.turbowarp.org/hello.txt', | ||
}, | ||
body: { | ||
type: 'string', | ||
defaultValue: 'body', | ||
}, | ||
}, | ||
}, | ||
{ | ||
opcode: 'encoding', | ||
blockType: 'reporter', | ||
text: this.formatMessage('NetworkExt.encoding'), | ||
arguments: { | ||
json: { | ||
type: 'string', | ||
defaultValue: '{"nihao":"666","wohao":"777"}', | ||
}, | ||
}, | ||
}, | ||
{ | ||
opcode: 'decoding', | ||
blockType: 'reporter', | ||
text: this.formatMessage('NetworkExt.decoding'), | ||
arguments: { | ||
uri: { | ||
type: 'string', | ||
defaultValue: 'nihao=666&wohao=777', | ||
}, | ||
}, | ||
} | ||
], | ||
} | ||
} | ||
encoding(args) | ||
{ | ||
let obj=JSON.parse(args.json); | ||
let encodedString = Object.keys(obj).map(key => key + '=' + obj[key]).join('&'); | ||
return encodedString; | ||
} | ||
decoding(args) | ||
{ | ||
let encodedString=args.uri; | ||
let decodedObj = {}; | ||
encodedString.split('&').forEach(function(keyValue) | ||
{ | ||
var pair = keyValue.split('='); | ||
decodedObj[pair[0]] = pair[1]; | ||
}); | ||
return JSON.stringify(decodedObj); | ||
} | ||
httpget(args) | ||
{ | ||
// console.log(args); | ||
let xhr= new XMLHttpRequest(); | ||
let url=args.url; | ||
if(args.query) | ||
{ | ||
url+='?'; | ||
url+=args.query; | ||
} | ||
xhr.open('GET',url,false); | ||
xhr.send(null); | ||
return xhr.responseText; | ||
} | ||
httppost(args) | ||
{ | ||
let xhr=new XMLHttpRequest(); | ||
xhr.open('POST',args.url,false); | ||
xhr.send(args.body); | ||
return xhr.responseText; | ||
} | ||
} | ||
|
||
window.tempExt = { | ||
Extension: Network, | ||
info: { | ||
name: 'NetworkExt.ExtName', | ||
description: 'NetworkExt.description', | ||
extensionId: 'HelloworldNetworkExt', | ||
// iconURL: icon, | ||
// insetIconURL: cover, | ||
featured: true, | ||
disabled: false, | ||
collaborator: 'Helloworld@CCW', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Recommendation: |
||
}, | ||
l10n: { | ||
'zh-cn': { | ||
'NetworkExt.ExtName': '网络扩展', | ||
'hcn.description': '让你的作品可以访问网络', | ||
}, | ||
en: { | ||
'hcn.extensionName': 'Network extension', | ||
'hcn.description': 'Make your work accessible to the Internet.', | ||
}, | ||
}, | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this not done?
(Just asking, it doesn't affect the outcome of the audit)