From f3496ff9d0ab1c0a73c23248d297161bc61f2247 Mon Sep 17 00:00:00 2001 From: taoya7 Date: Wed, 11 May 2022 10:51:18 +0800 Subject: [PATCH] init --- .editorconfig | 16 ++++++ .fatherrc.ts | 3 ++ .gitignore | 26 ++++++++++ .prettierignore | 7 +++ .prettierrc.js | 1 + .umirc.ts | 13 +++++ README.md | 33 ++++++++++++ docs/index.md | 4 ++ package.json | 45 ++++++++++++++++ src/API/介绍.md | 110 ++++++++++++++++++++++++++++++++++++++++ src/API/网络请求.md | 22 ++++++++ src/API/颜色转换.md | 21 ++++++++ src/index.ts | 0 src/组件/CommonTitle.md | 23 +++++++++ src/组件/弹窗.md | 21 ++++++++ src/组件/表格.md | 9 ++++ tsconfig.json | 13 +++++ typings.d.ts | 2 + 18 files changed, 369 insertions(+) create mode 100755 .editorconfig create mode 100644 .fatherrc.ts create mode 100644 .gitignore create mode 100644 .prettierignore create mode 100644 .prettierrc.js create mode 100644 .umirc.ts create mode 100644 README.md create mode 100644 docs/index.md create mode 100644 package.json create mode 100644 src/API/介绍.md create mode 100644 src/API/网络请求.md create mode 100644 src/API/颜色转换.md create mode 100644 src/index.ts create mode 100644 src/组件/CommonTitle.md create mode 100644 src/组件/弹窗.md create mode 100644 src/组件/表格.md create mode 100644 tsconfig.json create mode 100644 typings.d.ts diff --git a/.editorconfig b/.editorconfig new file mode 100755 index 0000000..7e3649a --- /dev/null +++ b/.editorconfig @@ -0,0 +1,16 @@ +# http://editorconfig.org +root = true + +[*] +indent_style = space +indent_size = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.md] +trim_trailing_whitespace = false + +[Makefile] +indent_style = tab diff --git a/.fatherrc.ts b/.fatherrc.ts new file mode 100644 index 0000000..920a2d0 --- /dev/null +++ b/.fatherrc.ts @@ -0,0 +1,3 @@ +export default { + esm: 'babel', +}; diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..552df4c --- /dev/null +++ b/.gitignore @@ -0,0 +1,26 @@ +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + +# dependencies +/node_modules +/npm-debug.log* +/yarn-error.log +/yarn.lock +/package-lock.json + +# production +/es +/docs-dist + +# misc +.DS_Store +/coverage + +# umi +.umi +.umi-production +.umi-test +.env.local + +# ide +/.vscode +/.idea diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..ecb24d3 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,7 @@ +**/*.svg +**/*.ejs +**/*.html +package.json +.umi +.umi-production +.umi-test diff --git a/.prettierrc.js b/.prettierrc.js new file mode 100644 index 0000000..2d93fab --- /dev/null +++ b/.prettierrc.js @@ -0,0 +1 @@ +module.exports = require('@umijs/fabric').prettier; diff --git a/.umirc.ts b/.umirc.ts new file mode 100644 index 0000000..5efeb36 --- /dev/null +++ b/.umirc.ts @@ -0,0 +1,13 @@ +import { defineConfig } from 'dumi'; + +/// 配置 +export default defineConfig({ + title: 'pad_stick', + favicon: + 'https://user-images.githubusercontent.com/9554297/83762004-a0761b00-a6a9-11ea-83b4-9c8ff721d4b8.png', + logo: 'https://user-images.githubusercontent.com/9554297/83762004-a0761b00-a6a9-11ea-83b4-9c8ff721d4b8.png', + outputPath: 'docs-dist', + // more config: https://d.umijs.org/config + mode: 'doc', + navs: [], +}); diff --git a/README.md b/README.md new file mode 100644 index 0000000..15a0d7f --- /dev/null +++ b/README.md @@ -0,0 +1,33 @@ +# pad_stick_doc + +## Getting Started + +Install dependencies, + +```bash +$ npm i +``` + +Start the dev server, + +```bash +$ npm start +``` + +Build documentation, + +```bash +$ npm run docs:build +``` + +Run test, + +```bash +$ npm test +``` + +Build library via `father-build`, + +```bash +$ npm run build +``` diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 0000000..dd57629 --- /dev/null +++ b/docs/index.md @@ -0,0 +1,4 @@ + +## Intro + + diff --git a/package.json b/package.json new file mode 100644 index 0000000..b42c523 --- /dev/null +++ b/package.json @@ -0,0 +1,45 @@ +{ + "private": true, + "name": "pad_stick_doc", + "version": "1.0.0", + "scripts": { + "start": "dumi dev", + "docs:build": "dumi build", + "docs:deploy": "gh-pages -d docs-dist", + "build": "father-build", + "deploy": "npm run docs:build && npm run docs:deploy", + "prettier": "prettier --write \"**/*.{js,jsx,tsx,ts,less,md,json}\"", + "test": "umi-test", + "test:coverage": "umi-test --coverage", + "prepublishOnly": "npm run build" + }, + "module": "es/index.js", + "typings": "es/index.d.ts", + "gitHooks": { + "pre-commit": "lint-staged" + }, + "lint-staged": { + "*.{js,jsx,less,md,json}": [ + "prettier --write" + ], + "*.ts?(x)": [ + "prettier --parser=typescript --write" + ] + }, + "dependencies": { + "react": "^16.12.0 || ^17.0.0" + }, + "devDependencies": { + "@testing-library/jest-dom": "^5.15.1", + "@testing-library/react": "^12.1.2", + "@types/jest": "^27.0.3", + "@umijs/fabric": "^2.8.1", + "@umijs/test": "^3.0.5", + "dumi": "^1.1.0", + "father-build": "^1.17.2", + "gh-pages": "^3.0.0", + "lint-staged": "^10.0.7", + "prettier": "^2.2.1", + "yorkie": "^2.0.0" + } +} diff --git a/src/API/介绍.md b/src/API/介绍.md new file mode 100644 index 0000000..03d0cce --- /dev/null +++ b/src/API/介绍.md @@ -0,0 +1,110 @@ + +# 介绍 + +工具库中的所有方法,均挂载在$u对象下 + +### 去除空格 + +该方法可以去除空格,分别可以去除所有空格,两端空格,左边空格,右边空格,默认为去除两端空格 + +```js +str 字符串 +pos 去除那些位置的空格,可选为:both-默认值,去除两端空格,left-去除左边空格,right-去除右边空格,all-去除包括中间和两端的所有空格 +``` + +```js +this.$u.trim(); +``` + +### 取一个区间数 + +取一个区间数 + +```js +/** + * @description 取一个区间数 + * @param {Number} min 最小值 + * @param {Number} max 最大值 + */ +this.$u.random(min, max); +``` + +### range + +如果value小于min,取min;如果value大于max,取max + +```js +/** + * @description 如果value小于min,取min;如果value大于max,取max + * @param {number} min + * @param {number} max + * @param {number} value + */ +this.$u.range(); +``` + + + + +### 路由 + +> 路由转驼峰 + +```js +// 使用 +this.$u.path2camelcase('/u/note/123'); +// uNote123 +``` + + + + +### 时间处理 + +> 格式化时间 + +```js +// 使用 +this.$u.formatDate(1652233263000); +// 2022-05-11 09:41:03 +``` + +> 获取月份天数 + +```js +getMonthDays(myMonth = new Date().getMonth()):number +``` + +```js +// 使用 +this.$u.getMonthDays(); +// 31 +``` + + +> 获取月开始日期 + +```js +getMonthStartDay(dateObj, pattern) +- dateObj 时间 +- pattern 格式化 +``` + +```js +this.$u.getMonthStartDay(); +// 2022-05-01 +``` + + +> 获得月结束日期 + +```js +getMonthEndDate(dateObj, pattern) +- dateObj 时间 +- pattern 格式化 +``` + +```js +this.$u.getMonthEndDate(); +// 2022-05-31 +``` diff --git a/src/API/网络请求.md b/src/API/网络请求.md new file mode 100644 index 0000000..61a2871 --- /dev/null +++ b/src/API/网络请求.md @@ -0,0 +1,22 @@ + +# 网络请求 + +开源请求库axios + +http://www.axios-js.com/ + +### 配置文件 + +`/src/boot/axios.js` + +### 使用 + +```js +this.$http.post('/mock', data).then(res=>{ + // 成功 +}).catch(e=>{ + // 失败 +}).finally(e=>{ + +}) +``` diff --git a/src/API/颜色转换.md b/src/API/颜色转换.md new file mode 100644 index 0000000..0b334e1 --- /dev/null +++ b/src/API/颜色转换.md @@ -0,0 +1,21 @@ +# 颜色转换 + + +### RGB转十六进制Hex + +将一个RGB颜色值转换成一个Hex的十六进制颜色值 + +```js +this.$u.rgbToHex("rgb(13, 145, 20)"); +// #0d9114 +``` + +### Hex转RGB + +将一个Hex的十六进制颜色值转换成一个RGB颜色值 + +```js +this.$u.hexToRgb("#0d9114"); +// rgb(13,145,20) +``` + diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/组件/CommonTitle.md b/src/组件/CommonTitle.md new file mode 100644 index 0000000..ea8b568 --- /dev/null +++ b/src/组件/CommonTitle.md @@ -0,0 +1,23 @@ +# CommonTitle + + +公共title样式 + +### 使用 + +```js +import CommonTitle from '@/pages/components/CommonTitle.vue'; +``` + +```js + +``` + +### 属性 + +| 属性 | 说明 | 类型 | 默认值 | +| -------- | ---- | ---- |-----| +| title | | | 数据填写 | +| color | | | blue | +| icon | | | '' | +| needIcon | | | true | diff --git a/src/组件/弹窗.md b/src/组件/弹窗.md new file mode 100644 index 0000000..91c617d --- /dev/null +++ b/src/组件/弹窗.md @@ -0,0 +1,21 @@ + +# 弹窗 + + +![](https://alicdn.taoya.art/img/202205110848983.png) + +```js +this.$confirm({ + title: '提示', + message: '您确定要退出登录吗?', + btn: { + okText: '确定', + cancelText: '取消' + } + }) + .then(() => { + }) + .catch(() => { + console.log('no') + }) +``` diff --git a/src/组件/表格.md b/src/组件/表格.md new file mode 100644 index 0000000..880757e --- /dev/null +++ b/src/组件/表格.md @@ -0,0 +1,9 @@ + +# 表格 + +```js +import CommonTable from '@/components/Table' +``` + + + diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..b1b4b2f --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,13 @@ +{ + "compilerOptions": { + "target": "esnext", + "module": "esnext", + "moduleResolution": "node", + "jsx": "react", + "esModuleInterop": true, + "types": ["jest"], + "strict": true, + "skipLibCheck": true, + "declaration": true + } +} diff --git a/typings.d.ts b/typings.d.ts new file mode 100644 index 0000000..71e0e9f --- /dev/null +++ b/typings.d.ts @@ -0,0 +1,2 @@ +declare module '*.css'; +declare module '*.less';