diff --git a/.gitignore b/.gitignore index 0575e5f..1315aa7 100644 --- a/.gitignore +++ b/.gitignore @@ -9,7 +9,4 @@ node_modules docs/.vuepress/dist # 百度链接推送 -urls.txt - -#其他 -SearchBox.vue \ No newline at end of file +urls.txt \ No newline at end of file diff --git a/docs/.vuepress/config.js b/docs/.vuepress/config.js index 4a6716a..64865dc 100644 --- a/docs/.vuepress/config.js +++ b/docs/.vuepress/config.js @@ -36,10 +36,13 @@ module.exports = { plugins: [ // 插件 require('./plugins/love-me'), // 鼠标点击爱心特效 require('./plugins/title-badge'), // h1标题徽章 + + require('./plugins/enhanced-search'), // 增强型搜索框 + 'vuepress-plugin-baidu-autopush', // 百度自动推送,作用:加快将页面推送给百度搜索 '@vuepress/back-to-top', // 返回顶部 - // ['@vuepress/search', { + // ['@vuepress/search', { ` // searchMaxSuggestions: 10 // }], diff --git a/docs/.vuepress/plugins/enhanced-search/EnhancedSearchBox.vue b/docs/.vuepress/plugins/enhanced-search/EnhancedSearchBox.vue new file mode 100644 index 0000000..b593855 --- /dev/null +++ b/docs/.vuepress/plugins/enhanced-search/EnhancedSearchBox.vue @@ -0,0 +1,304 @@ + + + + + diff --git a/docs/.vuepress/plugins/enhanced-search/README.md b/docs/.vuepress/plugins/enhanced-search/README.md new file mode 100644 index 0000000..f38dc14 --- /dev/null +++ b/docs/.vuepress/plugins/enhanced-search/README.md @@ -0,0 +1,18 @@ +# Enhanced-search + +此插件`Enhanced-search` 是基于官方的搜索框插件 [@vuepress/plugin-search](https://github.com/vuejs/vuepress/tree/master/packages/@vuepress/plugin-search) 做了功能添加,添加的功能如下: + +* 在搜索结果最底部添加了 `在MDN中搜索'xxx'` 和 `在Runoob中搜索'xxx'` 选项。 + + + +### 使用 + +在`config.js`的`plugins`选项添加插件: + +```js +require('./plugins/enhanced-search') +``` + +此插件会覆盖原本的 `plugin-search` 插件,但参数选项和 `plugin-search` 插件完全一致。 + diff --git a/docs/.vuepress/plugins/enhanced-search/index.js b/docs/.vuepress/plugins/enhanced-search/index.js new file mode 100644 index 0000000..c6b3c45 --- /dev/null +++ b/docs/.vuepress/plugins/enhanced-search/index.js @@ -0,0 +1,14 @@ +const { path } = require('@vuepress/shared-utils') + +module.exports = (options) => ({ + alias: { + '@SearchBox': + path.resolve(__dirname, 'EnhancedSearchBox.vue') + }, + + define: { + SEARCH_MAX_SUGGESTIONS: options.searchMaxSuggestions || 5, + SEARCH_PATHS: options.test || null, + SEARCH_HOTKEYS: options.searchHotkeys || ['s', '/'] + } +}) \ No newline at end of file diff --git a/docs/.vuepress/plugins/enhanced-search/search.svg b/docs/.vuepress/plugins/enhanced-search/search.svg new file mode 100644 index 0000000..03d8391 --- /dev/null +++ b/docs/.vuepress/plugins/enhanced-search/search.svg @@ -0,0 +1 @@ + diff --git a/docs/01.前端/30.Vue文章/40.Vue项目使用mock数据的几种方式.md b/docs/01.前端/30.Vue文章/40.Vue项目使用mock数据的几种方式.md index e8685dc..fa3713d 100644 --- a/docs/01.前端/30.Vue文章/40.Vue项目使用mock数据的几种方式.md +++ b/docs/01.前端/30.Vue文章/40.Vue项目使用mock数据的几种方式.md @@ -105,7 +105,7 @@ permalink: /pages/bd1af2f75fd361fc 3. 最后,在vue模板中使用即可 ```js - axios.get('/api/test.json') + axios.get('/api/test.json') // 注意这里需要.json后缀 .then(function(res){ console.log(res); })