├── .commitlintrc.js ├── .editorconfig ├── .eslintignore ├── .eslintrc.js ├── .github ├── CONTRIBUTING.md ├── GIT_COMMIT_SPECIFIC.md ├── ISSUE_TEMPLATE.md └── workflows │ └── ci.yml ├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── examples ├── basic-mpa │ ├── build.json │ ├── package.json │ ├── public │ │ ├── dashboard.html │ │ └── index.html │ ├── sandbox.config.json │ ├── src │ │ └── pages │ │ │ ├── Dashboard │ │ │ ├── app.ts │ │ │ ├── index.tsx │ │ │ ├── models │ │ │ │ └── counter.ts │ │ │ └── routes.ts │ │ │ └── Home │ │ │ ├── app.ts │ │ │ └── index.tsx │ └── tsconfig.json ├── basic-request │ ├── README.md │ ├── mock │ │ └── index.js │ ├── package.json │ ├── public │ │ ├── favicon.png │ │ └── index.html │ ├── sandbox.config.json │ ├── src │ │ ├── app.ts │ │ ├── global.scss │ │ ├── pages │ │ │ └── Home │ │ │ │ └── index.tsx │ │ └── routes.ts │ └── tsconfig.json ├── basic-rml │ ├── README.md │ ├── build.json │ ├── package.json │ ├── public │ │ ├── favicon.png │ │ └── index.html │ ├── sandbox.config.json │ ├── src │ │ ├── app.ts │ │ ├── components │ │ │ └── Simple │ │ │ │ └── index.rml │ │ ├── global.scss │ │ ├── pages │ │ │ └── Home │ │ │ │ └── index.rml │ │ └── routes.ts │ └── tsconfig.json ├── basic-service │ ├── README.md │ ├── build.json │ ├── mock │ │ └── index.js │ ├── package.json │ ├── public │ │ ├── favicon.png │ │ └── index.html │ ├── sandbox.config.json │ ├── src │ │ ├── app.ts │ │ ├── components │ │ │ └── Fetch │ │ │ │ └── index.tsx │ │ ├── global.scss │ │ ├── pages │ │ │ └── Home │ │ │ │ ├── components │ │ │ │ └── User │ │ │ │ │ ├── index.tsx │ │ │ │ │ └── service.ts │ │ │ │ └── index.tsx │ │ ├── routes.ts │ │ └── services │ │ │ └── todo.ts │ └── tsconfig.json ├── basic-spa │ ├── build.json │ ├── mock │ │ └── index.js │ ├── package.json │ ├── public │ │ ├── favicon.png │ │ └── index.html │ ├── sandbox.config.json │ ├── src │ │ ├── app.tsx │ │ ├── config.ts │ │ ├── layouts │ │ │ ├── index.module.scss │ │ │ └── index.tsx │ │ ├── pages │ │ │ ├── About │ │ │ │ ├── components │ │ │ │ │ ├── Child.tsx │ │ │ │ │ └── Todo.tsx │ │ │ │ └── index.tsx │ │ │ ├── Dashboard │ │ │ │ └── index.tsx │ │ │ ├── Home │ │ │ │ └── index.tsx │ │ │ └── NotFound │ │ │ │ └── index.tsx │ │ └── routes.ts │ └── tsconfig.json ├── basic-ssr │ ├── build.json │ ├── mock │ │ └── index.ts │ ├── package.json │ ├── public │ │ ├── favicon.png │ │ └── index.html │ ├── sandbox.config.json │ ├── src │ │ ├── app.ts │ │ ├── config.ts │ │ ├── layouts │ │ │ ├── index.module.scss │ │ │ └── index.tsx │ │ ├── models │ │ │ └── user.ts │ │ ├── pages │ │ │ ├── About │ │ │ │ └── index.tsx │ │ │ ├── Dashboard │ │ │ │ └── index.tsx │ │ │ ├── Home │ │ │ │ ├── index.module.scss │ │ │ │ └── index.tsx │ │ │ └── NotFound │ │ │ │ └── index.tsx │ │ └── routes.ts │ └── tsconfig.json ├── basic-store │ ├── README.md │ ├── build.json │ ├── package.json │ ├── public │ │ ├── favicon.png │ │ └── index.html │ ├── sandbox.config.json │ ├── src │ │ ├── app.ts │ │ ├── global.scss │ │ ├── layouts │ │ │ ├── index.module.scss │ │ │ └── index.tsx │ │ ├── models │ │ │ ├── counter.ts │ │ │ └── user.ts │ │ ├── pages │ │ │ ├── About │ │ │ │ ├── index.tsx │ │ │ │ └── model.ts │ │ │ ├── Home │ │ │ │ ├── index.tsx │ │ │ │ └── model.ts │ │ │ └── NotFound │ │ │ │ └── index.tsx │ │ └── routes.ts │ └── tsconfig.json ├── hello-world │ ├── README.md │ ├── package.json │ ├── public │ │ ├── favicon.png │ │ └── index.html │ ├── sandbox.config.json │ ├── src │ │ ├── app.ts │ │ ├── components │ │ │ └── Guide │ │ │ │ ├── index.module.scss │ │ │ │ └── index.tsx │ │ ├── global.scss │ │ ├── pages │ │ │ └── Home │ │ │ │ └── index.tsx │ │ └── routes.ts │ └── tsconfig.json ├── icestark-child │ ├── build.json │ ├── package.json │ ├── public │ │ ├── favicon.png │ │ └── index.html │ ├── sandbox.config.json │ ├── src │ │ ├── app.ts │ │ ├── global.css │ │ └── pages │ │ │ ├── About │ │ │ ├── _layout.tsx │ │ │ └── index.tsx │ │ │ ├── Dashboard │ │ │ └── index.tsx │ │ │ └── index.tsx │ └── tsconfig.json ├── icestark-layout │ ├── build.json │ ├── package.json │ ├── public │ │ ├── favicon.png │ │ └── index.html │ ├── sandbox.config.json │ ├── src │ │ ├── app.tsx │ │ ├── global.scss │ │ ├── layouts │ │ │ └── index.tsx │ │ └── pages │ │ │ ├── 404.tsx │ │ │ ├── Dashboard │ │ │ └── index.tsx │ │ │ └── Home │ │ │ └── index.tsx │ └── tsconfig.json ├── with-fusion-design │ ├── README.md │ ├── build.json │ ├── package.json │ ├── public │ │ ├── favicon.png │ │ └── index.html │ ├── sandbox.config.json │ ├── src │ │ ├── app.ts │ │ ├── global.scss │ │ ├── pages │ │ │ └── Home │ │ │ │ └── index.tsx │ │ └── routes.ts │ └── tsconfig.json └── with-rematch │ ├── README.md │ ├── build.json │ ├── package.json │ ├── public │ ├── favicon.png │ └── index.html │ ├── sandbox.config.json │ ├── src │ ├── app.ts │ ├── pages │ │ ├── 404.tsx │ │ ├── Rematch │ │ │ ├── Child.tsx │ │ │ ├── Child2.tsx │ │ │ └── index.tsx │ │ └── index.tsx │ ├── routes.ts │ └── stores │ │ └── user.ts │ └── tsconfig.json ├── lerna.json ├── package.json ├── packages ├── create-ice │ ├── README.md │ ├── __tests__ │ │ └── index.test.js │ ├── package.json │ ├── src │ │ ├── create.ts │ │ └── index.ts │ └── tsconfig.json ├── icejs │ ├── README.md │ ├── __tests__ │ │ └── cli.test.js │ ├── bin │ │ ├── build.js │ │ ├── child-process-start.js │ │ ├── ice-cli.js │ │ ├── start.js │ │ └── test.js │ ├── package.json │ ├── src │ │ └── index.ts │ └── tsconfig.json ├── plugin-config │ ├── README.md │ ├── __tests__ │ │ └── plugin-config.test.js │ ├── config │ │ └── index.ts │ ├── package.json │ ├── src │ │ ├── _config.ts │ │ └── index.ts │ └── tsconfig.json ├── plugin-core │ ├── README.md │ ├── package.json │ ├── src │ │ ├── _components.tsx │ │ ├── generator │ │ │ ├── index.ts │ │ │ ├── pageGenerator.ts │ │ │ └── templates │ │ │ │ ├── app │ │ │ │ ├── appConfig.ts.ejs │ │ │ │ ├── components │ │ │ │ │ ├── ErrorBoundary.tsx.ejs │ │ │ │ │ ├── ErrorBoundaryFallback.tsx.ejs │ │ │ │ │ └── index.ts.ejs │ │ │ │ ├── createApp.tsx.ejs │ │ │ │ ├── index.ts.ejs │ │ │ │ ├── lazy.ts.ejs │ │ │ │ ├── runtimeModule.tsx.ejs │ │ │ │ └── types.ts.ejs │ │ │ │ └── page │ │ │ │ └── index.ts.ejs │ │ ├── index.ts │ │ ├── module.tsx │ │ ├── types │ │ │ └── base.ts │ │ └── utils │ │ │ ├── checkExportData.ts │ │ │ ├── formatPath.ts │ │ │ ├── generateExports.ts │ │ │ ├── getPages.ts │ │ │ ├── getRoutes.ts │ │ │ └── removeExportData.ts │ └── tsconfig.json ├── plugin-helpers │ ├── README.md │ ├── __tests__ │ │ └── index.test.js │ ├── helpers │ │ ├── cookie.ts │ │ ├── index.ts │ │ └── urlParse.ts │ ├── package.json │ ├── src │ │ ├── _helpers.ts │ │ └── index.ts │ └── tsconfig.json ├── plugin-icestark │ ├── README.md │ ├── package.json │ ├── src │ │ ├── index.ts │ │ ├── module.tsx │ │ ├── runtime │ │ │ ├── Layout.tsx │ │ │ ├── _Router.tsx │ │ │ ├── _history.ts │ │ │ └── removeLayout.ts │ │ └── types │ │ │ ├── base.ts │ │ │ └── index.ts │ └── tsconfig.json ├── plugin-logger │ ├── README.md │ ├── logger │ │ └── index.ts │ ├── package.json │ ├── src │ │ ├── _logger.ts │ │ ├── index.ts │ │ ├── module.ts │ │ └── types │ │ │ └── index.ts │ └── tsconfig.json ├── plugin-mpa │ ├── README.md │ ├── package.json │ ├── src │ │ └── index.ts │ └── tsconfig.json ├── plugin-react-app │ ├── README.md │ ├── package.json │ └── src │ │ ├── cliOption │ │ ├── analyzer.js │ │ ├── analyzerPort.js │ │ ├── disableReload.js │ │ └── https.js │ │ ├── config │ │ ├── default.config.js │ │ ├── option.config.js │ │ └── validation.js │ │ ├── index.js │ │ ├── userConfig │ │ ├── alias.js │ │ ├── babelPlugins.js │ │ ├── babelPresets.js │ │ ├── compileDependencies.js │ │ ├── cssLoaderOptions.js │ │ ├── define.js │ │ ├── devPublicPath.js │ │ ├── devServer.js │ │ ├── entry.js │ │ ├── eslint.js │ │ ├── extensions.js │ │ ├── externals.js │ │ ├── filename.js │ │ ├── hash.js │ │ ├── ignoreHtmlTemplate.js │ │ ├── injectBabel.js │ │ ├── lessLoaderOptions.js │ │ ├── library.js │ │ ├── libraryExport.js │ │ ├── libraryTarget.js │ │ ├── minify.js │ │ ├── mock.js │ │ ├── modules.js │ │ ├── outputAssetsPath.js │ │ ├── outputDir.js │ │ ├── postcssrc.js │ │ ├── proxy.js │ │ ├── publicPath.js │ │ ├── sassLoaderOptions.js │ │ ├── sourcemap.js │ │ ├── targets.js │ │ ├── terserOptions.js │ │ └── vendor.js │ │ └── utils │ │ ├── babelPluginCorejsLock.js │ │ ├── collect.js │ │ ├── formatWinPath.js │ │ ├── getCertificate.js │ │ ├── getFilePath.js │ │ ├── polyfillLoader.js │ │ └── updateMiniCssLoaderPath.js ├── plugin-rematch │ ├── README.md │ ├── __tests__ │ │ └── index.test.js │ ├── package.json │ ├── src │ │ ├── _store.ts │ │ ├── generateStore.ts │ │ ├── index.ts │ │ ├── module.tsx │ │ └── template │ │ │ └── store.ts.ejs │ └── tsconfig.json ├── plugin-request │ ├── README.md │ ├── __tests__ │ │ └── plugin-request.test.js │ ├── package.json │ ├── request │ │ ├── axiosInstance.ts │ │ ├── request.ts │ │ └── useRequest.ts │ ├── src │ │ ├── _axiosInstance.ts │ │ ├── index.ts │ │ ├── module.ts │ │ └── types │ │ │ ├── base.ts │ │ │ └── index.ts │ └── tsconfig.json ├── plugin-router │ ├── README.md │ ├── __tests__ │ │ └── plugin-router.test.js │ ├── package.json │ ├── src │ │ ├── babelPluginLazy.ts │ │ ├── collector │ │ │ ├── amender.ts │ │ │ ├── nest.ts │ │ │ ├── splicer.ts │ │ │ └── walker.ts │ │ ├── index.ts │ │ ├── module.tsx │ │ ├── runtime │ │ │ ├── Router.tsx │ │ │ ├── _routes.ts │ │ │ └── formatRoutes.tsx │ │ ├── types │ │ │ ├── base.ts │ │ │ ├── collector.ts │ │ │ ├── index.ts │ │ │ └── router.ts │ │ └── utils │ │ │ └── index.ts │ ├── templates │ │ ├── history.ts │ │ ├── index.ts │ │ ├── react-router-dom.ts │ │ ├── useSearchParams.ts │ │ └── withSearchParams.tsx │ └── tsconfig.json ├── plugin-service │ ├── README.md │ ├── __tests__ │ │ └── plugin-service.test.js │ ├── package.json │ ├── src │ │ ├── _ice.ts │ │ ├── index.ts │ │ └── service │ │ │ └── createService.ts │ └── tsconfig.json ├── plugin-ssr │ ├── README.md │ ├── __tests__ │ │ └── plugin-ssr.test.js │ ├── package.json │ ├── src │ │ ├── index.ts │ │ └── server.ts.ejs │ └── tsconfig.json └── plugin-store │ ├── README.md │ ├── __tests__ │ └── plugin-store.test.js │ ├── package.json │ ├── src │ ├── _store.ts │ ├── babelPluginReplacePath.ts │ ├── generator.ts │ ├── index.ts │ ├── module.tsx │ └── template │ │ ├── appStore.ts.ejs │ │ ├── pageComponent.tsx.ejs │ │ ├── pageStore.ts.ejs │ │ └── types.ts.ejs │ └── tsconfig.json ├── scripts ├── build.ts ├── dependency-check.ts ├── fn │ ├── getPackages.ts │ └── shell.ts ├── owner.ts ├── publish.ts ├── rollback.ts ├── sync.ts └── watch.ts ├── tsconfig.json ├── tsconfig.settings.json └── yarn.lock /.commitlintrc.js: -------------------------------------------------------------------------------- 1 | const { commitlint } = require('@ice/spec'); 2 | 3 | module.exports = commitlint; 4 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = space 6 | indent_size = 2 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false 13 | 14 | [makefile] 15 | indent_style = tab 16 | indent_size = 4 17 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | # 忽略目录 2 | build/ 3 | test/ 4 | tests/ 5 | node_modules/ 6 | dist/ 7 | out/ 8 | 9 | # node 覆盖率文件 10 | coverage/ 11 | 12 | # 忽略测试文件 13 | /packages/*/__tests__ 14 | /packages/*/lib/ 15 | 16 | # 忽略第三方包 17 | /vendor/loader.js 18 | 19 | # 忽略文件 20 | **/*-min.js 21 | **/*.min.js 22 | 23 | workspace/ 24 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | const { eslint, tslint, deepmerge } = require('@ice/spec'); 2 | 3 | const commonRules = { 4 | "react/jsx-filename-extension": 0, 5 | "no-underscore-dangle": 0, 6 | "class-methods-use-this": 0, 7 | "no-param-reassign": 0, 8 | "comma-dangle": 0, 9 | "prefer-object-spread": 0, 10 | // TODO: open rule indent, consider of MemberExpression 11 | "indent": 0, 12 | }; 13 | 14 | const jsRules = deepmerge(eslint, { 15 | rules: { 16 | ...commonRules, 17 | }, 18 | }); 19 | 20 | const tsRules = deepmerge(tslint, { 21 | rules: { 22 | ...commonRules, 23 | "@typescript-eslint/no-explicit-any": 0, 24 | "@typescript-eslint/interface-name-prefix": 0, 25 | "@typescript-eslint/explicit-function-return-type": 0, 26 | }, 27 | }); 28 | 29 | delete tsRules.root; 30 | 31 | module.exports = { 32 | ...jsRules, 33 | overrides: [ 34 | { 35 | ...tsRules, 36 | files: ['**/*.ts', '**/*.tsx'], 37 | }, 38 | ], 39 | }; 40 | -------------------------------------------------------------------------------- /.github/GIT_COMMIT_SPECIFIC.md: -------------------------------------------------------------------------------- 1 | # GIT COMMIT MESSAGE CHEAT SHEET 2 | 3 | **Proposed format of the commit message** 4 | 5 | ``` 6 | : 7 | 8 | 9 | ``` 10 | 11 | All lines are wrapped at 100 characters ! 12 | 13 | **Allowed ``** 14 | 15 | - feat (A new feature) 16 | - fix (A bug fix) 17 | - docs (Documentation only changes) 18 | - style (Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)) 19 | - perf (A code change that improves performance) 20 | - refactor (A code change that neither fixes a bug nor adds a feature) 21 | - test (Adding missing tests or correcting existing tests) 22 | - build (Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)) 23 | - ci (Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)) 24 | - chore (Other changes that don't modify src or test files) 25 | - revert (Reverts a previous commit) 26 | - release (Relase version) 27 | 28 | 29 | **Breaking changes** 30 | 31 | All breaking changes have to be mentioned in message body, on separated line: 32 | 33 | ​ _Breaks removed $browser.setUrl() method (use $browser.url(newUrl))_ 34 | ​ _Breaks ng: repeat option is no longer supported on selects (use ng:options)_ 35 | 36 | **Message body** 37 | 38 | - uses the imperative, present tense: “change” not “changed” nor “changes” 39 | - includes motivation for the change and contrasts with previous behavior 40 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | **Do you want to request a *feature* or report a *bug*?** 2 | 3 | **What is the current behavior?** 4 | 5 | If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. 6 | 7 | * icejs version: 8 | * Node verson: 9 | * Platform: 10 | * `build.json`: 11 | * `src/app.(ts|js)`: 12 | 13 | **What is the expected behavior?** 14 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: [push] 4 | 5 | jobs: 6 | build: 7 | 8 | runs-on: ubuntu-latest 9 | 10 | strategy: 11 | matrix: 12 | node-version: [10.x] 13 | 14 | steps: 15 | - uses: actions/checkout@v2 16 | - name: Use Node.js ${{ matrix.node-version }} 17 | uses: actions/setup-node@v1 18 | with: 19 | node-version: ${{ matrix.node-version }} 20 | - run: npm run setup 21 | - run: npm run lint 22 | - run: npm run dependency:check 23 | env: 24 | CI: true 25 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Dependencies 2 | node_modules 3 | jspm_packages 4 | 5 | # Only keep yarn.lock in the root 6 | package-lock.json 7 | */**/yarn.lock 8 | 9 | # Logs 10 | *.log 11 | 12 | # Packages 13 | packages/*/lib/ 14 | 15 | # temp folder .ice 16 | examples/*/.ice 17 | 18 | .eslintcache 19 | docs/.vuepress/dist/ 20 | 21 | build 22 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # CHANGELOG for icejs 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT LICENSE 2 | 3 | Copyright (c) 2018-present Alibaba Inc. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # icejs has been [moved into the alibaba/ice](https://github.com/alibaba/ice). 2 | 3 | The move makes it much easier to release and develop in sync with the rest of ice! 4 | 5 | This repo will be made read-only, as all of the issues/labels have been moved over as well. Please report any bugs and open pull requests over on the [alibaba/ice](https://github.com/alibaba/ice/issues). 6 | -------------------------------------------------------------------------------- /examples/basic-mpa/build.json: -------------------------------------------------------------------------------- 1 | { 2 | "mpa": true, 3 | "plugins": [] 4 | } 5 | -------------------------------------------------------------------------------- /examples/basic-mpa/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "exmaple-basic-mpa", 3 | "description": "", 4 | "dependencies": { 5 | "ice.js": "^1.0.11", 6 | "react": "^16.4.1", 7 | "react-dom": "^16.4.1" 8 | }, 9 | "devDependencies": { 10 | "@types/react": "^16.9.13", 11 | "@types/react-dom": "^16.9.4" 12 | }, 13 | "scripts": { 14 | "start": "icejs start", 15 | "build": "icejs build" 16 | }, 17 | "engines": { 18 | "node": ">=8.0.0" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /examples/basic-mpa/public/dashboard.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | icejs · mpa example 8 | 9 | 10 | 11 |
dashboard content of html template
12 |
13 | 14 | 15 | -------------------------------------------------------------------------------- /examples/basic-mpa/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | icejs · mpa example 8 | 9 | 10 | 11 |
12 | 13 | 14 | -------------------------------------------------------------------------------- /examples/basic-mpa/sandbox.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "template": "node", 3 | "container": { 4 | "port": 3333 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /examples/basic-mpa/src/pages/Dashboard/app.ts: -------------------------------------------------------------------------------- 1 | import { createApp, IAppConfig } from 'ice'; 2 | import routes from './routes'; 3 | 4 | const appConfig: IAppConfig = { 5 | router: { 6 | routes 7 | }, 8 | }; 9 | 10 | createApp(appConfig); 11 | -------------------------------------------------------------------------------- /examples/basic-mpa/src/pages/Dashboard/index.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import { store } from 'ice/Dashboard'; 3 | 4 | const Dashboard = () => { 5 | const [pageState, pageActions] = store.useModel('counter'); 6 | return ( 7 | <> 8 |

Dashboard Page...

9 |
10 | 11 | {pageState.count} 12 | 13 |
14 | 15 | ); 16 | }; 17 | 18 | export default Dashboard; 19 | -------------------------------------------------------------------------------- /examples/basic-mpa/src/pages/Dashboard/models/counter.ts: -------------------------------------------------------------------------------- 1 | export const delay = (time) => new Promise((resolve) => setTimeout(() => resolve(), time)); 2 | 3 | export default { 4 | state: { 5 | count: 0 6 | }, 7 | 8 | reducers: { 9 | increment (prevState) { 10 | return { count: prevState.count + 1 }; 11 | }, 12 | decrement (prevState) { 13 | return { count: prevState.count - 1 }; 14 | } 15 | }, 16 | 17 | effects: (dispatch) => ({ 18 | async decrementAsync () { 19 | await delay(10); 20 | dispatch.counter.decrement(); 21 | }, 22 | }), 23 | }; 24 | -------------------------------------------------------------------------------- /examples/basic-mpa/src/pages/Dashboard/routes.ts: -------------------------------------------------------------------------------- 1 | import Index from './index'; 2 | 3 | export default [{ path: '/', component: Index }]; 4 | -------------------------------------------------------------------------------- /examples/basic-mpa/src/pages/Home/app.ts: -------------------------------------------------------------------------------- 1 | import { createApp, IAppConfig } from 'ice'; 2 | import Home from './index'; 3 | 4 | const appConfig: IAppConfig = { 5 | router: { 6 | routes: [{ path: '/', component: Home }], 7 | }, 8 | }; 9 | 10 | createApp(appConfig); 11 | -------------------------------------------------------------------------------- /examples/basic-mpa/src/pages/Home/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | const Home = () => { 4 | return ( 5 | <> 6 |

Home Page

7 | 8 | ); 9 | }; 10 | 11 | Home.pageConfig = { 12 | title: 'Home Page', 13 | }; 14 | 15 | export default Home; 16 | -------------------------------------------------------------------------------- /examples/basic-mpa/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "buildOnSave": false, 4 | "compilerOptions": { 5 | "baseUrl": ".", 6 | "outDir": "build", 7 | "module": "esnext", 8 | "target": "es6", 9 | "jsx": "react", 10 | "moduleResolution": "node", 11 | "allowSyntheticDefaultImports": true, 12 | "lib": [ 13 | "es6", 14 | "dom" 15 | ], 16 | "sourceMap": true, 17 | "allowJs": true, 18 | "rootDir": "./", 19 | "forceConsistentCasingInFileNames": true, 20 | "noImplicitReturns": true, 21 | "noImplicitThis": true, 22 | "noImplicitAny": false, 23 | "importHelpers": true, 24 | "strictNullChecks": true, 25 | "suppressImplicitAnyIndexErrors": true, 26 | "noUnusedLocals": true, 27 | "skipLibCheck": true, 28 | "paths": { 29 | "@/*": [ 30 | "./src/*" 31 | ], 32 | "ice": [ 33 | ".ice/index.ts" 34 | ], 35 | "ice/*": [ 36 | ".ice/pages/*" 37 | ] 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /examples/basic-request/README.md: -------------------------------------------------------------------------------- 1 | # data fetching with icejs 2 | 3 | https://github.com/ice-lab/icejs/tree/master/examples 4 | -------------------------------------------------------------------------------- /examples/basic-request/mock/index.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | 'GET /api/repo': { 3 | name: 'icejs', 4 | url: 'http://github.com/ice-lab/ice.js' 5 | }, 6 | 7 | 'GET /api/user': { 8 | name: 'taoxiaobao', 9 | age: '21' 10 | }, 11 | 12 | 'DELETE /api/user/123': { 13 | user: 123 14 | }, 15 | 16 | 'POST /api/users/:id': (req, res) => { 17 | const { id } = req.params; 18 | res.send({ id }); 19 | }, 20 | }; 21 | -------------------------------------------------------------------------------- /examples/basic-request/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "example-basic-request", 3 | "description": "data fetching with icejs", 4 | "dependencies": { 5 | "ice.js": "^1.0.0", 6 | "react": "^16.4.1", 7 | "react-dom": "^16.4.1" 8 | }, 9 | "devDependencies": { 10 | "@types/react": "^16.9.20", 11 | "@types/react-dom": "^16.9.5" 12 | }, 13 | "scripts": { 14 | "start": "icejs start", 15 | "build": "icejs build" 16 | }, 17 | "engines": { 18 | "node": ">=8.0.0" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /examples/basic-request/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | icejs · request example 8 | 9 | 10 | 11 |
12 | 13 | 14 | -------------------------------------------------------------------------------- /examples/basic-request/sandbox.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "template": "node", 3 | "container": { 4 | "port": 3333 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /examples/basic-request/src/app.ts: -------------------------------------------------------------------------------- 1 | import { createApp, IAppConfig, history } from 'ice'; 2 | 3 | const appConfig: IAppConfig = { 4 | app: { 5 | rootId: 'ice-container', 6 | }, 7 | request: { 8 | baseURL: '/api', 9 | interceptors: { 10 | response: { 11 | // 可选的 12 | onConfig: (config) => { 13 | console.log({history}); 14 | return config; 15 | }, 16 | // 可选的 17 | onError: (error) => { 18 | return Promise.reject(error); 19 | } 20 | }, 21 | } 22 | } 23 | }; 24 | 25 | createApp(appConfig); 26 | -------------------------------------------------------------------------------- /examples/basic-request/src/global.scss: -------------------------------------------------------------------------------- 1 | body { 2 | -webkit-font-smoothing: antialiased; 3 | } 4 | 5 | -------------------------------------------------------------------------------- /examples/basic-request/src/pages/Home/index.tsx: -------------------------------------------------------------------------------- 1 | import React, { useEffect } from 'react'; 2 | import { useRequest, request } from 'ice'; 3 | 4 | // 1. request in outside 5 | request('/user').then(res => console.log('request in outside:', res)); 6 | 7 | const Home = () => { 8 | // 2. useRequest hook 9 | const { data, loading, request: fetchRepo } = useRequest({ url: '/repo' }); 10 | 11 | useEffect(() => { 12 | fetchRepo(); 13 | 14 | // 3. requse.get alias 15 | request.get('/user').then(res => console.log('get:', res)); 16 | 17 | // 4. requse.post alias 18 | request.post('/users/123').then(res => console.log('post:', res)); 19 | 20 | // 5. requse.delete alias 21 | request.delete('/user/123').then(res => console.log('delete:', res)); 22 | 23 | // 6. request method 24 | request({ url: '/user'}).then((res) => {console.log('request:', res);}); 25 | 26 | }, [fetchRepo]); 27 | 28 | return ( 29 |
30 |

data fetching with icejs

31 | 32 | { 33 | loading ? 34 |
loading...
: 35 | <> 36 |
repo name:{data && data.name}
37 |
repo url:{data && data.url}
38 | 39 | } 40 |
41 | ); 42 | }; 43 | 44 | export default Home; 45 | -------------------------------------------------------------------------------- /examples/basic-request/src/routes.ts: -------------------------------------------------------------------------------- 1 | import Home from '@/pages/Home'; 2 | 3 | const routerConfig = [ 4 | { 5 | path: '/', 6 | component: Home 7 | } 8 | ]; 9 | 10 | export default routerConfig; -------------------------------------------------------------------------------- /examples/basic-request/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "buildOnSave": false, 4 | "compilerOptions": { 5 | "baseUrl": ".", 6 | "outDir": "build", 7 | "module": "esnext", 8 | "target": "es6", 9 | "jsx": "react", 10 | "moduleResolution": "node", 11 | "allowSyntheticDefaultImports": true, 12 | "lib": ["es6", "dom"], 13 | "sourceMap": true, 14 | "allowJs": true, 15 | "rootDir": "./", 16 | "forceConsistentCasingInFileNames": true, 17 | "noImplicitReturns": true, 18 | "noImplicitThis": true, 19 | "noImplicitAny": false, 20 | "importHelpers": true, 21 | "strictNullChecks": true, 22 | "suppressImplicitAnyIndexErrors": true, 23 | "noUnusedLocals": true, 24 | "skipLibCheck": true, 25 | "paths": { 26 | "@/*": ["./src/*"], 27 | "ice": [".ice/index.ts"], 28 | "ice/*": [".ice/pages/*"] 29 | } 30 | }, 31 | "include": ["src/*", ".ice", "src/components/Guide"], 32 | "exclude": ["node_modules", "build", "public"] 33 | } -------------------------------------------------------------------------------- /examples/basic-rml/README.md: -------------------------------------------------------------------------------- 1 | # rml with icejs 2 | 3 | https://github.com/ice-lab/icejs/tree/master/examples 4 | -------------------------------------------------------------------------------- /examples/basic-rml/build.json: -------------------------------------------------------------------------------- 1 | { 2 | "plugins": [ 3 | "build-plugin-ice-rml" 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /examples/basic-rml/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "example-basic-rml", 3 | "description": "rml with icejs", 4 | "dependencies": { 5 | "ice.js": "^1.0.0", 6 | "react": "^16.4.1", 7 | "react-dom": "^16.4.1" 8 | }, 9 | "devDependencies": { 10 | "@types/react": "^16.9.20", 11 | "@types/react-dom": "^16.9.5", 12 | "build-plugin-rml": "^1.1.0" 13 | }, 14 | "scripts": { 15 | "start": "icejs start", 16 | "build": "icejs build" 17 | }, 18 | "engines": { 19 | "node": ">=8.0.0" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /examples/basic-rml/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | RML Example 8 | 9 | 10 | 11 |
12 | 13 | 14 | -------------------------------------------------------------------------------- /examples/basic-rml/sandbox.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "template": "node", 3 | "container": { 4 | "port": 3333 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /examples/basic-rml/src/app.ts: -------------------------------------------------------------------------------- 1 | import { createApp, IAppConfig } from 'ice'; 2 | 3 | const appConfig: IAppConfig = { 4 | }; 5 | 6 | createApp(appConfig); 7 | -------------------------------------------------------------------------------- /examples/basic-rml/src/global.scss: -------------------------------------------------------------------------------- 1 | body { 2 | -webkit-font-smoothing: antialiased; 3 | } 4 | 5 | -------------------------------------------------------------------------------- /examples/basic-rml/src/pages/Home/index.rml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /examples/basic-rml/src/routes.ts: -------------------------------------------------------------------------------- 1 | import Home from '@/pages/Home/index.rml'; 2 | 3 | export default [ 4 | { 5 | path: '/', 6 | exact: true, 7 | component: Home 8 | }, 9 | ]; 10 | -------------------------------------------------------------------------------- /examples/basic-rml/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "buildOnSave": false, 4 | "compilerOptions": { 5 | "baseUrl": ".", 6 | "outDir": "build", 7 | "module": "esnext", 8 | "target": "es6", 9 | "jsx": "react", 10 | "moduleResolution": "node", 11 | "allowSyntheticDefaultImports": true, 12 | "lib": ["es6", "dom"], 13 | "sourceMap": true, 14 | "allowJs": true, 15 | "rootDir": "./", 16 | "forceConsistentCasingInFileNames": true, 17 | "noImplicitReturns": true, 18 | "noImplicitThis": true, 19 | "noImplicitAny": false, 20 | "importHelpers": true, 21 | "strictNullChecks": true, 22 | "suppressImplicitAnyIndexErrors": true, 23 | "noUnusedLocals": true, 24 | "skipLibCheck": true, 25 | "paths": { 26 | "@/*": ["./src/*"], 27 | "ice": [".ice/index.ts"], 28 | "ice/*": [".ice/pages/*"] 29 | } 30 | }, 31 | "include": ["src/*", ".ice", "src/components/Guide"], 32 | "exclude": ["node_modules", "build", "public"] 33 | } -------------------------------------------------------------------------------- /examples/basic-service/README.md: -------------------------------------------------------------------------------- 1 | # service for icejs 2 | 3 | https://github.com/ice-lab/icejs/tree/master/examples 4 | -------------------------------------------------------------------------------- /examples/basic-service/build.json: -------------------------------------------------------------------------------- 1 | { 2 | "plugins": [ 3 | "build-plugin-ice-service" 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /examples/basic-service/mock/index.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | 'GET /todo_getAll': { 3 | 'errorCode': '0', 4 | 'errorMsg': '', 5 | 'data': [ 6 | { 7 | 'id': '1', 8 | 'title': '安卓', 9 | 'dnoe': true 10 | }, 11 | { 12 | 'id': '2', 13 | 'title': 'iOS', 14 | 'dnoe': true 15 | } 16 | ], 17 | 'success': true 18 | }, 19 | 'GET /todo_getOne': { 20 | 'errorCode': '0', 21 | 'errorMsg': '', 22 | 'data': { 23 | 'id': '2222222', 24 | 'title': '安卓', 25 | 'dnoe': true 26 | }, 27 | 'requestId': '@guid', 28 | 'success': true 29 | }, 30 | 'POST /todo_add': { 31 | 'errorCode': '0', 32 | 'errorMsg': '', 33 | 'data': { 34 | 'id': '2222222', 35 | 'title': '安卓', 36 | 'dnoe': true 37 | }, 38 | 'requestId': '@guid', 39 | 'success': true 40 | }, 41 | }; 42 | -------------------------------------------------------------------------------- /examples/basic-service/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "example-basic-service", 3 | "description": "service for icejs", 4 | "dependencies": { 5 | "ice.js": "^1.0.0", 6 | "react": "^16.4.1", 7 | "build-plugin-ice-service": "*", 8 | "react-dom": "^16.4.1" 9 | }, 10 | "devDependencies": { 11 | "@types/react": "^16.9.20", 12 | "@types/react-dom": "^16.9.5" 13 | }, 14 | "scripts": { 15 | "start": "icejs start", 16 | "build": "icejs build" 17 | }, 18 | "engines": { 19 | "node": ">=8.0.0" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /examples/basic-service/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | icejs · service example 8 | 9 | 10 | 11 |
12 | 13 | 14 | -------------------------------------------------------------------------------- /examples/basic-service/sandbox.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "template": "node", 3 | "container": { 4 | "port": 3333 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /examples/basic-service/src/app.ts: -------------------------------------------------------------------------------- 1 | import { createApp, IAppConfig } from 'ice'; 2 | 3 | const appConfig: IAppConfig = { 4 | app: { 5 | rootId: 'ice-container', 6 | } 7 | }; 8 | 9 | createApp(appConfig); 10 | -------------------------------------------------------------------------------- /examples/basic-service/src/components/Fetch/index.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import todoService from '@/services/todo'; 3 | 4 | const Fetch = () => { 5 | async function handleRequest() { 6 | const data = await todoService.getAll(); 7 | console.log('getAllResult', data); 8 | } 9 | 10 | return ( 11 |
12 | 15 |
16 | ); 17 | }; 18 | 19 | export default Fetch; 20 | -------------------------------------------------------------------------------- /examples/basic-service/src/global.scss: -------------------------------------------------------------------------------- 1 | body { 2 | -webkit-font-smoothing: antialiased; 3 | } 4 | 5 | -------------------------------------------------------------------------------- /examples/basic-service/src/pages/Home/components/User/index.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import localService from './service'; 3 | 4 | const User = () => { 5 | async function handleGetTodo() { 6 | const data = await localService.getTodo({ id: '1' }); 7 | console.log('getTodo-data', data); 8 | console.log({...localService.getTodo}); 9 | } 10 | 11 | async function handleGetUser() { 12 | const data = await localService.getUser({ id: '1' }); 13 | console.log('getUser-data', data); 14 | console.log({...localService.getUser}); 15 | } 16 | 17 | return ( 18 |
19 | 22 | 25 |
26 | ); 27 | }; 28 | 29 | export default User; 30 | -------------------------------------------------------------------------------- /examples/basic-service/src/pages/Home/components/User/service.ts: -------------------------------------------------------------------------------- 1 | import { createService } from 'ice'; 2 | 3 | export interface GetUserParams { 4 | id: string; 5 | } 6 | 7 | export interface GetTodoParams { 8 | id: string; 9 | } 10 | 11 | export interface Todo { 12 | id: string; 13 | title: string; 14 | done: boolean; 15 | } 16 | 17 | export interface User { 18 | id: string; 19 | name: string; 20 | age: number; 21 | } 22 | 23 | interface Types { 24 | getTodo(params: GetTodoParams): Todo; 25 | getUser(params: GetUserParams): User; 26 | } 27 | 28 | const getTodo = { 29 | options: { 30 | url: '/todo_getOne', 31 | }, 32 | }; 33 | 34 | const getUser = { 35 | isInit: true, 36 | options: { 37 | url: '/user_getOne', 38 | }, 39 | }; 40 | 41 | export default createService( 42 | { 43 | getTodo, 44 | getUser, 45 | }, 46 | { 47 | options: { 48 | timeout: 3000, 49 | }, 50 | dataHandler(response) { 51 | if (response.success) { 52 | return response.data; 53 | } else { 54 | console.error(response.errorMsg); 55 | } 56 | } 57 | }, 58 | function(dataMap) { 59 | return dataMap.user; 60 | } 61 | ); 62 | -------------------------------------------------------------------------------- /examples/basic-service/src/pages/Home/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import Fetch from '@/components/Fetch'; 3 | import User from './components/User'; 4 | 5 | const Home = () => { 6 | return ( 7 | <> 8 | 9 | 10 | 11 | ); 12 | }; 13 | 14 | export default Home; 15 | -------------------------------------------------------------------------------- /examples/basic-service/src/routes.ts: -------------------------------------------------------------------------------- 1 | import Home from '@/pages/Home'; 2 | 3 | const routerConfig = [ 4 | { 5 | path: '/', 6 | component: Home 7 | } 8 | ]; 9 | 10 | export default routerConfig; -------------------------------------------------------------------------------- /examples/basic-service/src/services/todo.ts: -------------------------------------------------------------------------------- 1 | import { createService } from 'ice'; 2 | 3 | export interface GetOneParams { 4 | id: string; 5 | } 6 | 7 | export interface AddParams { 8 | title: string; 9 | done?: boolean; 10 | } 11 | 12 | export interface OriginTodo { 13 | id: string; 14 | title: string; 15 | done: boolean; 16 | label?: string; 17 | } 18 | 19 | export interface Todo extends OriginTodo { 20 | label: string; 21 | } 22 | 23 | export type Todos = OriginTodo[]; 24 | 25 | function transformTodo(todo: OriginTodo): Todo { 26 | return { 27 | ...todo, 28 | label: todo.done ? '已完成' : '未完成', 29 | }; 30 | } 31 | 32 | interface Types { 33 | getOne(params: GetOneParams): Todo; 34 | getAll(): Todos; 35 | add(params: AddParams): Todo; 36 | } 37 | 38 | const getAll = { 39 | options: { 40 | url: '/todo_getAll', 41 | }, 42 | }; 43 | 44 | const getOne = { 45 | options: { 46 | url: '/todo_getOne', 47 | }, 48 | dataHandle: transformTodo, 49 | }; 50 | 51 | const add = { 52 | options: { 53 | url: '/todo_add', 54 | method: 'post', 55 | }, 56 | dataHandle: transformTodo, 57 | }; 58 | 59 | export default createService( 60 | { 61 | getOne, 62 | getAll, 63 | add, 64 | }, 65 | { 66 | dataHandler(response) { 67 | return response.data; 68 | } 69 | } 70 | ); 71 | -------------------------------------------------------------------------------- /examples/basic-service/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "buildOnSave": false, 4 | "compilerOptions": { 5 | "baseUrl": ".", 6 | "outDir": "build", 7 | "module": "esnext", 8 | "target": "es6", 9 | "jsx": "react", 10 | "moduleResolution": "node", 11 | "allowSyntheticDefaultImports": true, 12 | "lib": ["es6", "dom"], 13 | "sourceMap": true, 14 | "allowJs": true, 15 | "rootDir": "./", 16 | "forceConsistentCasingInFileNames": true, 17 | "noImplicitReturns": true, 18 | "noImplicitThis": true, 19 | "noImplicitAny": false, 20 | "importHelpers": true, 21 | "strictNullChecks": true, 22 | "suppressImplicitAnyIndexErrors": true, 23 | "noUnusedLocals": true, 24 | "skipLibCheck": true, 25 | "paths": { 26 | "@/*": ["./src/*"], 27 | "ice": [".ice/index.ts"], 28 | "ice/*": [".ice/pages/*"], 29 | "$ice/*": [".ice/*"] 30 | } 31 | }, 32 | "include": ["src/*", ".ice", "src/components/Guide"], 33 | "exclude": ["node_modules", "build", "public"] 34 | } 35 | -------------------------------------------------------------------------------- /examples/basic-spa/build.json: -------------------------------------------------------------------------------- 1 | { 2 | "ignoreHtmlTemplate": true, 3 | "plugins": [], 4 | "modeConfig": { 5 | "prod": { 6 | "ignoreHtmlTemplate": false 7 | } 8 | }, 9 | "eslint": { 10 | "disable": false, 11 | "quiet": true 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /examples/basic-spa/mock/index.js: -------------------------------------------------------------------------------- 1 | const projects = [ 2 | { 3 | id: 1, 4 | name: 'facebook/react', 5 | description: 'A declarative, efficient, and flexible JavaScript library for building user interfaces', 6 | logo: 'https://avatars3.githubusercontent.com/u/69631', 7 | }, 8 | { 9 | id: 2, 10 | name: 'vuejs/vue', 11 | description: 'Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web. ', 12 | logo: 'https://avatars1.githubusercontent.com/u/6128107', 13 | }, 14 | { 15 | id: 3, 16 | name: 'angular/angular', 17 | description: 'One framework. Mobile & desktop. ', 18 | logo: 'https://avatars3.githubusercontent.com/u/139426', 19 | }, 20 | { 21 | id: 4, 22 | name: 'nuxt/nuxt.js', 23 | description: 'The Vue.js Framework', 24 | logo: 'https://avatars2.githubusercontent.com/u/23360933', 25 | }, 26 | { 27 | id: 5, 28 | name: 'zeit/next.js', 29 | description: 'The React Framework', 30 | logo: 'https://avatars0.githubusercontent.com/u/14985020', 31 | }, 32 | { 33 | id: 6, 34 | name: 'ice-lab/nice.js', 35 | description: 'A universal framework based on React.js.', 36 | logo: 'https://avatars1.githubusercontent.com/u/1961952', 37 | }, 38 | ]; 39 | 40 | // mock/index.js 41 | module.exports = { 42 | 'GET /api/repo': { 43 | status: 'SUCCESS', 44 | data: { 45 | group: 'ice.js', 46 | url: 'http://github.com/ice-lab/ice.js' 47 | } 48 | }, 49 | 50 | 'GET /api/projects': { 51 | status: 'SUCCESS', 52 | data: projects 53 | } 54 | }; 55 | -------------------------------------------------------------------------------- /examples/basic-spa/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "exmaple-basic-spa", 3 | "description": "", 4 | "dependencies": { 5 | "ice.js": "^1.0.11", 6 | "react": "^16.4.1", 7 | "react-dom": "^16.4.1" 8 | }, 9 | "devDependencies": { 10 | "@types/react": "^16.9.13", 11 | "@types/react-dom": "^16.9.4" 12 | }, 13 | "scripts": { 14 | "start": "icejs start --mode dev", 15 | "build": "icejs build --mode prod", 16 | "test": "icejs test --jest-watchAll" 17 | }, 18 | "engines": { 19 | "node": ">=8.0.0" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /examples/basic-spa/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | icejs · spa example 8 | 9 | 10 | 11 |
12 | 13 | 14 | -------------------------------------------------------------------------------- /examples/basic-spa/sandbox.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "template": "node", 3 | "container": { 4 | "port": 3333 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /examples/basic-spa/src/app.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { createApp, APP_MODE, IAppConfig } from 'ice'; 3 | 4 | const appConfig: IAppConfig = { 5 | app: { 6 | rootId: 'ice-container', 7 | errorBoundary: true, 8 | parseSearchParams: true 9 | }, 10 | logger: { 11 | level: APP_MODE === 'build' ? 'error' : 'debug', 12 | }, 13 | router: { 14 | basename: '/ice', 15 | type: 'hash', 16 | fallback:
加载中...
17 | }, 18 | request: { 19 | timeout: 5000, 20 | baseURL: '/', 21 | interceptors: { 22 | request: { 23 | onConfig: (config) => { 24 | return config; 25 | } 26 | } 27 | } 28 | } 29 | }; 30 | 31 | createApp(appConfig); 32 | -------------------------------------------------------------------------------- /examples/basic-spa/src/config.ts: -------------------------------------------------------------------------------- 1 | // config runtime APP_MODE 2 | // eslint-disable-next-line @typescript-eslint/camelcase 3 | window.__app_mode__ = 'build'; 4 | 5 | const config = { 6 | dev: { 7 | appId: 'dev-id', 8 | API_URL: `http://localhost:${process.env.SERVER_PORT}`, 9 | }, 10 | build: { 11 | API_URL: 'http://github.com/api' 12 | }, 13 | default: { 14 | 'appId': 'default-id', 15 | 'sercet': 'hahjhjhj' 16 | } 17 | }; 18 | 19 | export default config; -------------------------------------------------------------------------------- /examples/basic-spa/src/layouts/index.module.scss: -------------------------------------------------------------------------------- 1 | .title { 2 | height: 70px; 3 | display: flex; 4 | align-items: center; 5 | justify-content: center; 6 | } 7 | 8 | .main { 9 | display: flex; 10 | justify-content: center; 11 | flex-direction: column; 12 | align-items: center; 13 | } -------------------------------------------------------------------------------- /examples/basic-spa/src/layouts/index.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import styles from './index.module.scss'; 3 | 4 | const Layout = ({ children }) => { 5 | return ( 6 |
7 |

SPA

8 |
9 | {children} 10 |
11 |
12 | ); 13 | }; 14 | 15 | export default Layout; 16 | -------------------------------------------------------------------------------- /examples/basic-spa/src/pages/About/components/Child.tsx: -------------------------------------------------------------------------------- 1 | import React, { useEffect } from 'react'; 2 | 3 | const Child = () => { 4 | function getData() { 5 | throw new Error('test Error'); 6 | } 7 | 8 | useEffect(() => { 9 | getData(); 10 | }, []); 11 | 12 | return ( 13 |
14 | Child 15 |
16 | ); 17 | }; 18 | 19 | export default Child; 20 | -------------------------------------------------------------------------------- /examples/basic-spa/src/pages/About/components/Todo.tsx: -------------------------------------------------------------------------------- 1 | /* eslint @typescript-eslint/explicit-member-accessibility:0 */ 2 | import React, { PureComponent } from 'react'; 3 | 4 | class Todo extends PureComponent { 5 | componentDidMount() { 6 | throw new Error('test error boundary'); 7 | } 8 | 9 | render() { 10 | return ( 11 |
12 | TODO Component 13 |
14 | ); 15 | } 16 | } 17 | 18 | export default Todo; 19 | -------------------------------------------------------------------------------- /examples/basic-spa/src/pages/About/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Link, lazy, ErrorBoundary } from 'ice'; 3 | 4 | const Todo = lazy(() => import('./components/Todo')); 5 | const Child = lazy(() => import('./components/Child')); 6 | 7 | const MyFallbackComponent = () => ( 8 |
9 |

Oops! An error occured!

10 |

Here’s what we know…

11 |
12 | ); 13 | 14 | const About = () => { 15 | const myErrorHandler = (error: Error, componentStack: string) => { 16 | // Do something with the error 17 | // E.g. log to an error logging client here 18 | console.log({error, componentStack}); 19 | }; 20 | 21 | return ( 22 | <> 23 |

About Page

24 | 25 | 26 | 27 | 28 | 29 | 30 | dashboard
31 | Home 32 | 33 | ); 34 | }; 35 | 36 | export default About; 37 | -------------------------------------------------------------------------------- /examples/basic-spa/src/pages/Dashboard/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Link, useSearchParams, withSearchParams } from 'ice'; 3 | 4 | @withSearchParams 5 | class Foo extends React.PureComponent { 6 | public render() { 7 | console.log('Foo:', this.props.searchParams); 8 | return ( 9 | <>Foo 10 | ); 11 | } 12 | } 13 | 14 | const Bar = () => { 15 | const searchParams = useSearchParams(); 16 | console.log('Bar:', searchParams); 17 | return ( 18 | <>Bar 19 | ); 20 | }; 21 | 22 | const Dashboard = (props) => { 23 | console.log('props:', props); 24 | return ( 25 | <> 26 |

Dashboard Page...

27 | 28 | 29 | About 30 | 31 | ); 32 | }; 33 | 34 | export default Dashboard; 35 | -------------------------------------------------------------------------------- /examples/basic-spa/src/pages/Home/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Link, helpers, logger, config } from 'ice'; 3 | 4 | logger.debug('helpers from ice', helpers.urlParse); 5 | logger.debug('logger from ice', logger.debug); 6 | 7 | logger.info('=== info ==='); 8 | logger.warn('=== warn ==='); 9 | logger.error('=== error ==='); 10 | logger.debug('=== debug ==='); 11 | logger.trace('=== trace ==='); 12 | 13 | export default function Home(props) { 14 | 15 | logger.info('Home props', props); 16 | logger.info('render home config.appId', config.appId); 17 | 18 | return ( 19 | <> 20 |

Home Page...{props.count}

21 | About
22 | Dashboard 23 | 24 | ); 25 | } 26 | 27 | Home.getInitialProps = async () => { 28 | return { count: 1 }; 29 | }; 30 | 31 | Home.pageConfig = { 32 | title: 'Home Page' 33 | }; 34 | -------------------------------------------------------------------------------- /examples/basic-spa/src/pages/NotFound/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Link } from 'ice'; 3 | 4 | const Home = (props) => { 5 | console.log('render 404', props); 6 | 7 | return ( 8 | <> 9 |

404 Page...

10 | home
11 | About
12 | Dashboard 13 | 14 | ); 15 | }; 16 | 17 | export default Home; 18 | -------------------------------------------------------------------------------- /examples/basic-spa/src/routes.ts: -------------------------------------------------------------------------------- 1 | import { lazy } from 'ice'; 2 | import Layout from '@/layouts'; 3 | 4 | const Dashboard = lazy(() => import('@/pages/Dashboard')); 5 | const Home = lazy(() => import('@/pages/Home')); 6 | const About = lazy(() => import('@/pages/About')); 7 | const Notfound = lazy(() => import('@/pages/NotFound')); 8 | 9 | export default [ 10 | { 11 | path: '/', 12 | component: Layout, 13 | children: [ 14 | { 15 | path: '/dashboard', 16 | exact: true, 17 | component: Dashboard 18 | }, 19 | { 20 | path: '/about', 21 | exact: true, 22 | component: About 23 | }, 24 | { 25 | path: '/', 26 | exact: true, 27 | component: Home 28 | }, 29 | { 30 | path: '*', 31 | component: Notfound 32 | }, 33 | ] 34 | } 35 | ]; 36 | -------------------------------------------------------------------------------- /examples/basic-spa/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "buildOnSave": false, 4 | "compilerOptions": { 5 | "baseUrl": ".", 6 | "outDir": "build", 7 | "module": "esnext", 8 | "target": "es6", 9 | "jsx": "react", 10 | "moduleResolution": "node", 11 | "allowSyntheticDefaultImports": true, 12 | "lib": [ 13 | "es6", 14 | "dom" 15 | ], 16 | "sourceMap": true, 17 | "allowJs": true, 18 | "rootDir": "./", 19 | "forceConsistentCasingInFileNames": true, 20 | "noImplicitReturns": true, 21 | "noImplicitThis": true, 22 | "noImplicitAny": false, 23 | "importHelpers": true, 24 | "strictNullChecks": true, 25 | "suppressImplicitAnyIndexErrors": true, 26 | "noUnusedLocals": true, 27 | "skipLibCheck": true, 28 | "paths": { 29 | "@/*": [ 30 | "./src/*" 31 | ], 32 | "ice": [ 33 | ".ice/index.ts" 34 | ], 35 | "ice/*": [ 36 | ".ice/pages/*" 37 | ] 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /examples/basic-ssr/build.json: -------------------------------------------------------------------------------- 1 | { 2 | "plugins": [], 3 | "ssr": true 4 | } 5 | -------------------------------------------------------------------------------- /examples/basic-ssr/mock/index.ts: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | 'GET /api/user': { 3 | status: 'SUCCESS', 4 | data: { 5 | user: { 6 | name: 'Jack Ma', 7 | id: 10001, 8 | } 9 | }, 10 | }, 11 | 'GET /api/profile': { 12 | status: 'SUCCESS', 13 | data: { 14 | profile: { 15 | id: 10001, 16 | name: 'Jack Ma', 17 | edu: 'Hangzhou Normal University', 18 | address: 'Hangzhou' 19 | } 20 | }, 21 | }, 22 | }; 23 | -------------------------------------------------------------------------------- /examples/basic-ssr/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "exmaple-basic-ssr", 3 | "description": "", 4 | "dependencies": { 5 | "ice.js": "^1.0.11", 6 | "react": "^16.4.1", 7 | "react-dom": "^16.4.1" 8 | }, 9 | "devDependencies": { 10 | "@types/react": "^16.9.13", 11 | "@types/react-dom": "^16.9.4" 12 | }, 13 | "scripts": { 14 | "start": "icejs start --mode dev", 15 | "build": "icejs build --mode prod" 16 | }, 17 | "engines": { 18 | "node": ">=8.0.0" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /examples/basic-ssr/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | icejs · ssr example 8 | 9 | 10 | 11 |
12 | 13 | 14 | -------------------------------------------------------------------------------- /examples/basic-ssr/sandbox.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "template": "node", 3 | "container": { 4 | "port": 3333 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /examples/basic-ssr/src/app.ts: -------------------------------------------------------------------------------- 1 | import { createApp, IAppConfig, config, request } from 'ice'; 2 | 3 | const appConfig: IAppConfig = { 4 | app: { 5 | getInitialData: async () => { 6 | const res = await request('/user'); 7 | return res; 8 | } 9 | }, 10 | router: { 11 | type: 'browser' 12 | }, 13 | request: { 14 | baseURL: config.baseURL 15 | }, 16 | store: { 17 | getInitialStates: (initialData) => { 18 | return initialData.data; 19 | } 20 | } 21 | }; 22 | 23 | createApp(appConfig); 24 | -------------------------------------------------------------------------------- /examples/basic-ssr/src/config.ts: -------------------------------------------------------------------------------- 1 | const config = { 2 | dev: { 3 | baseURL: 'http://localhost:3333/api' 4 | }, 5 | prod: { 6 | baseURL: 'http://example.com/api' 7 | } 8 | }; 9 | 10 | export default config; 11 | -------------------------------------------------------------------------------- /examples/basic-ssr/src/layouts/index.module.scss: -------------------------------------------------------------------------------- 1 | .title { 2 | height: 70px; 3 | display: flex; 4 | align-items: center; 5 | justify-content: center; 6 | } 7 | 8 | .main { 9 | display: flex; 10 | justify-content: center; 11 | flex-direction: column; 12 | align-items: center; 13 | } -------------------------------------------------------------------------------- /examples/basic-ssr/src/layouts/index.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import styles from './index.module.scss'; 3 | 4 | const Layout = ({ children }) => { 5 | return ( 6 |
7 |

SSR

8 |
9 | {children} 10 |
11 |
12 | ); 13 | }; 14 | 15 | export default Layout; -------------------------------------------------------------------------------- /examples/basic-ssr/src/models/user.ts: -------------------------------------------------------------------------------- 1 | export const delay = (time) => new Promise((resolve) => setTimeout(() => resolve(), time)); 2 | 3 | export default { 4 | state: { 5 | name: '', 6 | id: '' 7 | }, 8 | 9 | reducers: { 10 | update (prevState, payload) { 11 | return { 12 | ...prevState, 13 | ...payload, 14 | }; 15 | }, 16 | }, 17 | 18 | effects: (dispatch) => ({ 19 | async getUserInfo () { 20 | await delay(1000); 21 | dispatch.user.update({ 22 | name: 'taobao', 23 | id: '123', 24 | }); 25 | }, 26 | }), 27 | }; 28 | -------------------------------------------------------------------------------- /examples/basic-ssr/src/pages/About/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Link, logger } from 'ice'; 3 | 4 | const About = (props) => { 5 | logger.info('About props', props); 6 | return ( 7 | <> 8 |

{props.title}

9 | dashboard
10 | home 11 | 12 | ); 13 | }; 14 | 15 | About.getInitialProps = async () => { 16 | return { title: 'About Page...' }; 17 | }; 18 | 19 | export default About; 20 | -------------------------------------------------------------------------------- /examples/basic-ssr/src/pages/Dashboard/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Link, logger } from 'ice'; 3 | 4 | const Dashboard = (props) => { 5 | logger.info('Dashboard props', props); 6 | return ( 7 | <> 8 |

{props.title}

9 | about 10 | 11 | ); 12 | }; 13 | 14 | Dashboard.getInitialProps = async () => { 15 | return new Promise((resolve) => { 16 | setTimeout(() => { 17 | resolve({ title: 'Dashboard Page xxxx...' }); 18 | }, 1 * 1000); 19 | }); 20 | // return { title: 'Dashboard Page...' } 21 | }; 22 | 23 | export default Dashboard; 24 | -------------------------------------------------------------------------------- /examples/basic-ssr/src/pages/Home/index.module.scss: -------------------------------------------------------------------------------- 1 | .title { 2 | color: red; 3 | } 4 | -------------------------------------------------------------------------------- /examples/basic-ssr/src/pages/Home/index.tsx: -------------------------------------------------------------------------------- 1 | import React, { useState, useEffect } from 'react'; 2 | import { request, Link, logger, store as appStore } from 'ice'; 3 | import styles from './index.module.scss'; 4 | 5 | export default function Home(props) { 6 | logger.info('Home props', props); 7 | 8 | const [dataSource, setData] = useState([]); 9 | useEffect(() => { 10 | setTimeout(() => { 11 | setData([4, 5, 6, 7]); 12 | }, 1 * 1000); 13 | }, []); 14 | 15 | const [userState] = appStore.useModel('user'); 16 | 17 | return ( 18 | <> 19 |

{props.title}

20 |
21 |
name:{userState.name}
22 |
id:{userState.id}
23 |
address:{props.profile && props.profile.address}
24 |
data:{dataSource.join(' ')}
25 |
26 |
27 | about 28 | dashboard 29 | 30 | ); 31 | } 32 | 33 | Home.getInitialProps = async () => { 34 | const res = await request('/profile'); 35 | return { ...res.data, title: 'Home Page...' }; 36 | }; 37 | -------------------------------------------------------------------------------- /examples/basic-ssr/src/pages/NotFound/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Link, logger } from 'ice'; 3 | 4 | const Home = (props) => { 5 | logger.info('render 404', props); 6 | 7 | return ( 8 | <> 9 |

404 Page...

10 | home
11 | about
12 | dashboard 13 | 14 | ); 15 | }; 16 | 17 | export default Home; 18 | -------------------------------------------------------------------------------- /examples/basic-ssr/src/routes.ts: -------------------------------------------------------------------------------- 1 | import Layout from '@/layouts'; 2 | import Dashboard from '@/pages/Dashboard'; 3 | import Home from '@/pages/Home'; 4 | import About from '@/pages/About'; 5 | import Notfound from '@/pages/NotFound'; 6 | 7 | export default [ 8 | { 9 | path: '/', 10 | component: Layout, 11 | children: [ 12 | { 13 | path: '/dashboard', 14 | exact: true, 15 | component: Dashboard 16 | }, 17 | { 18 | path: '/', 19 | exact: true, 20 | component: Home 21 | }, 22 | { 23 | path: '/about', 24 | exact: true, 25 | component: About 26 | }, 27 | { 28 | path: '*', 29 | component: Notfound 30 | } 31 | ] 32 | } 33 | ]; 34 | -------------------------------------------------------------------------------- /examples/basic-ssr/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "buildOnSave": false, 4 | "compilerOptions": { 5 | "baseUrl": ".", 6 | "outDir": "build", 7 | "module": "esnext", 8 | "target": "es6", 9 | "jsx": "react", 10 | "moduleResolution": "node", 11 | "allowSyntheticDefaultImports": true, 12 | "lib": [ 13 | "es6", 14 | "dom" 15 | ], 16 | "sourceMap": true, 17 | "allowJs": true, 18 | "rootDir": "./", 19 | "forceConsistentCasingInFileNames": true, 20 | "noImplicitReturns": true, 21 | "noImplicitThis": true, 22 | "noImplicitAny": false, 23 | "importHelpers": true, 24 | "strictNullChecks": true, 25 | "suppressImplicitAnyIndexErrors": true, 26 | "noUnusedLocals": true, 27 | "skipLibCheck": true, 28 | "paths": { 29 | "@/*": [ 30 | "./src/*" 31 | ], 32 | "ice": [ 33 | ".ice/index.ts" 34 | ], 35 | "ice/*": [ 36 | ".ice/pages/*" 37 | ] 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /examples/basic-store/README.md: -------------------------------------------------------------------------------- 1 | # store management with icejs 2 | 3 | https://github.com/ice-lab/icejs/tree/master/examples 4 | -------------------------------------------------------------------------------- /examples/basic-store/build.json: -------------------------------------------------------------------------------- 1 | { 2 | "plugins": [], 3 | "router": { 4 | "lazy": false 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /examples/basic-store/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "example-basic-store", 3 | "description": "store management with icejs", 4 | "dependencies": { 5 | "ice.js": "^1.0.0", 6 | "react": "^16.4.1", 7 | "react-dom": "^16.4.1" 8 | }, 9 | "devDependencies": { 10 | "@types/react": "^16.9.20", 11 | "@types/react-dom": "^16.9.5" 12 | }, 13 | "scripts": { 14 | "start": "icejs start", 15 | "build": "icejs build" 16 | }, 17 | "engines": { 18 | "node": ">=8.0.0" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /examples/basic-store/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | icejs · store example 8 | 9 | 10 | 11 |
12 | 13 | 14 | -------------------------------------------------------------------------------- /examples/basic-store/sandbox.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "template": "node", 3 | "container": { 4 | "port": 3333 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /examples/basic-store/src/app.ts: -------------------------------------------------------------------------------- 1 | import { createApp, IAppConfig } from 'ice'; 2 | 3 | const appConfig: IAppConfig = { 4 | app: { 5 | rootId: 'ice-container', 6 | }, 7 | }; 8 | 9 | createApp(appConfig); 10 | -------------------------------------------------------------------------------- /examples/basic-store/src/global.scss: -------------------------------------------------------------------------------- 1 | body { 2 | -webkit-font-smoothing: antialiased; 3 | } 4 | 5 | -------------------------------------------------------------------------------- /examples/basic-store/src/layouts/index.module.scss: -------------------------------------------------------------------------------- 1 | .title { 2 | height: 70px; 3 | display: flex; 4 | align-items: center; 5 | justify-content: center; 6 | } 7 | 8 | .main { 9 | display: flex; 10 | justify-content: center; 11 | flex-direction: column; 12 | align-items: center; 13 | } -------------------------------------------------------------------------------- /examples/basic-store/src/layouts/index.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import styles from './index.module.scss'; 3 | 4 | const Layout = ({ children }) => { 5 | return ( 6 |
7 |

Header

8 |
9 | {children} 10 |
11 |
12 | ); 13 | }; 14 | 15 | export default Layout; 16 | -------------------------------------------------------------------------------- /examples/basic-store/src/models/counter.ts: -------------------------------------------------------------------------------- 1 | import { IRootDispatch } from 'ice'; 2 | 3 | export const delay = (time) => new Promise((resolve) => setTimeout(() => resolve(), time)); 4 | 5 | export default { 6 | state: { 7 | count: 0 8 | }, 9 | 10 | reducers: { 11 | increment (prevState) { 12 | return { count: prevState.count + 1 }; 13 | }, 14 | decrement (prevState) { 15 | return { count: prevState.count - 1 }; 16 | } 17 | }, 18 | 19 | effects: (dispatch: IRootDispatch) => ({ 20 | async decrementAsync () { 21 | await delay(10); 22 | dispatch.counter.decrement(); 23 | }, 24 | }), 25 | }; 26 | -------------------------------------------------------------------------------- /examples/basic-store/src/models/user.ts: -------------------------------------------------------------------------------- 1 | import { IRootDispatch } from 'ice'; 2 | 3 | export const delay = (time) => new Promise((resolve) => setTimeout(() => resolve(), time)); 4 | 5 | export default { 6 | state: { 7 | name: '', 8 | id: '' 9 | }, 10 | 11 | reducers: { 12 | update (prevState, payload) { 13 | return { 14 | ...prevState, 15 | ...payload, 16 | }; 17 | }, 18 | }, 19 | 20 | effects: (dispatch: IRootDispatch) => ({ 21 | async getUserInfo () { 22 | await delay(1000); 23 | dispatch.user.update({ 24 | name: 'taobao', 25 | id: '123', 26 | }); 27 | }, 28 | }), 29 | }; 30 | -------------------------------------------------------------------------------- /examples/basic-store/src/pages/About/index.tsx: -------------------------------------------------------------------------------- 1 | import React, { useEffect } from 'react'; 2 | import { Link, store as appStore } from 'ice'; 3 | import { store as pageStore } from 'ice/About'; 4 | 5 | const About = (props) => { 6 | console.log(props); 7 | const [userState, userActions] = appStore.useModel('user'); 8 | const [pageState, pageActions] = pageStore.useModel('default'); 9 | const actionsState = appStore.useModelEffectsState('user'); 10 | 11 | useEffect(() => { 12 | const fetchData = async () => { 13 | await pageActions.getPageTitle(); 14 | await userActions.getUserInfo(); 15 | }; 16 | 17 | fetchData(); 18 | }, [pageActions, userActions]); 19 | 20 | return ( 21 | <> 22 |

{pageState.title}

23 | 24 | { 25 | actionsState.getUserInfo.isLoading 26 | ?
loading...
27 | :
28 |
Name:{userState.name}
29 |
id:{userState.id}
30 |
31 | } 32 | 33 | home 34 | 35 | ); 36 | }; 37 | 38 | About.pageConfig = { 39 | title: 'About' 40 | }; 41 | 42 | export default About; 43 | -------------------------------------------------------------------------------- /examples/basic-store/src/pages/About/model.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | state: { 3 | title: '' 4 | }, 5 | 6 | reducers: { 7 | update (prevState, payload) { 8 | return { 9 | ...prevState, 10 | ...payload, 11 | }; 12 | }, 13 | }, 14 | 15 | effects: (dispatch) => ({ 16 | async getPageTitle () { 17 | dispatch.default.update({ 18 | title: 'About Page' 19 | }); 20 | }, 21 | }), 22 | }; 23 | -------------------------------------------------------------------------------- /examples/basic-store/src/pages/Home/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Link, store as appStore } from 'ice'; 3 | import { store as pageStore } from 'ice/Home'; 4 | 5 | export default () => { 6 | const [counterState, counterActions] = appStore.useModel('counter'); 7 | const [pageState] = pageStore.useModel('default'); 8 | 9 | return ( 10 | <> 11 |

{pageState.title}

12 | 13 |
14 | 15 | {counterState.count} 16 | 17 |
18 | 19 | about 20 | 21 | ); 22 | }; 23 | -------------------------------------------------------------------------------- /examples/basic-store/src/pages/Home/model.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | state: { 3 | title: 'Home Page' 4 | }, 5 | }; 6 | -------------------------------------------------------------------------------- /examples/basic-store/src/pages/NotFound/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Link } from 'ice'; 3 | 4 | const NotFound = () => { 5 | return ( 6 | <> 7 |

404 Page...

8 | home
9 | About
10 | 11 | ); 12 | }; 13 | 14 | export { NotFound }; 15 | -------------------------------------------------------------------------------- /examples/basic-store/src/routes.ts: -------------------------------------------------------------------------------- 1 | // import { lazy } from 'ice'; 2 | 3 | import Layout from '@/layouts/index'; 4 | import Home from '@/pages/Home'; 5 | import About from '@/pages/About'; 6 | import { NotFound } from '@/pages/NotFound'; 7 | 8 | // const Home = lazy(() => import('@/pages/Home')); 9 | // const About =lazy(() => import('@/pages/About')); 10 | // const NotFound = lazy(() => import('@/pages/NotFound')); 11 | 12 | export default [ 13 | { 14 | path: '/', 15 | component: Layout, 16 | children: [ 17 | { 18 | path: '/', 19 | exact: true, 20 | component: Home 21 | }, 22 | { 23 | path: '/about', 24 | component: About 25 | }, 26 | { 27 | path: '*', 28 | component: NotFound, 29 | } 30 | ] 31 | } 32 | ]; 33 | -------------------------------------------------------------------------------- /examples/basic-store/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "buildOnSave": false, 4 | "compilerOptions": { 5 | "baseUrl": ".", 6 | "outDir": "build", 7 | "module": "esnext", 8 | "target": "es6", 9 | "jsx": "react", 10 | "moduleResolution": "node", 11 | "allowSyntheticDefaultImports": true, 12 | "lib": ["es6", "dom"], 13 | "sourceMap": true, 14 | "allowJs": true, 15 | "rootDir": "./", 16 | "forceConsistentCasingInFileNames": true, 17 | "noImplicitReturns": true, 18 | "noImplicitThis": true, 19 | "noImplicitAny": false, 20 | "importHelpers": true, 21 | "strictNullChecks": true, 22 | "suppressImplicitAnyIndexErrors": true, 23 | "noUnusedLocals": true, 24 | "skipLibCheck": true, 25 | "paths": { 26 | "@/*": ["./src/*"], 27 | "ice": [".ice/index.ts"], 28 | "ice/*": [".ice/pages/*"] 29 | } 30 | }, 31 | "include": ["src/*", ".ice", "src/components/Guide"], 32 | "exclude": ["node_modules", "build", "public"] 33 | } -------------------------------------------------------------------------------- /examples/hello-world/README.md: -------------------------------------------------------------------------------- 1 | # Hello World with icejs 2 | 3 | https://github.com/ice-lab/icejs/tree/master/examples 4 | -------------------------------------------------------------------------------- /examples/hello-world/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "example-hello-world", 3 | "description": "hello world", 4 | "dependencies": { 5 | "ice.js": "^1.0.0", 6 | "react": "^16.4.1", 7 | "react-dom": "^16.4.1" 8 | }, 9 | "devDependencies": { 10 | "@types/react": "^16.9.20", 11 | "@types/react-dom": "^16.9.5" 12 | }, 13 | "scripts": { 14 | "start": "icejs start", 15 | "build": "icejs build" 16 | }, 17 | "engines": { 18 | "node": ">=8.0.0" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /examples/hello-world/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | icejs · hello world example 8 | 9 | 10 | 11 |
12 | 13 | 14 | -------------------------------------------------------------------------------- /examples/hello-world/sandbox.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "template": "node", 3 | "container": { 4 | "port": 3333 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /examples/hello-world/src/app.ts: -------------------------------------------------------------------------------- 1 | import { createApp, IAppConfig } from 'ice'; 2 | 3 | const appConfig: IAppConfig = { 4 | app: { 5 | rootId: 'ice-container', 6 | }, 7 | }; 8 | 9 | createApp(appConfig); 10 | -------------------------------------------------------------------------------- /examples/hello-world/src/components/Guide/index.module.scss: -------------------------------------------------------------------------------- 1 | .container { 2 | min-height: 600px; 3 | overflow: hidden; 4 | text-align: center; 5 | background-color: #fff; 6 | } 7 | 8 | .title { 9 | font-size: 40px; 10 | text-align: center; 11 | } 12 | 13 | .description { 14 | margin-top: 40px; 15 | } 16 | 17 | .action { 18 | margin-top: 40px; 19 | } -------------------------------------------------------------------------------- /examples/hello-world/src/components/Guide/index.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import styles from './index.module.scss'; 3 | 4 | const Guide = () => { 5 | return ( 6 |
7 |

Welcome to icejs!

8 | 9 |

This is a awesome project, enjoy it!

10 | 11 | 30 |
31 | ); 32 | }; 33 | 34 | export default Guide; 35 | -------------------------------------------------------------------------------- /examples/hello-world/src/global.scss: -------------------------------------------------------------------------------- 1 | body { 2 | -webkit-font-smoothing: antialiased; 3 | } 4 | 5 | -------------------------------------------------------------------------------- /examples/hello-world/src/pages/Home/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import Guide from '@/components/Guide'; 3 | 4 | const Home = () => { 5 | return ; 6 | }; 7 | 8 | export default Home; 9 | -------------------------------------------------------------------------------- /examples/hello-world/src/routes.ts: -------------------------------------------------------------------------------- 1 | import Home from '@/pages/Home'; 2 | 3 | const routerConfig = [ 4 | { 5 | path: '/', 6 | component: Home 7 | } 8 | ]; 9 | 10 | export default routerConfig; -------------------------------------------------------------------------------- /examples/hello-world/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "buildOnSave": false, 4 | "compilerOptions": { 5 | "baseUrl": ".", 6 | "outDir": "build", 7 | "module": "esnext", 8 | "target": "es6", 9 | "jsx": "react", 10 | "moduleResolution": "node", 11 | "allowSyntheticDefaultImports": true, 12 | "lib": ["es6", "dom"], 13 | "sourceMap": true, 14 | "allowJs": true, 15 | "rootDir": "./", 16 | "forceConsistentCasingInFileNames": true, 17 | "noImplicitReturns": true, 18 | "noImplicitThis": true, 19 | "noImplicitAny": false, 20 | "importHelpers": true, 21 | "strictNullChecks": true, 22 | "suppressImplicitAnyIndexErrors": true, 23 | "noUnusedLocals": true, 24 | "skipLibCheck": true, 25 | "paths": { 26 | "@/*": ["./src/*"], 27 | "ice": [".ice/index.ts"], 28 | "ice/*": [".ice/pages/*"] 29 | } 30 | }, 31 | "include": ["src/*", ".ice", "src/components/Guide"], 32 | "exclude": ["node_modules", "build", "public"] 33 | } -------------------------------------------------------------------------------- /examples/icestark-child/build.json: -------------------------------------------------------------------------------- 1 | { 2 | "sourcemap": true, 3 | "router": { 4 | "lazy": true 5 | }, 6 | "plugins": [ 7 | "build-plugin-icestark" 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /examples/icestark-child/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "example-icestark-child", 3 | "description": "icestark child", 4 | "dependencies": { 5 | "ice.js": "^1.0.11", 6 | "react": "^16.4.1", 7 | "react-dom": "^16.4.1" 8 | }, 9 | "devDependencies": { 10 | "@types/react": "^16.9.13", 11 | "@types/react-dom": "^16.9.4" 12 | }, 13 | "scripts": { 14 | "start": "icejs start", 15 | "build": "icejs build" 16 | }, 17 | "engines": { 18 | "node": ">=8.0.0" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /examples/icestark-child/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | icejs · icestark child example 8 | 9 | 10 | 11 |
12 | 13 | 14 | -------------------------------------------------------------------------------- /examples/icestark-child/sandbox.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "template": "node", 3 | "container": { 4 | "port": 3333 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /examples/icestark-child/src/app.ts: -------------------------------------------------------------------------------- 1 | import { createApp, IAppConfig } from 'ice'; 2 | 3 | const appConfig: IAppConfig = { 4 | app: { 5 | rootId: 'ice-container' 6 | }, 7 | logger: { 8 | level: 'warn' 9 | }, 10 | icestark: { 11 | type: 'child' 12 | }, 13 | }; 14 | 15 | createApp(appConfig); 16 | -------------------------------------------------------------------------------- /examples/icestark-child/src/global.css: -------------------------------------------------------------------------------- 1 | body { 2 | -webkit-font-smoothing: antialiased; 3 | } -------------------------------------------------------------------------------- /examples/icestark-child/src/pages/About/_layout.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | export default function BasicLayout({ 4 | children, 5 | }: { 6 | children: React.ReactNode; 7 | }) { 8 | return ( 9 |
10 |
11 | Header 12 | {children} 13 |
14 |
15 | ); 16 | } 17 | -------------------------------------------------------------------------------- /examples/icestark-child/src/pages/About/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Link } from 'ice'; 3 | 4 | const Child = () => { 5 | return ( 6 |
7 | Child 8 |
9 | ); 10 | }; 11 | 12 | const About = () => { 13 | return ( 14 | <> 15 |

About Page

16 | 17 | About
18 | Home 19 | 20 | ); 21 | }; 22 | 23 | export default About; 24 | -------------------------------------------------------------------------------- /examples/icestark-child/src/pages/Dashboard/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Link } from 'ice'; 3 | 4 | const Dashboard = () => { 5 | return ( 6 | <> 7 |

Dashboard Page...

8 | About 9 | 10 | ); 11 | }; 12 | 13 | export default Dashboard; 14 | -------------------------------------------------------------------------------- /examples/icestark-child/src/pages/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Link } from 'ice'; 3 | 4 | const Home = (props) => { 5 | return ( 6 | <> 7 |

Home Page...{props.a}

8 | About
9 | Dashboard 10 | 11 | ); 12 | }; 13 | 14 | Home.getInitialProps = async () => { 15 | return { a: 1 }; 16 | }; 17 | 18 | Home.pageConfig = { 19 | title: 'Home Page' 20 | }; 21 | 22 | export default Home; 23 | -------------------------------------------------------------------------------- /examples/icestark-child/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "buildOnSave": false, 4 | "compilerOptions": { 5 | "baseUrl": ".", 6 | "outDir": "build", 7 | "module": "esnext", 8 | "target": "es6", 9 | "jsx": "react", 10 | "moduleResolution": "node", 11 | "allowSyntheticDefaultImports": true, 12 | "lib": [ 13 | "es6", 14 | "dom" 15 | ], 16 | "sourceMap": true, 17 | "allowJs": true, 18 | "rootDir": "./", 19 | "forceConsistentCasingInFileNames": true, 20 | "noImplicitReturns": true, 21 | "noImplicitThis": true, 22 | "noImplicitAny": false, 23 | "importHelpers": true, 24 | "strictNullChecks": true, 25 | "suppressImplicitAnyIndexErrors": true, 26 | "noUnusedLocals": true, 27 | "skipLibCheck": true, 28 | "paths": { 29 | "@/*": [ 30 | "./src/*" 31 | ], 32 | "ice": [ 33 | ".ice/index.ts" 34 | ] 35 | } 36 | }, 37 | "include": [ 38 | ".ice", 39 | "src" 40 | ] 41 | } 42 | -------------------------------------------------------------------------------- /examples/icestark-layout/build.json: -------------------------------------------------------------------------------- 1 | { 2 | "plugins": [ 3 | "build-plugin-icestark", 4 | ["build-plugin-fusion", { 5 | "themePackage": "@icedesign/theme", 6 | "themeConfig": { 7 | "nextPrefix": "next-fd-" 8 | } 9 | }] 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /examples/icestark-layout/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "example-icestark-layout", 3 | "description": "icestark layout", 4 | "dependencies": { 5 | "@alifd/next": "^1.19.12", 6 | "@icedesign/theme": "^1.2.0", 7 | "ice.js": "^1.0.11", 8 | "react": "^16.4.1", 9 | "react-dom": "^16.4.1" 10 | }, 11 | "devDependencies": { 12 | "@types/react": "^16.9.13", 13 | "@types/react-dom": "^16.9.4", 14 | "build-plugin-fusion": "^0.1.0", 15 | "build-plugin-icestark": "^1.0.11" 16 | }, 17 | "scripts": { 18 | "start": "icejs start", 19 | "build": "icejs build" 20 | }, 21 | "engines": { 22 | "node": ">=8.0.0" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /examples/icestark-layout/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | icejs · icestark layout example 8 | 9 | 10 | 11 |
12 | 13 | 14 | -------------------------------------------------------------------------------- /examples/icestark-layout/sandbox.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "template": "node", 3 | "container": { 4 | "port": 3333 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /examples/icestark-layout/src/app.tsx: -------------------------------------------------------------------------------- 1 | import { createApp, IAppConfig } from 'ice'; 2 | import * as React from 'react'; 3 | import { ConfigProvider } from '@alifd/next'; 4 | 5 | const appConfig: IAppConfig = { 6 | app: { 7 | rootId: 'ice-container', 8 | addProvider: ({ children }) => ( 9 | {children} 10 | ), 11 | }, 12 | logger: { 13 | level: 'warn' 14 | }, 15 | router: { 16 | type: 'browser', 17 | }, 18 | icestark: { 19 | type: 'framework', 20 | getApps: async () => { 21 | const apps = await new Promise((resolve) => { 22 | setTimeout(() => { 23 | resolve([ 24 | { 25 | path: '/seller', 26 | title: '商家平台', 27 | url: [ 28 | '//ice.alicdn.com/icestark/child-seller-react/index.js', 29 | '//ice.alicdn.com/icestark/child-seller-react/index.css', 30 | // '//127.0.0.1:3444/js/index.js', 31 | // '//127.0.0.1:3444/css/index.css', 32 | ], 33 | }, 34 | { 35 | path: '/waiter', 36 | title: '小二平台', 37 | url: [ 38 | '//ice.alicdn.com/icestark/child-waiter-vue/app.js', 39 | '//ice.alicdn.com/icestark/child-waiter-vue/app.css', 40 | // '//localhost:8080/app.js', 41 | // '//localhost:8080/css/app.css', 42 | ], 43 | }, 44 | ]); 45 | }, 1000); 46 | }); 47 | return apps; 48 | }, 49 | removeRoutesLayout: true, 50 | }, 51 | }; 52 | 53 | createApp(appConfig); 54 | -------------------------------------------------------------------------------- /examples/icestark-layout/src/global.scss: -------------------------------------------------------------------------------- 1 | body { 2 | -webkit-font-smoothing: antialiased; 3 | } -------------------------------------------------------------------------------- /examples/icestark-layout/src/pages/404.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Link } from 'ice'; 3 | 4 | const Home = (props) => { 5 | console.log('render home', props); 6 | 7 | return ( 8 | <> 9 |

404040404 Page...

10 | home
11 | About
12 | Dashboard 13 | 14 | ); 15 | }; 16 | 17 | export default Home; 18 | -------------------------------------------------------------------------------- /examples/icestark-layout/src/pages/Dashboard/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | export default function Dashboard() { 4 | return ( 5 |
6 | Dashboard page 7 |
8 | ); 9 | } -------------------------------------------------------------------------------- /examples/icestark-layout/src/pages/Home/index.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | 3 | export default function Home() { 4 | return
home page
; 5 | } -------------------------------------------------------------------------------- /examples/icestark-layout/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "buildOnSave": false, 4 | "compilerOptions": { 5 | "baseUrl": ".", 6 | "outDir": "build", 7 | "module": "esnext", 8 | "target": "es6", 9 | "jsx": "react", 10 | "moduleResolution": "node", 11 | "allowSyntheticDefaultImports": true, 12 | "lib": [ 13 | "es6", 14 | "dom" 15 | ], 16 | "sourceMap": true, 17 | "allowJs": true, 18 | "rootDir": "./", 19 | "forceConsistentCasingInFileNames": true, 20 | "noImplicitReturns": true, 21 | "noImplicitThis": true, 22 | "noImplicitAny": false, 23 | "importHelpers": true, 24 | "strictNullChecks": true, 25 | "suppressImplicitAnyIndexErrors": true, 26 | "noUnusedLocals": true, 27 | "skipLibCheck": true, 28 | "paths": { 29 | "@/*": [ 30 | "./src/*" 31 | ], 32 | "ice": [ 33 | ".ice/index.ts" 34 | ] 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /examples/with-fusion-design/README.md: -------------------------------------------------------------------------------- 1 | # with fusion design 2 | 3 | https://github.com/ice-lab/icejs/tree/master/examples 4 | -------------------------------------------------------------------------------- /examples/with-fusion-design/build.json: -------------------------------------------------------------------------------- 1 | { 2 | "plugins": [ 3 | [ 4 | "build-plugin-fusion", 5 | { 6 | "themePackage": "@alifd/theme-design-pro" 7 | } 8 | ], 9 | [ 10 | "build-plugin-moment-locales", 11 | { 12 | "locales": [ 13 | "zh-cn" 14 | ] 15 | } 16 | ] 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /examples/with-fusion-design/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "example-with-fusion-design", 3 | "description": "with fusion design", 4 | "dependencies": { 5 | "@alifd/next": "^1.19.4", 6 | "moment": "^2.24.0", 7 | "ice.js": "^1.0.0", 8 | "react": "^16.4.1", 9 | "react-dom": "^16.4.1" 10 | }, 11 | "devDependencies": { 12 | "@alifd/theme-design-pro": "^0.x", 13 | "build-plugin-fusion": "^0.1.0", 14 | "build-plugin-moment-locales": "^0.1.0" 15 | }, 16 | "scripts": { 17 | "start": "icejs start", 18 | "build": "icejs build" 19 | }, 20 | "engines": { 21 | "node": ">=8.0.0" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /examples/with-fusion-design/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | icejs · with fusion design example 8 | 9 | 10 | 11 |
12 | 13 | 14 | -------------------------------------------------------------------------------- /examples/with-fusion-design/sandbox.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "template": "node", 3 | "container": { 4 | "port": 3333 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /examples/with-fusion-design/src/app.ts: -------------------------------------------------------------------------------- 1 | import { createApp, IAppConfig } from 'ice'; 2 | 3 | const appConfig: IAppConfig = { 4 | app: { 5 | rootId: 'ice-container' 6 | } 7 | }; 8 | 9 | createApp(appConfig); 10 | -------------------------------------------------------------------------------- /examples/with-fusion-design/src/global.scss: -------------------------------------------------------------------------------- 1 | // 引入默认全局样式 2 | @import '@alifd/next/reset.scss'; 3 | 4 | body { 5 | -webkit-font-smoothing: antialiased; 6 | } 7 | 8 | -------------------------------------------------------------------------------- /examples/with-fusion-design/src/pages/Home/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Button } from '@alifd/next'; 3 | 4 | const Dashboard = () => { 5 | return ( 6 | <> 7 |

icejs with fusion design

8 | 9 | 10 | 11 | 12 | ); 13 | }; 14 | 15 | export default Dashboard; 16 | -------------------------------------------------------------------------------- /examples/with-fusion-design/src/routes.ts: -------------------------------------------------------------------------------- 1 | import Home from '@/pages/Home'; 2 | 3 | export default [ 4 | { 5 | path: '/', 6 | exact: true, 7 | component: Home 8 | } 9 | ]; 10 | -------------------------------------------------------------------------------- /examples/with-fusion-design/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "buildOnSave": false, 4 | "compilerOptions": { 5 | "baseUrl": ".", 6 | "outDir": "build", 7 | "module": "esnext", 8 | "target": "es6", 9 | "jsx": "react", 10 | "moduleResolution": "node", 11 | "allowSyntheticDefaultImports": true, 12 | "lib": ["es6", "dom"], 13 | "sourceMap": true, 14 | "allowJs": true, 15 | "rootDir": "./", 16 | "forceConsistentCasingInFileNames": true, 17 | "noImplicitReturns": true, 18 | "noImplicitThis": true, 19 | "noImplicitAny": false, 20 | "importHelpers": true, 21 | "strictNullChecks": true, 22 | "suppressImplicitAnyIndexErrors": true, 23 | "noUnusedLocals": true, 24 | "skipLibCheck": true, 25 | "paths": { 26 | "@/*": ["./src/*"], 27 | "ice": [".ice/index.ts"], 28 | "ice/*": [".ice/pages/*"] 29 | } 30 | }, 31 | "include": ["src/*", ".ice"], 32 | "exclude": ["node_modules", "build", "public"] 33 | } -------------------------------------------------------------------------------- /examples/with-rematch/README.md: -------------------------------------------------------------------------------- 1 | # with rematch 2 | 3 | https://github.com/ice-lab/icejs/tree/master/examples 4 | -------------------------------------------------------------------------------- /examples/with-rematch/build.json: -------------------------------------------------------------------------------- 1 | { 2 | "plugins": [ 3 | "build-plugin-ice-rematch" 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /examples/with-rematch/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "example-with-rematch", 3 | "version": "1.0.0", 4 | "description": "with rematch", 5 | "dependencies": { 6 | "react": "^16.4.1", 7 | "react-dom": "^16.4.1" 8 | }, 9 | "devDependencies": { 10 | "@types/react": "^16.9.13", 11 | "@types/react-dom": "^16.9.4" 12 | }, 13 | "scripts": { 14 | "start": "icejs start", 15 | "build": "icejs build" 16 | }, 17 | "engines": { 18 | "node": ">=8.0.0" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /examples/with-rematch/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | icejs · with rematch example 8 | 9 | 10 | 11 |
12 | 13 | 14 | -------------------------------------------------------------------------------- /examples/with-rematch/sandbox.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "template": "node", 3 | "container": { 4 | "port": 3333 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /examples/with-rematch/src/app.ts: -------------------------------------------------------------------------------- 1 | import { createApp } from 'ice'; 2 | 3 | const appConfig = { 4 | app: { 5 | rootId: 'ice-container' 6 | } 7 | }; 8 | 9 | createApp(appConfig); 10 | -------------------------------------------------------------------------------- /examples/with-rematch/src/pages/404.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Link } from 'ice'; 3 | 4 | const Home = (props) => { 5 | console.log('render home', props); 6 | 7 | return ( 8 | <> 9 |

404040404 Page...

10 | home
11 | About
12 | Dashboard 13 | 14 | ); 15 | }; 16 | 17 | export default Home; 18 | -------------------------------------------------------------------------------- /examples/with-rematch/src/pages/Rematch/Child.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import { connect } from 'ice'; 3 | 4 | const Home = (props) => { 5 | const { userState, userAction } = props; 6 | return ( 7 | <> 8 |
9 |
stars: {userState.stars}
10 | { 11 | userAction.updateStars(1); 12 | }}>新增一个 star 13 |
14 | 15 | ); 16 | }; 17 | 18 | const mapState = models => ({ 19 | userState: models.user, 20 | }); 21 | 22 | const mapDispatch = actions => ({ 23 | userAction: actions.user, 24 | }); 25 | 26 | export default connect( 27 | mapState, 28 | mapDispatch, 29 | )(Home); 30 | -------------------------------------------------------------------------------- /examples/with-rematch/src/pages/Rematch/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { connect } from 'ice'; 3 | import Child from './Child'; 4 | // import Child2 from './Child2'; 5 | 6 | const Home = (props) => { 7 | const { userState } = props; 8 | return ( 9 | <> 10 |
page stars: {userState.stars}
11 | 12 | {/* */} 13 | 14 | ); 15 | }; 16 | 17 | const mapState = state => ({ 18 | userState: state.user, 19 | }); 20 | 21 | export default connect(mapState)(Home); 22 | -------------------------------------------------------------------------------- /examples/with-rematch/src/pages/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Link, helpers } from 'ice'; 3 | 4 | console.log('helpers from ice', helpers); 5 | 6 | const Home = (props) => { 7 | console.log('Home props', props); 8 | return ( 9 | <> 10 |

Home Page...{props.a}

11 | About
12 | Dashboard 13 | 14 | ); 15 | }; 16 | 17 | Home.getInitialProps = async () => { 18 | return {a: 1}; 19 | }; 20 | 21 | Home.pageConfig = { 22 | title: 'hahah', 23 | }; 24 | 25 | export default Home; 26 | -------------------------------------------------------------------------------- /examples/with-rematch/src/routes.ts: -------------------------------------------------------------------------------- 1 | import Page404 from '@/pages/404'; 2 | import PageRematch from '@/pages/Rematch/index'; 3 | import Page from '@/pages/index'; 4 | 5 | export default [ 6 | { 7 | path: '/rematch', 8 | exact: true, 9 | component: PageRematch 10 | }, 11 | { 12 | path: '/', 13 | exact: true, 14 | component: Page 15 | }, 16 | { 17 | component: Page404 18 | }, 19 | ]; 20 | -------------------------------------------------------------------------------- /examples/with-rematch/src/stores/user.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | state: { 3 | stars: 0 4 | }, 5 | reducers: { 6 | updateStars(state, count) { 7 | return {...state, stars: state.stars + count}; 8 | }, 9 | }, 10 | effects: (dispatch) => ({ 11 | async updateStarsAsync(count) { 12 | await new Promise(resolve => setTimeout(resolve, 1000)); 13 | dispatch.user.updateStars(count); 14 | }, 15 | }), 16 | }; 17 | -------------------------------------------------------------------------------- /examples/with-rematch/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "buildOnSave": false, 4 | "compilerOptions": { 5 | "baseUrl": ".", 6 | "outDir": "build", 7 | "module": "esnext", 8 | "target": "es6", 9 | "jsx": "react", 10 | "moduleResolution": "node", 11 | "allowSyntheticDefaultImports": true, 12 | "lib": [ 13 | "es6", 14 | "dom" 15 | ], 16 | "sourceMap": true, 17 | "allowJs": true, 18 | "rootDir": "./", 19 | "forceConsistentCasingInFileNames": true, 20 | "noImplicitReturns": true, 21 | "noImplicitThis": true, 22 | "noImplicitAny": false, 23 | "importHelpers": true, 24 | "strictNullChecks": true, 25 | "suppressImplicitAnyIndexErrors": true, 26 | "noUnusedLocals": true, 27 | "skipLibCheck": true, 28 | "paths": { 29 | "@/*": [ 30 | "./src/*" 31 | ], 32 | "ice": [ 33 | ".ice/index" 34 | ] 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /lerna.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.2.1", 3 | "npmClient": "yarn", 4 | "useWorkspaces": true, 5 | "packages": [ 6 | "packages/*" 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /packages/create-ice/README.md: -------------------------------------------------------------------------------- 1 | # create-ice 2 | 3 | create icejs project. 4 | 5 | ## Usage 6 | 7 | ```bash 8 | $ npm init ice 9 | # or with template 10 | $ npm init ice