Skip to content

Commit

Permalink
添加创建标签工具
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaohuohumax committed Jan 10, 2024
1 parent 4efac39 commit 3e6a8d2
Show file tree
Hide file tree
Showing 19 changed files with 1,094 additions and 58 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ node_modules
dist
*.local
.vscode/*
!.vscode/extensions.json
app/tool
!.vscode/extensions.json
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

**基于 `Github API` `Github Pages` `Issue` `Label` 实现的简单网站, 可用于搭建简单博客, 记录笔记等**

### 在线访问
### 🔗在线访问

[Live Demo](https://xiaohuohumax.github.io/MiaoJi/)

由于未添加 `Token`, 所以访问频次有限制(大概60次/每人/每小时), 详见[REST API](https://docs.github.com/zh/rest/using-the-rest-api/rate-limits-for-the-rest-api)

## 功能
## 📊功能

+ 文章笔记
+ 轮播图
Expand All @@ -29,7 +29,7 @@ pnpm dev
pnpm build
```

## 标签规则
## 📏标签规则

[标签规则](./doc/label.md)

Expand All @@ -45,3 +45,8 @@ pnpm build
## 📂配置文件

[app.config.ts](./app/web/app.config.ts) 或者 [dist/app.config.ts](./app/web/dist/app.config.js)


## 🧰标签生成辅助工具

[工具 app/create-label](./app/create-label/README.md)
11 changes: 11 additions & 0 deletions app/label/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# 项目名称
VITE_APP_NAME = MiaoJi(喵记)

# Issue 仓库名称
VITE_ISSUE_REPO = test-github

# Issue 仓库持有者
VITE_ISSUE_owner = xiaohuohumax

# Issue 标签创建权限 Token
VITE_GITHUB_TOKEN =
8 changes: 8 additions & 0 deletions app/label/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# @miaoji/label

## 0.1.1

### Patch Changes

- Updated dependencies
- @miaoji/api@1.4.0
14 changes: 14 additions & 0 deletions app/label/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# MiaoJi(喵记)标签辅助工具

**此工具用于快速创建 MiaoJi(喵记) Issue 标签**

## 使用

1. 修改环境变量 (仓库, 拥有者, Token等)
2. 修改[配置](./app.config.ts)自定义标签 (名称, 描述, 颜色等)
3. 执行脚本

```
pnpm i
pnpm start
```
126 changes: 126 additions & 0 deletions app/label/app.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
import { Label } from '@miaoji/api';
import { defaultLabel, LabelName } from '@miaoji/base';

const { label } = defaultLabel;

const appConfig: AppConfig = {
// 需要创建的标签
// 颜色不填则为随机
cLabels: [
{
title: '主要功能标签',
labels: [
{
name: label.communicationLabel,
description: '留言',
},
{
name: label.linkLabel,
description: '友链',
},
{
name: label.aboutLabel,
description: '关于',
},
{
name: label.docLabel,
description: '文章',
},
{
name: label.bannerLabel,
description: '轮播图',
},
{
name: label.historyLabel,
description: '历史记录',
},
{
name: label.photoLabel,
description: '相册',
}
]
},
{
title: '友链相关',
labels: [
{
name: label.applyLinkLabel,
description: '友链申请',
},
]
},
{
title: '历史记录相关',
labels: [
{
name: 'func:history:warning',
description: '历史:警告',
color: 'f08a00'
},
{
name: 'func:history:success',
description: '历史:成功',
color: '2a947d'
},
{
name: 'func:history:info',
description: '历史:信息',
color: '3889c5'
},
{
name: 'func:history:error',
description: '历史:错误',
color: 'd03a52'
},
{
name: 'func:history:default',
description: '历史:默认',
color: '909092'
},
]
},
{
title: '其他辅助',
labels: [
{
name: label.hiddenCommentLabel,
description: '隐藏评论',
},
]
},
],
name: import.meta.env.VITE_APP_NAME,
api: {
// github rest api 一般不变
apiBaseUrl: 'https://api.github.com',
// 仓库名称
repo: import.meta.env.VITE_ISSUE_REPO,
// 持有者
owner: import.meta.env.VITE_ISSUE_owner,
// github token Issue 标签创建权限
accessToken: import.meta.env.VITE_GITHUB_TOKEN,
},
// 标签
label: label,
};

export type CLabel = Partial<Omit<Label, 'id'>> & {
name: string
}

type AppConfig = {
cLabels: {
title: string,
labels: CLabel[]
}[],
name: string,
api: {
apiBaseUrl: string,
repo: string,
owner: string,
accessToken?: string
},
label: LabelName
}

export default appConfig;
28 changes: 28 additions & 0 deletions app/label/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "@miaoji/label",
"version": "0.1.1",
"description": "MiaoJi(喵记)标签辅助工具",
"main": "index.ts",
"type": "module",
"repository": "https://github.com/xiaohuohumax/MiaoJi",
"author": {
"name": "xiaohuohumax",
"url": "https://github.com/xiaohuohumax"
},
"scripts": {
"start": "vite-node src/index.ts"
},
"keywords": [],
"license": "MIT",
"dependencies": {
"@inquirer/prompts": "^3.3.0",
"@miaoji/api": "workspace:^",
"@miaoji/base": "workspace:^",
"@miaoji/util": "workspace:^",
"@types/node": "^20.10.6",
"await-to-js": "^3.0.0",
"axios": "^1.6.3",
"typescript": "^5.0.2",
"vite-node": "^1.1.3"
}
}
28 changes: 28 additions & 0 deletions app/label/src/api/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { LabelApi } from '@miaoji/api';
import { RequestExecutor } from '@miaoji/util';
import appConfig from '../../app.config';

const executor = RequestExecutor.create({
baseURL: appConfig.api.apiBaseUrl,
timeout: 10_0000,
headers: {
Accept: 'application/json',
Authorization: 'Bearer ' + appConfig.api.accessToken
},
interceptors: {
reqtInterceptors(config) {
return config;
},
reqInterceptorCatch(err) {
return Promise.reject(err);
},
resInterceptors(response) {
return response;
},
resInterceptorCatch(err) {
return Promise.reject(err);
},
}
});

export const labelApi = new LabelApi(executor, appConfig.api.owner, appConfig.api.repo);
Loading

0 comments on commit 3e6a8d2

Please sign in to comment.