我正在使用电子制作桌面应用程序,我决定使用摩纳哥编辑器并使用安装它,npm install monaco-editor但是当我运行该应用程序时,它说Cannot find module 'monaco-editor'
我用作electron-react-boilerplate样板。
我尝试了两种使用 ESM 安装它的方法
这是我的package.json:
{
"name": "electron-react-boilerplate",
"productName": "ElectronReact",
"version": "0.17.1",
"description": "Electron application boilerplate based on React, React Router, Webpack, React Hot Loader for rapid application development",
"scripts": {
"build": "concurrently \"yarn build-main\" \"yarn build-renderer\"",
"build-dll": "cross-env NODE_ENV=development webpack --config ./configs/webpack.config.renderer.dev.dll.babel.js --colors",
"build-e2e": "cross-env E2E_BUILD=true yarn build",
"build-main": "cross-env NODE_ENV=production webpack --config ./configs/webpack.config.main.prod.babel.js --colors",
"build-renderer": "cross-env NODE_ENV=production webpack --config ./configs/webpack.config.renderer.prod.babel.js --colors",
"dev": "cross-env START_HOT=1 …Run Code Online (Sandbox Code Playgroud) 我正在编写将字节流反序列化为对象的代码,但我一直在获取结构体字段的指针。
基本上代码的工作原理如下:它获取指向结构的指针,然后根据它序列化它的类型,例如。如果它是一个整数,则占用接下来的 4 个字节。棘手的情况是,如果它是一个结构体,因为我必须对其所有属性递归运行反序列化,并且我不知道如何获取其字段的地址以将它们传递给反序列化。
func Deserialize(objPtr interface{}, b []byte) (bytesRead int) {
// it should be the address of the object
val := reflect.ValueOf(objPtr).Elem()
valPtr := reflect.ValueOf(objPtr)
// check if either the object or *object is Serializable
_, isSerializable := (val.Interface()).(Serializable)
_, bo := (valPtr.Interface()).(Serializable)
isSerializable = isSerializable || bo
// specific type serialization
if isSerializable{
return objPtr.(Serializable).Deserializebyte(b)
}
switch val.Kind() {
case reflect.Uint32, reflect.Int, reflect.Int32:
res := reflect.ValueOf(binary.LittleEndian.Uint32(b[:4]))
valPtr.Set(res)
return 4
case reflect.Uint64, reflect.Int64:
res := reflect.ValueOf(binary.LittleEndian.Uint32(b[:8]))
valPtr.Set(res)
return …Run Code Online (Sandbox Code Playgroud)