Skip to content

Commit

Permalink
!3 cdn version
Browse files Browse the repository at this point in the history
Merge pull request !3 from 工作专用/master
  • Loading branch information
工作专用 authored and zhangmrit committed Jun 18, 2019
1 parent b7e1132 commit eead7ea
Show file tree
Hide file tree
Showing 21 changed files with 177 additions and 36 deletions.
14 changes: 7 additions & 7 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ module.exports = {
]
], // if your use import on Demand, Use this code

plugins: [
[ 'import', {
'libraryName': 'ant-design-vue',
'libraryDirectory': 'es',
'style': true // `style: true` 会加载 less 文件
} ]
]
// plugins: [
// [ 'import', {
// 'libraryName': 'ant-design-vue',
// 'libraryDirectory': 'es',
// 'style': true // `style: true` 会加载 less 文件
// } ]
// ]
}
5 changes: 5 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>logo.png">
<title>RUOYI ANT</title>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/moment.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/locale/zh-cn.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/antd.min.css"/>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/antd.min.js"></script>
<style>#loading-mask{position:fixed;left:0;top:0;height:100%;width:100%;background:#fff;user-select:none;z-index:9999;overflow:hidden}.loading-wrapper{position:absolute;top:50%;left:50%;transform:translate(-50%,-100%)}.loading-dot{animation:antRotate 1.2s infinite linear;transform:rotate(45deg);position:relative;display:inline-block;font-size:64px;width:64px;height:64px;box-sizing:border-box}.loading-dot i{width:22px;height:22px;position:absolute;display:block;background-color:#1890ff;border-radius:100%;transform:scale(.75);transform-origin:50% 50%;opacity:.3;animation:antSpinMove 1s infinite linear alternate}.loading-dot i:nth-child(1){top:0;left:0}.loading-dot i:nth-child(2){top:0;right:0;-webkit-animation-delay:.4s;animation-delay:.4s}.loading-dot i:nth-child(3){right:0;bottom:0;-webkit-animation-delay:.8s;animation-delay:.8s}.loading-dot i:nth-child(4){bottom:0;left:0;-webkit-animation-delay:1.2s;animation-delay:1.2s}@keyframes antRotate{to{-webkit-transform:rotate(405deg);transform:rotate(405deg)}}@-webkit-keyframes antRotate{to{-webkit-transform:rotate(405deg);transform:rotate(405deg)}}@keyframes antSpinMove{to{opacity:1}}@-webkit-keyframes antSpinMove{to{opacity:1}}</style>
</head>
<body>
Expand Down
5 changes: 4 additions & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@
</template>

<script>
import zhCN from 'ant-design-vue/lib/locale-provider/zh_CN'
// import zhCN from 'ant-design-vue/lib/locale-provider/zh_CN'
import { locales } from 'ant-design-vue'
import { AppDeviceEnquire } from '@/utils/mixin'
const zhCN = locales.zh_CN
export default {
mixins: [AppDeviceEnquire],
data () {
Expand Down
3 changes: 1 addition & 2 deletions src/components/AvatarList/Item.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
</template>

<script>
import Avatar from 'ant-design-vue/es/avatar'
import Tooltip from 'ant-design-vue/es/tooltip'
import { Avatar, Tooltip } from 'ant-design-vue'
export default {
name: 'AvatarItem',
Expand Down
2 changes: 1 addition & 1 deletion src/components/AvatarList/List.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
-->

<script>
import Avatar from 'ant-design-vue/es/avatar'
import { Avatar } from 'ant-design-vue'
import AvatarItem from './Item'
import { filterEmpty } from '@/components/_util/util'

Expand Down
2 changes: 1 addition & 1 deletion src/components/DescriptionList/DescriptionList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</template>

<script>
import { Col } from 'ant-design-vue/es/grid/'
import { Col } from 'ant-design-vue'
const Item = {
name: 'DetailListItem',
Expand Down
2 changes: 1 addition & 1 deletion src/components/Ellipsis/Ellipsis.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script>
import Tooltip from 'ant-design-vue/es/tooltip'
import { Tooltip } from 'ant-design-vue'
import { cutStrByFullLength, getStrFullLength } from '@/components/_util/util'
/*
const isSupportLineClamp = document.body.style.webkitLineClamp !== undefined;
Expand Down
3 changes: 1 addition & 2 deletions src/components/Menu/menu.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Menu from 'ant-design-vue/es/menu'
import Icon from 'ant-design-vue/es/icon'
import { Menu, Icon } from 'ant-design-vue'

const { Item, SubMenu } = Menu

Expand Down
4 changes: 2 additions & 2 deletions src/components/Menu/menu.render.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Menu from 'ant-design-vue/es/menu'
import Icon from 'ant-design-vue/es/icon'
import { Menu } from 'ant-design-vue'
import { Icon } from 'ant-design-vue'

const { Item, SubMenu } = Menu

Expand Down
2 changes: 1 addition & 1 deletion src/components/NumberInfo/NumberInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</template>

<script>
import Icon from 'ant-design-vue/es/icon'
import { Icon } from 'ant-design-vue'
export default {
name: 'NumberInfo',
Expand Down
2 changes: 1 addition & 1 deletion src/components/SettingDrawer/settingConfig.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { message } from 'ant-design-vue/es'
import { Message as message } from 'ant-design-vue'
// import defaultSettings from '../defaultSettings';
import themeColor from './themeColor.js'

Expand Down
2 changes: 1 addition & 1 deletion src/components/Table/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import T from 'ant-design-vue/es/table/Table'
import { Table as T } from 'ant-design-vue'
import get from 'lodash.get'

export default {
Expand Down
2 changes: 1 addition & 1 deletion src/permission.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import store from './store'

import NProgress from 'nprogress' // progress bar
import 'nprogress/nprogress.css' // progress bar style
import notification from 'ant-design-vue/es/notification'
import { Notification as notification } from 'ant-design-vue'
import { ACCESS_TOKEN } from '@/store/mutation-types'

NProgress.configure({ showSpinner: false }) // NProgress Configuration
Expand Down
3 changes: 2 additions & 1 deletion src/utils/filter.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Vue from 'vue'
import moment from 'moment'
import 'moment/locale/zh-cn'
// 已从cdn加载
// import 'moment/locale/zh-cn'
moment.locale('zh-cn')

Vue.filter('NumberFormat', function (value) {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import store from '@/store'
import {
VueAxios
} from './axios'
import notification from 'ant-design-vue/es/notification'
import { Notification as notification } from 'ant-design-vue'
import {
ACCESS_TOKEN
} from '@/store/mutation-types'
Expand Down
4 changes: 1 addition & 3 deletions src/views/account/settings/Custom.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@

<script>
import { updateTheme, colorList } from '@/components/SettingDrawer/settingConfig'
import ASwitch from 'ant-design-vue/es/switch'
import AList from 'ant-design-vue/es/list'
import AListItem from 'ant-design-vue/es/list/Item'
import { Switch as ASwitch, List as AList, ListItem as AListItem } from 'ant-design-vue'
import { mixin } from '@/utils/mixin'
const Meta = AListItem.Meta
Expand Down
4 changes: 2 additions & 2 deletions src/views/list/QueryList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

<script>
import ATextarea from 'ant-design-vue/es/input/TextArea'
import AInput from 'ant-design-vue/es/input/Input'
import { Textarea as ATextarea } from 'ant-design-vue'
import { Input as AInput } from 'ant-design-vue'
// 动态切换组件
import List from '@/views/list/table/List'
import Edit from '@/views/list/table/Edit'
Expand Down
2 changes: 1 addition & 1 deletion src/views/system/DeptList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
</template>

<script>
import T from 'ant-design-vue/es/table/Table'
import { Table as T } from 'ant-design-vue'
import { getDeptList, delDept } from '@/api/system'
import DeptModal from './modules/DeptModal.vue'
import { treeData } from '@/utils/treeutil'
Expand Down
2 changes: 1 addition & 1 deletion src/views/system/PermissionList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
</template>

<script>
import T from 'ant-design-vue/es/table/Table'
import { Table as T } from 'ant-design-vue'
import { getPermissions, delPerm } from '@/api/system'
import PermissionModal from './modules/PermissionModal.vue'
import { treeData } from '@/utils/treeutil'
Expand Down
130 changes: 130 additions & 0 deletions src/zmr.vue.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
const path = require('path')
const webpack = require('webpack')
const ThemeColorReplacer = require('webpack-theme-color-replacer')
const generate = require('@ant-design/colors/lib/generate').default

function resolve (dir) {
return path.join(__dirname, dir)
}

// vue.config.js
module.exports = {
configureWebpack: {
externals: {
'axios': 'axios',
'vue-router': 'VueRouter',
'vuex': 'Vuex',
'vue': 'Vue',
'moment': 'moment',
'ant-design-vue': 'antd'
},
plugins: [
// Ignore all locale files of moment.js
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
new webpack.IgnorePlugin(/moment\\/),
// 生成仅包含颜色的替换样式(主题色等)
// TODO 需要增加根据环境不开启主题需求
new ThemeColorReplacer({
fileName: 'css/theme-colors.css', // TODO 需要处理的暗坑
matchColors: getAntdSerials('#1890ff'), // 主色系列
// 改变样式选择器,解决样式覆盖问题
changeSelector (selector) {
switch (selector) {
case '.ant-calendar-today .ant-calendar-date':
return ':not(.ant-calendar-selected-date)' + selector
case '.ant-btn:focus,.ant-btn:hover':
return '.ant-btn:focus:not(.ant-btn-primary),.ant-btn:hover:not(.ant-btn-primary)'
case '.ant-btn.active,.ant-btn:active':
return '.ant-btn.active:not(.ant-btn-primary),.ant-btn:active:not(.ant-btn-primary)'
case '.ant-menu-horizontal>.ant-menu-item-active,.ant-menu-horizontal>.ant-menu-item-open,.ant-menu-horizontal>.ant-menu-item-selected,.ant-menu-horizontal>.ant-menu-item:hover,.ant-menu-horizontal>.ant-menu-submenu-active,.ant-menu-horizontal>.ant-menu-submenu-open,.ant-menu-horizontal>.ant-menu-submenu-selected,.ant-menu-horizontal>.ant-menu-submenu:hover':
case '.ant-menu-horizontal > .ant-menu-item-active,.ant-menu-horizontal > .ant-menu-item-open,.ant-menu-horizontal > .ant-menu-item-selected,.ant-menu-horizontal > .ant-menu-item:hover,.ant-menu-horizontal > .ant-menu-submenu-active,.ant-menu-horizontal > .ant-menu-submenu-open,.ant-menu-horizontal > .ant-menu-submenu-selected,.ant-menu-horizontal > .ant-menu-submenu:hover':
return '.ant-menu-horizontal > .ant-menu-item-active,.ant-menu-horizontal > .ant-menu-item-open,.ant-menu-horizontal > .ant-menu-item-selected,.ant-menu-horizontal > .ant-menu-item:hover,.ant-menu-horizontal > .ant-menu-submenu-active,.ant-menu-horizontal > .ant-menu-submenu-open,.ant-menu-horizontal:not(.ant-menu-dark) > .ant-menu-submenu-selected,.ant-menu-horizontal:not(.ant-menu-dark) > .ant-menu-submenu:hover'
default :
return selector
}
}
})
]
},

chainWebpack: (config) => {
config.resolve.alias
.set('@$', resolve('src'))

const svgRule = config.module.rule('svg')
svgRule.uses.clear()
svgRule
.oneOf('inline')
.resourceQuery(/inline/)
.use('vue-svg-icon-loader')
.loader('vue-svg-icon-loader')
.end()
.end()
.oneOf('external')
.use('file-loader')
.loader('file-loader')
.options({
name: 'assets/[name].[hash:8].[ext]'
})
/* svgRule.oneOf('inline')
.resourceQuery(/inline/)
.use('vue-svg-loader')
.loader('vue-svg-loader')
.end()
.end()
.oneOf('external')
.use('file-loader')
.loader('file-loader')
.options({
name: 'assets/[name].[hash:8].[ext]'
})
*/
},

css: {
loaderOptions: {
less: {
modifyVars: {
/* less 变量覆盖,用于自定义 ant design 主题 */

/*
'primary-color': '#F5222D',
'link-color': '#F5222D',
'border-radius-base': '4px',
*/
},
javascriptEnabled: true
}
}
},

devServer: {
// development server port 8000
port: 8000,
proxy: {
'/api': {
// target: 'https://mock.ihx.me/mock/5baf3052f7da7e07e04a5116/antd-pro',
target: 'https://www.easy-mock.com/mock/5ce2743c2dda2d3b1365fb1b/ruoyi-cloud',
// target: 'http://myzuul.com:9527',
pathRewrite: { '^/api': '' },
ws: false,
changeOrigin: true
}
}
},

// disable source map in production
productionSourceMap: false,
lintOnSave: undefined,
// babel-loader no-ignore node_modules/*
transpileDependencies: []
}

function getAntdSerials (color) {
// 淡化(即less的tint)
const lightens = new Array(9).fill().map((t, i) => {
return ThemeColorReplacer.varyColor.lighten(color, i / 10)
})
const colorPalettes = generate(color)
return lightens.concat(colorPalettes)
}
18 changes: 12 additions & 6 deletions vue.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,24 @@ function resolve (dir) {
// vue.config.js
module.exports = {
configureWebpack: {
externals: {
// key表示包名(import foo from 'xx' 里的xx)
// value表示window下的全局变量名(库暴露出来的namespace,可查lib对应的webpack配置里的library字段)
'vue': 'Vue',
'moment': 'moment',
'ant-design-vue': 'antd'
},
plugins: [
// Ignore all locale files of moment.js
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
new webpack.IgnorePlugin(/moment\//),
// 生成仅包含颜色的替换样式(主题色等)
// TODO 需要增加根据环境不开启主题需求
new ThemeColorReplacer({
fileName: 'css/theme-colors.css', // TODO 需要处理的暗坑
matchColors: getAntdSerials('#1890ff'), // 主色系列
// 改变样式选择器,解决样式覆盖问题
changeSelector (selector) {
changeSelector(selector) {
switch (selector) {
case '.ant-calendar-today .ant-calendar-date':
return ':not(.ant-calendar-selected-date)' + selector
Expand All @@ -30,17 +38,16 @@ module.exports = {
case '.ant-menu-horizontal>.ant-menu-item-active,.ant-menu-horizontal>.ant-menu-item-open,.ant-menu-horizontal>.ant-menu-item-selected,.ant-menu-horizontal>.ant-menu-item:hover,.ant-menu-horizontal>.ant-menu-submenu-active,.ant-menu-horizontal>.ant-menu-submenu-open,.ant-menu-horizontal>.ant-menu-submenu-selected,.ant-menu-horizontal>.ant-menu-submenu:hover':
case '.ant-menu-horizontal > .ant-menu-item-active,.ant-menu-horizontal > .ant-menu-item-open,.ant-menu-horizontal > .ant-menu-item-selected,.ant-menu-horizontal > .ant-menu-item:hover,.ant-menu-horizontal > .ant-menu-submenu-active,.ant-menu-horizontal > .ant-menu-submenu-open,.ant-menu-horizontal > .ant-menu-submenu-selected,.ant-menu-horizontal > .ant-menu-submenu:hover':
return '.ant-menu-horizontal > .ant-menu-item-active,.ant-menu-horizontal > .ant-menu-item-open,.ant-menu-horizontal > .ant-menu-item-selected,.ant-menu-horizontal > .ant-menu-item:hover,.ant-menu-horizontal > .ant-menu-submenu-active,.ant-menu-horizontal > .ant-menu-submenu-open,.ant-menu-horizontal:not(.ant-menu-dark) > .ant-menu-submenu-selected,.ant-menu-horizontal:not(.ant-menu-dark) > .ant-menu-submenu:hover'
default :
default:
return selector
}
}
})
]
},

chainWebpack: (config) => {
config.resolve.alias
.set('@$', resolve('src'))
chainWebpack: config => {
config.resolve.alias.set('@$', resolve('src'))

const svgRule = config.module.rule('svg')
svgRule.uses.clear()
Expand Down Expand Up @@ -77,7 +84,6 @@ module.exports = {
less: {
modifyVars: {
/* less 变量覆盖,用于自定义 ant design 主题 */

/*
'primary-color': '#F5222D',
'link-color': '#F5222D',
Expand Down

0 comments on commit eead7ea

Please sign in to comment.