Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Iceworks 3.x] 项目统一规范 #1865

Merged
merged 56 commits into from May 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
a781a2f
feat: 添加项目列表和项目服务
alvinhui Apr 24, 2019
646fa44
feat: 补全项目相关 API 声明
alvinhui Apr 25, 2019
5243201
feat: 补充项目接口
alvinhui Apr 25, 2019
da22a17
feat: 依赖管理接口
alvinhui Apr 26, 2019
9cc9794
feat: 项目的 todo
alvinhui Apr 26, 2019
082c96f
chore: lint
alvinhui Apr 26, 2019
1096e2b
feat: 添加菜单和路由接口
alvinhui Apr 26, 2019
a3472fe
Merge remote-tracking branch 'origin/iceworks/release-3.x' into icewo…
alvinhui Apr 28, 2019
4d0c9f9
chore: fix lint
alvinhui Apr 28, 2019
708d844
feat: 添加项目的数据模拟 API
alvinhui Apr 28, 2019
295e8d0
refactor: 项目接口
alvinhui Apr 28, 2019
11514db
Merge remote-tracking branch 'origin/iceworks/release-3.x' into icewo…
alvinhui Apr 29, 2019
de159a5
chore: lint
alvinhui Apr 29, 2019
de8d3cf
chore: 划分 interface
alvinhui Apr 29, 2019
b38b154
feat: 项目开发相关
alvinhui Apr 29, 2019
62a7859
feat: 切换当前项目
alvinhui Apr 30, 2019
988470d
chore: 全局初始化 projects && project
alvinhui Apr 30, 2019
b9571b0
chore: 默认路由交给前端
alvinhui Apr 30, 2019
bd24dcc
feat: 前端开发调试
alvinhui Apr 30, 2019
805cdd4
fix: 应用内只有单一的 socket 实例
alvinhui Apr 30, 2019
fb80d5f
chore: 本地IP不需要防范 csrf
alvinhui May 3, 2019
17f853d
refactor: projectsService
alvinhui May 3, 2019
79b2cc4
feat: 项目操作的插件机制
alvinhui May 3, 2019
a44c3d3
chore: lint for iceworks server
alvinhui May 3, 2019
760be44
feat: 跑通启动调试服务
alvinhui May 4, 2019
cbb6a06
chore: rename
alvinhui May 4, 2019
bf1aa0f
refactor: 使用插件封装项目操作
alvinhui May 4, 2019
3639093
feat: 停止调试
alvinhui May 4, 2019
3345701
chore: rename
alvinhui May 4, 2019
9830856
chore: 变量声明方式优化
alvinhui May 5, 2019
71113fd
feat: add project
alvinhui May 5, 2019
aee5c0a
fix: icestore API 问题修复
alvinhui May 5, 2019
2901a93
fix: projects 设置默认值
alvinhui May 5, 2019
3886667
fix: 查找项目的错误处理
alvinhui May 5, 2019
aeacedc
fix: 接口容错
alvinhui May 5, 2019
4d10b8a
fix: 回滚实验性代码
alvinhui May 5, 2019
6694274
fix: 变量声明时还未初始化
alvinhui May 5, 2019
757b064
chore: rename
alvinhui May 5, 2019
a849121
refactor: socket 请求封装入 store
alvinhui May 5, 2019
08eaa93
fix: 变量引用错误
alvinhui May 5, 2019
22ec650
refactor: 移除 iceworks-events
alvinhui May 5, 2019
796712c
chore: rename currentProject => project
alvinhui May 5, 2019
806600d
refactor: 封装 socket emit
alvinhui May 5, 2019
6181bc9
refactor: 所有请求通过 socket,移除 fetch
alvinhui May 5, 2019
290f6d0
refactor: 统一使用小数点作为命名分隔符
alvinhui May 5, 2019
089dbd4
chore: lint
alvinhui May 5, 2019
0b571ea
fix: 移除无用的代码
alvinhui May 5, 2019
aacdcc9
chore: rename specifyVersion
alvinhui May 5, 2019
7c5db3c
chore: rename ProjectClient
alvinhui May 5, 2019
65dbdbc
chore: rename setEnv => settingsEnv
alvinhui May 5, 2019
4a348e6
chore: rename readdirAsync
alvinhui May 5, 2019
ed3e083
fix: import 声明方式
alvinhui May 5, 2019
c80a3ba
chore: rename project-client to project-manager
alvinhui May 5, 2019
b15c534
refactor: 命名规范
alvinhui May 5, 2019
655298c
chore: 变量命名
alvinhui May 5, 2019
65f218f
chore: 删除无用的文件
alvinhui May 5, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/iceworks-client/package.json
Expand Up @@ -6,10 +6,11 @@
"@alifd/next": "^1.13.13",
"@alifd/theme-2": "^0.0.22",
"@alifd/theme-3": "^0.1.0",
"@icedesign/notification": "^1.0.5",
"alife-logger": "^1.5.1",
"classnames": "^2.2.6",
"cookies-js": "^1.2.3",
"deepmerge": "^3.2.0",
"iceworks-events": "^0.1.0",
"icestore": "^0.1.0",
"lodash.map": "^4.6.0",
"loglevel": "^1.6.1",
Expand Down
6 changes: 6 additions & 0 deletions packages/iceworks-client/public/index.html
Expand Up @@ -10,5 +10,11 @@

<body>
<div id="iceworks"></div>
<script>
window.iceworksConfig = {
socketUrl: "//127.0.0.1:7001/",
apiUrl: "//127.0.0.1:7001/api/",
};
</script>
</body>
</html>
25 changes: 0 additions & 25 deletions packages/iceworks-client/src/components/ConnectionBar/index.js

This file was deleted.

This file was deleted.

15 changes: 13 additions & 2 deletions packages/iceworks-client/src/components/GlobalBar/index.js
@@ -1,8 +1,19 @@
import React from 'react';
import React, { useEffect } from 'react';
import stores from '@stores';
import styles from './index.module.scss';

const GlobalBar = () => {
return <div className={styles.globalBar}>Global Bar</div>;
const project = stores.useStore('project');

useEffect(() => {
project.refresh();
}, []);

return (
<div className={styles.globalBar}>
{project.dataSource.name}
</div>
);
};

export default GlobalBar;
16 changes: 12 additions & 4 deletions packages/iceworks-client/src/components/XtermTerminal/index.js
@@ -1,31 +1,39 @@
import React, { useRef, useEffect } from 'react';
// import PropTypes from 'prop-types';
import { Terminal } from 'xterm';
import { ICEWORKS_TASK_DEV_DATA } from 'iceworks-events';
import { useSocket } from '@hooks/useSocket';
import useSocket from '@hooks/useSocket';
import * as fit from 'xterm/dist/addons/fit/fit';
import * as webLinks from 'xterm/dist/addons/webLinks/webLinks';
import stores from '@stores';
import 'xterm/dist/xterm.css';
import log from '@utils/logger';
import styles from './index.module.scss';

const logger = log.getLogger('xterm');
alvinhui marked this conversation as resolved.
Show resolved Hide resolved

Terminal.applyAddon(fit);
Terminal.applyAddon(webLinks);

const XtermTerminal = () => {
const xtermRef = useRef(null);
const project = stores.useStore('project');

const term = new Terminal({
cols: 100,
rows: 30,
});

useEffect(() => {
logger.debug('xterm loaded.');

project.refresh();

term.open(xtermRef.current);
term.fit();
term.write('\x1B[1;3;31mIceworks CLI\x1B[0m $ ');
term.write(`\x1B[1;3;31m${project.dataSource.name}\x1B[0m $ `);
}, []);

useSocket(ICEWORKS_TASK_DEV_DATA, (data) => {
useSocket('project.index.dev.data', (data) => {
term.write(data);
});

Expand Down
@@ -1,11 +1,9 @@
/* eslint consistent-return:0 */
import { useContext, useEffect } from 'react';
import { useEffect } from 'react';
import logger from '@utils/logger';
import Context from './Context';

function useSocket(eventName, callback) {
const [socket] = useContext(Context);
import socket from '@src/socket';

export default function useSocket(eventName, callback) {
useEffect(() => {
if (eventName && callback) {
logger.debug(`socket on ${eventName}.`);
Expand All @@ -20,5 +18,3 @@ function useSocket(eventName, callback) {

return socket;
}

export default useSocket;
5 changes: 0 additions & 5 deletions packages/iceworks-client/src/hooks/useSocket/Context.js

This file was deleted.

39 changes: 0 additions & 39 deletions packages/iceworks-client/src/hooks/useSocket/SocketProvider.js

This file was deleted.

5 changes: 0 additions & 5 deletions packages/iceworks-client/src/hooks/useSocket/index.js

This file was deleted.

29 changes: 13 additions & 16 deletions packages/iceworks-client/src/index.js
@@ -1,31 +1,28 @@
import React from 'react';
import React, { useEffect } from 'react';
import ReactDOM from 'react-dom';
import { BrowserRouter as Router, Route } from 'react-router-dom';
import '@utils/logger';
import '@alifd/next/reset.scss';

import logger from '@utils/logger';
import MainLayout from '@layouts/MainLayout/index';
import LocaleProvider from '@components/Locale';
import { ThemeProvider } from '@components/ThemeProvider';
import { SocketProvider } from '@hooks/useSocket';
import appConfig from './appConfig';

import './global.scss';
import './variables.scss';

const URL = appConfig.socketUrl;

const App = () => {
useEffect(() => {
logger.info('App loaded.');
}, []);

return (
<SocketProvider url={URL}>
<LocaleProvider>
<ThemeProvider>
<Router>
<Route path="/" component={MainLayout} />
</Router>
</ThemeProvider>
</LocaleProvider>
</SocketProvider>
<LocaleProvider>
<ThemeProvider>
<Router>
<Route path="/" component={MainLayout} />
</Router>
</ThemeProvider>
</LocaleProvider>
);
};

Expand Down
2 changes: 0 additions & 2 deletions packages/iceworks-client/src/layouts/MainLayout/index.js
@@ -1,7 +1,6 @@
import React from 'react';
import NavigationBar from '@components/NavigationBar';
import RouteRender from '@components/RouteRender';
import ConnectionBar from '@components/ConnectionBar';
import GlobalBar from '@components/GlobalBar';
import menuConfig from '@src/menuConfig';
import routerConfig from '@src/routerConfig';
Expand All @@ -10,7 +9,6 @@ import styles from './index.module.scss';
const MainLayout = () => {
return (
<div className={styles.container}>
<ConnectionBar />

<div className={styles.content}>
<NavigationBar menuData={menuConfig} />
Expand Down
49 changes: 34 additions & 15 deletions packages/iceworks-client/src/pages/Dev/index.js
@@ -1,26 +1,38 @@
import React from 'react';
import { Button } from '@alifd/next';
import {
ICEWORKS_TASK_DEV_OPEN,
ICEWORKS_TASK_DEV_DATA,
} from 'iceworks-events';
import Card from '@components/Card';
import Icon from '@components/Icon';
import Modal from '@components/Modal';
import XtermTerminal from '@components/XtermTerminal';
import useModal from '@hooks/useModal';
import { useSocket } from '@hooks/useSocket';
import logger from '@utils/logger';
import stores from '@stores';
import IceNotification from '@icedesign/notification';
import styles from './index.module.scss';

const Dev = () => {
const project = stores.useStore('project');
const { on, toggleModal } = useModal();
const socket = useSocket(ICEWORKS_TASK_DEV_DATA, (data) => {
logger.debug(ICEWORKS_TASK_DEV_DATA, data);
});

const dev = () => {
socket.emit(ICEWORKS_TASK_DEV_OPEN, 'dev');
const devStart = async () => {
try {
await project.devStart();
} catch (error) {
IceNotification.error({
message: '启动调试服务失败',
description: error.message || '当前项目依赖未安装或依赖缺失,请重装依赖后重试。',
});
}
};

const devStop = async () => {
try {
await project.devStop();
} catch (error) {
IceNotification.error({
message: '终止调试服务失败',
description: error.message || '请重试。',
});
}
};

return (
Expand All @@ -33,10 +45,17 @@ const Dev = () => {
<div className={styles.actionBar}>
{/* Left Button Group */}
<div className={styles.leftActionBar}>
<Button type="primary" className={styles.btn} onClick={dev}>
<Icon type="start" className={styles.icon} />
运行
</Button>
{
project.dataSource.devStatus !== 'working' ?
<Button type="primary" className={styles.btn} onClick={devStart}>
<Icon type="start" className={styles.icon} />
运行
</Button> :
<Button type="primary" className={styles.btn} onClick={devStop}>
<Icon type="stop" className={styles.icon} />
停止
</Button>
}
<Button type="secondary" className={styles.btn} onClick={toggleModal}>
<Icon type="settings" className={styles.icon} />
设置
Expand Down
5 changes: 1 addition & 4 deletions packages/iceworks-client/src/pages/Material/index.js
Expand Up @@ -4,15 +4,12 @@ import stores from '@stores';
const Material = () => {
const materials = stores.useStore('materials');

const handleClick = () => {
};

useEffect(() => {
materials.refresh();
}, []);

return (
<div onClick={handleClick}>
<div>
<h2>Material</h2>
<p>
{materials.dataSource.map(({ name }) => {
Expand Down
@@ -0,0 +1,22 @@
import React from 'react';
import stores from '../../stores';

const Page = () => {
const dependencies = stores.useStore('dependencies');
const { dataSource } = dependencies;

return (
<div>
<h3>Dependencies</h3>
<div>
<ul>
{dataSource.map(({ package: _package }) => {
return <li>{_package}</li>;
})}
</ul>
</div>
</div>
);
};

export default Page;
@@ -0,0 +1,22 @@
import React from 'react';
import stores from '../../stores';

const Page = () => {
const pages = stores.useStore('pages');
const { dataSource } = pages;

return (
<div>
<h3>Pages</h3>
<div>
<ul>
{dataSource.map(({ name }) => {
return <li>{name}</li>;
})}
</ul>
</div>
</div>
);
};

export default Page;