diff --git a/README.md b/README.md index 0f01961..968640c 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ -# poros +# Poros [![Build With Umi](https://img.shields.io/badge/build%20with-umi-028fe4.svg?style=flat-square)](http://umijs.org/) poros [![dumi](https://img.shields.io/badge/docs%20by-dumi-blue)](https://github.com/umijs/dumi) -A Electron React framework based on umi. +An electron react framework based on Umi. ## Getting Started @@ -12,8 +12,176 @@ A Electron React framework based on umi. pnpm create poros ``` +### Launch Poros App -## Community +```bash +pnpm start +``` + +## Features + +You can quickly build an Electron project, and you can develop, package, upgrade, etc. it has all the features of Umi. It also integrates commonly used electron libraries, such as: electron-log, electron-store... +More features will be integrated in the future. + +### preset plugins +- initial-state +- access +- model +- react-query +- antd +- locale() + +> You can use umi plugins directly. If you have any problems, please contact me. + +## Folder Structure + +``` +├── config +│   ├── builder.ts // electron-builder config +│   ├── config.ts // umi config +│   ├── logger.ts // electron-log config +│   └── routes.ts // umi routes config +├── mock +│   └── demo.ts +├── src +│   ├── constants +│   │   └── index.ts +│   ├── locales // locale dir +│   │   ├── en-US.ts +│   │   └── zh-CN.ts +│   ├── main // main process dir +│   │   └── index.ts +│   ├── preload // preload dir +│   │   └── index.ts +│   ├── renderer // renderer process dir, same as umi +│   │ ├── assets +│   │ ├── models +│   │ ├── pages +│   │ └── utils +│   └── app.ts // global setting, same as umi +├── package.json +├── pnpm-lock.yaml +├── tsconfig.json +└── typings.d.ts +``` + +## API + +> import { something} from 'poros'; + +### Main Process + +```typescript +/** + * electron-log + * https://github.com/megahertz/electron-log + * >> config/config.ts + * export default defineConfig({ + * logger : { + * transports: { + * file: { + * level: 'warn', + * format: '[{y}-{m}-{d} {h}:{i}:{s}.{ms}] [{level}]{scope} {text}', + * maxSize: 1048576, + * }, + * console: { + * level: 'debug', + * }, + * }, + * } + * }); + */ +import { logger } from 'poros'; +logger.info('xxx'); +logger.error('xxx'); +logger.warn('xxx'); + +/** + * electron-store + * https://github.com/sindresorhus/electron-store + * export default defineConfig({ + * localStore: { + * schema: { + * unicorn: { + * type: 'string', + * default: '🦄', + * }, + * }, + * }, + * }); + */ +import { localStore } from 'poros'; +localStore.set('unicorn', 'xxx'); +localStore.get('unicorn'); + +/** + * initialize + * Must exec initialize before app ready. + */ +import { initialize } from 'poros'; + +/** + * i18n + * Enable with locale plugin + * The program will restart after switching languages + */ +import { localeInfo, getIntl, setIntl, getLocale, setLocale, getAllLocales, i18n } from 'poros'; + +/** + * utils + */ +import { isMacOS, isWindows, isLinux, isX86, isX64, isDev, isProd } from 'poros'; +``` + +### Renderer Process + +> a little different from umi + +```typescript +/** + * electron-log + * same usage as in the main process + */ +import { logger } from 'poros'; +logger.info('xxx'); +logger.error('xxx'); +logger.warn('xxx'); + +/** + * electron-store + * same usage as in the main process + */ +import { localStore } from 'poros'; +localStore.set('unicorn', 'xxx'); +localStore.get('unicorn'); + +/** + * i18n + * enable with locale plugin + * The program will restart after switching languages + */ +import { localeInfo, getIntl, setIntl, getLocale, setLocale, getAllLocales, i18n } from 'poros'; +``` + + +## Todo +### IPC +- point-to-point communication between windows and pages +- one-to-many broadcast communication between windows and pages +- communication between different window or page contexts. + +### Windows Management +- provide a window base class +- multi-window management +- window preloading to improve window opening speed + +### Main Process HMR +Currently, if changes are made to the main process code, the app automatically restarts, which is inconvenient. In the future, I hope to enable hot updates. +### More Plugins +You can use umi plugins directly. If you have any problems, please contact me. + +## Refer +- [umi-plugin-electron-builder](https://github.com/BySlin/umi-plugin-electron-builder) - umi的electron插件 ## LICENSE diff --git a/package.json b/package.json index 3ab52ff..171cd84 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "poros", - "version": "1.0.0-beta.5", + "version": "1.0.0", "private": true, "scripts": { "bootstrap": "poros-scripts bootstrap", @@ -19,7 +19,12 @@ "changeset": "esno scripts/changeset.ts", "version-packages": "changeset version" }, - "keywords": [], + "keywords": [ + "electron", + "umi", + "react", + "typescript" + ], "author": "王建明 ", "devDependencies": { "@changesets/cli": "^2.26.1", diff --git a/packages/create-poros/package.json b/packages/create-poros/package.json index f473543..def0aba 100644 --- a/packages/create-poros/package.json +++ b/packages/create-poros/package.json @@ -1,6 +1,6 @@ { "name": "create-poros", - "version": "1.0.0-beta.5", + "version": "1.0.0", "description": "create-poros", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/packages/plugins/package.json b/packages/plugins/package.json index 7e905e4..f2085ea 100644 --- a/packages/plugins/package.json +++ b/packages/plugins/package.json @@ -1,6 +1,6 @@ { "name": "@porosjs/plugins", - "version": "1.0.0-beta.5", + "version": "1.0.0", "description": "@porosjs/plugins", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/packages/poros/package.json b/packages/poros/package.json index 0dd1f46..b99de0d 100644 --- a/packages/poros/package.json +++ b/packages/poros/package.json @@ -1,7 +1,7 @@ { "name": "poros", - "version": "1.0.0-beta.5", - "description": "poros", + "version": "1.0.0", + "description": "An electron react framework based on Umi", "main": "index.js", "types": "index.d.ts", "files": [ diff --git a/packages/poros/src/preset.ts b/packages/poros/src/preset.ts index 1d94587..9a8fc99 100644 --- a/packages/poros/src/preset.ts +++ b/packages/poros/src/preset.ts @@ -6,7 +6,6 @@ export default () => { require.resolve('@porosjs/plugins/dist/initial-state'), require.resolve('@porosjs/plugins/dist/access'), require.resolve('@umijs/plugins/dist/model'), - require.resolve('@umijs/plugins/dist/qiankun'), require.resolve('@porosjs/plugins/dist/react-query'), require.resolve('@porosjs/plugins/dist/locale'), require.resolve('@umijs/plugins/dist/antd'),