# vue admin template 自己不断修改的vue admin 模板 ## 全局的form表单验证 ```html 提交 ``` ## 需要共享的全局枚举参数 > 全部放在`@/utils/enum.js`里面,已全部挂载到Vue.prototype下面 ## 需要共享的全局方法 > 全部放在`@/utils/filter.js`里面,已全部挂载到Vue.prototype下面 ## 所有的api请求 > 统一的axios参数在`@/api/index.js`下面,已全部挂载到Vue.prototype下面 ```js // 具体使用方法,例: // methods: { async handleSubmit() { this.$refs.form.validate(async valid => { if (valid) { // this.$fetch第三个参数可选,默认'post',如果是使用get方法,第三个参数传'get' const data = await this.$fetch('/v1/front/otherApi', { ...this.form }) if (data.code === 0) { this.$message.success('提交成功') this.$emit('success') this.dialog = false } else { this.reloadImg() } } }) } , } ``` ## dialog弹窗 > dialog弹窗尽量使用组件引入,dialog例子在`@/components/_dialog/exampleDialog`里面 ```html ``` ## 表格统一分页,统一风格 > 使用`@/mixin/page.js` 使用前最好看一下 > 下面例子包含了表格统一和全局枚举(enum)的应用 ```js // 页面引用js部分 import page from '@/mixin/page' export default { mixins: [page], data() { return { time: [], searchForm: {}, tableData: [], tableUrl: '/v1/front/user/list' } }, methods: {}, mounted() { this.init() }, } ``` ```html ``` ## other 1. 有一些不需要放在vuex下面的,可以使用事件总线$bus,在`@/utils/vue-bus.js`里面。 ## 需要node环境,最好在v10以上 --- ### npm可以用,最好使用yarn ```bash #npm 更换淘宝源 npm config set registry https://registry.npm.taobao.org # 安装yarn npm install yarn -g #yarn 更换淘宝源 yarn config set registry https://registry.npm.taobao.org -g #yarn 和 npm 设置 node-sass 参数 npm config set sass_binary_site=s://npm.taobao.org/mirrors/node-sass/ -g yarn config set sass_binary_site https://npm.taobao.org/mirrors/node-sass/ -g #npm 和 yarn 都设置一下puppeteer的下载参数 (暂时还不需要,如使用puppeteer服务器预渲染则需要设置) // npm config set puppeteer_download_host=https://npm.taobao.org/mirrors // yarn config set puppeteer_download_host https://npm.taobao.org/mirrors ``` ### 安装依赖 ```bash yarn ## or npm i ``` ### 如果涉及到服务器预渲染,就需要下面依赖 ```bash # ubuntu sudo apt install -y gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget #centos sudo yum install pango.x86_64 libXcomposite.x86_64 libXcursor.x86_64 libXdamage.x86_64 libXext.x86_64 libXi.x86_64 libXtst.x86_64 cups-libs.x86_64 libXScrnSaver.x86_64 libXrandr.x86_64 GConf2.x86_64 alsa-lib.x86_64 atk.x86_64 gtk3.x86_64 ipa-gothic-fonts xorg-x11-fonts-100dpi xorg-x11-fonts-75dpi xorg-x11-utils xorg-x11-fonts-cyrillic xorg-x11-fonts-Type1 xorg-x11-fonts-misc ``` ### 最后 打包 ```bash npm run build ## or yarn build ``` ### 项目原型 [1.0.2](https://lanhuapp.com/web/#/item/project/product?tid=5ddf565c-cf9f-4c95-93a2-3562c922f9fe&pid=9277d254-dab7-44a5-80d6-6b509e98bd9a&docId=5e8445f1-9d3d-442d-b920-6181c1c4dd1d&docType=axure&image_id=5e8445f1-9d3d-442d-b920-6181c1c4dd1d&type=share_mark&tab=product&teamId=5ddf565c-cf9f-4c95-93a2-3562c922f9fe&parentId=4b6c220ce9af44048d1651a1b0795083&versionId=3a98d574-5fa1-4cb5-a103-ec645aefe419&pageId=3eff6d883532438d9890fc7998f53c8d) [1.0.3](https://lanhuapp.com/web/#/item/project/product?pid=ccbe8173-3fc4-4d09-848a-3a679c2fd9a2&image_id=26c030c2-8554-424b-a66f-6a33aea4aaea&tid=5ddf565c-cf9f-4c95-93a2-3562c922f9fe&versionId=afe58104-7c7c-40ce-a0e0-627a692801a3&docId=26c030c2-8554-424b-a66f-6a33aea4aaea&docType=axure&pageId=4b6c220ce9af44048d1651a1b0795083&parentId=4240400d-9285-4c11-a54e-098316aff4e1) [1.0.4](https://lanhuapp.com/web/#/item/project/product?type=share_mark&tab=product&pid=a715254b-1cd9-4ab9-a65b-71495f4acfcd&versionId=72acd672-e782-453f-8e5c-c66da20fc485&docId=c16df015-ec8c-4b40-8bd1-898d9784b553&image_id=c16df015-ec8c-4b40-8bd1-898d9784b553&docType=axure&imgId=undefined&pageId=84926059225646a8858112580ff22023&teamId=5ddf565c-cf9f-4c95-93a2-3562c922f9fe&parentId=6a82f9603eab434eacf5530268367328) [1.0.7](https://lanhuapp.com/web/#/item/project/product?type=share_mark&tab=product&pid=857f3c51-346e-4241-bfc6-e4523804873f&versionId=ee98571f-c7d9-4459-a07d-ae7229d281e4&docId=780445f9-f1fe-4f3b-b984-fc9addc32cc8&image_id=780445f9-f1fe-4f3b-b984-fc9addc32cc8&docType=axure&imgId=undefined&pageId=0b087cc077684fc7bfe6934c381964d3&teamId=5ddf565c-cf9f-4c95-93a2-3562c922f9fe) ### 接口地址 [API](https://docs.apipost.cn/preview/daaffe406af38896/222cebb9efb6a71e?target_id=d464d242-326f-4385-86c8-053e7e0c92ff#d464d242-326f-4385-86c8-053e7e0c92ff) ### 页面地址 [测试](http://swago-admin.codedreamit.com/login) [生产](http://admin.swago.cn/login)