This commit is contained in:
parent
68b8fe0f57
commit
ea5714d2ee
|
|
@ -1,5 +1,4 @@
|
|||
/// <reference types="node" />
|
||||
/// <reference types="node" />
|
||||
import { PathLike } from 'fs';
|
||||
import { checkFileExistsAndCreateType } from './enum';
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -62,9 +62,9 @@ function packageJsonContent({ name, version, description, cliversion, cliname, i
|
|||
"react-router-dom": "^6.3.0",
|
||||
"react-scripts": "5.0.1",
|
||||
"rmc-pull-to-refresh": "^1.0.13",
|
||||
"tdesign-icons-react": "^0.1.3",
|
||||
"tdesign-mobile-react": "^0.1.2",
|
||||
"tdesign-react": "^0.37.0",
|
||||
"tdesign-icons-react": "^0.1.4",
|
||||
"tdesign-mobile-react": "^0.2.0",
|
||||
"tdesign-react": "^0.37.1",
|
||||
"url": "^0.11.0",
|
||||
"uuid": "^8.3.2"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ function copyLocaleFiles() {
|
|||
//build locales
|
||||
consola.success(`${chalk.greenBright('读取locales,生成json数据')}`);
|
||||
// locales到mp/dist下
|
||||
const buildPath = Path.resolve(paths.appBuild, Locales);
|
||||
const buildPath = Path.resolve(paths.appSrc, Locales);
|
||||
const json = buildLocales({
|
||||
projectPath: paths.appRootSrc,
|
||||
businessProjectPath: paths.oakGeneralBusinessAppPath,
|
||||
|
|
|
|||
|
|
@ -68,9 +68,9 @@ export function packageJsonContent({
|
|||
"react-router-dom": "^6.3.0",
|
||||
"react-scripts": "5.0.1",
|
||||
"rmc-pull-to-refresh": "^1.0.13",
|
||||
"tdesign-icons-react": "^0.1.3",
|
||||
"tdesign-mobile-react": "^0.1.2",
|
||||
"tdesign-react": "^0.37.0",
|
||||
"tdesign-icons-react": "^0.1.4",
|
||||
"tdesign-mobile-react": "^0.2.0",
|
||||
"tdesign-react": "^0.37.1",
|
||||
"url": "^0.11.0",
|
||||
"uuid": "^8.3.2"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -22,7 +22,11 @@ import { AspectWrapper } from 'oak-domain/lib/types';
|
|||
import { BasicFeatures } from 'oak-frontend-base/lib/features';
|
||||
import { AppType } from 'oak-app-domain/Application/Schema';
|
||||
|
||||
export default function initialize(type: AppType, url?: string) {
|
||||
export default function initialize(
|
||||
type: AppType,
|
||||
url?: string,
|
||||
i18nOptions?: Record<string, any>
|
||||
) {
|
||||
let wholeFeatures = {};
|
||||
const createFeatures = (
|
||||
aspectWrapper: AspectWrapper<
|
||||
|
|
@ -72,7 +76,8 @@ export default function initialize(type: AppType, url?: string) {
|
|||
checkers,
|
||||
watchers,
|
||||
data as any,
|
||||
ActionDefDict
|
||||
ActionDefDict,
|
||||
i18nOptions
|
||||
);
|
||||
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,11 @@ import { AspectDict } from './aspects/AspectDict';
|
|||
import { BasicFeatures } from 'oak-frontend-base/lib/features';
|
||||
import { AppType } from 'oak-app-domain/Application/Schema';
|
||||
|
||||
export default function initialize(type: AppType, url: string) {
|
||||
export default function initialize(
|
||||
type: AppType,
|
||||
url: string,
|
||||
i18nOptions?: Record<string, any>
|
||||
) {
|
||||
let wholeFeatures = {};
|
||||
const createFeatures = (
|
||||
aspectWrapper: AspectWrapper<
|
||||
|
|
@ -87,7 +91,8 @@ export default function initialize(type: AppType, url: string) {
|
|||
routers,
|
||||
connector,
|
||||
checkers,
|
||||
ActionDefDict
|
||||
ActionDefDict,
|
||||
i18nOptions
|
||||
);
|
||||
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
@import 'tdesign-react/es/style/index.css'; // 少量公共样式
|
||||
|
||||
@import 'tdesign-mobile-react/es/style/index.css'; // 少量公共样式
|
||||
|
||||
:root {
|
||||
--td-screen-xs: 576px;
|
||||
}
|
||||
|
|
@ -11,31 +11,35 @@ import { getAppType } from './utils/env';
|
|||
import initialize from '../../src/initialize';
|
||||
|
||||
const appType = getAppType();
|
||||
const { features, i18n } = initialize(appType, window.location.hostname);
|
||||
const i18nOptions = {
|
||||
version: '1.0.0',
|
||||
};
|
||||
const { features, i18n } = initialize(
|
||||
appType,
|
||||
window.location.hostname,
|
||||
i18nOptions
|
||||
);
|
||||
Object.assign(global, {
|
||||
features,
|
||||
})
|
||||
});
|
||||
|
||||
const root = ReactDOM.createRoot(
|
||||
document.getElementById('root') as HTMLElement
|
||||
);
|
||||
|
||||
features.application.getApplication()
|
||||
.then(
|
||||
() => {
|
||||
root.render(
|
||||
// <React.StrictMode>
|
||||
<BrowserRouter>
|
||||
<I18nextProvider i18n={i18n as any}>
|
||||
<ResponsiveProvider>
|
||||
<App />
|
||||
</ResponsiveProvider>
|
||||
</I18nextProvider>
|
||||
</BrowserRouter>
|
||||
// </React.StrictMode>
|
||||
);
|
||||
}
|
||||
)
|
||||
features.application.getApplication().then(() => {
|
||||
root.render(
|
||||
// <React.StrictMode>
|
||||
<BrowserRouter>
|
||||
<I18nextProvider i18n={i18n as any}>
|
||||
<ResponsiveProvider>
|
||||
<App />
|
||||
</ResponsiveProvider>
|
||||
</I18nextProvider>
|
||||
</BrowserRouter>
|
||||
// </React.StrictMode>
|
||||
);
|
||||
});
|
||||
|
||||
// If you want to start measuring performance in your app, pass a function
|
||||
// to log results (for example: reportWebVitals(console.log))
|
||||
|
|
|
|||
|
|
@ -6,7 +6,17 @@ import initialize from '../../src/initialize';
|
|||
* 初始化,小程序这里必须输入访问的目标域名,系统根据domain和system的关系来判定appId
|
||||
*/
|
||||
const url = 'localhost';
|
||||
const { features } = initialize('wechatMp', url);
|
||||
const systemInfo = wx.getSystemInfoSync();
|
||||
const { language } = systemInfo; // 系统语言
|
||||
let translations: Record<string, any> = {};
|
||||
if (language === 'zh_CN') {
|
||||
translations = require('./locales/zh_CN.json');
|
||||
}
|
||||
const i18nOptions = {
|
||||
translations,
|
||||
defaultLocale: language,
|
||||
};
|
||||
const { features } = initialize('wechatMp', url, i18nOptions);
|
||||
|
||||
export interface IAppOption {
|
||||
globalData: {
|
||||
|
|
|
|||
Loading…
Reference in New Issue