Skip to content

添加Scbackend扩展 - #318

Open
hwxqyworld wants to merge 2 commits into
Gandi-IDE:mainfrom
hwxqyworld:main
Open

添加Scbackend扩展#318
hwxqyworld wants to merge 2 commits into
Gandi-IDE:mainfrom
hwxqyworld:main

Conversation

@hwxqyworld

Copy link
Copy Markdown

No description provided.

Comment thread extensions/Helloworld/ScbackendSDK.js Outdated
Comment on lines +12 to +18
"scbackendsdk.connect": "\u8FDE\u63A5\u5230 [remaddr] \u670D\u52A1\u5668\u4E0A\u7684 [instname] \u5B9E\u4F8B",
"scbackendsdk.connectwait": "\u8FDE\u63A5\u5230 [remaddr] \u670D\u52A1\u5668\u7684 [instname] \u5B9E\u4F8B \u5E76\u7B49\u5F85\u8FDE\u63A5\u5B8C\u6210",
"scbackendsdk.disconnect": "\u65AD\u5F00\u8FDE\u63A5",
"scbackendsdk.isconnected": "\u5DF2\u8FDE\u63A5\uFF1F",
"scbackendsdk.send": "\u53D1\u9001\u6D88\u606F [msg]",
"scbackendsdk.whenmessage": "\u5F53\u6536\u5230\u6D88\u606F",
"scbackendsdk.getmsg": "\u6536\u5230\u7684\u6D88\u606F"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不建议unicode编码,不太便于检查

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tsup打包出来就是这样的,你加入编辑器里就可以正常显示了

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

网上有配置,直接放config里

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tsup打包出来就是这样的,你加入编辑器里就可以正常显示了

请参考 https://esbuild.github.io/api/#charset

{
  charset: 'utf8',
}

Comment on lines +36 to +43
const translate = function(key) {
const locale = globalThis.navigator.language.slice(0, 2);
if (l10n_default[locale] && l10n_default[locale][key]) {
return l10n_default[locale][key];
} else {
return l10n_default["en"][key] || key;
}
};

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

有runtime.getFormatMessage不用?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这玩意我真不知道我去改改

Comment thread extensions/Helloworld/ScbackendSDK.js Outdated
Comment on lines +161 to +162
async connectwait(args, util) {
await new Promise((resolve, reject) => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

直接return这个promise呗

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

对吼

Comment thread extensions/Helloworld/ScbackendSDK.js Outdated
Comment on lines +118 to +121
blockMenu: {
acceptReporters: true,
items: [{ text: translate("scbackendsdk.connect.wait"), value: true }, { text: translate("scbackendsdk.connect.dontwait"), value: false }]
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

啥玩意,都没用上

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

忘了删了

@BenPaoDeXiaoZhi BenPaoDeXiaoZhi left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

你几乎无法在这个文件里找到任何一个驼峰命名的变量或属性


// src/index.js
(function(Scratch2) {
if (Scratch2.extensions.unsandboxed === false) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

建议直接感叹号

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tsup自动打包成这样的

},
{
blockType: Scratch2.BlockType.COMMAND,
opcode: "connectwait",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

驼峰命名法这么难吗

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我记得opcode不能大写字母

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以的

Comment thread extensions/Helloworld/ScbackendSDK.js Outdated
if (reject) reject(event);
};
this.ws.onerror = (error) => {
if (reject) reject(error);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

建议添加兜底的console error

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kukemc

kukemc commented Nov 4, 2025

Copy link
Copy Markdown
Contributor

与其说什么Scbackend,不如直接改成websocket扩展 还能更通用更实用一些。

@hwxqyworld

Copy link
Copy Markdown
Author

与其说什么Scbackend,不如直接改成websocket扩展 还能更通用更实用一些。

某些人说WebSocket危险,上来给我打了个危险标签,我那还敢搞,Scbackend可控一点,至于WebSocket我可不敢得罪人了

@kukemc

kukemc commented Nov 4, 2025

Copy link
Copy Markdown
Contributor

与其说什么Scbackend,不如直接改成websocket扩展 还能更通用更实用一些。

某些人说WebSocket危险,上来给我打了个危险标签,我那还敢搞,Scbackend可控一点,至于WebSocket我可不敢得罪人了

不管是ws还是你这个都过不了审,因为官方扩展是不允许这种能从网络获取信息的扩展的。

@hwxqyworld

Copy link
Copy Markdown
Author

与其说什么Scbackend,不如直接改成websocket扩展 还能更通用更实用一些。

某些人说WebSocket危险,上来给我打了个危险标签,我那还敢搞,Scbackend可控一点,至于WebSocket我可不敢得罪人了

不管是ws还是你这个都过不了审,因为官方扩展是不允许这种能从网络获取信息的扩展的。

?为啥啊,mmo不也从网络获取信息
如果我给捐一个后端大家一起用,是不是可以

@kukemc

kukemc commented Nov 4, 2025

Copy link
Copy Markdown
Contributor

与其说什么Scbackend,不如直接改成websocket扩展 还能更通用更实用一些。

某些人说WebSocket危险,上来给我打了个危险标签,我那还敢搞,Scbackend可控一点,至于WebSocket我可不敢得罪人了

不管是ws还是你这个都过不了审,因为官方扩展是不允许这种能从网络获取信息的扩展的。

?为啥啊,mmo不也从网络获取信息 如果我给捐一个后端大家一起用,是不是可以

第三方的后端第一不能保证服务的稳定性,第二是不能保证传输的内容一定是安全的,第三用户可以自由改后端 写个获取什么不是轻轻松松的事情

@hwxqyworld

Copy link
Copy Markdown
Author

与其说什么Scbackend,不如直接改成websocket扩展 还能更通用更实用一些。

某些人说WebSocket危险,上来给我打了个危险标签,我那还敢搞,Scbackend可控一点,至于WebSocket我可不敢得罪人了

不管是ws还是你这个都过不了审,因为官方扩展是不允许这种能从网络获取信息的扩展的。

?为啥啊,mmo不也从网络获取信息 如果我给捐一个后端大家一起用,是不是可以

第三方的后端第一不能保证服务的稳定性,第二是不能保证传输的内容一定是安全的,第三用户可以自由改后端 写个获取什么不是轻轻松松的事情

那,怎么办,现在社区里外挂大哥作妖就不管了吗

@BenPaoDeXiaoZhi BenPaoDeXiaoZhi left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

再改改吧,tsup的可以直接抄网上的解决方案,其他没用的部分删一下

@hwxqyworld

Copy link
Copy Markdown
Author

再改改吧,tsup的可以直接抄网上的解决方案,其他没用的部分删一下

好的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants