零基础小白建立自己的导航网站

2021-05-04 11:27

阅读:357

YPE html>

标签:egit   增加   参考   菜鸟   plugin   不能   cee   split   修改   

前言

我就是那个零基础小白,前端、网页什么的我都没有学习过,只是有一点C#的Winform编程工作经验。做这些东西只是兴趣使然,遇到不懂的地方也只能自己找资料自学。
本文只是想记录一下自己的学习经历,也为其他有兴趣的同胞提供一些参考。
使用的是开源项目geekape/geek-navigation,这是最终的导航网站 猿导航 http://quyonghu.cn。

准备工作

开始之前,你必须准备好下面的工作:

  • 安装了node.js、npm(安装过程参考安装Node.js和npm)
  • 安装了git for windows(或者其它git客户端)
  • 代码编辑软件(我用的是VS2017)
  • 电脑连网,网速不能太差

上面这些工具是我在折腾个人博客网站和GitBook时安装好的,安装问题可以网上查找教程,这里不在赘述。
我安装的node.js是node-v10.16.0-x64、Git客户端是PortableGit-2.22.0-64,下载链接在文章末尾。

有感而发:个人博客网站现处于无限期暂停状态,主要原因是技术不够会浪费很多时间走弯路、需求也不迫切。GitBook项目处于无限期延迟状态,一方面是我太懒了一拖再拖,一方面也没有想好写什么,目前靠写博客积累经验。这里对软件进行归纳整理也是为了以后重启项目方便。做事情不能只有三分钟热度啊,哎!——2019-12-29

下载导航源代码

安装好PortableGit后会有一个git-cmd.exe,后面的所有命令都在这里面执行。
我使用的导航站源码是geek-navigation静态导航(JSON文件)版本,参照github上面的使用教程,运行命令:

// 1. 下载源码
git clone https://github.com/geekape/geek-navigation/tree/json-navigation

我的运行结果如下:

D:\blog\PortableGit>git clone https://github.com/geekape/geek-navigation/tree/js
on-navigation
Cloning into 'json-navigation'...
fatal: repository 'https://github.com/geekape/geek-navigation/tree/json-navigati
on/' not found

提示找不到,只能到github手动下载了,为了方便我的源码放在D盘根目录。

安装依赖项

参照github上面的使用教程,运行命令(记得要先进入源码的目录):

//进入源码目录
cd D:\geek-navigation-json-navigation
// 2.安装依赖,进入根目录
npm install 或 cnpm install

我的运行结果如下:

D:\blog\PortableGit>
D:\blog\PortableGit>cd D:\geek-navigation-json-navigation

D:\geek-navigation-json-navigation>npm install
npm WARN deprecated core-js@2.6.10: core-js@ yorkie@2.0.0 install D:\geek-navigation-json-navigation\node_modules\yorkie
> node bin/install.js

setting up Git hooks
can't find .git directory, skipping Git hooks installation

> node-sass@4.13.0 install D:\geek-navigation-json-navigation\node_modules\node-
sass
> node scripts/install.js

Downloading binary from https://github.com/sass/node-sass/releases/download/v4.1
3.0/win32-x64-64_binding.node
Download complete  ] - :
Binary saved to D:\geek-navigation-json-navigation\node_modules\node-sass\vendor
\win32-x64-64\binding.node
Caching binary to C:\Users\admin\AppData\Roaming\npm-cache\node-sass\4.13.0\win3
2-x64-64_binding.node

> core-js@2.6.10 postinstall D:\geek-navigation-json-navigation\node_modules\cor
e-js
> node postinstall || echo "ignore"

Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfill
ing JavaScript standard library!

The project needs your help! Please consider supporting of core-js on Open Colle
ctive or Patreon:
> https://opencollective.com/core-js
> https://www.patreon.com/zloirock

Also, the author of core-js ( https://github.com/zloirock ) is looking for a goo
d job -)


> ejs@2.7.4 postinstall D:\geek-navigation-json-navigation\node_modules\ejs
> node ./postinstall.js

Thank you for installing EJS: built with the Jake JavaScript build tool (https:/
/jakejs.com/)


> node-sass@4.13.0 postinstall D:\geek-navigation-json-navigation\node_modules\n
ode-sass
> node scripts/build.js

Binary found at D:\geek-navigation-json-navigation\node_modules\node-sass\vendor
\win32-x64-64\binding.node
Testing binary
Binary is fine
npm notice created a lockfile as package-lock.json. You should commit this file.

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules\fse
vents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@
1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"}
)

added 1486 packages from 980 contributors and audited 25243 packages in 583.07s
found 0 vulnerabilities

安装成功,我用了大概20分钟,下面就可以查看网站了。

查看网站

参照github上面的使用教程,运行命令:

// 3. 运行
npm run serve

同样要先进入源码的目录,紧接着上一步的可以直接运行命令
我的运行结果:

D:\geek-navigation-json-navigation>npm run serve

> geek-navigation@0.1.0 serve D:\geek-navigation-json-navigation
> vue-cli-service serve

 INFO  Starting development server...
98% after emitting CopyPlugin

 WARNING  Compiled with 2 warnings                                    5:45:37 PM


Module Warning (from ./node_modules/eslint-loader/index.js):
error: 'Mock' is defined but never used (no-unused-vars) at src\main.js:5:8:
  3 | import App from './App.vue'
  4 | import router from "./router"
> 5 | import Mock from "./mock"
    |        ^
  6 | import localStorage from "./utils/localStorage"
  7 | const Storage = new localStorage('NAV')
  8 | Vue.config.productionTip = false


error: Mixed spaces and tabs (no-mixed-spaces-and-tabs) at src\main.js:22:2:
  20 | new Vue({
  21 |  router,
> 22 |          render: h => h(App)
     |  ^
  23 | }).$mount('#app')
  24 |


2 errors found.

Module Warning (from ./node_modules/eslint-loader/index.js):
error: 'index' is defined but never used (vue/no-unused-vars) at src\pages\Index
.vue:18:57:
  16 |             active-text-color="#fff"
  17 |           >
> 18 |             
     |                                                         ^
  19 |               
> 23 |               
     |                                                          ^
  24 |                 
  25 |                   
  26 |                   {{nav.classify}}


2 errors found.

You may use special comments to disable some warnings.
Use // eslint-disable-next-line to ignore the next line.
Use /* eslint-disable */ to ignore all warnings in a file.

  App running at:
  - Local:   http://localhost:8080
  - Network: http://192.168.1.101:8080

  Note that the development build is not optimized.
  To create a production build, run npm run build.

接下来直接在浏览器打开localhost:8080,查看网站内容。

自定义网站内容

增加修改一级分类

找到geek-navigation-json-navigation\src\pages目录下的Index.vue文件,打开后编写自己的一级分类。我是用VS2017打开文件的,理论上可以用任何一款代码编辑器打开它。
在开始位置编写自己网站的名称,我的是“猿导航”,内容如下:


评论


亲,登录后才可以留言!