Ant Design Vue Pro

repository·master·Indexed 27 days ago

https://github.com/vuecomponent/ant-design-vue-pro

An out-of-the-box UI solution and Vue boilerplate for building enterprise applications based on Ant Design Vue 1.x for Vue 2. It includes specialized components like STable for automated data loading and IconSelector, as well as built-in support for async route mapping, permission logic, and dynamic theme color replacement via the ThemeColorReplacer plugin.

Tokens
10.2K
Snippets
27
Records
86
Agent score
92%

What's inside ant-design-vue-pro

  1. Configure webpack-bundle-analyzer in vue.config.js

    master

    Add BundleAnalyzerPlugin to the configureWebpack.plugins array in your vue.config.js file to enable dependency analysis during the build process.

    const path = require('path')
    const webpack = require('webpack')
    const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
    
    function resolve (dir) {
      return path.join(__dirname, dir)
    }
    
    // vue.config.js
    module.exports = {
      configureWebpack: {
        plugins: [
          // Ignore all locale files of moment.js
          new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
          // 依赖大小分析工具
          new BundleAnalyzerPlugin(),
        ]
      },
      
      // ...
    }
  2. Use the STable component with automated data loading

    master

    The STable component is a wrapper around the standard Ant Design Vue Table component. It simplifies pagination and data fetching by allowing you to pass a Promise directly to the :data prop. You do not need to manually handle pagination logic in your page component; the component handles it based on the returned Promise.

    <template>
      <s-table
        ref="table"
        :columns="columns"
        :data="loadData"
      />
    </template>
    
    <script>
    import STable from '@/components'
    
    export default {
      components: { STable },
      data() {
        return {
          columns: [
            { title: 'Name', dataIndex: 'name' }
          ],
          // loadData MUST return a Promise
          loadData: parameter => {
            return this.$http.get('/api/data', {
              params: parameter
            }).then(res => {
              // The component expects the result structure to contain data, pageNo, and totalCount
              return res.result
            })
          }
        }
      }
    }
    </script>
  3. Use the FooterToolbar component

    master

    The FooterToolbar is a fixed toolbar component positioned at the bottom of the content area. It remains stationary while the user scrolls, making it ideal for long pages where data collection or submission actions (like a 'Submit' button) need to be constantly accessible.

    import FooterToolBar from '@/components/FooterToolbar'
    
    export default {
        components: {
            FooterToolBar
        }
    }