Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
limichange committed Jan 4, 2020
1 parent 7a1a23f commit e69aa79
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 68 deletions.
46 changes: 21 additions & 25 deletions renderer/next.config.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,27 @@
const withCSS = require('@zeit/next-css')
const withLess = require('@zeit/next-less')

module.exports = withCSS(
withLess({
webpack(config) {
config.module.rules.forEach(rule => {
if (Array.isArray(rule.use)) {
rule.use.forEach(u => {
if (u.loader === 'css-loader' && u.options) {
delete u.options.minimize
}
})
}
})
module.exports = withLess({
lessLoaderOptions: {
javascriptEnabled: true
},
webpack(config) {
config.module.rules.push({
test: /\.css$/,
use: ['style-loader', 'css-loader']
})

return Object.assign(config, {
target: 'electron-renderer',
devtool: 'cheap-module-source-map',
plugins: config.plugins.filter(p => {
return p.constructor.name !== 'UglifyJsPlugin'
})
return Object.assign(config, {
target: 'electron-renderer',
devtool: 'cheap-module-source-map',
plugins: config.plugins.filter(p => {
return p.constructor.name !== 'UglifyJsPlugin'
})
},
exportPathMap() {
return {
'/main': { page: '/main' }
}
})
},
exportPathMap() {
return {
'/main': { page: '/main' }
}
})
)
}
})
26 changes: 13 additions & 13 deletions renderer/pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import App from 'next/app'
import 'antd/dist/antd.css'
import 'antd/dist/antd.less'

export default class IMApp extends App {
componentDidCatch(error: any, errorInfo: any) {
// This is needed to render errors correctly in development / production
// todo
// super.componentDidCatch(error, errorInfo)
}
componentDidCatch(error: any, errorInfo: any) {
// This is needed to render errors correctly in development / production
// todo
// super.componentDidCatch(error, errorInfo)
}

componentDidMount() {
console.log('app componentDidMount')
}
componentDidMount() {
console.log('app componentDidMount')
}

render() {
const { Component, pageProps } = this.props
return <Component {...pageProps} />
}
render() {
const { Component, pageProps } = this.props
return <Component {...pageProps} />
}
}
7 changes: 6 additions & 1 deletion renderer/pages/main/Editor/LeftPanel/Hover/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import uuid from 'uuid'
import { useState } from 'react'
import { useState, useRef, useEffect } from 'react'
import store from '../../store/editorStore'
import useSubscribe from '../../../../../hooks/useSubscribe'
import classnames from 'classnames'
Expand All @@ -11,8 +11,13 @@ interface Hover {

export default function Hover(props) {
const [editorStoreState] = useSubscribe(store)
const ref = useRef(props.children)
const { uuid: key } = props

useEffect(() => {
console.log(ref.current)
}, [])

function onClick() {
store.setIndex('0')
store.setComponentKey(key)
Expand Down
16 changes: 16 additions & 0 deletions renderer/pages/main/Editor/LeftPanel/MonacoEditor.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React, { Component } from 'react'
import MonacoEditor from 'react-monaco-editor'

export default props => (
<MonacoEditor
width={500}
height={200}
language='javascript'
theme='vs-dark'
value=''
options={{ selectOnLineNumbers: true }}
onChange={() => null}
editorDidMount={() => null}
{...props}
/>
)
17 changes: 3 additions & 14 deletions renderer/pages/main/Editor/LeftPanel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ import Hover from './Hover'
import editorStore from '../store/editorStore'
import uuid from 'uuid'
import useSubscribe from '../../../../hooks/useSubscribe'
import MonacoEditor from 'react-monaco-editor'
import dynamic from 'next/dynamic'
import './index.less'
// import MonacoEditor from './MonacoEditor'

function RightPanel() {
function LeftPanel() {
const [components, setComponents] = useState([])
const [editorState] = useSubscribe(editorStore)
const [collectedProps, drop] = useDrop({
Expand Down Expand Up @@ -58,18 +57,8 @@ function RightPanel() {
return (
<div className='LeftPanel' ref={drop}>
{components}
{/* <MonacoEditor
language='javascript'
theme='vs-dark'
value={'todo'}
options={{
selectOnLineNumbers: true
}}
/> */}
</div>
)
}

export default dynamic(() => Promise.resolve(RightPanel), {
ssr: false
})
export default LeftPanel
4 changes: 2 additions & 2 deletions renderer/pages/main/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ class LayoutComponent extends React.Component {
mode='inline'>
<Menu.Item key='1'>
<Icon type='message' />
<span>编辑</span>
<span>Editor</span>
</Menu.Item>
<Menu.Item key='5'>
<Icon type='setting' />
<span>设置</span>
<span>Setting</span>
</Menu.Item>
</Menu>
</Sider>
Expand Down
16 changes: 3 additions & 13 deletions renderer/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": false,
Expand All @@ -18,12 +14,6 @@
"isolatedModules": true,
"jsx": "preserve"
},
"exclude": [
"node_modules"
],
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx"
]
"exclude": ["node_modules"],
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"]
}

0 comments on commit e69aa79

Please sign in to comment.