Skip to content

Commit de5371d

Browse files
committed
Merge branch 'main' into dev/ui
2 parents 2d7359a + d37aedb commit de5371d

32 files changed

+7925
-6390
lines changed

.github/workflows/preview-build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
npm run build:h5-netlify
2626
2727
- name: Upload dist artifact
28-
uses: actions/upload-artifact@v4
28+
uses: actions/upload-artifact@v3
2929
with:
3030
name: dist
3131
path: dist
@@ -37,7 +37,7 @@ jobs:
3737

3838
- name: Upload PR number
3939
if: ${{ always() }}
40-
uses: actions/upload-artifact@v4
40+
uses: actions/upload-artifact@v3
4141
with:
4242
name: pr
4343
path: ./pr-id.txt

.github/workflows/preview-deploy.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' && github.repository == 'doocs/md'
1313
steps:
1414
- name: Download PR artifact
15-
uses: dawidd6/action-download-artifact@v6
15+
uses: dawidd6/action-download-artifact@v2
1616
with:
1717
workflow: ${{ github.event.workflow_run.workflow_id }}
1818
name: pr
@@ -22,7 +22,7 @@ jobs:
2222
run: echo "id=$(<pr-id.txt)" >> "$GITHUB_OUTPUT"
2323

2424
- name: Download dist artifact
25-
uses: dawidd6/action-download-artifact@v6
25+
uses: dawidd6/action-download-artifact@v2
2626
with:
2727
workflow: ${{ github.event.workflow_run.workflow_id }}
2828
workflow_conclusion: success
@@ -35,7 +35,7 @@ jobs:
3535
npx surge --project ./ --domain $DEPLOY_DOMAIN --token ${{ secrets.SURGE_TOKEN }}
3636
3737
- name: Upload status comment
38-
uses: actions-cool/maintain-one-comment@v3
38+
uses: actions-cool/maintain-one-comment@v2
3939
with:
4040
token: ${{ secrets.GITHUB_TOKEN }}
4141
body: |
@@ -49,7 +49,7 @@ jobs:
4949

5050
- name: The job failed
5151
if: ${{ failure() }}
52-
uses: actions-cool/maintain-one-comment@v3
52+
uses: actions-cool/maintain-one-comment@v2
5353
with:
5454
token: ${{ secrets.GITHUB_TOKEN }}
5555
body: |
@@ -66,7 +66,7 @@ jobs:
6666
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'failure' && github.repository == 'doocs/md'
6767
steps:
6868
- name: Download PR artifact
69-
uses: dawidd6/action-download-artifact@v6
69+
uses: dawidd6/action-download-artifact@v2
7070
with:
7171
workflow: ${{ github.event.workflow_run.workflow_id }}
7272
name: pr
@@ -76,7 +76,7 @@ jobs:
7676
run: echo "id=$(<pr-id.txt)" >> "$GITHUB_OUTPUT"
7777

7878
- name: The job failed
79-
uses: actions-cool/maintain-one-comment@v3
79+
uses: actions-cool/maintain-one-comment@v2
8080
with:
8181
token: ${{ secrets.GITHUB_TOKEN }}
8282
body: |

.github/workflows/release-cli.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
node-version: '20'
1818
registry-url: 'https://registry.npmjs.org'
1919
- run: npm install
20-
- run: npm run build-cli
20+
- run: npm run build:cli
2121
- run: cd md-cli && npm ci && npm publish
2222
env:
2323
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,7 @@ yarn.lock
5252
pnpm-lock.yaml
5353
auto-imports.d.ts
5454
components.d.ts
55+
56+
.wxt
57+
.output
58+
web-ext.config.ts

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
<div align="center">
1010

11-
[![status](https://img.shields.io/github/actions/workflow/status/doocs/md/build.yml?style=flat-square&labelColor=564341&color=42cc23)](https://github.com/doocs/md/actions) [![node](https://img.shields.io/badge/node-%3E%3D20-42cc23?style=flat-square&labelColor=564341)](https://nodejs.org/en/about/previous-releases) [![release](https://img.shields.io/github/v/release/doocs/md?style=flat-square&labelColor=564341&color=42cc23)](https://github.com/doocs/md/releases) [![license](https://img.shields.io/github/license/doocs/md?style=flat-square&labelColor=564341&color=42cc23)](./LICENSE) [![pr](https://img.shields.io/badge/prs-welcome-42cc23?style=flat-square&labelColor=564341)](https://github.com/doocs/md/pulls)<br>[![stars](https://img.shields.io/github/stars/doocs/md?style=flat-square&labelColor=564341&color=42cc23)](https://github.com/doocs/md/stargazers) [![forks](https://img.shields.io/github/forks/doocs/md?style=flat-square&labelColor=564341&color=42cc23)](https://github.com/doocs/md)
11+
[![status](https://img.shields.io/github/actions/workflow/status/doocs/md/build.yml?style=flat-square&labelColor=564341&color=42cc23)](https://github.com/doocs/md/actions) [![node](https://img.shields.io/badge/node-%3E%3D20-42cc23?style=flat-square&labelColor=564341)](https://nodejs.org/en/about/previous-releases) [![pr](https://img.shields.io/badge/prs-welcome-42cc23?style=flat-square&labelColor=564341)](https://github.com/doocs/md/pulls) [![stars](https://img.shields.io/github/stars/doocs/md?style=flat-square&labelColor=564341&color=42cc23)](https://github.com/doocs/md/stargazers) [![forks](https://img.shields.io/github/forks/doocs/md?style=flat-square&labelColor=564341&color=42cc23)](https://github.com/doocs/md)<br> [![release](https://img.shields.io/github/v/release/doocs/md?style=flat-square&labelColor=564341&color=42cc23)](https://github.com/doocs/md/releases) [![npm](https://img.shields.io/npm/v/@doocs/md-cli?style=flat-square&labelColor=564341&color=42cc23)](https://www.npmjs.com/package/@doocs/md-cli) [![docker](https://img.shields.io/badge/docker-latest-42cc23?style=flat-square&labelColor=564341)](https://hub.docker.com/r/doocs/md)
1212

1313
</div>
1414

bin/release.js

Lines changed: 44 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,48 @@
1+
import fs from 'fs/promises';
2+
import path from 'path';
3+
import { fileURLToPath } from 'url';
4+
import packageJson from '../md-cli/package.json' assert { type: 'json' };
5+
import child_process from 'child_process';
6+
7+
const __filename = fileURLToPath(import.meta.url);
8+
const __dirname = path.dirname(__filename);
9+
110
(async function () {
2-
const fs = require('fs');
3-
const path = require('path');
4-
const packageJson = require('../md-cli/package.json');
5-
const child_process = require('child_process');
6-
// 自动更新版本
7-
// version可以传递如 6.1.1 | patch | minor | major
8-
const execCommand = arr => (Array.isArray(arr) ? arr : [arr]).forEach(c => {
9-
try {
10-
console.log(`start: ${c}...`)
11-
console.log(child_process.execSync(c).toString('utf8'))
12-
} catch (error) {
13-
console.log('\x1B[31m%s\x1B[0m', error.stdout.toString())
14-
process.exit(1)
15-
}
16-
})
17-
const getNewVersion = (oldVersion, version = 'patch') => {
11+
const execCommand = (arr) =>
12+
(Array.isArray(arr) ? arr : [arr]).forEach((c) => {
13+
try {
14+
console.log(`start: ${c}...`);
15+
console.log(child_process.execSync(c).toString("utf8"));
16+
} catch (error) {
17+
console.log("\x1B[31m%s\x1B[0m", error.stdout.toString());
18+
process.exit(1);
19+
}
20+
});
21+
const getNewVersion = (oldVersion, version = "patch") => {
1822
// [<newversion> | major | minor | patch]
19-
if (/^([0-9]+\.*)+$/.test(version)) return version
20-
const types = ['major', 'minor', 'patch']
21-
const index = types.indexOf(version)
23+
if (/^([0-9]+\.*)+$/.test(version)) return version;
24+
const types = ["major", "minor", "patch"];
25+
const index = types.indexOf(version);
2226
if (index >= 0) {
23-
const versionArr = oldVersion.split('.')
24-
versionArr[index] = Number(versionArr[index]) + 1
25-
return versionArr.map((e, i) => i > index ? 0 : e).join('.')
26-
}
27-
return getNewVersion(oldVersion)
27+
const versionArr = oldVersion.split(".");
28+
versionArr[index] = Number(versionArr[index]) + 1;
29+
return versionArr.map((e, i) => (i > index ? 0 : e)).join(".");
2830
}
29-
const newVersionObj = {
30-
version: getNewVersion(packageJson.version, process.argv[2]),
31-
};
32-
fs.writeFileSync(
33-
path.resolve(__dirname, '../md-cli/package.json'),
34-
JSON.stringify(Object.assign({}, packageJson, newVersionObj), null, 2) +
35-
'\n'
36-
);
37-
console.log(newVersionObj);
38-
execCommand([
39-
`git commit -a -m 'chore: update version cli-v${newVersionObj.version}'`,
40-
`git tag cli-v${newVersionObj.version}`,
41-
'git push && git push --tags',
42-
])
43-
console.log('\x1B[32m%s\x1B[0m', '发布完成,请关注github CI构建')
44-
}())
31+
return getNewVersion(oldVersion);
32+
};
33+
const newVersionObj = {
34+
version: getNewVersion(packageJson.version, process.argv[2]),
35+
};
36+
await fs.writeFile(
37+
path.resolve(__dirname, "../md-cli/package.json"),
38+
JSON.stringify(Object.assign({}, packageJson, newVersionObj), null, 2) +
39+
"\n"
40+
);
41+
console.log(newVersionObj);
42+
execCommand([
43+
`git commit -a -m 'chore: update version cli-v${newVersionObj.version}'`,
44+
`git tag cli-v${newVersionObj.version}`,
45+
"git push && git push --tags",
46+
]);
47+
console.log("\x1B[32m%s\x1B[0m", "发布完成,请关注 GitHub CI 构建");
48+
})();

eslint.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default antfu({
55
unocss: true,
66
typescript: true,
77
formatters: true,
8-
ignores: [`.github`, `bin`, `md-cli`, `src/assets`],
8+
ignores: [`.github`, `bin`, `md-cli`, `src/assets`, `example`],
99
}, {
1010
rules: {
1111
'semi': [`error`, `never`],

example/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Example
2+
3+
## worker.js
4+
5+
公众号openapi接口代理服务示例,该项目将请求转发至微信公众号api。
6+
7+
开发调试:
8+
9+
```
10+
cd example
11+
npx wrangler dev worker.js
12+
```
13+
14+
部署:
15+
16+
请将其部署到cloudflare workers。

example/worker.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* @typedef {object} Env
3+
* @property
4+
*/
5+
6+
export default {
7+
/**
8+
* @param {Request} request
9+
* @param {Env} env
10+
* @param {ExecutionContext} ctx
11+
* @returns {Promise<Response>}
12+
*/
13+
async fetch(request, env, ctx) {
14+
const url = new URL(request.url)
15+
const targetUrl = `https://api.weixin.qq.com`
16+
const proxyRequest = new Request(targetUrl + url.pathname + url.search, {
17+
method: request.method,
18+
headers: request.headers,
19+
body: request.body,
20+
})
21+
const response = await fetch(proxyRequest)
22+
const proxyResponse = new Response(response.body, {
23+
status: response.status,
24+
statusText: response.statusText,
25+
headers: response.headers,
26+
})
27+
setCorsHeaders(proxyResponse.headers)
28+
return proxyResponse
29+
},
30+
}
31+
// 设置 CORS 头部
32+
function setCorsHeaders(headers) {
33+
headers.set(`Access-Control-Allow-Origin`, `*`)
34+
headers.set(`Access-Control-Allow-Methods`, `GET, POST, PUT, DELETE`)
35+
headers.set(`Access-Control-Allow-Headers`, `*`)
36+
}

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
}
8787
</script>
8888
<script>
89-
MathJax = {
89+
window.MathJax = {
9090
loader: { load: ['[tex]/ams'] },
9191
tex: { packages: { '[+]': ['ams'] }, tags: 'ams' },
9292
svg: { fontCache: 'none' },

0 commit comments

Comments
 (0)