Skip to content

Commit

Permalink
Merge pull request #6 from crawlab-team/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Marvin Zhang authored Sep 12, 2019
2 parents c332cef + 971ca8e commit d016569
Show file tree
Hide file tree
Showing 10 changed files with 174 additions and 111 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ tmp/
yarn.lock
.DS_Store
package-lock.json
.umi/
61 changes: 45 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,42 +7,71 @@
- MongoDB 3.6+
- NodeJS 8.12+

## 安装步骤
## 安装方式

**克隆Github Repo**
ArtiPub提供3种安装方式如下。

- [Docker](#通过Docker安装) (大约5分钟): 适合对Docker有一定基础的开发者
- [npm](#通过npm包安装) (大约3分钟): 适合熟悉Node.js或npm的开发者
- [源码](#通过源码安装) (大约5-10分钟): 适合希望了解内核原理的开发者

### 通过Docker安装

通过Docker,可以免去

**安装Docker Compose**

```bash
git clone https://github.com/crawlab-team/artipub
docker-compose
```

**安装前端**
### 通过npm包安装

**安装npm包**

```bash
cd frontend
npm install
npm install -g artipub
```

**安装后端**
安装npm包时,为了加速下载速度,可以加入`--registry`参数来设置镜像源(后面源码安装时也可以这样操作)

```bash
cd ../backend
npm install
npm install -g artipub --registry=https://registry.npm.taobao.org
```

**运行ArtiPub**

```bash
artipub start
```

## 运行步骤
然后在浏览器中输入`http://localhost:8000`可以看到界面。

### 通过源码安装

**克隆Github Repo**

```bash
git clone https://github.com/crawlab-team/artipub
```

**安装npm包**

```bash
cd artipub
npm install
```

**运行前端**
**启动前端**

```bash
cd ../frontend
npm run start
npm run start:frontend
```

**运行后端**
**启动后端**

```bash
cd ../backend
npm run start
npm run start:backend
```

## 为什么创建这个工具
Expand Down
1 change: 1 addition & 0 deletions cli.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env node
const os = require('os')
const exec = require('child_process').exec
const path = require('path')
Expand Down
17 changes: 17 additions & 0 deletions src/models/article.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export interface ArticleModelState {
currentArticle?: Article;
pubModalVisible?: boolean;
platformModalVisible?: boolean;
fetchHandle?: number;
}

export interface ArticleModelType {
Expand All @@ -45,6 +46,7 @@ export interface ArticleModelType {
setPubModalVisible: Effect;
publishArticle: Effect;
setPlatformModalVisible: Effect;
setFetchHandle: Effect;
};
reducers: {
saveArticle: Reducer<ArticleModelState>;
Expand All @@ -55,6 +57,7 @@ export interface ArticleModelType {
saveArticlePlatformIds: Reducer<ArticleModelState>;
savePubModalVisible: Reducer<ArticleModelState>;
savePlatformModalVisible: Reducer<ArticleModelState>;
saveFetchHandle: Reducer<ArticleModelState>;
};
}

Expand All @@ -67,6 +70,7 @@ const ArticleModel: ArticleModelType = {
currentArticle: { title: '', content: '', contentHtml: '', platformIds: [] },
pubModalVisible: false,
platformModalVisible: false,
fetchHandle: undefined,
},

effects: {
Expand Down Expand Up @@ -162,6 +166,13 @@ const ArticleModel: ArticleModelType = {
payload: action.payload,
});
},

*setFetchHandle(action, { put }) {
yield put({
type: 'saveFetchHandle',
payload: action.payload,
});
},
},

reducers: {
Expand Down Expand Up @@ -225,6 +236,12 @@ const ArticleModel: ArticleModelType = {
platformModalVisible: action.payload,
};
},
saveFetchHandle(state, action) {
return {
...state,
fetchHandle: action.payload,
};
},
},
};

Expand Down
8 changes: 4 additions & 4 deletions src/pages/.umi/LocaleWrapper.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ defaultAntd = defaultAntd.default || defaultAntd;
const localeInfo = {
'en-US': {
messages: {
...((locale) => locale.__esModule ? locale.default : locale)(require('C:/Users/marvzhang/artipub/src/locales/en-US.ts')),
...((locale) => locale.__esModule ? locale.default : locale)(require('/Users/yeqing/projects/artipub/src/locales/en-US.ts')),
},
locale: 'en-US',
antd: require('antd/lib/locale-provider/en_US'),
Expand All @@ -45,7 +45,7 @@ const localeInfo = {
},
'pt-BR': {
messages: {
...((locale) => locale.__esModule ? locale.default : locale)(require('C:/Users/marvzhang/artipub/src/locales/pt-BR.ts')),
...((locale) => locale.__esModule ? locale.default : locale)(require('/Users/yeqing/projects/artipub/src/locales/pt-BR.ts')),
},
locale: 'pt-BR',
antd: require('antd/lib/locale-provider/pt_BR'),
Expand All @@ -54,7 +54,7 @@ const localeInfo = {
},
'zh-CN': {
messages: {
...((locale) => locale.__esModule ? locale.default : locale)(require('C:/Users/marvzhang/artipub/src/locales/zh-CN.ts')),
...((locale) => locale.__esModule ? locale.default : locale)(require('/Users/yeqing/projects/artipub/src/locales/zh-CN.ts')),
},
locale: 'zh-CN',
antd: require('antd/lib/locale-provider/zh_CN'),
Expand All @@ -63,7 +63,7 @@ const localeInfo = {
},
'zh-TW': {
messages: {
...((locale) => locale.__esModule ? locale.default : locale)(require('C:/Users/marvzhang/artipub/src/locales/zh-TW.ts')),
...((locale) => locale.__esModule ? locale.default : locale)(require('/Users/yeqing/projects/artipub/src/locales/zh-TW.ts')),
},
locale: 'zh-TW',
antd: require('antd/lib/locale-provider/zh_TW'),
Expand Down
50 changes: 25 additions & 25 deletions src/pages/.umi/dva.js
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
import dva from 'dva';
import { Component } from 'react';
import createLoading from 'dva-loading';
import history from '@tmp/history';
import dva from 'dva'
import { Component } from 'react'
import createLoading from 'dva-loading'
import history from '@tmp/history'

let app = null;
let app = null

export function _onCreate() {
const plugins = require('umi/_runtimePlugin');
const runtimeDva = plugins.mergeConfig('dva');
const plugins = require('umi/_runtimePlugin')
const runtimeDva = plugins.mergeConfig('dva')
app = dva({
history,

...(runtimeDva.config || {}),
...(window.g_useSSR ? { initialState: window.g_initialData } : {}),
});
})

app.use(createLoading());
(runtimeDva.plugins || []).forEach(plugin => {
app.use(plugin);
});
app.model({ namespace: 'article', ...(require('C:/Users/marvzhang/artipub/src/models/article.ts').default) });
app.model({ namespace: 'global', ...(require('C:/Users/marvzhang/artipub/src/models/global.ts').default) });
app.model({ namespace: 'login', ...(require('C:/Users/marvzhang/artipub/src/models/login.ts').default) });
app.model({ namespace: 'platform', ...(require('C:/Users/marvzhang/artipub/src/models/platform.ts').default) });
app.model({ namespace: 'setting', ...(require('C:/Users/marvzhang/artipub/src/models/setting.ts').default) });
app.model({ namespace: 'task', ...(require('C:/Users/marvzhang/artipub/src/models/task.ts').default) });
app.model({ namespace: 'user', ...(require('C:/Users/marvzhang/artipub/src/models/user.ts').default) });
return app;
app.use(plugin)
})

app.model({ namespace: 'article', ...(require('/Users/yeqing/projects/artipub/src/models/article.ts').default) })
app.model({ namespace: 'global', ...(require('/Users/yeqing/projects/artipub/src/models/global.ts').default) })
app.model({ namespace: 'login', ...(require('/Users/yeqing/projects/artipub/src/models/login.ts').default) })
app.model({ namespace: 'platform', ...(require('/Users/yeqing/projects/artipub/src/models/platform.ts').default) })
app.model({ namespace: 'setting', ...(require('/Users/yeqing/projects/artipub/src/models/setting.ts').default) })
app.model({ namespace: 'task', ...(require('/Users/yeqing/projects/artipub/src/models/task.ts').default) })
app.model({ namespace: 'user', ...(require('/Users/yeqing/projects/artipub/src/models/user.ts').default) })
return app
}

export function getApp() {
return app;
return app
}

export class _DvaContainer extends Component {
render() {
const app = getApp();
app.router(() => this.props.children);
return app.start()();
const app = getApp()
app.router(() => this.props.children)
return app.start()()
}
}
2 changes: 1 addition & 1 deletion src/pages/.umi/polyfills.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ import 'regenerator-runtime/runtime';

// Include this seperatly since it's not included in core-js
// ref: https://github.com/zloirock/core-js/issues/117
import '../../../node_modules/umi-build-dev/node_modules/url-polyfill/url-polyfill.js';
import '../../../node_modules/url-polyfill/url-polyfill.js';
24 changes: 12 additions & 12 deletions src/pages/.umi/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Router as DefaultRouter, Route, Switch } from 'react-router-dom';
import dynamic from 'umi/dynamic';
import renderRoutes from 'umi/lib/renderRoutes';
import history from '@tmp/history';
import RendererWrapper0 from 'C:/Users/marvzhang/artipub/src/pages/.umi/LocaleWrapper.jsx';
import RendererWrapper0 from '/Users/yeqing/projects/artipub/src/pages/.umi/LocaleWrapper.jsx';
import _dvaDynamic from 'dva/dynamic';

const Router = require('dva/router').routerRedux.ConnectedRouter;
Expand All @@ -19,7 +19,7 @@ const routes = [
? _dvaDynamic({
component: () =>
import(/* webpackChunkName: "p__ArticleEdit__ArticleEdit" */ '../ArticleEdit/ArticleEdit'),
LoadingComponent: require('C:/Users/marvzhang/artipub/src/components/PageLoading/index')
LoadingComponent: require('/Users/yeqing/projects/artipub/src/components/PageLoading/index')
.default,
})
: require('../ArticleEdit/ArticleEdit').default,
Expand All @@ -35,7 +35,7 @@ const routes = [
? _dvaDynamic({
component: () =>
import(/* webpackChunkName: "p__ArticleEdit__ArticleEdit" */ '../ArticleEdit/ArticleEdit'),
LoadingComponent: require('C:/Users/marvzhang/artipub/src/components/PageLoading/index')
LoadingComponent: require('/Users/yeqing/projects/artipub/src/components/PageLoading/index')
.default,
})
: require('../ArticleEdit/ArticleEdit').default,
Expand All @@ -51,7 +51,7 @@ const routes = [
? _dvaDynamic({
component: () =>
import(/* webpackChunkName: "p__Paste__Paste" */ '../Paste/Paste'),
LoadingComponent: require('C:/Users/marvzhang/artipub/src/components/PageLoading/index')
LoadingComponent: require('/Users/yeqing/projects/artipub/src/components/PageLoading/index')
.default,
})
: require('../Paste/Paste').default,
Expand All @@ -67,7 +67,7 @@ const routes = [
? _dvaDynamic({
component: () =>
import(/* webpackChunkName: "p__Demo__Demo" */ '../Demo/Demo'),
LoadingComponent: require('C:/Users/marvzhang/artipub/src/components/PageLoading/index')
LoadingComponent: require('/Users/yeqing/projects/artipub/src/components/PageLoading/index')
.default,
})
: require('../Demo/Demo').default,
Expand All @@ -79,7 +79,7 @@ const routes = [
? _dvaDynamic({
component: () =>
import(/* webpackChunkName: "layouts__BasicLayout" */ '../../layouts/BasicLayout'),
LoadingComponent: require('C:/Users/marvzhang/artipub/src/components/PageLoading/index')
LoadingComponent: require('/Users/yeqing/projects/artipub/src/components/PageLoading/index')
.default,
})
: require('../../layouts/BasicLayout').default,
Expand All @@ -99,7 +99,7 @@ const routes = [
? _dvaDynamic({
component: () =>
import(/* webpackChunkName: "p__PlatformList__PlatformList" */ '../PlatformList/PlatformList'),
LoadingComponent: require('C:/Users/marvzhang/artipub/src/components/PageLoading/index')
LoadingComponent: require('/Users/yeqing/projects/artipub/src/components/PageLoading/index')
.default,
})
: require('../PlatformList/PlatformList').default,
Expand All @@ -113,7 +113,7 @@ const routes = [
? _dvaDynamic({
component: () =>
import(/* webpackChunkName: "p__ArticleList__ArticleList" */ '../ArticleList/ArticleList'),
LoadingComponent: require('C:/Users/marvzhang/artipub/src/components/PageLoading/index')
LoadingComponent: require('/Users/yeqing/projects/artipub/src/components/PageLoading/index')
.default,
})
: require('../ArticleList/ArticleList').default,
Expand All @@ -124,7 +124,7 @@ const routes = [
? _dvaDynamic({
component: () =>
import(/* webpackChunkName: "p__404" */ '../404'),
LoadingComponent: require('C:/Users/marvzhang/artipub/src/components/PageLoading/index')
LoadingComponent: require('/Users/yeqing/projects/artipub/src/components/PageLoading/index')
.default,
})
: require('../404').default,
Expand All @@ -133,7 +133,7 @@ const routes = [
{
component: () =>
React.createElement(
require('C:/Users/marvzhang/artipub/node_modules/umi-build-dev/lib/plugins/404/NotFound.js')
require('/Users/yeqing/projects/artipub/node_modules/umi-build-dev/lib/plugins/404/NotFound.js')
.default,
{ pagesPath: 'src/pages', hasRoutesInConfig: true },
),
Expand All @@ -144,7 +144,7 @@ const routes = [
component: __IS_BROWSER
? _dvaDynamic({
component: () => import(/* webpackChunkName: "p__404" */ '../404'),
LoadingComponent: require('C:/Users/marvzhang/artipub/src/components/PageLoading/index')
LoadingComponent: require('/Users/yeqing/projects/artipub/src/components/PageLoading/index')
.default,
})
: require('../404').default,
Expand All @@ -153,7 +153,7 @@ const routes = [
{
component: () =>
React.createElement(
require('C:/Users/marvzhang/artipub/node_modules/umi-build-dev/lib/plugins/404/NotFound.js')
require('/Users/yeqing/projects/artipub/node_modules/umi-build-dev/lib/plugins/404/NotFound.js')
.default,
{ pagesPath: 'src/pages', hasRoutesInConfig: true },
),
Expand Down
2 changes: 1 addition & 1 deletion src/pages/.umi/umi.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import React from 'react';
import ReactDOM from 'react-dom';
import findRoute, {
getUrlQuery,
} from 'C:/Users/marvzhang/artipub/node_modules/umi-build-dev/lib/findRoute.js';
} from '/Users/yeqing/projects/artipub/node_modules/umi-build-dev/lib/findRoute.js';

// runtime plugins
const plugins = require('umi/_runtimePlugin');
Expand Down
Loading

0 comments on commit d016569

Please sign in to comment.