docs: 支持 PWA

pull/41/head
zjx0905 2023-04-11 22:09:29 +08:00
parent 75b8bff470
commit bb18e385bd
8 changed files with 2059 additions and 59 deletions

View File

@ -44,6 +44,9 @@ jobs:
- name: Build asset
run: pnpm build:asset
- name: Test
run: pnpm typecheck
- name: Test
run: pnpm test:cov

View File

@ -1,63 +1,24 @@
import { defineConfig } from 'vitepress';
import { VitePWA } from 'vite-plugin-pwa';
import { themeConfig } from './themeConfig';
// https://vitepress.dev/reference/site-config
export default defineConfig({
title: 'axios-miniprogram',
description: '基于 Promise 的 HTTP 请求库,适用于各大小程序平台。',
srcDir: 'pages',
themeConfig: {
// https://vitepress.dev/reference/default-theme-config
nav: [
{ text: '指南', link: '/guide/introduction' },
{ text: '配置', link: '/config/preview' },
{ text: 'API', link: '/api/interceptors' },
themeConfig,
vite: {
plugins: [
VitePWA({
outDir: '.vitepress/dist',
manifest: {
name: 'axios-miniprogram',
short_name: 'axios',
theme_color: '#ffffff',
icons: [],
},
}),
],
sidebar: [
{
text: '指南',
items: [
{ text: '简介', link: '/guide/introduction' },
{ text: '快速上手', link: '/guide/quick-start' },
],
},
{
text: '配置',
items: [
{ text: '默认配置', link: '/config/preview' },
{ text: 'method', link: '/config/method' },
{ text: 'dataType', link: '/config/data-type' },
{ text: 'responseType', link: '/config/response-type' },
{ text: 'validateStatus', link: '/config/validate-status' },
{ text: 'paramsSerializer', link: '/config/params-serializer' },
{ text: 'transformRequest', link: '/config/transform-request' },
{ text: 'transformResponse', link: '/config/transform-response' },
{ text: 'errorHandler', link: '/config/error-handler' },
{ text: 'upload', link: '/config/upload' },
{ text: 'download', link: '/config/download' },
{ text: 'adapter', link: '/config/adapter' },
],
},
{
text: 'API',
items: [
{ text: 'interceptors', link: '/api/interceptors' },
{ text: 'CancelToken', link: '/api/cancel-token' },
{ text: 'isCancel', link: '/api/is-cancel' },
{ text: 'isAxiosError', link: '/api/is-axios-error' },
{ text: 'getUri', link: '/api/get-uri' },
{ text: 'create', link: '/api/create' },
{ text: 'fork', link: '/api/fork' },
{ text: 'Axios', link: '/api/axios' },
],
},
],
socialLinks: [
{ icon: 'github', link: 'https://github.com/zjx0905/axios-miniprogram' },
],
returnToTopLabel: '返回顶部',
outlineTitle: '导航栏',
},
});

View File

@ -0,0 +1,58 @@
import { DefaultTheme } from 'vitepress';
export const themeConfig: DefaultTheme.Config = {
// https://vitepress.dev/reference/default-theme-config
nav: [
{ text: '指南', link: '/guide/introduction' },
{ text: '配置', link: '/config/preview' },
{ text: 'API', link: '/api/interceptors' },
],
sidebar: [
{
text: '指南',
items: [
{ text: '简介', link: '/guide/introduction' },
{ text: '快速上手', link: '/guide/quick-start' },
],
},
{
text: '配置',
items: [
{ text: '默认配置', link: '/config/preview' },
{ text: 'method', link: '/config/method' },
{ text: 'dataType', link: '/config/data-type' },
{ text: 'responseType', link: '/config/response-type' },
{ text: 'validateStatus', link: '/config/validate-status' },
{ text: 'paramsSerializer', link: '/config/params-serializer' },
{ text: 'transformRequest', link: '/config/transform-request' },
{ text: 'transformResponse', link: '/config/transform-response' },
{ text: 'errorHandler', link: '/config/error-handler' },
{ text: 'upload', link: '/config/upload' },
{ text: 'download', link: '/config/download' },
{ text: 'adapter', link: '/config/adapter' },
],
},
{
text: 'API',
items: [
{ text: 'interceptors', link: '/api/interceptors' },
{ text: 'CancelToken', link: '/api/cancel-token' },
{ text: 'isCancel', link: '/api/is-cancel' },
{ text: 'isAxiosError', link: '/api/is-axios-error' },
{ text: 'getUri', link: '/api/get-uri' },
{ text: 'create', link: '/api/create' },
{ text: 'fork', link: '/api/fork' },
{ text: 'Axios', link: '/api/axios' },
],
},
],
socialLinks: [
{ icon: 'github', link: 'https://github.com/zjx0905/axios-miniprogram' },
],
returnToTopLabel: '返回顶部',
outlineTitle: '导航栏',
darkModeSwitchLabel: '主题',
};

View File

@ -7,6 +7,7 @@
"preview": "vitepress preview"
},
"devDependencies": {
"vite-plugin-pwa": "^0.14.7",
"vitepress": "1.0.0-alpha.61"
}
}

View File

@ -14,7 +14,7 @@
"noUnusedLocals": true,
"strictNullChecks": true,
"forceConsistentCasingInFileNames": true,
"types": ["vite/client", "vite-plugin-pwa/client", "vitepress"]
"types": ["vite-plugin-pwa/client", "vitepress"]
},
"include": [
"./.vitepress/**/*.ts",

View File

@ -43,6 +43,7 @@
"test": "vitest run",
"test:watch": "vitest",
"test:cov": "vitest run --coverage",
"typecheck": "tsc --noEmit",
"lint": "eslint --cache .",
"lint:fix": "pnpm lint --fix",
"docs:dev": "pnpm -C docs dev",

File diff suppressed because it is too large Load Diff

View File

@ -3,15 +3,18 @@
"rootDir": ".",
"baseUrl": ".",
"lib": ["ESNext"],
"target": "ESNext",
"target": "es2015",
"module": "ESNext",
"strict": true,
"noEmit": true,
"moduleResolution": "node",
"skipLibCheck": true,
"skipDefaultLibCheck": true,
"paths": {
"@/*": ["src/*"]
}
},
"types": ["vitest", "vitest/globals"]
},
"include": ["./src", "./test", "./global.d.ts", "./global.variables.d.ts"],
"exclude": ["node_modules"]
"include": ["./src", "./global.d.ts", "./global.variables.d.ts"],
"exclude": ["node_modules", "**/*.md", "**/dist"]
}