Skip to content
This repository has been archived by the owner on May 9, 2020. It is now read-only.

Commit

Permalink
Merge pull request #157 from ice-lab/release-next
Browse files Browse the repository at this point in the history
* chore: release version

* fix: semicolons is required (#162)

* chore: fallback example (#169)

* fix: onHook position (#173)

* chore: version

* v1.1.3-alpha.0

* fix: pass location params to StaticRouter (#176)

* fix: pass location params

* fix: context params

* chore: code optimization

* fix: pass staticRouter context

* Feat/enhance request (#161)

* feat: enhance request

* refactor: load module time (#174)

* refactor: load module

Co-authored-by: ClarkXia <[email protected]>

* feat: downgraded to csr when ssr error (#179)

* fix: define process.env.APP_MODE in ssr (#181)

* fix: define process.env.APP_MODE in ssr

* fix: modify define plugin

Co-authored-by: 大果 <[email protected]>

* fix: publish script (#180)

* v1.1.3-alpha.1

* fix: ssr to csr (#182)

* fix: use window variable

* chore: typo

* fix: remove define variables

* refactor: server render

* v1.1.3-alpha.2

* chore: fix lint (#183)

* chore: update example

* fix: params

* chore: revert beforeload (#185)

* Revert "Feat/enhance request (#161)"

This reverts commit 0ceed05.

* v1.1.3-alpha.3

* feat: support runtime app_mode (#189)

* feat: support runtime app_mode

* feat: support process.env.SERVER_PORT

* fix: lock core-js version (#184)

* fix: lint error (#190)

* feat: add static module (#188)

* fix: set polyfill

* fix: before load module

* fix: load module in createApp

* chore: rename variable

* feat: support uglify

* refactor: code optim

* fix: window is not defined (#193)

* v1.1.3-alpha.4

* v1.1.3
  • Loading branch information
chenbin92 authored Mar 30, 2020
2 parents 422af4c + 1be8fc9 commit 45cf3c4
Show file tree
Hide file tree
Showing 119 changed files with 775 additions and 649 deletions.
3 changes: 1 addition & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ const { eslint, tslint, deepmerge } = require('@ice/spec');

const commonRules = {
"react/jsx-filename-extension": 0,
"semi": 0,
"no-underscore-dangle": 0,
"class-methods-use-this": 0,
"no-param-reassign": 0,
"comma-dangle": 0,
"comma-dangle": 0
};

const jsRules = deepmerge(eslint, {
Expand Down
8 changes: 4 additions & 4 deletions examples/basic-mpa/src/pages/Dashboard/app.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { createApp, IAppConfig } from 'ice'
import Dashboard from './index'
import { createApp, IAppConfig } from 'ice';
import Dashboard from './index';

const appConfig: IAppConfig = {
router: {
routes: [{ path: '/', component: Dashboard }],
},
}
};

createApp(appConfig)
createApp(appConfig);
12 changes: 6 additions & 6 deletions examples/basic-mpa/src/pages/Dashboard/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as React from 'react'
import { store } from 'ice/Dashboard'
import * as React from 'react';
import { store } from 'ice/Dashboard';

const Dashboard = () => {
const [pageState, pageActions] = store.useModel('counter')
const [pageState, pageActions] = store.useModel('counter');
return (
<>
<h2>Dashboard Page...</h2>
Expand All @@ -12,7 +12,7 @@ const Dashboard = () => {
<button type="button" onClick={pageActions.decrement}>-</button>
</div>
</>
)
}
);
};

export default Dashboard
export default Dashboard;
4 changes: 2 additions & 2 deletions examples/basic-mpa/src/pages/Dashboard/models/counter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ export default {

reducers: {
increment (prevState) {
return { count: prevState.count + 1 }
return { count: prevState.count + 1 };
},
decrement (prevState) {
return { count: prevState.count - 1 }
return { count: prevState.count - 1 };
}
},

Expand Down
8 changes: 4 additions & 4 deletions examples/basic-mpa/src/pages/Home/app.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { createApp, IAppConfig } from 'ice'
import Home from './index'
import { createApp, IAppConfig } from 'ice';
import Home from './index';

const appConfig: IAppConfig = {
router: {
routes: [{ path: '/', component: Home }],
},
}
};

createApp(appConfig)
createApp(appConfig);
6 changes: 3 additions & 3 deletions examples/basic-mpa/src/pages/Home/index.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import React from 'react'
import React from 'react';

const Home = () => {
return (
<>
<h2>Home Page</h2>
</>
);
}
};

Home.pageConfig = {
title: 'Home Page',
};

export default Home
export default Home;
37 changes: 20 additions & 17 deletions examples/basic-request/src/pages/Home/index.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
import React, { useEffect } from 'react'
import { useRequest, request } from 'ice'
import React, { useEffect } from 'react';
import { useRequest, request } from 'ice';

// 1. request in outside
request('/user').then(res => console.log('request in outside:', res));

const Home = () => {
// 1. useRequest hook
const { data, loading, request: fetchRepo } = useRequest({ url: '/repo' })
// 2. useRequest hook
const { data, loading, request: fetchRepo } = useRequest({ url: '/repo' });

useEffect(() => {
fetchRepo()

request('/user').then(res => console.log('get:', res))
// 2. requse.get alias
request.get('/user').then(res => console.log('get:', res))
fetchRepo();

// 3. requse.get alias
request.get('/user').then(res => console.log('get:', res));

// 3. requse.post alias
request.post('/users/123').then(res => console.log('post:', res))
// 4. requse.post alias
request.post('/users/123').then(res => console.log('post:', res));

// 4. requse.delete alias
request.delete('/user/123').then(res => console.log('delete:', res))
// 5. requse.delete alias
request.delete('/user/123').then(res => console.log('delete:', res));

// 5. request method
request({ url: '/user'}).then((res) => {console.log('request:', res)})
}, [])
// 6. request method
request({ url: '/user'}).then((res) => {console.log('request:', res);});
// eslint-disable-next-line
}, []);

return (
<div>
Expand All @@ -35,7 +38,7 @@ const Home = () => {
</>
}
</div>
)
);
};

export default Home;
6 changes: 3 additions & 3 deletions examples/basic-request/src/routes.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import Home from '@/pages/Home'
import Home from '@/pages/Home';

const routerConfig = [
{
path: '/',
component: Home
}
]
];

export default routerConfig
export default routerConfig;
2 changes: 1 addition & 1 deletion examples/basic-spa/mock/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const projects = [
description: 'A universal framework based on React.js.',
logo: 'https://avatars1.githubusercontent.com/u/1961952',
},
]
];

// mock/index.js
module.exports = {
Expand Down
10 changes: 6 additions & 4 deletions examples/basic-spa/src/app.ts → examples/basic-spa/src/app.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { createApp, APP_MODE, IAppConfig } from 'ice'
import React from 'react';
import { createApp, APP_MODE, IAppConfig } from 'ice';

const appConfig: IAppConfig = {
app: {
Expand All @@ -8,19 +9,20 @@ const appConfig: IAppConfig = {
level: APP_MODE === 'build' ? 'error' : 'debug',
},
router: {
type: 'hash'
type: 'hash',
fallback: <div>加载中...</div>
},
request: {
timeout: 5000,
baseURL: '/',
interceptors: {
request: {
onConfig: (config) => {
return config
return config;
}
}
}
}
};

createApp(appConfig)
createApp(appConfig);
6 changes: 5 additions & 1 deletion examples/basic-spa/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
// config runtime APP_MODE
// eslint-disable-next-line @typescript-eslint/camelcase
window.__app_mode__ = 'build';

const config = {
dev: {
appId: 'dev-id',
API_URL: 'http://localhost:3333'
API_URL: `http://localhost:${process.env.SERVER_PORT}`,
},
build: {
API_URL: 'http://github.com/api'
Expand Down
14 changes: 7 additions & 7 deletions examples/basic-spa/src/pages/About/index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import React from 'react'
import { Link } from 'ice'
import React from 'react';
import { Link } from 'ice';

const Child = () => {
return (
<div>
Child
</div>
)
}
);
};

const About = () => {
return (
Expand All @@ -17,7 +17,7 @@ const About = () => {
<Link to="/dashboard">dashboard</Link><br />
<Link to="/">Home</Link>
</>
)
}
);
};

export default About
export default About;
10 changes: 5 additions & 5 deletions examples/basic-spa/src/pages/Dashboard/index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import React from 'react'
import { Link } from 'ice'
import React from 'react';
import { Link } from 'ice';

const Dashboard = () => {
return (
<>
<h2>Dashboard Page...</h2>
<Link to="/about">About</Link>
</>
)
}
);
};

export default Dashboard
export default Dashboard;
17 changes: 4 additions & 13 deletions examples/basic-spa/src/pages/Home/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import { Link, helpers, logger, config } from 'ice'
import React from 'react';
import { Link, helpers, logger, config } from 'ice';

logger.debug('helpers from ice', helpers.urlParse);
logger.debug('logger from ice', logger.debug);
Expand All @@ -15,26 +15,17 @@ export default function Home(props) {
logger.info('Home props', props);
logger.info('render home config.appId', config.appId);

// const { data, error, loading, request: fetchRepo } = useRequest({ url: '/api/repo' })
// logger.info('useRequest:', { data, error, loading, fetchRepo })

// useEffect(() => {
// (async function () {
// await fetchRepo()
// }())
// }, [])

return (
<>
<h2>Home Page...{props.a}</h2>
<h2>Home Page...{props.count}</h2>
<Link to="/about">About</Link><br />
<Link to="/dashboard">Dashboard</Link>
</>
);
}

Home.getInitialProps = async () => {
return {a: 1}
return { count: 1 };
};

Home.pageConfig = {
Expand Down
8 changes: 4 additions & 4 deletions examples/basic-spa/src/pages/NotFound/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import { Link } from 'ice'
import React from 'react';
import { Link } from 'ice';

const Home = (props) => {
console.log('render 404', props);
Expand All @@ -12,6 +12,6 @@ const Home = (props) => {
<Link to="/dashboard">Dashboard</Link>
</>
);
}
};

export default Home
export default Home;
21 changes: 16 additions & 5 deletions examples/basic-ssr/mock/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
module.exports = {
'GET /api/user': {
status: 'SUCCESS',
data: {
user: {
name: 'Jack Ma',
id: 10001,
}
},
},
'GET /api/profile': {
status: 'SUCCESS',
data: {
name: '淘小宝',
department: '技术部',
avatar: 'https://img.alicdn.com/tfs/TB1L6tBXQyWBuNjy0FpXXassXXa-80-80.png',
userid: 10001,
profile: {
id: 10001,
name: 'Jack Ma',
edu: 'Hangzhou Normal University',
address: 'Hangzhou'
}
},
},
};
};
2 changes: 1 addition & 1 deletion examples/basic-ssr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"@types/react-dom": "^16.9.4"
},
"scripts": {
"start": "icejs start",
"start": "icejs start --mode dev",
"build": "icejs build --mode prod"
},
"engines": {
Expand Down
12 changes: 8 additions & 4 deletions examples/basic-ssr/src/app.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
import { createApp, IAppConfig } from 'ice'
import { createApp, IAppConfig, config, request } from 'ice';

const appConfig: IAppConfig = {
app: {
getInitialData: async () => {
return { user: { name: 'Jack Ma', id: '01' } }
const res = await request('/user');
return res;
}
},
router: {
type: 'browser'
},
request: {
baseURL: config.baseURL
},
store: {
getInitialStates: (initialData) => {
return initialData
return initialData.data;
}
}
};

createApp(appConfig)
createApp(appConfig);
Loading

0 comments on commit 45cf3c4

Please sign in to comment.