-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5090 from alibaba/release/2.5.0
Release/2.5.0
- Loading branch information
Showing
185 changed files
with
3,241 additions
and
308 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"plugins": [ | ||
[ | ||
"build-plugin-ice-i18n", | ||
{ | ||
"locales": [ | ||
"zh-CN", | ||
"en-US" | ||
], | ||
"defaultLocale": "zh-CN", | ||
"redirect": true | ||
} | ||
] | ||
], | ||
"vite": false, | ||
"ssr": "static" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"dependencies": { | ||
"react": "^17.0.0", | ||
"react-dom": "^17.0.0", | ||
"react-intl": "^5.22.0" | ||
}, | ||
"devDependencies": { | ||
"@types/react": "^17.0.0", | ||
"@types/react-dom": "^17.0.0" | ||
}, | ||
"scripts": { | ||
"start": "RUNTIME_DEBUG=true ../../packages/icejs/bin/ice-cli.js start", | ||
"build": "../../packages/icejs/bin/ice-cli.js build" | ||
}, | ||
"engines": { | ||
"node": ">=8.0.0" | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
|
||
<head> | ||
<meta charset="utf-8" /> | ||
<meta http-equiv="x-ua-compatible" content="ie=edge,chrome=1" /> | ||
<meta name="viewport" content="width=device-width" /> | ||
<title>icejs · i18n example</title> | ||
</head> | ||
|
||
<body> | ||
<div id="ice-container"></div> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { runApp, IAppConfig, useLocale, getDefaultLocale } from 'ice'; | ||
import { IntlProvider as ReactIntlProvider } from 'react-intl'; | ||
import { messages } from './locales'; | ||
|
||
function IntlProvider({ children }) { | ||
const [locale] = useLocale(); | ||
const defaultLocale = getDefaultLocale(); | ||
|
||
return ( | ||
<ReactIntlProvider | ||
messages={messages[locale]} | ||
locale={locale} | ||
defaultLocale={defaultLocale} | ||
> | ||
{children} | ||
</ReactIntlProvider> | ||
); | ||
} | ||
|
||
const appConfig: IAppConfig = { | ||
router: { | ||
type: 'browser', | ||
basename: '/ice' | ||
}, | ||
app: { | ||
addProvider: ({ children }) => { | ||
return ( | ||
<IntlProvider>{children}</IntlProvider> | ||
); | ||
} | ||
} | ||
}; | ||
|
||
runApp(appConfig); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { FormattedMessage } from 'react-intl'; | ||
import { useLocale, getAllLocales, Link, useLocation } from 'ice'; | ||
|
||
export default function LocaleSwitcher() { | ||
const location = useLocation(); | ||
|
||
const [activeLocale, setLocale] = useLocale(); | ||
const allLocales = getAllLocales(); | ||
const otherLocales = allLocales.filter((locale) => activeLocale !== locale); | ||
return ( | ||
<div> | ||
<p><FormattedMessage id="localeSwitcher" />:</p> | ||
<ul> | ||
{ | ||
otherLocales.map((locale: string) => { | ||
return ( | ||
<li key={locale}> | ||
<Link to={location.pathname} onClick={() => setLocale(locale)}>{locale}</Link> | ||
</li> | ||
); | ||
}) | ||
} | ||
</ul> | ||
</div> | ||
); | ||
} |
5 changes: 5 additions & 0 deletions
5
examples/basic-i18n/src/layouts/BasicLayout/index.module.less
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.basicLayout { | ||
h1 { | ||
color: red; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { FormattedMessage } from 'react-intl'; | ||
import styles from './index.module.less'; | ||
|
||
function BasicLayout({ children }) { | ||
return ( | ||
<main className={styles.basicLayout}> | ||
<h1><FormattedMessage id="basicLayout" /></h1> | ||
{children} | ||
</main> | ||
); | ||
} | ||
|
||
export default BasicLayout; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './locales'; | ||
export * from './messages'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export const LOCALES = { | ||
ENGLISH: 'en-US', | ||
ZH_CN: 'zh-CN' | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { LOCALES } from './locales'; | ||
|
||
export const messages = { | ||
[LOCALES.ENGLISH]: { | ||
homeTitle: 'Home', | ||
aboutTitle: 'About', | ||
currentLocale: 'Current locale', | ||
defaultLocale: 'Default locale', | ||
configuredLocales: 'Configured locales', | ||
localeSwitcher: 'Locale Switcher', | ||
basicLayout: 'BasicLayout', | ||
}, | ||
[LOCALES.ZH_CN]: { | ||
homeTitle: '首页', | ||
aboutTitle: '关于', | ||
currentLocale: '当前语言', | ||
defaultLocale: '默认语言', | ||
configuredLocales: '配置的语言', | ||
localeSwitcher: '语言切换', | ||
basicLayout: '主布局' | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { useLocale, getAllLocales, getDefaultLocale, Link } from 'ice'; | ||
import { FormattedMessage } from 'react-intl'; | ||
import LocaleSwitcher from '@/components/LocaleSwitcher'; | ||
|
||
function About() { | ||
const [locale] = useLocale(); | ||
const allLocales = getAllLocales(); | ||
const defaultLocale = getDefaultLocale(); | ||
return ( | ||
<div> | ||
<h2><FormattedMessage id="aboutTitle" /></h2> | ||
<div><FormattedMessage id="configuredLocales" />: {JSON.stringify(allLocales)}</div> | ||
<div><FormattedMessage id="defaultLocale" />: {defaultLocale}</div> | ||
<div><FormattedMessage id="currentLocale" />: {locale}</div> | ||
<Link to="/">Home</Link> | ||
<LocaleSwitcher /> | ||
</div> | ||
); | ||
} | ||
|
||
export default About; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { useLocale, getAllLocales, getDefaultLocale, Link, getLocale } from 'ice'; | ||
import { FormattedMessage } from 'react-intl'; | ||
import LocaleSwitcher from '@/components/LocaleSwitcher'; | ||
|
||
function Home() { | ||
const [locale] = useLocale(); | ||
const allLocales = getAllLocales(); | ||
const defaultLocale = getDefaultLocale(); | ||
return ( | ||
<div> | ||
<h2><FormattedMessage id="homeTitle" /></h2> | ||
<div><FormattedMessage id="configuredLocales" />: {JSON.stringify(allLocales)}</div> | ||
<div><FormattedMessage id="defaultLocale" />: {defaultLocale}</div> | ||
<div><FormattedMessage id="currentLocale" />: {locale}</div> | ||
<Link to="/about">About</Link> | ||
<LocaleSwitcher /> | ||
</div> | ||
); | ||
} | ||
|
||
Home.getInitialProps = function () { | ||
console.log('getLocale in getInitialProps', getLocale()); | ||
}; | ||
|
||
export default Home; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { IRouterConfig } from 'ice'; | ||
import BasicLayout from '@/layouts/BasicLayout'; | ||
import Home from '@/pages/Home'; | ||
import About from '@/pages/About'; | ||
|
||
const routerConfig: IRouterConfig[] = [ | ||
{ | ||
path: '/', | ||
component: BasicLayout, | ||
children: [ | ||
{ | ||
path: '/about', | ||
exact: true, | ||
component: About | ||
}, | ||
{ | ||
path: '/', | ||
exact: true, | ||
component: Home, | ||
}, | ||
] | ||
}, | ||
]; | ||
|
||
export default routerConfig; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
declare module '*.module.less' { | ||
const classes: { [key: string]: string }; | ||
export default classes; | ||
} | ||
|
||
declare module '*.svg' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"compileOnSave": false, | ||
"buildOnSave": false, | ||
"compilerOptions": { | ||
"baseUrl": ".", | ||
"outDir": "build", | ||
"module": "esnext", | ||
"target": "es6", | ||
"jsx": "react-jsx", | ||
"moduleResolution": "node", | ||
"allowSyntheticDefaultImports": true, | ||
"lib": ["es6", "dom"], | ||
"sourceMap": true, | ||
"allowJs": true, | ||
"rootDir": "./", | ||
"forceConsistentCasingInFileNames": true, | ||
"noImplicitReturns": true, | ||
"noImplicitThis": true, | ||
"noImplicitAny": false, | ||
"importHelpers": true, | ||
"strictNullChecks": true, | ||
"suppressImplicitAnyIndexErrors": true, | ||
"noUnusedLocals": true, | ||
"skipLibCheck": true, | ||
"types": ["node"], | ||
"paths": { | ||
"@/*": ["./src/*"], | ||
"ice": [".ice/index.ts"], | ||
"ice/*": [".ice/pages/*"] | ||
} | ||
}, | ||
"include": ["src/*"], | ||
"exclude": ["node_modules", "build", "public"] | ||
} |
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
examples/basic-mpa/package.json → examples/basic-mpa-vite/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"mpa": { | ||
"openPage": "Dashboard", | ||
"template": { | ||
"web.html": [ | ||
"Dashboard", | ||
"Home" | ||
] | ||
}, | ||
"rewrites": { | ||
"dashboard": "site/dashboard" | ||
} | ||
}, | ||
"devServer": { | ||
"devMiddleware": { | ||
"writeToDisk": true | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "basic-mpa-webpack", | ||
"description": "", | ||
"dependencies": { | ||
"react": "^16.4.1", | ||
"react-dom": "^16.4.1" | ||
}, | ||
"devDependencies": { | ||
"@types/react": "^16.9.13", | ||
"@types/react-dom": "^16.9.4" | ||
}, | ||
"scripts": { | ||
"start": "../../packages/icejs/bin/ice-cli.js start", | ||
"build": "../../packages/icejs/bin/ice-cli.js build" | ||
}, | ||
"engines": { | ||
"node": ">=8.0.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta http-equiv="x-ua-compatible" content="ie=edge,chrome=1" /> | ||
<meta name="viewport" content="width=device-width" /> | ||
<title>icejs · mpa example</title> | ||
</head> | ||
<body> | ||
<div>current page: <%= pageName %></div> | ||
<div id="ice-container"></div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta http-equiv="x-ua-compatible" content="ie=edge,chrome=1" /> | ||
<meta name="viewport" content="width=device-width" /> | ||
<title>icejs · mpa example</title> | ||
</head> | ||
|
||
<body> | ||
<div>using web.html template</div> | ||
<div id="ice-container"></div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"template": "node", | ||
"container": { | ||
"port": 3333 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { runApp, IAppConfig } from 'ice'; | ||
import Index from './index'; | ||
|
||
const appConfig: IAppConfig = { | ||
router: { | ||
type: 'hash', | ||
routes: [{ path: '/', component: Index }], | ||
}, | ||
}; | ||
|
||
runApp(appConfig); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import React from 'react'; | ||
|
||
const About = () => { | ||
return ( | ||
<> | ||
<h2>About Page...</h2> | ||
</> | ||
); | ||
}; | ||
|
||
export default About; |
Oops, something went wrong.