Skip to content

Commit

Permalink
🚨 chore: 修正 lint 错误
Browse files Browse the repository at this point in the history
  • Loading branch information
arvinxx committed Feb 5, 2021
1 parent 111f392 commit e4a731c
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 13 deletions.
34 changes: 34 additions & 0 deletions docs/guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
## 框架设计思想

框架的设计思想为 MVC 加 Service 方式,组合而成。 MVC 是老生常谈,但是我这里似乎不能完全意义上的称做 MVC,只是有 MVC 结构罢了,(没错 MVC 也是松耦合且可以按需调整),Model 用来专注干数据或者业务该干的事情,(你也可以放在 Controller 做,没人阻止你这么干)。

MainProcessHelper 也负责在 electron 启动时启动渲染窗口。

### Main

框架整体上分为 MVC、common、service 和 process 四大结构
service 自己封装了一些诸如消息通知,http 请求,用 localStorage 本地化存储等服务,开发者可以自行扩展,并按需引用,

process 中主要针对主进程和渲染进程分别写了 MainProcessHelper 和 RendererProcessHelper,

用来辅助主进程和渲染进程的通信,同时

### Renderer

### common

common 中有 Logger,Config,Router 三个组件,分别用于日志,配置和路由。

## 框架约定

### Renderer

采用 umi 的约定

文件夹中,控制器写在 Controller 文件夹中,建议命名为类似于【DemoController】,控制器代码需要在 html 用通过 script 标签的 src 属性引入,在 Controller 中可以按需通过 require 引入服务及 common 组件,在 Controller 中可以使用 jquery,或者开发者可以自行扩展。

建议: 在每个 Controller 中引用 BaseController,可以方便使用 openNewWindow 方法 在每个 Controller 中引用 RendererProcessHelper,可以方便的像主进程通知消息,方便的注册回调函数。

## 框架引用的第三方组件

- log4js 日志 https://www.npmjs.com/package/log4js
1 change: 0 additions & 1 deletion src/renderer/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"extends": "../../tsconfig.json",
"include": [".", "../../types"],
"compilerOptions": {
"jsx": "react-jsx",
"baseUrl": ".",
"paths": {
"@/common": ["../common"],
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"importHelpers": true,
"esModuleInterop": true,
"sourceMap": true,
"jsx": "react-jsx",
//
"strict": true,
"noUnusedLocals": true,
Expand Down
24 changes: 12 additions & 12 deletions types/MainProcess/Database.d.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import type { UserService } from '../../src/main/services';
declare namespace Main {
import type { UserService } from '../../src/main/services';

declare global {
namespace Main {
interface Repository {
user: UserService;
}
interface Repository {
user: UserService;
}
}

namespace NodeJS {
interface Global {
repository: {
user: UserService;
};
}
declare namespace NodeJS {
import type { UserService } from '../../src/main/services';

interface Global {
repository: {
user: UserService;
};
}
}

0 comments on commit e4a731c

Please sign in to comment.