客栈前端

ArvinQi 18b86e72d0 fix: bugs 6 anni fa
assets d574035d1d 背景图 6 anni fa
components 03989189cf 二维码 6 anni fa
dist abff63f8a4 generate 7 anni fa
layouts 764e0ff8d4 自动跳出处理 6 anni fa
middleware f0911cb626 注释middleware 7 anni fa
mixins e97067a31d add token 6 anni fa
pages 18b86e72d0 fix: bugs 6 anni fa
plugins 281fa41510 fix: bugs of login 6 anni fa
static 9a776359f5 techpage 的跳转 7 anni fa
store 6745cff0f4 fix: bugs of sign 6 anni fa
.editorconfig a464f8934b init 7 anni fa
.gitignore e95b9c5cef add sign 6 anni fa
.npmrc d7c577ca12 add npmrc 7 anni fa
LICENSE 38873a476d Initial commit 7 anni fa
README.md 23bf0ae2b4 文档更新 6 anni fa
app.html 699ca7492e update axios config & move baidu 6 anni fa
nuxt.config.js c6dcdf2cd2 Merge branch 'feature/27838' into dev 6 anni fa
package.json 646d235abe fix: bugs 6 anni fa
yarn.lock 646d235abe fix: bugs 6 anni fa

README.md

程序员客栈--前端项目

基于Nuxtjs,Element UI,该项目包括客栈主站和技术圈。自动化部署,dev分支自动更新到dev环境,master分支自动更新到线上环境

Build Setup 建议用yarn保证版本稳定运行

# install dependencies
$ yarn install

# serve with hot reload at localhost:3000, local.proginn.com:3000
$ yarn run dev

目录结构

.
├── LICENSE
├── README.md
├── app.html                # app html template
├── assets                  # static img css
│   ├── README.md
│   ├── css
│   └── img
├── components              # components
│   ├── README.md
│   ├── agreement.vue
│   ├── footer.vue
│   ├── group
│   ├── header.vue
│   ├── inner_header.vue
│   ├── input
│   ├── type
│   ├── ver_code.vue
│   ├── ws
│   └── wx_header.vue
├── dist                    # useless
│   ├── 200.html
│   ├── README.md
│   ├── _nuxt
│   ├── cert
│   ├── favicon.ico
│   ├── index.html
│   └── type
├── layouts                 # layout
│   ├── README.md
│   ├── default.vue
│   └── opacity_header.vue
├── middleware              # middelware useless now
│   ├── README.md
│   └── authenticated.js
├── mixins                  # mixins
│   ├── getDeviceType.js    # deviceType
│   ├── group.js
│   └── wx.js
├── nuxt.config.js          # nuxt config
├── package.json            # package.json
├── pages                   # pages(static router)
│   ├── README.md
│   ├── cert
│   ├── community
│   ├── group
│   ├── index.vue
│   ├── setting
│   ├── type
│   ├── user
│   └── wo
├── plugins
│   ├── README.md
│   ├── axios.js            # useless
│   ├── common.js           # common methods
│   ├── element.js          # element ui inject
│   ├── http.js             # useless
│   └── nuxtAxios.js        # nuxt axios config
├── static
│   ├── README.md
│   └── favicon.ico         # favicon
├── store
│   ├── README.md
│   └── index.js            # create store
└── yarn.lock               # 勿删

开发注意

  • 路由没有明确的区分技术圈和主站,所以修改之前最好确认请求路径以确认修改页面
  • 由于测试环境和线上环境cookie键值相同,所以尽量在隐身模式下测试开发环境避免不必要的麻烦
  • 开发之前需要本地设置host(127.0.0.1 local.proginn.com)以使用cookie
  • API交互格式统一application/x-www-form-urlencoded,否者无法访问成功
  • 调用API尽量只能使用Nuxtjs本身集成的Axios,使用方式 js async asyncData({ $axios, params, req }) { let id = params.id; let headers = req && req.headers; let res = await $axios.$get( `/api/user/getUserInfo?id=${id}&page=1&size=10`, { headers } ); return { title: `${res.data.info.nickname}的技术圈主页-程序员客栈` }; }, methods: { async getDetail() { let res = await this.$axios.$get( `/api/user/getUserInfo?id=${this.$route.params.id}&page=1&size=10` ); // console.log(res.data) document.title = `${res.data.info.nickname}的技术圈主页-程序员客栈`; if (res) { this.idInfo = res.data; } }, }
  • 项目全局使用Vuex作为状态管理保存登录状态,可以调用全局store获取userInfo
  • 使用mixins实现设备判断,设备状态包括pc,ios,android,通过this.deviceType可以获取
  • 路由鉴权未实现,有接口不同页面需要不同处理,即使API返回都是未登录可能也不要跳转到登录页