feat:增加skeleton

This commit is contained in:
下羊 2020-02-26 09:08:10 +08:00
parent a198922fb3
commit a39d82e652
27 changed files with 435 additions and 3 deletions

View File

@ -1 +1 @@
编辑器框架
## todo

View File

@ -1,7 +1,7 @@
{
"name": "editor-framework",
"name": "@ali/lowcode-engine-editor",
"version": "0.0.1",
"description": "alibaba lowcode editor framework",
"description": "alibaba lowcode editor core",
"files": [
"demo/",
"es/",

View File

@ -0,0 +1,12 @@
# http://editorconfig.org
root = true
[*]
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.md]
trim_trailing_whitespace = false

View File

@ -0,0 +1,11 @@
# 忽略目录
build/
tests/
demo/
# node 覆盖率文件
coverage/
# 忽略文件
**/*-min.js
**/*.min.js

View File

@ -0,0 +1,7 @@
const { eslint, deepmerge } = require('@ice/spec');
module.exports = deepmerge(eslint, {
rules: {
"global-require": 0,
},
});

20
packages/editor-skeleton/.gitignore vendored Normal file
View File

@ -0,0 +1,20 @@
# See https://help.github.com/ignore-files/ for more about ignoring files.
# dependencies
/node_modules
# production
/build
/dist
# misc
.idea/
.happypack
.DS_Store
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# ignore d.ts auto generated by css-modules-typescript-loader
*.module.scss.d.ts

View File

@ -0,0 +1,7 @@
# 忽略目录
build/
tests/
demo/
# node 覆盖率文件
coverage/

View File

@ -0,0 +1,3 @@
const { stylelint } = require('@ice/spec');
module.exports = stylelint;

View File

@ -0,0 +1 @@
## todo

View File

@ -0,0 +1,4 @@
{
"type": "ice-scripts",
"builder": "@ali/builder-ice-scripts"
}

View File

@ -0,0 +1,30 @@
const path = require('path');
module.exports = {
entry: 'src/index.tsx',
publicPath: './',
alias: {
'@': path.resolve(__dirname, './src'),
},
plugins: [
['ice-plugin-fusion', {
themePackage: '@icedesign/theme',
}],
['ice-plugin-moment-locales', {
locales: ['zh-cn'],
}],
],
chainWebpack: (config) => {
// 修改对应 css module的 loader默认修改 scss-module 同理可以修改 css-module 和 less-module 规则
['scss-module'].forEach((rule) => {
if (config.module.rules.get(rule)) {
config.module.rule(rule).use('ts-css-module-loader')
.loader(require.resolve('css-modules-typescript-loader'))
.options({ modules: true, sass: true });
// 指定应用loader的位置
config.module.rule(rule).use('ts-css-module-loader').before('css-loader');
}
});
},
};

View File

@ -0,0 +1,9 @@
{
"compilerOptions": {
"baseUrl": ".",
"jsx": "react",
"paths": {
"@/*": ["./src/*"]
}
}
}

View File

@ -0,0 +1,47 @@
{
"name": "@ali/lowcode-engine-skeleton",
"version": "0.0.1",
"description": "alibaba lowcode editor skeleton",
"author": "xiayang.xy",
"dependencies": {
"@alifd/next": "^1.x",
"@icedesign/theme": "^1.x",
"@types/react": "^16.8.3",
"@types/react-dom": "^16.8.2",
"moment": "^2.23.0",
"prop-types": "^15.5.8",
"react": "^16.4.1",
"react-dom": "^16.4.1",
"react-router-dom": "^5.0.1"
},
"devDependencies": {
"@ice/spec": "^0.1.1",
"css-modules-typescript-loader": "^2.0.4",
"eslint": "^6.0.1",
"ice-plugin-fusion": "^0.1.4",
"ice-plugin-moment-locales": "^0.1.0",
"ice-scripts": "^2.0.0",
"stylelint": "^10.1.0"
},
"scripts": {
"start": "ice-scripts dev",
"build": "ice-scripts build",
"lint": "npm run eslint && npm run stylelint",
"eslint": "eslint --cache --ext .js,.jsx ./",
"stylelint": "stylelint ./**/*.scss"
},
"engines": {
"node": ">=8.0.0"
},
"iceworks": {
"type": "react",
"adapter": "adapter-react-v3"
},
"ideMode": {
"name": "ice-react"
},
"repository": {
"type": "git",
"url": "https://github.com/ice-lab/react-materials/tree/master/scaffolds/ice-ts"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="x-ua-compatible" content="ie=edge,chrome=1" />
<meta name="viewport" content="width=device-width" />
<title>ICE TypeScript Starter</title>
</head>
<body>
<div id="ice-container"></div>
</body>
</html>

View File

@ -0,0 +1,15 @@
import React from 'react';
export interface Props {
name: string;
}
const Greeting = ({ name }: Props) => {
return (
<div style={{ textAlign: 'center', fontSize: '40px', fontWeight: 'bold' }}>
Hello, {name}
</div>
);
};
export default Greeting;

View File

@ -0,0 +1,11 @@
.item {
height: 34px;
line-height: 34px;
}
.title {
text-align: center;
}
.container {
width: 470px;
margin: 40px auto;
}

View File

@ -0,0 +1,71 @@
import React from 'react';
import { Button } from '@alifd/next';
import styles from './index.module.scss';
const Guide = () => {
return (
<div className={styles.container}>
<h2 className={styles.title}>使</h2>
<ul>
<li className={styles.item}>
1. 0 1
</li>
<li className={styles.item}>2. 菜单配置: menuConfig.js</li>
<li className={styles.item}>3. 路由配置: routerConfig.js</li>
<li className={styles.item}>
4. GUI {' '}
<a
href="https://alibaba.github.io/ice/iceworks"
target="_blank"
rel="noopener noreferrer"
>
Iceworks
</a>{' '}
</li>
<li className={styles.item}>
5. {' '}
<a
href="https://alibaba.github.io/ice/block"
target="_blank"
rel="noopener noreferrer"
>
</a>{' '}
pages
</li>
<li className={styles.item}>
6. 便
<a
href="https://alibaba.github.io/ice/docs/iceworks"
target="_blank"
rel="noopener noreferrer"
>
iceworks
</a>{' '}
</li>
</ul>
<div style={{ textAlign: 'center', marginTop: '40px' }}>
<a
href="https://alibaba.github.io/ice/docs/iceworks"
target="_blank"
rel="noopener noreferrer"
>
<Button type="secondary" style={{ marginRight: '20px' }}>
{' '}
</Button>
</a>
<a
href="https://www.tslang.cn/docs/home.html"
target="_blank"
rel="noopener noreferrer"
>
<Button type="primary"> TypeScript</Button>
</a>
</div>
</div>
);
};
export default Guide;

View File

@ -0,0 +1,5 @@
// 菜单配置
const asideMenuConfig = [];
export { asideMenuConfig };

View File

@ -0,0 +1,21 @@
import Dashboard from '@/pages/Dashboard';
import BasicLayout from '@/layouts/BasicLayout';
const routerConfig = [
{
path: '/',
component: BasicLayout,
children: [
{
path: '/dashboard',
component: Dashboard,
},
{
path: '/',
redirect: '/dashboard',
}
],
},
];
export default routerConfig;

View File

@ -0,0 +1,6 @@
// 引入默认全局样式
@import '@alifd/next/reset.scss';
body {
-webkit-font-smoothing: antialiased;
}

View File

@ -0,0 +1,13 @@
import ReactDOM from 'react-dom';
import './global.scss';
import router from './router';
const ICE_CONTAINER = document.getElementById('ice-container');
if (!ICE_CONTAINER) {
throw new Error('当前页面不存在 <div id="ice-container"></div> 节点.');
}
ReactDOM.render(router(), ICE_CONTAINER);

View File

@ -0,0 +1,9 @@
import React from 'react';
export default function BasicLayout({ children }) {
return (
<div style={{ paddingTop: '100px' }}>
{children}
</div>
);
}

View File

@ -0,0 +1,12 @@
import React from 'react';
import Guide from '@/components/Guide';
import Greeting from '@/components/Greeting';
export default function Dashboard() {
return (
<div>
<Greeting name="TypeScript" />
<Guide />
</div>
);
}

View File

@ -0,0 +1,73 @@
import React from 'react';
import { HashRouter as Router, Switch, Route, Redirect } from 'react-router-dom';
import path from 'path';
import routes from '@/config/routes';
const RouteItem = (props) => {
const { redirect, path: routePath, component, key } = props;
if (redirect) {
return (
<Redirect
exact
key={key}
from={routePath}
to={redirect}
/>
);
}
return (
<Route
key={key}
component={component}
path={routePath}
/>
);
};
const router = () => {
return (
<Router>
<Switch>
{routes.map((route, id) => {
const { component: RouteComponent, children, ...others } = route;
return (
<Route
key={id}
{...others}
component={(props) => {
return (
children ? (
<RouteComponent key={id} {...props}>
<Switch>
{children.map((routeChild, idx) => {
const { redirect, path: childPath, component } = routeChild;
return RouteItem({
key: `${id}-${idx}`,
redirect,
path: childPath && path.join(route.path, childPath),
component,
});
})}
</Switch>
</RouteComponent>
) : (
<>
{
RouteItem({
key: id,
...route,
})
}
</>
)
);
}}
/>
);
})}
</Switch>
</Router>
);
};
export default router;

View File

@ -0,0 +1 @@
// test file

View File

@ -0,0 +1,31 @@
{
"compileOnSave": false,
"buildOnSave": false,
"compilerOptions": {
"baseUrl": ".",
"outDir": "build",
"module": "esnext",
"target": "es6",
"jsx": "react",
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"lib": ["es6", "dom"],
"sourceMap": true,
"allowJs": true,
"rootDir": "src",
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": false,
"importHelpers": true,
"strictNullChecks": true,
"suppressImplicitAnyIndexErrors": true,
"noUnusedLocals": true,
"skipLibCheck": true,
"paths": {
"@/*": ["./src/*"]
}
},
"include": ["src/*"],
"exclude": ["node_modules", "build", "public"]
}