📝: document contributor

更新文档
This commit is contained in:
就眠儀式 2022-06-23 15:44:38 +08:00
parent 057b3c4243
commit 0869ae03c6
13 changed files with 194 additions and 8 deletions

View File

@ -14,7 +14,8 @@
"vue-i18n": "^9.1.10", "vue-i18n": "^9.1.10",
"@vueuse/core": "^8.7.3", "@vueuse/core": "^8.7.3",
"pinia": "^2.0.14", "pinia": "^2.0.14",
"pinia-plugin-persist": "^1.0.0" "pinia-plugin-persist": "^1.0.0",
"axios": "^0.27.2"
}, },
"devDependencies": { "devDependencies": {
"@types/markdown-it": "^12.2.3", "@types/markdown-it": "^12.2.3",

View File

@ -0,0 +1,80 @@
<template>
<div class="contributor">
<lay-tooltip
:content="contributor.login"
v-for="contributor in contributors"
:key="contributor.id"
:is-dark="false"
>
<a :href="contributor.htmlUrl" target="_blank">
<lay-avatar :src="contributor.avatarUrl" radius></lay-avatar>
</a>
</lay-tooltip>
</div>
</template>
<script lang="ts" setup>
import axios from "axios";
import { Ref, ref } from "vue";
export interface LayContributor {
filePath: string;
}
const props = withDefaults(defineProps<LayContributor>(), {
filePath: "",
});
const suffix = ".md";
const githubAPI = "https://api.github.com/repos/layui/layui-vue/commits?path=/package/document/src/document/zh-CN/components/";
const contributors: Ref<any> = ref([]);
var compare = function (x: any, y: any) {
if (x.commits < y.commits) {
return 1;
} else if (x.commits > y.commits) {
return -1;
} else {
return 0;
}
};
const fetchContributors = () => {
axios.get(githubAPI + props.filePath + suffix).then((result) => {
const topic: any[] = [];
result.data.forEach((item: any) => {
if (item.committer) {
const itemdata = {
id: item.committer["id"],
login: item.committer["login"],
avatarUrl: item.committer["avatar_url"],
htmlUrl: item.committer["html_url"],
commits: 1,
};
if (topic.some((e) => e.id == itemdata.id)) {
topic.forEach((item) => {
if (item.id === itemdata.id) {
item.commits = item.commits + 1;
}
});
} else {
topic.push(itemdata);
}
}
});
contributors.value = topic.sort(compare);
});
};
fetchContributors();
</script>
<style>
.contributor {
text-align: left;
margin: 30px 20px;
}
.contributor img {
margin: 5px;
}
</style>

View File

@ -115,5 +115,8 @@ export default {
::: :::
::: contributor animation
:::
::: previousNext animation ::: previousNext animation
::: :::

View File

@ -136,5 +136,8 @@ export default {
::: :::
::: contributor avatar
:::
::: previousNext avatar ::: previousNext avatar
::: :::

View File

@ -131,5 +131,8 @@ export default {
::: :::
::: contributor backtop
:::
::: previousNext backtop ::: previousNext backtop
::: :::

View File

@ -87,7 +87,8 @@ export default {
::: :::
::: contributor badge
:::
::: previousNext badge ::: previousNext badge
::: :::

View File

@ -110,7 +110,8 @@ export default {
::: :::
::: contributor breadcrumb
:::
::: previousNext breadcrumb ::: previousNext breadcrumb
::: :::

View File

@ -369,7 +369,8 @@ export default {
::: :::
::: contributor button
:::
::: previousNext button ::: previousNext button
::: :::

View File

@ -16,7 +16,7 @@
<li> <li>
<h3>1.2.0 <span class="layui-badge-rim">2022-06-21</span></h3> <h3>1.2.0 <span class="layui-badge-rim">2022-06-21</span></h3>
<ul> <ul>
<li>[新增] dropdown 组件 placement 属性, 设置下拉面板位置</li> <li>[新增] dropdown 组件 placement 属性, 设置下拉面板位置</li>
<li>[新增] dropdown 组件 autoFitPosition 属性, 超出浏览器边界自动调整下拉面板位置, 默认为 true。</li> <li>[新增] dropdown 组件 autoFitPosition 属性, 超出浏览器边界自动调整下拉面板位置, 默认为 true。</li>
<li>[新增] dropdown 组件 autoFitWidth 与 autoFitMinWidth 属性, 是否将下拉面板宽度与最小宽度设置为触发器宽度, 默认 false。</li> <li>[新增] dropdown 组件 autoFitWidth 与 autoFitMinWidth 属性, 是否将下拉面板宽度与最小宽度设置为触发器宽度, 默认 false。</li>
<li>[新增] dropdown 组件 updateAtScroll 属性, 是否在容器滚动时更新下拉面板的位置,默认 false。</li> <li>[新增] dropdown 组件 updateAtScroll 属性, 是否在容器滚动时更新下拉面板的位置,默认 false。</li>
@ -27,7 +27,7 @@
<li>[修复] progress 组件 circle 模式夜间主题不兼容的问题。</li> <li>[修复] progress 组件 circle 模式夜间主题不兼容的问题。</li>
<li>[新增] carousel 组件 过渡动画,默认为滑动。</li> <li>[新增] carousel 组件 过渡动画,默认为滑动。</li>
<li>[修复] carousel 组件 autoplay 属性为false时仍自动播放问题。</li> <li>[修复] carousel 组件 autoplay 属性为false时仍自动播放问题。</li>
<li>[修复] cascader 按需加载无法正常引入使用。</li> <li>[修复] cascader 组件 按需加载无法正常引入使用。</li>
</ul> </ul>
</li> </li>
</ul> </ul>

View File

@ -8,6 +8,7 @@ import LayCode from "./components/LayCode.vue";
import LaySearch from "./components/LaySearch.vue"; import LaySearch from "./components/LaySearch.vue";
import LayTableBox from "./components/LayTableBox.vue"; import LayTableBox from "./components/LayTableBox.vue";
import LayAnchor from "./components/LayAnchor.vue"; import LayAnchor from "./components/LayAnchor.vue";
import LayContributor from "./components/LayContributor.vue";
import "./assets/css/index.css"; import "./assets/css/index.css";
export function createApp(): { export function createApp(): {
@ -24,7 +25,8 @@ export function createApp(): {
.component("LayCode", LayCode) .component("LayCode", LayCode)
.component("LaySearch", LaySearch) .component("LaySearch", LaySearch)
.component("LayTableBox", LayTableBox) .component("LayTableBox", LayTableBox)
.component("LayAnchor", LayAnchor); .component("LayAnchor", LayAnchor)
.component("LayContributor", LayContributor);
return { app, router }; return { app, router };
} }

View File

@ -11,6 +11,7 @@ import createTable from "./create-table";
import createAnchor from "./create-anchor"; import createAnchor from "./create-anchor";
import preWrapper from "./pre-wrapper"; import preWrapper from "./pre-wrapper";
import previousNext from "./previous-next"; import previousNext from "./previous-next";
import contributor from "./contributor";
const plugins = [ const plugins = [
vue({ vue({
@ -32,7 +33,8 @@ const plugins = [
.use(...createTitle("title", "")) .use(...createTitle("title", ""))
.use(...createDescribe("describe", "")) .use(...createDescribe("describe", ""))
.use(...createAnchor("anchor", "")) .use(...createAnchor("anchor", ""))
.use(...previousNext("previousNext", "")); .use(...previousNext("previousNext", ""))
.use(...contributor("contributor",""));
}, },
}), }),
] as any; ] as any;

View File

@ -0,0 +1,31 @@
import container from "markdown-it-container";
import type Token from "markdown-it/lib/token";
type ContainerArgs = [
typeof container,
string,
{
render(tokens: Token[], idx: number): string;
}
];
export default function createContainer(
klass: string,
defaultTitle: string
): ContainerArgs {
return [
container,
klass,
{
render(tokens, idx) {
const token = tokens[idx];
const info = token.info.trim().slice(klass.length).trim();
if (token.nesting === 1) {
return `<lay-contributor file-path='${info}'></lay-contributor>`;
} else {
return ``;
}
},
},
];
}

View File

@ -99,6 +99,7 @@ importers:
'@types/markdown-it-container': ^2.0.4 '@types/markdown-it-container': ^2.0.4
'@types/prettier': ^2.4.4 '@types/prettier': ^2.4.4
'@vueuse/core': ^8.7.3 '@vueuse/core': ^8.7.3
axios: ^0.27.2
escape-html: ^1.0.3 escape-html: ^1.0.3
markdown-it-container: ^3.0.0 markdown-it-container: ^3.0.0
pinia: ^2.0.14 pinia: ^2.0.14
@ -113,6 +114,7 @@ importers:
vue-router: ^4.0.15 vue-router: ^4.0.15
dependencies: dependencies:
'@vueuse/core': 8.7.3_vue@3.2.37 '@vueuse/core': 8.7.3_vue@3.2.37
axios: 0.27.2
pinia: 2.0.14_typescript@4.6.3+vue@3.2.37 pinia: 2.0.14_typescript@4.6.3+vue@3.2.37
pinia-plugin-persist: 1.0.0_pinia@2.0.14+vue@3.2.37 pinia-plugin-persist: 1.0.0_pinia@2.0.14+vue@3.2.37
vue-i18n: 9.1.10_vue@3.2.37 vue-i18n: 9.1.10_vue@3.2.37
@ -2078,6 +2080,19 @@ packages:
resolution: {integrity: sha512-p4DO/JXwjs8klJyJL8Q2oM4ks5fUTze/h5k10oPPKMiLe1fj3G1QMzPHNmN1Py4ycOk7WlO2DcGXv1qiESJCZA==} resolution: {integrity: sha512-p4DO/JXwjs8klJyJL8Q2oM4ks5fUTze/h5k10oPPKMiLe1fj3G1QMzPHNmN1Py4ycOk7WlO2DcGXv1qiESJCZA==}
dev: false dev: false
/asynckit/0.4.0:
resolution: {integrity: sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==}
dev: false
/axios/0.27.2:
resolution: {integrity: sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==}
dependencies:
follow-redirects: 1.15.1
form-data: 4.0.0
transitivePeerDependencies:
- debug
dev: false
/babel-plugin-dynamic-import-node/2.3.3: /babel-plugin-dynamic-import-node/2.3.3:
resolution: {integrity: sha512-jZVI+s9Zg3IqA/kdi0i6UDCybUI3aSBLnglhYbSSjKlV7yF1F/5LWv8MakQmvYpnbJDS6fcBL2KzHSxNCMtWSQ==} resolution: {integrity: sha512-jZVI+s9Zg3IqA/kdi0i6UDCybUI3aSBLnglhYbSSjKlV7yF1F/5LWv8MakQmvYpnbJDS6fcBL2KzHSxNCMtWSQ==}
dependencies: dependencies:
@ -2246,6 +2261,13 @@ packages:
resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==} resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==}
dev: true dev: true
/combined-stream/1.0.8:
resolution: {integrity: sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==}
engines: {node: '>= 0.8'}
dependencies:
delayed-stream: 1.0.0
dev: false
/commitizen/4.2.4: /commitizen/4.2.4:
resolution: {integrity: sha512-LlZChbDzg3Ir3O2S7jSo/cgWp5/QwylQVr59K4xayVq8S4/RdKzSyJkghAiZZHfhh5t4pxunUoyeg0ml1q/7aw==} resolution: {integrity: sha512-LlZChbDzg3Ir3O2S7jSo/cgWp5/QwylQVr59K4xayVq8S4/RdKzSyJkghAiZZHfhh5t4pxunUoyeg0ml1q/7aw==}
engines: {node: '>= 10'} engines: {node: '>= 10'}
@ -2491,6 +2513,11 @@ packages:
object-keys: 1.1.1 object-keys: 1.1.1
dev: true dev: true
/delayed-stream/1.0.0:
resolution: {integrity: sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==}
engines: {node: '>=0.4.0'}
dev: false
/detect-file/1.0.0: /detect-file/1.0.0:
resolution: {integrity: sha1-8NZtA2cqglyxtzvbP+YjEMjlUrc=} resolution: {integrity: sha1-8NZtA2cqglyxtzvbP+YjEMjlUrc=}
engines: {node: '>=0.10.0'} engines: {node: '>=0.10.0'}
@ -3110,6 +3137,25 @@ packages:
resolution: {integrity: sha512-WIWGi2L3DyTUvUrwRKgGi9TwxQMUEqPOPQBVi71R96jZXJdFskXEmf54BoZaS1kknGODoIGASGEzBUYdyMCBJg==} resolution: {integrity: sha512-WIWGi2L3DyTUvUrwRKgGi9TwxQMUEqPOPQBVi71R96jZXJdFskXEmf54BoZaS1kknGODoIGASGEzBUYdyMCBJg==}
dev: true dev: true
/follow-redirects/1.15.1:
resolution: {integrity: sha512-yLAMQs+k0b2m7cVxpS1VKJVvoz7SS9Td1zss3XRwXj+ZDH00RJgnuLx7E44wx02kQLrdM3aOOy+FpzS7+8OizA==}
engines: {node: '>=4.0'}
peerDependencies:
debug: '*'
peerDependenciesMeta:
debug:
optional: true
dev: false
/form-data/4.0.0:
resolution: {integrity: sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==}
engines: {node: '>= 6'}
dependencies:
asynckit: 0.4.0
combined-stream: 1.0.8
mime-types: 2.1.35
dev: false
/fs-extra/10.0.1: /fs-extra/10.0.1:
resolution: {integrity: sha512-NbdoVMZso2Lsrn/QwLXOy6rm0ufY2zEOKCDzJR/0kBsb0E6qed0P3iYK+Ath3BfvXEeu4JhEtXLgILx5psUfag==} resolution: {integrity: sha512-NbdoVMZso2Lsrn/QwLXOy6rm0ufY2zEOKCDzJR/0kBsb0E6qed0P3iYK+Ath3BfvXEeu4JhEtXLgILx5psUfag==}
engines: {node: '>=12'} engines: {node: '>=12'}
@ -3734,6 +3780,18 @@ packages:
picomatch: 2.3.1 picomatch: 2.3.1
dev: true dev: true
/mime-db/1.52.0:
resolution: {integrity: sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==}
engines: {node: '>= 0.6'}
dev: false
/mime-types/2.1.35:
resolution: {integrity: sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==}
engines: {node: '>= 0.6'}
dependencies:
mime-db: 1.52.0
dev: false
/mime/1.6.0: /mime/1.6.0:
resolution: {integrity: sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==} resolution: {integrity: sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==}
engines: {node: '>=4'} engines: {node: '>=4'}