Skip to content

Commit 0ce906e

Browse files
committed
feat: init
1 parent 9ee2876 commit 0ce906e

File tree

285 files changed

+28717
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

285 files changed

+28717
-2
lines changed

.eslintignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
dist/
2+
node_modules
3+
node_modules/
4+
patches/
5+
types/
6+
!packages/.vitepress
7+
!/.eslintrc.js
8+
!/rollup.config.js
9+
!.test
10+
.temp

.eslintrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extends": "@mpxjs/eslint-config-ts",
3+
"rules": {
4+
"@typescript-eslint/no-non-null-assertion": "off",
5+
"@typescript-eslint/no-explicit-any": "off",
6+
"@typescript-eslint/ban-types": "off",
7+
"curly": ["error", "multi-or-nest", "consistent"],
8+
"no-return-assign": "off"
9+
}
10+
}

.gitignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
.DS_Store
2+
.idea
3+
.temp
4+
*.log
5+
components.d.ts
6+
dist
7+
index.json
8+
indexes.json
9+
node_modules
10+
types
11+
coverage
12+
.eslintcache
13+
packages/*/LICENSE
14+
packages/contributing.md
15+
packages/*/index.mjs

CONTRIBUTING.md

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# 如何共建
2+
3+
感谢您对本项目的贡献感兴趣!
4+
5+
## 开发
6+
7+
### 前置工作
8+
9+
克隆仓库到本地并且安装依赖
10+
11+
```bash
12+
pnpm install
13+
```
14+
15+
我们使用VitePress进行快速开发和记录。您可以通过以下方式在本地启动
16+
17+
```bash
18+
pnpm dev
19+
```
20+
21+
## 共建
22+
23+
### 现有方法
24+
25+
请随意增强现有功能。请尽量不要引入破坏性的改变。
26+
27+
### 新方法
28+
29+
有一些添加新功能的注意事项
30+
31+
- 在开始工作之前,最好先打开一个问题进行讨论。
32+
- 实现应作为文件夹放置在`packages/core`下,并在`index.ts`中公开`
33+
-`核心`包中,尽量不要引入第三方依赖关系,因为这个包的目标是尽可能地轻量级。
34+
- 如果您想引入第三方依赖关系,请创建新的插件。
35+
- 您可以在`packages/core/template/`下找到函数模板,详细信息请参见[模版文件夹](#模版文件夹)部分。
36+
- 为函数编写文档时,`<--FOOTER_STARTS-->``<--FOOTER_ENDS-->`将在构建时自动更新,因此不需要更新它们。
37+
38+
> 请注意,您不需要更新包`index.ts`。它们是自动生成的。
39+
40+
### 新的插件
41+
42+
非常欢迎新的附加组件!
43+
44+
-`packages/`下创建一个新文件夹,并将其命名为npm包名称。
45+
-`meta/packages.ts`中添加加载项详细信息
46+
- 创建`README.md`在该文件夹下。
47+
- 向核心包添加函数。
48+
- 提交并作为PR提交。
49+
50+
## 项目结构
51+
52+
### Monorepo
53+
54+
我们使用monorepo管理包
55+
56+
```
57+
packages
58+
shared/ - 跨包共享utils
59+
core/ - 核心包
60+
[...addons]/ - 附加包
61+
```
62+
63+
### 模版文件夹
64+
65+
模版文件夹通常包含以下4个文件:
66+
67+
> 您可以在`packages/core/template/`下找到模板
68+
69+
```bash
70+
index.ts # 函数源代码本身
71+
demo.mpx # 例子
72+
index.test.ts # vitest单元测试
73+
index.md # 文档
74+
```
75+
76+
`index.ts`您应该导出带有名称的函数
77+
78+
```ts
79+
// DO
80+
export { useMyFunction }
81+
82+
// DON'T
83+
export default useMyFunction
84+
```
85+
86+
`index.md`第一句话将在函数列表中显示为简短的介绍,因此请尽量保持简短明了。
87+
88+
```md
89+
# useMyFunction
90+
91+
这将是介绍。详细说明...
92+
93+
```
94+
95+
阅读有关[参考指南](https://mpxuse.cn/guidelines).
96+
97+
## 代码风格
98+
99+
只要安装了开发依赖项,就不用担心代码样式。Git钩子将在提交时为您格式化并修复它们。
100+
101+
## 感谢
102+
103+
再次感谢您对这个项目感兴趣!你真棒!

DEVELOPMENT.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
## 开发文档
2+
3+
- demo的`@mpxjs/core``@mpxjs/api-proxy``@mpxjs/store`被移到了最外层,因为要和`packages`里共用。下面demo的设计会解释。
4+
5+
### DEMO设计
6+
7+
demo里面的组件代码是自动生成的,通过`npm run demo`来生成,是粘贴复制了`packages`里的`demo.mpx`,而每个demo引用的方法还在`packages`里,所以mpx相关核心方法移到了最上层,这样use方法和demo里引用的是同一份mpx,而不是各自的node_modules,出现两个mpx引用。
8+
9+
### 开发容易出现的问题
10+
11+
例如你在你的方法中引入其他方法,需要这么操作
12+
```js
13+
import { resolveUnref } from '../resolveUnref'
14+
import { resolveUnref } from '..'
15+
```
16+
⚠️ 如果错误操作,就会发生一些莫名的错误,不要这么操作。

README.md

Lines changed: 103 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,103 @@
1-
# mpxuse
2-
composition-api的公用方法
1+
<p align="center">
2+
<a href="https://github.com/mpx-ecology/mpxuse#gh-light-mode-only">
3+
<img src="https://raw.githubusercontent.com/mpx-ecology/mpxuse/main/packages/public/logo-vertical.png#gh-light-mode-only" alt="Mpxuse - Mpx的composition-api的公用方法" width="300">
4+
</a>
5+
<a href="https://github.com/mpx-ecology/mpxuse#gh-dark-mode-only">
6+
<img src="https://raw.githubusercontent.com/mpx-ecology/mpxuse/main/packages/public/logo-vertical-dark.png#gh-dark-mode-only" alt="Mpxuse - Mpx的composition-api的公用方法" width="300">
7+
</a>
8+
<br>
9+
Mpx的composition-api的公用方法
10+
</p>
11+
12+
<p align="center">
13+
<a href="https://www.npmjs.com/package/@mpxjs/mpxuse-core" target="__blank"><img src="https://img.shields.io/npm/v/@mpxjs/mpxuse-core?color=a1b858&label=" alt="NPM version"></a>
14+
<a href="https://www.npmjs.com/package/@mpxjs/mpxuse-core" target="__blank"><img alt="NPM Downloads" src="https://img.shields.io/npm/dm/@mpxjs/mpxuse-core?color=50a36f&label="></a>
15+
<a href="https://mpx-ecology.github.io/mpxuse" target="__blank"><img src="https://img.shields.io/static/v1?label=&message=docs%20%26%20demos&color=1e8a7a" alt="Docs & Demos"></a>
16+
<img alt="函数数量" src="https://raw.githubusercontent.com/mpx-ecology/mpxuse/main/packages/public/badge-function-count.svg">
17+
<br>
18+
<a href="https://github.com/mpx-ecology/mpxuse" target="__blank"><img alt="GitHub stars" src="https://img.shields.io/github/stars/mpx-ecology/mpxuse?style=social"></a>
19+
</p>
20+
21+
## 🚀 功能
22+
23+
- 🎪 [**文档和演示**](https://mpx-ecology.github.io/mpxuse)
24+
- 🕶 **支持版本**: mpx2.8版本以上
25+
-**完全tree shakeable**: 仅打包所引用的, [bundle size](https://mpx-ecology.github.io/mpxuse/export-size)
26+
- 🦾 **Type Strong**: [TypeScript](https://www.typescriptlang.org/)编写, [TS Docs](https://github.com/microsoft/tsdoc)
27+
- 🔩 **灵活配置**: 可配置的事件筛选器和目标
28+
29+
## 🦄 用法
30+
31+
```ts
32+
import { useCounter } from '@mpxjs/mpxuse-core'
33+
34+
const { count, inc, dec, set, reset } = useCounter()
35+
defineExpose({
36+
count, inc, dec, set, reset
37+
})
38+
```
39+
40+
```html
41+
<template>
42+
<view>
43+
<view>Count: {{ count }}</view>
44+
<button bindtap="inc">
45+
Increment
46+
</button>
47+
<button bindtap="dec">
48+
Decrement
49+
</button>
50+
<button bindtap="inc(5)">
51+
Increment (+5)
52+
</button>
53+
<button bindtap="dec(5)">
54+
Decrement (-5)
55+
</button>
56+
<button bindtap="set(100)">
57+
Set (100)
58+
</button>
59+
<button bindtap="reset">
60+
Reset
61+
</button>
62+
</view>
63+
</template>
64+
65+
```
66+
67+
参考 [所有函数](https://mpx-ecology.github.io/mpxuse/functions) 或者 [文档](https://mpx-ecology.github.io/mpxuse/) 查看更多
68+
69+
## 📦 安装
70+
71+
> 🎩 mpx版本需要2.8以上才支持组合式Composition API!
72+
73+
```bash
74+
npm i @mpxjs/mpxuse-core
75+
```
76+
77+
###### Demos
78+
79+
可clone仓库执行
80+
81+
```js
82+
pnpm i
83+
cd demo && pnpm i
84+
npm run watch
85+
```
86+
87+
## 🧱 贡献
88+
89+
参考 [**如何共建**](https://mpx-ecology.github.io/mpxuse/contributing)
90+
91+
## 🌸 感谢
92+
93+
这个项目的灵感来源于以下几个很棒的项目。
94+
95+
- [vueuse/vueuse](https://github.com/vueuse/vueuse)
96+
97+
## 👨‍🚀 贡献者
98+
99+
[pagnkelly](https://github.com/pagnkelly)
100+
101+
## 📄 License
102+
103+
[MIT License](https://github.com/mpx-ecology/mpxuse/blob/main/LICENSE) © 2022 [pagnkelly](https://github.com/pagnkelly)

demo/.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true

demo/.eslintrc.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
root: true,
3+
extends: '@mpxjs/eslint-config-ts',
4+
rules: {
5+
'no-return-assign': 'off'
6+
}
7+
}

demo/.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.DS_Store
2+
node_modules/
3+
npm-debug.log
4+
.idea/
5+
deploy/
6+
output/
7+
dist/
8+
.vscode/
9+
.cache/

demo/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Demo
2+
3+
> A mpx project
4+
5+
## Dev
6+
7+
```bash
8+
# install dep
9+
npm i
10+
11+
# for dev
12+
npm run watch
13+
14+
# for online
15+
npm run build
16+
```
17+
18+
npm script规范 [build|watch]:[dev|prod]:[cross|web|none]
19+
20+
build默认prod,watch默认dev。另单独提供了build:dev和watch:prod,用于单次构建分析看未压缩代码分析问题和持续压缩代码便于大体积项目真机调试。
21+
22+
建议自行调整cross的目标。npm-run-all是为了兼容windows下无法同时执行两个npm script,若不需要转web平台,可考虑去掉。

0 commit comments

Comments
 (0)