Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
D
dataease
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
zhu
dataease
Commits
e64013b2
提交
e64013b2
authored
3月 08, 2021
作者:
fit2cloud-chenyw
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat:删除不必要依赖
上级
8d553314
隐藏空白字符变更
内嵌
并排
正在显示
9 个修改的文件
包含
112 行增加
和
318 行删除
+112
-318
package.json
frontend/package.json
+0
-8
.eslintrc.js
frontend/tests/unit/.eslintrc.js
+0
-5
Breadcrumb.spec.js
frontend/tests/unit/components/Breadcrumb.spec.js
+0
-98
Hamburger.spec.js
frontend/tests/unit/components/Hamburger.spec.js
+0
-18
SvgIcon.spec.js
frontend/tests/unit/components/SvgIcon.spec.js
+0
-22
formatTime.spec.js
frontend/tests/unit/utils/formatTime.spec.js
+0
-30
parseTime.spec.js
frontend/tests/unit/utils/parseTime.spec.js
+0
-28
validate.spec.js
frontend/tests/unit/utils/validate.spec.js
+0
-17
vue.config.js
frontend/vue.config.js
+112
-92
没有找到文件。
frontend/package.json
浏览文件 @
e64013b2
...
@@ -10,8 +10,6 @@
...
@@ -10,8 +10,6 @@
"build:stage"
:
"vue-cli-service build --mode staging"
,
"build:stage"
:
"vue-cli-service build --mode staging"
,
"preview"
:
"node build/index.js --preview"
,
"preview"
:
"node build/index.js --preview"
,
"lint"
:
"eslint --ext .js,.vue src"
,
"lint"
:
"eslint --ext .js,.vue src"
,
"test:unit"
:
"jest --clearCache && vue-cli-service test:unit"
,
"test:ci"
:
"npm run lint && npm run test:unit"
,
"svgo"
:
"svgo -f src/icons/svg --config=src/icons/svgo.yml"
"svgo"
:
"svgo -f src/icons/svg --config=src/icons/svgo.yml"
},
},
"dependencies"
:
{
"dependencies"
:
{
...
@@ -23,7 +21,6 @@
...
@@ -23,7 +21,6 @@
"js-cookie"
:
"2.2.0"
,
"js-cookie"
:
"2.2.0"
,
"normalize.css"
:
"7.0.0"
,
"normalize.css"
:
"7.0.0"
,
"nprogress"
:
"0.2.0"
,
"nprogress"
:
"0.2.0"
,
"path-to-regexp"
:
"2.4.0"
,
"screenfull"
:
"4.2.0"
,
"screenfull"
:
"4.2.0"
,
"stylus"
:
"^0.54.8"
,
"stylus"
:
"^0.54.8"
,
"stylus-loader"
:
"^5.0.0"
,
"stylus-loader"
:
"^5.0.0"
,
...
@@ -40,13 +37,8 @@
...
@@ -40,13 +37,8 @@
"@babel/register"
:
"7.0.0"
,
"@babel/register"
:
"7.0.0"
,
"@vue/cli-plugin-babel"
:
"3.6.0"
,
"@vue/cli-plugin-babel"
:
"3.6.0"
,
"@vue/cli-plugin-eslint"
:
"^3.9.1"
,
"@vue/cli-plugin-eslint"
:
"^3.9.1"
,
"@vue/cli-plugin-unit-jest"
:
"3.6.3"
,
"@vue/cli-service"
:
"3.6.0"
,
"@vue/cli-service"
:
"3.6.0"
,
"@vue/test-utils"
:
"1.0.0-beta.29"
,
"autoprefixer"
:
"^9.5.1"
,
"babel-core"
:
"7.0.0-bridge.0"
,
"babel-eslint"
:
"10.0.1"
,
"babel-eslint"
:
"10.0.1"
,
"babel-jest"
:
"23.6.0"
,
"chalk"
:
"2.4.2"
,
"chalk"
:
"2.4.2"
,
"connect"
:
"3.6.6"
,
"connect"
:
"3.6.6"
,
"eslint"
:
"5.15.3"
,
"eslint"
:
"5.15.3"
,
...
...
frontend/tests/unit/.eslintrc.js
deleted
100644 → 0
浏览文件 @
8d553314
module
.
exports
=
{
env
:
{
jest
:
true
}
}
frontend/tests/unit/components/Breadcrumb.spec.js
deleted
100644 → 0
浏览文件 @
8d553314
import
{
mount
,
createLocalVue
}
from
'@vue/test-utils'
import
VueRouter
from
'vue-router'
import
ElementUI
from
'element-ui'
import
Breadcrumb
from
'@/components/Breadcrumb/index.vue'
const
localVue
=
createLocalVue
()
localVue
.
use
(
VueRouter
)
localVue
.
use
(
ElementUI
)
const
routes
=
[
{
path
:
'/'
,
name
:
'home'
,
children
:
[{
path
:
'dashboard'
,
name
:
'dashboard'
}]
},
{
path
:
'/menu'
,
name
:
'menu'
,
children
:
[{
path
:
'menu1'
,
name
:
'menu1'
,
meta
:
{
title
:
'menu1'
},
children
:
[{
path
:
'menu1-1'
,
name
:
'menu1-1'
,
meta
:
{
title
:
'menu1-1'
}
},
{
path
:
'menu1-2'
,
name
:
'menu1-2'
,
redirect
:
'noredirect'
,
meta
:
{
title
:
'menu1-2'
},
children
:
[{
path
:
'menu1-2-1'
,
name
:
'menu1-2-1'
,
meta
:
{
title
:
'menu1-2-1'
}
},
{
path
:
'menu1-2-2'
,
name
:
'menu1-2-2'
}]
}]
}]
}]
const
router
=
new
VueRouter
({
routes
})
describe
(
'Breadcrumb.vue'
,
()
=>
{
const
wrapper
=
mount
(
Breadcrumb
,
{
localVue
,
router
})
it
(
'dashboard'
,
()
=>
{
router
.
push
(
'/dashboard'
)
const
len
=
wrapper
.
findAll
(
'.el-breadcrumb__inner'
).
length
expect
(
len
).
toBe
(
1
)
})
it
(
'normal route'
,
()
=>
{
router
.
push
(
'/menu/menu1'
)
const
len
=
wrapper
.
findAll
(
'.el-breadcrumb__inner'
).
length
expect
(
len
).
toBe
(
2
)
})
it
(
'nested route'
,
()
=>
{
router
.
push
(
'/menu/menu1/menu1-2/menu1-2-1'
)
const
len
=
wrapper
.
findAll
(
'.el-breadcrumb__inner'
).
length
expect
(
len
).
toBe
(
4
)
})
it
(
'no meta.title'
,
()
=>
{
router
.
push
(
'/menu/menu1/menu1-2/menu1-2-2'
)
const
len
=
wrapper
.
findAll
(
'.el-breadcrumb__inner'
).
length
expect
(
len
).
toBe
(
3
)
})
// it('click link', () => {
// router.push('/menu/menu1/menu1-2/menu1-2-2')
// const breadcrumbArray = wrapper.findAll('.el-breadcrumb__inner')
// const second = breadcrumbArray.at(1)
// console.log(breadcrumbArray)
// const href = second.find('a').attributes().href
// expect(href).toBe('#/menu/menu1')
// })
// it('noRedirect', () => {
// router.push('/menu/menu1/menu1-2/menu1-2-1')
// const breadcrumbArray = wrapper.findAll('.el-breadcrumb__inner')
// const redirectBreadcrumb = breadcrumbArray.at(2)
// expect(redirectBreadcrumb.contains('a')).toBe(false)
// })
it
(
'last breadcrumb'
,
()
=>
{
router
.
push
(
'/menu/menu1/menu1-2/menu1-2-1'
)
const
breadcrumbArray
=
wrapper
.
findAll
(
'.el-breadcrumb__inner'
)
const
redirectBreadcrumb
=
breadcrumbArray
.
at
(
3
)
expect
(
redirectBreadcrumb
.
contains
(
'a'
)).
toBe
(
false
)
})
})
frontend/tests/unit/components/Hamburger.spec.js
deleted
100644 → 0
浏览文件 @
8d553314
import
{
shallowMount
}
from
'@vue/test-utils'
import
Hamburger
from
'@/components/Hamburger/index.vue'
describe
(
'Hamburger.vue'
,
()
=>
{
it
(
'toggle click'
,
()
=>
{
const
wrapper
=
shallowMount
(
Hamburger
)
const
mockFn
=
jest
.
fn
()
wrapper
.
vm
.
$on
(
'toggleClick'
,
mockFn
)
wrapper
.
find
(
'.hamburger'
).
trigger
(
'click'
)
expect
(
mockFn
).
toBeCalled
()
})
it
(
'prop isActive'
,
()
=>
{
const
wrapper
=
shallowMount
(
Hamburger
)
wrapper
.
setProps
({
isActive
:
true
})
expect
(
wrapper
.
contains
(
'.is-active'
)).
toBe
(
true
)
wrapper
.
setProps
({
isActive
:
false
})
expect
(
wrapper
.
contains
(
'.is-active'
)).
toBe
(
false
)
})
})
frontend/tests/unit/components/SvgIcon.spec.js
deleted
100644 → 0
浏览文件 @
8d553314
import
{
shallowMount
}
from
'@vue/test-utils'
import
SvgIcon
from
'@/components/SvgIcon/index.vue'
describe
(
'SvgIcon.vue'
,
()
=>
{
it
(
'iconClass'
,
()
=>
{
const
wrapper
=
shallowMount
(
SvgIcon
,
{
propsData
:
{
iconClass
:
'test'
}
})
expect
(
wrapper
.
find
(
'use'
).
attributes
().
href
).
toBe
(
'#icon-test'
)
})
it
(
'className'
,
()
=>
{
const
wrapper
=
shallowMount
(
SvgIcon
,
{
propsData
:
{
iconClass
:
'test'
}
})
expect
(
wrapper
.
classes
().
length
).
toBe
(
1
)
wrapper
.
setProps
({
className
:
'test'
})
expect
(
wrapper
.
classes
().
includes
(
'test'
)).
toBe
(
true
)
})
})
frontend/tests/unit/utils/formatTime.spec.js
deleted
100644 → 0
浏览文件 @
8d553314
import
{
formatTime
}
from
'@/utils/index.js'
describe
(
'Utils:formatTime'
,
()
=>
{
const
d
=
new
Date
(
'2018-07-13 17:54:01'
)
// "2018-07-13 17:54:01"
const
retrofit
=
5
*
1000
it
(
'ten digits timestamp'
,
()
=>
{
expect
(
formatTime
((
d
/
1000
).
toFixed
(
0
))).
toBe
(
'7月13日17时54分'
)
})
it
(
'test now'
,
()
=>
{
expect
(
formatTime
(
+
new
Date
()
-
1
)).
toBe
(
'刚刚'
)
})
it
(
'less two minute'
,
()
=>
{
expect
(
formatTime
(
+
new
Date
()
-
60
*
2
*
1000
+
retrofit
)).
toBe
(
'2分钟前'
)
})
it
(
'less two hour'
,
()
=>
{
expect
(
formatTime
(
+
new
Date
()
-
60
*
60
*
2
*
1000
+
retrofit
)).
toBe
(
'2小时前'
)
})
it
(
'less one day'
,
()
=>
{
expect
(
formatTime
(
+
new
Date
()
-
60
*
60
*
24
*
1
*
1000
)).
toBe
(
'1天前'
)
})
it
(
'more than one day'
,
()
=>
{
expect
(
formatTime
(
d
)).
toBe
(
'7月13日17时54分'
)
})
it
(
'format'
,
()
=>
{
expect
(
formatTime
(
d
,
'{y}-{m}-{d} {h}:{i}'
)).
toBe
(
'2018-07-13 17:54'
)
expect
(
formatTime
(
d
,
'{y}-{m}-{d}'
)).
toBe
(
'2018-07-13'
)
expect
(
formatTime
(
d
,
'{y}/{m}/{d} {h}-{i}'
)).
toBe
(
'2018/07/13 17-54'
)
})
})
frontend/tests/unit/utils/parseTime.spec.js
deleted
100644 → 0
浏览文件 @
8d553314
import
{
parseTime
}
from
'@/utils/index.js'
describe
(
'Utils:parseTime'
,
()
=>
{
const
d
=
new
Date
(
'2018-07-13 17:54:01'
)
// "2018-07-13 17:54:01"
it
(
'timestamp'
,
()
=>
{
expect
(
parseTime
(
d
)).
toBe
(
'2018-07-13 17:54:01'
)
})
it
(
'ten digits timestamp'
,
()
=>
{
expect
(
parseTime
((
d
/
1000
).
toFixed
(
0
))).
toBe
(
'2018-07-13 17:54:01'
)
})
it
(
'new Date'
,
()
=>
{
expect
(
parseTime
(
new
Date
(
d
))).
toBe
(
'2018-07-13 17:54:01'
)
})
it
(
'format'
,
()
=>
{
expect
(
parseTime
(
d
,
'{y}-{m}-{d} {h}:{i}'
)).
toBe
(
'2018-07-13 17:54'
)
expect
(
parseTime
(
d
,
'{y}-{m}-{d}'
)).
toBe
(
'2018-07-13'
)
expect
(
parseTime
(
d
,
'{y}/{m}/{d} {h}-{i}'
)).
toBe
(
'2018/07/13 17-54'
)
})
it
(
'get the day of the week'
,
()
=>
{
expect
(
parseTime
(
d
,
'{a}'
)).
toBe
(
'五'
)
// 星期五
})
it
(
'get the day of the week'
,
()
=>
{
expect
(
parseTime
(
+
d
+
1000
*
60
*
60
*
24
*
2
,
'{a}'
)).
toBe
(
'日'
)
// 星期日
})
it
(
'empty argument'
,
()
=>
{
expect
(
parseTime
()).
toBeNull
()
})
})
frontend/tests/unit/utils/validate.spec.js
deleted
100644 → 0
浏览文件 @
8d553314
import
{
validUsername
,
isExternal
}
from
'@/utils/validate.js'
describe
(
'Utils:validate'
,
()
=>
{
it
(
'validUsername'
,
()
=>
{
expect
(
validUsername
(
'admin'
)).
toBe
(
true
)
expect
(
validUsername
(
'editor'
)).
toBe
(
true
)
expect
(
validUsername
(
'xxxx'
)).
toBe
(
false
)
})
it
(
'isExternal'
,
()
=>
{
expect
(
isExternal
(
'https://github.com/PanJiaChen/vue-element-admin'
)).
toBe
(
true
)
expect
(
isExternal
(
'http://github.com/PanJiaChen/vue-element-admin'
)).
toBe
(
true
)
expect
(
isExternal
(
'github.com/PanJiaChen/vue-element-admin'
)).
toBe
(
false
)
expect
(
isExternal
(
'/dashboard'
)).
toBe
(
false
)
expect
(
isExternal
(
'./dashboard'
)).
toBe
(
false
)
expect
(
isExternal
(
'dashboard'
)).
toBe
(
false
)
})
})
frontend/vue.config.js
浏览文件 @
e64013b2
...
@@ -8,30 +8,10 @@ function resolve(dir) {
...
@@ -8,30 +8,10 @@ function resolve(dir) {
const
name
=
defaultSettings
.
title
||
'vue Admin Template'
// page title
const
name
=
defaultSettings
.
title
||
'vue Admin Template'
// page title
// If your port is set to 80,
// use administrator privileges to execute the command line.
// For example, Mac: sudo npm run
// You can change the port by the following methods:
// port = 9528 npm run dev OR npm run dev --port = 9528
const
port
=
process
.
env
.
port
||
process
.
env
.
npm_config_port
||
9528
// dev port
const
port
=
process
.
env
.
port
||
process
.
env
.
npm_config_port
||
9528
// dev port
// All configuration item explanations can be find in https://cli.vuejs.org/config/
module
.
exports
=
{
module
.
exports
=
{
/**
productionSourceMap
:
true
,
* You will need to set publicPath if you plan to deploy your site under a sub path,
// 使用mock-server
* for example GitHub Pages. If you plan to deploy your site to https://foo.github.io/bar/,
* then publicPath should be set to "/bar/".
* In most cases please use '/' !!!
* Detail: https://cli.vuejs.org/config/#publicpath
*/
publicPath
:
'/'
,
outputDir
:
'dist'
,
assetsDir
:
'static'
,
lintOnSave
:
process
.
env
.
NODE_ENV
===
'development'
,
productionSourceMap
:
false
,
css
:
{
sourceMap
:
true
// 开启 CSS source maps
},
devServer
:
{
devServer
:
{
port
:
port
,
port
:
port
,
open
:
true
,
open
:
true
,
...
@@ -42,91 +22,131 @@ module.exports = {
...
@@ -42,91 +22,131 @@ module.exports = {
before
:
require
(
'./mock/mock-server.js'
)
before
:
require
(
'./mock/mock-server.js'
)
},
},
configureWebpack
:
{
configureWebpack
:
{
// provide the app's title in webpack's name field, so that
// it can be accessed in index.html to inject the correct title.
name
:
name
,
name
:
name
,
devtool
:
'source-map'
,
resolve
:
{
resolve
:
{
alias
:
{
alias
:
{
'@'
:
resolve
(
'src'
)
'@'
:
resolve
(
'src'
)
}
}
}
}
},
},
chainWebpack
(
config
)
{
chainWebpack
:
config
=>
{
config
.
plugins
.
delete
(
'preload'
)
// TODO: need test
config
.
module
.
rules
.
delete
(
'svg'
)
// 删除默认配置中处理svg,
config
.
plugins
.
delete
(
'prefetch'
)
// TODO: need test
// const svgRule = config.module.rule('svg')
// svgRule.uses.clear()
// set svg-sprite-loader
config
.
module
.
rule
(
'svg'
)
.
exclude
.
add
(
resolve
(
'src/icons'
))
.
end
()
config
.
module
config
.
module
.
rule
(
'
icons
'
)
.
rule
(
'
svg-sprite-loader
'
)
.
test
(
/
\.
svg$/
)
.
test
(
/
\.
svg$/
)
.
include
.
add
(
resolve
(
'src/icons'
))
.
include
.
add
(
resolve
(
'src/icons'
))
// 处理svg目录
.
end
()
.
end
()
.
use
(
'svg-sprite-loader'
)
.
use
(
'svg-sprite-loader'
)
.
loader
(
'svg-sprite-loader'
)
.
loader
(
'svg-sprite-loader'
)
.
options
({
.
options
({
symbolId
:
'icon-[name]'
symbolId
:
'icon-[name]'
})
})
.
end
()
}
// set preserveWhitespace
}
config
.
module
// module.exports = {
.
rule
(
'vue'
)
.
use
(
'vue-loader'
)
.
loader
(
'vue-loader'
)
.
tap
(
options
=>
{
options
.
compilerOptions
.
preserveWhitespace
=
true
return
options
})
.
end
()
config
// publicPath: '/',
// https://webpack.js.org/configuration/devtool/#development
// outputDir: 'dist',
.
when
(
process
.
env
.
NODE_ENV
===
'development'
,
// assetsDir: 'static',
config
=>
config
.
devtool
(
'source-map'
)
// lintOnSave: process.env.NODE_ENV === 'development',
// config => config.devtool('cheap-source-map')
// productionSourceMap: false,
)
// css: {
// sourceMap: true // 开启 CSS source maps
// },
// devServer: {
// port: port,
// open: true,
// overlay: {
// warnings: false,
// errors: true
// },
// before: require('./mock/mock-server.js')
// },
// configureWebpack: {
config
// name: name,
.
when
(
process
.
env
.
NODE_ENV
!==
'development'
,
// resolve: {
config
=>
{
// alias: {
config
// '@': resolve('src')
.
plugin
(
'ScriptExtHtmlWebpackPlugin'
)
// }
.
after
(
'html'
)
// }
.
use
(
'script-ext-html-webpack-plugin'
,
[{
// },
// `runtime` must same as runtimeChunk name. default is `runtime`
// chainWebpack(config) {
inline
:
/runtime
\.
.*
\.
js$/
// config.plugins.delete('preload') // TODO: need test
}])
// config.plugins.delete('prefetch') // TODO: need test
.
end
()
config
// config.module
.
optimization
.
splitChunks
({
// .rule('svg')
chunks
:
'all'
,
// .exclude.add(resolve('src/icons'))
cacheGroups
:
{
// .end()
libs
:
{
// config.module
name
:
'chunk-libs'
,
// .rule('icons')
test
:
/
[\\/]
node_modules
[\\/]
/
,
// .test(/\.svg$/)
priority
:
10
,
// .include.add(resolve('src/icons'))
chunks
:
'initial'
// only package third parties that are initially dependent
// .end()
},
// .use('svg-sprite-loader')
elementUI
:
{
// .loader('svg-sprite-loader')
name
:
'chunk-elementUI'
,
// split elementUI into a single package
// .options({
priority
:
20
,
// the weight needs to be larger than libs and app or it will be packaged into libs or app
// symbolId: 'icon-[name]'
test
:
/
[\\/]
node_modules
[\\/]
_
?
element-ui
(
.*
)
/
// in order to adapt to cnpm
// })
},
// .end()
commons
:
{
name
:
'chunk-commons'
,
// config.module
test
:
resolve
(
'src/components'
),
// can customize your rules
// .rule('vue')
minChunks
:
3
,
// minimum common number
// .use('vue-loader')
priority
:
5
,
// .loader('vue-loader')
reuseExistingChunk
:
true
// .tap(options => {
}
// options.compilerOptions.preserveWhitespace = true
}
// return options
})
// })
config
.
optimization
.
runtimeChunk
(
'single'
)
// .end()
}
)
// config
}
// .when(process.env.NODE_ENV === 'development',
}
// config => config.devtool('source-map')
// )
// config
// .when(process.env.NODE_ENV !== 'development',
// config => {
// config
// .plugin('ScriptExtHtmlWebpackPlugin')
// .after('html')
// .use('script-ext-html-webpack-plugin', [{
// inline: /runtime\..*\.js$/
// }])
// .end()
// config
// .optimization.splitChunks({
// chunks: 'all',
// cacheGroups: {
// libs: {
// name: 'chunk-libs',
// test: /[\\/]node_modules[\\/]/,
// priority: 10,
// chunks: 'initial' // only package third parties that are initially dependent
// },
// elementUI: {
// name: 'chunk-elementUI', // split elementUI into a single package
// priority: 20, // the weight needs to be larger than libs and app or it will be packaged into libs or app
// test: /[\\/]node_modules[\\/]_?element-ui(.*)/ // in order to adapt to cnpm
// },
// commons: {
// name: 'chunk-commons',
// test: resolve('src/components'), // can customize your rules
// minChunks: 3, // minimum common number
// priority: 5,
// reuseExistingChunk: true
// }
// }
// })
// config.optimization.runtimeChunk('single')
// }
// )
// }
// }
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论