Skip to content

Commit

Permalink
feat: 初始化
Browse files Browse the repository at this point in the history
  • Loading branch information
agileago committed Nov 9, 2021
1 parent a48174b commit 553c9af
Show file tree
Hide file tree
Showing 6 changed files with 559 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .cz-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module.exports = {
},

allowCustomScopes: true,
allowBreakingChanges: ['特性', '修复'],
allowBreakingChanges: ['feat', 'fix'],
subjectLimit: 100,
skipQuestions: ['body', 'footer'],
}
21 changes: 14 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
# vue3 class component
# vue3 oop

使用类来书写vue3组件,实践`OOP`
类组件+自动化的依赖注入(可选) = 极致的代码体验

### 使用前提条件
### 前提条件

需要安装 `reflect-metadata` 这个库,并且在项目入口需要引入:
需要**reflect-metadata** 的支持

```shell
npm add reflect-metadata
yarn add @abraham/reflection injection-js
```

项目入口需要引入 `reflect-metadata`

```typescript
import 'reflect-metadata'
import '@abraham/reflection'
```

**`tsconfig.json`** 需要增加配置:
Expand All @@ -20,6 +22,7 @@ import 'reflect-metadata'
{
"compilerOptions": {
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"useDefineForClassFields": false
}
}
Expand All @@ -28,9 +31,13 @@ import 'reflect-metadata'
### 安装

```shell
npm add @titanmatrix/vue3-class-component --save
yarn add vue3-oop
```

### vite配置

因为esbuild不支持装饰器的metadata属性,所以需要安装 [vite-plugin-ts](https://github.com/CarterLi/vite/tree/main/packages/plugin-vue-jsx#readme) 插件使用原始ts编译

### API

| 装饰器 | 描述 |
Expand Down
4 changes: 2 additions & 2 deletions conventionalcommit.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"types": {
"特性": {
"feat": {
"description": "特性: 一个新的特性",
"scopes": {
"特性模块一": {},
"特性模块二": {}
}
},
"修复": {
"fix": {
"description": "修复: 修复一个Bug"
},
"逻辑": {
Expand Down
11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
"lint": "eslint --fix .",
"format": "prettier --write '**/*.{ts,tsx,js,vue,css,scss,html,json}'",
"chrome": "open -n /Applications/Google\\ Chrome.app/ --args --disable-web-security --user-data-dir=$HOME/MyChromeDevUserData/",
"release": "npm run build && npm version patch && npm publish",
"prepare": "install-peers"
"prepare": "install-peers",
"release": "standard-version",
"prepublishOnly": "yarn run-s build release"
},
"files": [
"dist",
Expand Down Expand Up @@ -66,6 +67,7 @@
"lint-staged": "^11.1.2",
"prettier": "^2.3.2",
"rimraf": "^3.0.2",
"standard-version": "^9.3.2",
"typescript": "^4.3.5",
"vite": "^2.5.0",
"vite-plugin-ts": "^1.1.8",
Expand All @@ -91,7 +93,6 @@
]
},
"peerDependencies": {
"autobind-decorator": "^2.4.0",
"injection-js": "^2.4.0",
"vue": "^3.2.20",
"vue-router": "^4.0.12"
Expand All @@ -100,5 +101,7 @@
"registry": "https://registry.npmjs.org",
"access": "public"
},
"dependencies": {}
"dependencies": {
"autobind-decorator": "^2.4.0"
}
}
2 changes: 1 addition & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default defineConfig(({ command, mode }) => {
formats: ['es', 'cjs'],
},
rollupOptions: {
external: ['vue', 'injection-js', 'autobind-decorator'],
external: ['vue', 'injection-js'],
},
minify: false,
},
Expand Down
Loading

0 comments on commit 553c9af

Please sign in to comment.