1 Star 0 Fork 76

mailzhb / vue-admin-block

forked from ldy31325755 / vue-admin-block 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

Demo: http://vab.cssue.com/

  • Username: admin
  • Password: wasd@007

特性

  1. 基于 Vue.js 的企业级中后台开源集成方案
  2. 基于 Vue 官方命令行工具 Vue CLI 3 脚手架搭建
  3. 使用 Vue 官方核心插件 Vue Router, Vuex
  4. 使用 Vue 官方建议的 Axios 插件进行 HTTP 操作
  5. 采用时下热门的 UI 组件库 iView
  6. 通过 Mock.js 插件拦截 Ajax 请求并生成随机数据
  7. 使用 cssnext 预处理 编写样式

开发构建

目录结构

├── /public            # 静态文件
├── /src               # 源码目录
│ ├── /assets          # 静态资源
│ ├── /components      # 公共组件
│ ├── /layouts         # 布局组件
│ ├── /mock            # 数据模拟
│ ├── /router          # 路由配置
│ ├── /services        # 数据接口
│ ├── /store           # vuex状态管理
│ ├── /utils           # 工具库
│ ├── /views           # 路由组件(页面维度)
│ ├── App.vue          # 组件入口
│ ├── config.js        # 应用配置
│ └── main.js          # 应用入口
├── .editorconfig      # 定义代码格式
├── .env.development   # 开发环境
├── .env.production    # 生产环境
├── .env.release       # 预生产环境
├── .env.test          # 测试环境
├── .gitignore         # git忽视
├── babel.config.js    # ES6语法编译配置
├── LICENSE            # 版权信息
├── package.json       # 依赖包
├── README.md          # 项目文档
└── vue.config.js      # 项目配置

开发流程

Step 1, 新建路由组件(测试)views/Test.vue

<template>
  <Content id="test">
    <Spin v-if="loading" size="large" fix />
    <h2>This is a {{ title }}</h2>
  </Content>
</template>
<script>
import {
  _test // 测试接口
} from '@/services/test' // 接口文件
export default {
  name: 'Test', // 组件名称
  data: () => ({
    title: '',
    loading: false
  }),
  mounted() {
    this.$Loading.start()
    this.loading = true
    // 模拟异步请求
    setTimeout(() => {
      _test().then(res => {
        this.$Loading.finish()
        this.loading = false
        this.title = res.data
      }).catch(err => {
        this.$Loading.error()
        this.loading = false
        console.error(err)
      })
    }, 500)
  }
}
</script>
<style lang="postcss" scoped>
/* 样式使用 cssnext 预处理 */
:root {
  --bdColor: #ccc;
}
#test {
  & h2 {
    border-left: 4px solid var(--bdColor);
    padding-left: 12px;
  }
}
</style>

Step 2, 添加临时菜单(测试)mock/app.js

import Mock from "mockjs";

export default () => {
  Mock.mock(/\/menu/, {
    data: [
      {
        path: "/test", // 路由地址
        name: "Test", // 菜单名称
        icon: "md-document", // 菜单 Icon 图标
        compName: "Test", // 组件名称
        compPath: "/Test" // 组件地址( 默认指向 src/views 路由组件目录
      }
    ]
  });
};

* 注意

  1. 添加临时菜单需要重新登录才能更新新菜单
  2. 因为路由是通过菜单动态生成,所以无需再为项目配置路由

Step 3, 新建接口管理文件(测试) services/test.js

import ax from "@/utils/axios";

export const _test = () => ax.get("/test"); // 测试接口

* 提示

  • 如果后端提供正式接口,那么无须再模拟假数据,直接跳过 Step 4 和 Step 5
  • 如需使用 vuex 管理状态, 请阅读 src/layouts/partials/Sidebar.vue 组件和 src/store 目录源码

Step 4, 新建数据模拟文件(测试) mock/test.js

import Mock from "mockjs";

export default () => {
  Mock.mock(/\/test/, () => ({
    data: "test page" // 测试数据
  }));
};

Step 5, 使用数据模拟文件(测试) mock/index.js

import test from "./test";

export default () => {
  test(); // 测试
};

快速开始

Step 1, 安装依赖:

# 安装依赖
yarn
# 或
npm i

Step 2, 开发:

yarn start
# 或
npm start

Step 3, 构建:

# 构建最小测试
yarn test
# 或
npm test

# 构建最小预发布
yarn release
# 或
npm run release

# 构建最小生产
yarn build
# 或
npm run build
The MIT License (MIT) Copyright (c) 2019 ldy505755 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

基于 Vue, Vue Router, Vuex, Axios, iView, Mock.js 企业级中后台管理系统典型模板 展开 收起
JavaScript
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
JavaScript
1
https://gitee.com/mailzhb/vue-admin-block.git
git@gitee.com:mailzhb/vue-admin-block.git
mailzhb
vue-admin-block
vue-admin-block
master

搜索帮助

14c37bed 8189591 565d56ea 8189591