From baa5869fe58531bace3badc86a9cb41e64e5dbba Mon Sep 17 00:00:00 2001 From: zuiidea Date: Sun, 16 Sep 2018 23:38:17 +0800 Subject: [PATCH] doc:Initialize --- .eslintignore | 3 +- docs/_sidebar.md | 8 ++++ docs/configuration.md | 0 docs/deploy.md | 0 docs/index.html | 39 +++++++++++++++-- docs/quickstart.md | 1 + docs/sw.js | 83 +++++++++++++++++++++++++++++++++++++ docs/zh-cn/README.md | 1 + docs/zh-cn/_sidebar.md | 8 ++++ docs/zh-cn/configuration.md | 0 docs/zh-cn/deploy.md | 0 docs/zh-cn/quickstart.md | 1 + package.json | 3 +- 13 files changed, 141 insertions(+), 6 deletions(-) create mode 100644 docs/_sidebar.md create mode 100644 docs/configuration.md create mode 100644 docs/deploy.md create mode 100644 docs/quickstart.md create mode 100644 docs/sw.js create mode 100644 docs/zh-cn/README.md create mode 100644 docs/zh-cn/_sidebar.md create mode 100644 docs/zh-cn/configuration.md create mode 100644 docs/zh-cn/deploy.md create mode 100644 docs/zh-cn/quickstart.md diff --git a/.eslintignore b/.eslintignore index de014a1..96a82df 100644 --- a/.eslintignore +++ b/.eslintignore @@ -3,4 +3,5 @@ src/public src/routes/chart/ECharts/theme src/routes/chart/highCharts/mapdata src/locales/_build/ -src/locales/**/*.js \ No newline at end of file +src/locales/**/*.js +docs/**/*.js diff --git a/docs/_sidebar.md b/docs/_sidebar.md new file mode 100644 index 0000000..b323620 --- /dev/null +++ b/docs/_sidebar.md @@ -0,0 +1,8 @@ +- Getting started + - [Quick Start](quickstart.md) +- Customization + - [Configuration](configuration.md) +- Guide + - [Deploy](deploy.md) +- Changelog + - 5.0.0 diff --git a/docs/configuration.md b/docs/configuration.md new file mode 100644 index 0000000..e69de29 diff --git a/docs/deploy.md b/docs/deploy.md new file mode 100644 index 0000000..e69de29 diff --git a/docs/index.html b/docs/index.html index 586611f..cec1d27 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1,5 +1,6 @@ + antd-admin - An admin dashboard application demo built upon Ant Design and UmiJS @@ -8,14 +9,44 @@ + -
+ +
Loading...
+ + + - + + \ No newline at end of file diff --git a/docs/quickstart.md b/docs/quickstart.md new file mode 100644 index 0000000..21b5e03 --- /dev/null +++ b/docs/quickstart.md @@ -0,0 +1 @@ +# getting-started diff --git a/docs/sw.js b/docs/sw.js new file mode 100644 index 0000000..cf6295c --- /dev/null +++ b/docs/sw.js @@ -0,0 +1,83 @@ +/* =========================================================== + * docsify sw.js + * =========================================================== + * Copyright 2016 @huxpro + * Licensed under Apache 2.0 + * Register service worker. + * ========================================================== */ + +const RUNTIME = 'docsify' +const HOSTNAME_WHITELIST = [ + self.location.hostname, + 'fonts.gstatic.com', + 'fonts.googleapis.com', + 'unpkg.com' +] + +// The Util Function to hack URLs of intercepted requests +const getFixedUrl = (req) => { + var now = Date.now() + var url = new URL(req.url) + + // 1. fixed http URL + // Just keep syncing with location.protocol + // fetch(httpURL) belongs to active mixed content. + // And fetch(httpRequest) is not supported yet. + url.protocol = self.location.protocol + + // 2. add query for caching-busting. + // Github Pages served with Cache-Control: max-age=600 + // max-age on mutable content is error-prone, with SW life of bugs can even extend. + // Until cache mode of Fetch API landed, we have to workaround cache-busting with query string. + // Cache-Control-Bug: https://bugs.chromium.org/p/chromium/issues/detail?id=453190 + if (url.hostname === self.location.hostname) { + url.search += (url.search ? '&' : '?') + 'cache-bust=' + now + } + return url.href +} + +/** + * @Lifecycle Activate + * New one activated when old isnt being used. + * + * waitUntil(): activating ====> activated + */ +self.addEventListener('activate', event => { + event.waitUntil(self.clients.claim()) +}) + +/** + * @Functional Fetch + * All network requests are being intercepted here. + * + * void respondWith(Promise r) + */ +self.addEventListener('fetch', event => { + // Skip some of cross-origin requests, like those for Google Analytics. + if (HOSTNAME_WHITELIST.indexOf(new URL(event.request.url).hostname) > -1) { + // Stale-while-revalidate + // similar to HTTP's stale-while-revalidate: https://www.mnot.net/blog/2007/12/12/stale + // Upgrade from Jake's to Surma's: https://gist.github.com/surma/eb441223daaedf880801ad80006389f1 + const cached = caches.match(event.request) + const fixedUrl = getFixedUrl(event.request) + const fetched = fetch(fixedUrl, { cache: 'no-store' }) + const fetchedCopy = fetched.then(resp => resp.clone()) + + // Call respondWith() with whatever we get first. + // If the fetch fails (e.g disconnected), wait for the cache. + // If there’s nothing in cache, wait for the fetch. + // If neither yields a response, return offline pages. + event.respondWith( + Promise.race([fetched.catch(_ => cached), cached]) + .then(resp => resp || fetched) + .catch(_ => { /* eat any errors */ }) + ) + + // Update the cache with the version we fetched (only for ok status) + event.waitUntil( + Promise.all([fetchedCopy, caches.open(RUNTIME)]) + .then(([response, cache]) => response.ok && cache.put(event.request, response)) + .catch(_ => { /* eat any errors */ }) + ) + } +}) \ No newline at end of file diff --git a/docs/zh-cn/README.md b/docs/zh-cn/README.md new file mode 100644 index 0000000..3a988af --- /dev/null +++ b/docs/zh-cn/README.md @@ -0,0 +1 @@ +# Antd Admin diff --git a/docs/zh-cn/_sidebar.md b/docs/zh-cn/_sidebar.md new file mode 100644 index 0000000..a09572f --- /dev/null +++ b/docs/zh-cn/_sidebar.md @@ -0,0 +1,8 @@ +- 入门 + - [快速开始](quickstart.md) +- 定制化 + - [配置项](configuration.md) +- 指南 + - [部署](deploy.md) +- 更新日志 + - 5.0.0 diff --git a/docs/zh-cn/configuration.md b/docs/zh-cn/configuration.md new file mode 100644 index 0000000..e69de29 diff --git a/docs/zh-cn/deploy.md b/docs/zh-cn/deploy.md new file mode 100644 index 0000000..e69de29 diff --git a/docs/zh-cn/quickstart.md b/docs/zh-cn/quickstart.md new file mode 100644 index 0000000..21b5e03 --- /dev/null +++ b/docs/zh-cn/quickstart.md @@ -0,0 +1 @@ +# getting-started diff --git a/package.json b/package.json index db24481..c7aa94b 100644 --- a/package.json +++ b/package.json @@ -100,6 +100,7 @@ "prettier": "prettier --write 'src/**/*'", "precommit": "lint-staged", "add-locale": "lingui add-locale", - "extract": "lingui extract" + "extract": "lingui extract", + "doc": "docsify serve docs" } }