我已经设置了一个在 192.168.2.254 的本地服务器上运行的完整节点。我只是想制作一个简单的脚本,基本上是订阅区块链上的新头。
\nconst { ApiPromise, WsProvider } = require(\'@polkadot/api\');\n\nasync function main () {\n const wsProvider = new WsProvider(\'wss://192.168.2.254:9944\');\n const api = await ApiPromise.create({ provider: wsProvider });\n\n let count = 0;\n\n const unsubscribe = await api.rpc.chain.subscribeNewHeads((header) => {\n console.log(`Chain is at block: #${header.number}`);\n\n if (++count === 256) {\n unsubscribe();\n process.exit(0);\n }\n });\n}\n\nmain().catch(console.error);\nRun Code Online (Sandbox Code Playgroud)\n在服务器上,我还按照 Polkadot wiki 的建议使用自签名 ssl 证书设置了 nginx。这是块配置:
\nserver {\n server_name 192.168.2.254\n\n root /var/www/html;\n index index.html;\n\n location / {\n try_files $uri $uri/ =404;\n\n proxy_pass http://localhost:9944;\n proxy_set_header …Run Code Online (Sandbox Code Playgroud) 在我的本地环境中,unicode 字符工作正常,但是当我运行 webpack 进行捆绑和部署时,类似于“\uf00c”的字符串变成了“?” 在 index_bundle.js 中
我认为 babel 配置或 webpack 配置存在问题,但我无法解决它,因为我是整个堆栈的新手。
这是代码:
<Label className="switch switch-icon switch-pill switch-success">
<Input type="checkbox" className="switch-input" defaultChecked onChange={this.handleActivateUser.bind(this, user.id)}/>
<span className="switch-label" data-on={'\uf00c'} data-off={'\uf00d'}></span>
<span className="switch-handle"></span>
</Label>
Run Code Online (Sandbox Code Playgroud)
我的 .babelrc:
{
"presets": [
["env"], ["react"]
],
"plugins": ["transform-class-properties", "transform-object-rest-spread"]
}
Run Code Online (Sandbox Code Playgroud)
还有我的 webpack.config.js:
var path = require('path');
var HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const extractCSS = new ExtractTextPlugin('[name].fonts.css');
const extractSCSS = new ExtractTextPlugin('[name].styles.css');
const webpackUglifyJsPlugin = require('webpack-uglify-js-plugin');
var webpack = require('webpack');
config …Run Code Online (Sandbox Code Playgroud)