Browse Source

增加ui组件及自定义样式

zq-develop
zq 3 months ago
parent
commit
a4bbe47ed7
  1. 78
      package-lock.json
  2. 1
      package.json
  3. 4
      src/App.vue
  4. 1
      src/assets/radio_checked.svg
  5. 1
      src/assets/radio_nochecked.svg
  6. 52
      src/components/GuipButton.vue
  7. 0
      src/components/GuipConfirm.vue
  8. 25
      src/components/GuipInput.vue
  9. 0
      src/components/GuipModal.vue
  10. 26
      src/components/GuipRadio.vue
  11. 23
      src/components/GuipSelect.vue
  12. 20
      src/components/GuipTable.vue
  13. 24
      src/components/GuipTextarea.vue
  14. 0
      src/components/NavMenu.vue
  15. 7
      src/main.js
  16. 8
      src/router/index.js
  17. 1
      src/style/config.json
  18. 67
      src/style/theme/common.scss
  19. BIN
      src/style/theme/fonts/element-icons.ttf
  20. BIN
      src/style/theme/fonts/element-icons.woff
  21. 1
      src/style/theme/index.css
  22. 218
      src/views/elementGroups.vue
  23. 10
      vue.config.js

78
package-lock.json

@ -9,6 +9,7 @@
"version": "0.1.0",
"dependencies": {
"core-js": "^3.8.3",
"element-ui": "^2.15.14",
"vue": "^2.6.14",
"vue-router": "^3.5.1",
"vuex": "^3.6.2"
@ -3784,6 +3785,14 @@
"lodash": "^4.17.14"
}
},
"node_modules/async-validator": {
"version": "1.8.5",
"resolved": "https://registry.npmjs.org/async-validator/-/async-validator-1.8.5.tgz",
"integrity": "sha512-tXBM+1m056MAX0E8TL2iCjg8WvSyXu0Zc8LNtYqrVeyoL3+esHRZ4SieE9fKQyyU09uONjnMEjrNBMqT0mbvmA==",
"dependencies": {
"babel-runtime": "6.x"
}
},
"node_modules/at-least-node": {
"version": "1.0.0",
"resolved": "https://registry.npmmirror.com/at-least-node/-/at-least-node-1.0.0.tgz",
@ -3832,6 +3841,12 @@
"postcss": "^8.1.0"
}
},
"node_modules/babel-helper-vue-jsx-merge-props": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/babel-helper-vue-jsx-merge-props/-/babel-helper-vue-jsx-merge-props-2.0.3.tgz",
"integrity": "sha512-gsLiKK7Qrb7zYJNgiXKpXblxbV5ffSwR0f5whkPAaBAR4fhi6bwRZxX9wBlIc5M/v8CCkXUbXZL4N/nSE97cqg==",
"license": "MIT"
},
"node_modules/babel-loader": {
"version": "8.4.1",
"resolved": "https://registry.npmmirror.com/babel-loader/-/babel-loader-8.4.1.tgz",
@ -3919,6 +3934,30 @@
"@babel/core": "^7.4.0 || ^8.0.0-0 <8.0.0"
}
},
"node_modules/babel-runtime": {
"version": "6.26.0",
"resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz",
"integrity": "sha512-ITKNuq2wKlW1fJg9sSW52eepoYgZBggvOAHC0u/CYu/qxQ9EVzThCgR69BnSXLHjy2f7SY5zaQ4yt7H9ZVxY2g==",
"license": "MIT",
"dependencies": {
"core-js": "^2.4.0",
"regenerator-runtime": "^0.11.0"
}
},
"node_modules/babel-runtime/node_modules/core-js": {
"version": "2.6.12",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.12.tgz",
"integrity": "sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ==",
"deprecated": "core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.",
"hasInstallScript": true,
"license": "MIT"
},
"node_modules/babel-runtime/node_modules/regenerator-runtime": {
"version": "0.11.1",
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz",
"integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==",
"license": "MIT"
},
"node_modules/balanced-match": {
"version": "1.0.2",
"resolved": "https://registry.npmmirror.com/balanced-match/-/balanced-match-1.0.2.tgz",
@ -5133,7 +5172,6 @@
"version": "1.5.2",
"resolved": "https://registry.npmmirror.com/deepmerge/-/deepmerge-1.5.2.tgz",
"integrity": "sha512-95k0GDqvBjZavkuvzx/YqVLv/6YYa17fz6ILMSf7neqQITCPbnfEnQvEgMPNjH4kgobe7+WIL0yJEHku+H3qtQ==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=0.10.0"
@ -5572,6 +5610,23 @@
"dev": true,
"license": "ISC"
},
"node_modules/element-ui": {
"version": "2.15.14",
"resolved": "https://registry.npmjs.org/element-ui/-/element-ui-2.15.14.tgz",
"integrity": "sha512-2v9fHL0ZGINotOlRIAJD5YuVB8V7WKxrE9Qy7dXhRipa035+kF7WuU/z+tEmLVPBcJ0zt8mOu1DKpWcVzBK8IA==",
"license": "MIT",
"dependencies": {
"async-validator": "~1.8.1",
"babel-helper-vue-jsx-merge-props": "^2.0.0",
"deepmerge": "^1.2.0",
"normalize-wheel": "^1.0.1",
"resize-observer-polyfill": "^1.5.0",
"throttle-debounce": "^1.0.1"
},
"peerDependencies": {
"vue": "^2.5.17"
}
},
"node_modules/emoji-regex": {
"version": "8.0.0",
"resolved": "https://registry.npmmirror.com/emoji-regex/-/emoji-regex-8.0.0.tgz",
@ -8686,6 +8741,12 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/normalize-wheel": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/normalize-wheel/-/normalize-wheel-1.0.1.tgz",
"integrity": "sha512-1OnlAPZ3zgrk8B91HyRj+eVv+kS5u+Z0SCsak6Xil/kmgEia50ga7zfkumayonZrImffAxPU/5WcyGhzetHNPA==",
"license": "BSD-3-Clause"
},
"node_modules/npm-run-path": {
"version": "2.0.2",
"resolved": "https://registry.npmmirror.com/npm-run-path/-/npm-run-path-2.0.2.tgz",
@ -10268,6 +10329,12 @@
"dev": true,
"license": "MIT"
},
"node_modules/resize-observer-polyfill": {
"version": "1.5.1",
"resolved": "https://registry.npmjs.org/resize-observer-polyfill/-/resize-observer-polyfill-1.5.1.tgz",
"integrity": "sha512-LwZrotdHOo12nQuZlHEmtuXdqGoOD0OhaxopaNFxWzInpEgaLWoVuAMbTzixuosCx2nEG58ngzW3vxdWoxIgdg==",
"license": "MIT"
},
"node_modules/resolve": {
"version": "1.22.10",
"resolved": "https://registry.npmmirror.com/resolve/-/resolve-1.22.10.tgz",
@ -11480,6 +11547,15 @@
"url": "https://opencollective.com/webpack"
}
},
"node_modules/throttle-debounce": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/throttle-debounce/-/throttle-debounce-1.1.0.tgz",
"integrity": "sha512-XH8UiPCQcWNuk2LYePibW/4qL97+ZQ1AN3FNXwZRBNPPowo/NRU5fAlDCSNBJIYCKbioZfuYtMhG4quqoJhVzg==",
"license": "MIT",
"engines": {
"node": ">=4"
}
},
"node_modules/thunky": {
"version": "1.1.0",
"resolved": "https://registry.npmmirror.com/thunky/-/thunky-1.1.0.tgz",

1
package.json

@ -9,6 +9,7 @@
},
"dependencies": {
"core-js": "^3.8.3",
"element-ui": "^2.15.14",
"vue": "^2.6.14",
"vue-router": "^3.5.1",
"vuex": "^3.6.2"

4
src/App.vue

@ -2,7 +2,8 @@
<div id="app">
<nav>
<router-link to="/">Home</router-link> |
<router-link to="/about">About</router-link>
<router-link to="/about">About</router-link> |
<router-link to="/ui">组件示例文件</router-link>
</nav>
<router-view/>
</div>
@ -11,6 +12,7 @@
<style lang="scss">
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
font-family: Microsoft YaHei UI;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;

1
src/assets/radio_checked.svg

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" fill="none" version="1.1" width="14" height="14" viewBox="0 0 14 14"><g><g><rect x="0" y="0" width="14" height="14" rx="7" fill="#FFFFFF" fill-opacity="1"/><rect x="0.5" y="0.5" width="13" height="13" rx="6.5" fill-opacity="0" stroke-opacity="1" stroke="#006AFF" fill="none" stroke-width="1"/></g><g><rect x="2.380126953125" y="2.3798828125" width="9.239999771118164" height="9.239999771118164" rx="4.619999885559082" fill="#006AFF" fill-opacity="1"/><rect x="2.710126966238022" y="2.709882825613022" width="8.57999974489212" height="8.57999974489212" rx="4.28999987244606" fill-opacity="0" stroke-opacity="1" stroke="#006AFF" fill="none" stroke-width="0.6600000262260437"/></g></g></svg>

After

Width:  |  Height:  |  Size: 771 B

1
src/assets/radio_nochecked.svg

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" fill="none" version="1.1" width="14" height="14" viewBox="0 0 14 14"><g><g><rect x="0" y="0" width="14" height="14" rx="7" fill="#FFFFFF" fill-opacity="1"/><rect x="0.5" y="0.5" width="13" height="13" rx="6.5" fill-opacity="0" stroke-opacity="1" stroke="#DFE2E6" fill="none" stroke-width="1"/></g></g></svg>

After

Width:  |  Height:  |  Size: 390 B

52
src/components/GuipButton.vue

@ -0,0 +1,52 @@
<template>
<el-button
:type="type"
:plain="plain"
:loading="loading"
:size="size"
:disabled="disabled"
:style="{...btnstyle}"
>
<slot></slot>
</el-button>
</template>
<script>
export default {
name: 'GuipButton',
// props:['type','plain'],
props:{
type:{
type:String,
default:''
},
size:{
type:String,
default:'normal'
},
// false
plain:{
type:Boolean,
default:false
},
loading:{
type:Boolean,
default:false
},
disabled:{
type:Boolean,
default:false
},
btnstyle:Object
},
data() {
return {
radio: ''
}
},
mounted(){
}
}
</script>

0
src/components/GuipConfirm.vue

25
src/components/GuipInput.vue

@ -0,0 +1,25 @@
<template>
<el-input
type="text"
:style="{...styleObject}"
:rows="2"
placeholder="请输入内容"
:disabled="disabled"
v-model="textarea">
</el-input>
</template>
<script>
export default {
name: 'GuipInput',
props:['styleObject','disabled'],
data() {
return {
textarea: ''
}
},
mounted(){
}
}
</script>

0
src/components/GuipModal.vue

26
src/components/GuipRadio.vue

@ -0,0 +1,26 @@
<template>
<el-radio
:label="label"
:disabled="disabled"
:v-model="defaultValue"
>
<template #label>
<span><img src="../assets/radio_checked.svg" alt="custom icon" style="width: 16px; height: 16px;"> {{ text }}</span>
</template>
</el-radio>
</template>
<script>
export default {
name: 'GuipRadio',
props:['radio','label','defaultValue','disabled','text'],
data() {
return {
// radio: '1'
}
},
mounted(){
}
}
</script>

23
src/components/GuipSelect.vue

@ -0,0 +1,23 @@
<template>
<el-select v-model="value" placeholder="请选择">
<el-option
v-for="item in options"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</template>
<script>
export default {
name: 'GuipTextarea',
props:['options'],
data() {
return {
value: ''
}
}
}
</script>

20
src/components/GuipTable.vue

@ -0,0 +1,20 @@
<template>
<el-table
:data="tableData"
height="250"
:border=true
style="width: 100%">
<slot></slot>
</el-table>
</template>
<script>
export default {
name: 'GuipTextarea',
props:['tableData'],
data() {
return {
}
}
}
</script>

24
src/components/GuipTextarea.vue

@ -0,0 +1,24 @@
<template>
<el-input
type="textarea"
:style="{width:styleObject.width,height:styleObject.height}"
:rows="2"
placeholder="请输入内容"
v-model="textarea">
</el-input>
</template>
<script>
export default {
name: 'GuipTextarea',
props:['styleObject'],
data() {
return {
textarea: ''
}
},
mounted(){
}
}
</script>

0
src/components/NavMenu.vue

7
src/main.js

@ -2,9 +2,12 @@ import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import './style/theme/index.css'
import './style/theme/common.scss'
Vue.config.productionTip = false
Vue.use(ElementUI);
new Vue({
router,
store,

8
src/router/index.js

@ -17,6 +17,14 @@ const routes = [
// this generates a separate chunk (about.[hash].js) for this route
// which is lazy-loaded when the route is visited.
component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
},
{
path: '/ui',
name: 'ui',
// route level code-splitting
// this generates a separate chunk (about.[hash].js) for this route
// which is lazy-loaded when the route is visited.
component: () => import(/* webpackChunkName: "about" */ '../views/elementGroups.vue')
}
]

1
src/style/config.json

@ -0,0 +1 @@
{"global":{"$--color-primary":"#006AFF","$--color-success":"#0DAF49","$--color-warning":"#F08614","$--color-danger":"#FF4D4F","$--color-text-primary":"#1E2226","$--color-text-placeholder":"#BABDC2","$--color-text-secondary":"#1E2226","$--border-color-base":"#DFE2E6"},"local":{}}

67
src/style/theme/common.scss

@ -0,0 +1,67 @@
body{
font-family: Microsoft YaHei UI;
font-size: 14px;
}
/* button==== start */
.el-button{
width: 144px;
height: 46px;
font-family: Microsoft YaHei UI;
font-size: 14px;
letter-spacing: 0.08em;
display: flex;
align-items: center;
justify-content: center;
}
.el-button--normal{
color: #626573;
}
.el-button--mild{
background: #FFFFFF;
border: 1px solid #006AFF;
color: #006AFF;
}
.el-button--primary,.el-button--success,.el-button--info,.el-button--warning,.el-button--danger{
color: #fff !important;
}
.el-button--medium{//中等按钮
width: 97px;
height: 33px;
font-size: 14px;
line-height: 14px;
span{
height: 14px;
}
}
.el-button--small{//小的按钮
width: 80px;
height: 32px;
font-size: 12px;
}
.el-button--mini{ //迷你按钮
width: 80px;
height: 28px;
font-size: 12px;
}
/* button==== end */
// radio ---start
.el-radio__input.is-checked .el-radio__inner::after {
content: ''; /* 清空默认的伪元素内容 */
width: 14px;
height: 14px;
background-image: url('../../assets/radio_checked.svg'); /* 使用你的自定义图标 */
background-size: contain;
background-repeat: no-repeat;
}
.el-radio__label{
font-weight: normal;
}
// radio ---end
// input ---start
// input ---end

BIN
src/style/theme/fonts/element-icons.ttf

Binary file not shown.

BIN
src/style/theme/fonts/element-icons.woff

Binary file not shown.

1
src/style/theme/index.css

File diff suppressed because one or more lines are too long

218
src/views/elementGroups.vue

@ -0,0 +1,218 @@
<template>
<div class="elementWrap">
<div class="ele-item">
<label for="">下拉框</label>
<GuipSelect msg="Welcome to Your Vue.js App" :options="options"/>
</div>
<div class="ele-item">
<label for="">表格</label>
<GuipTable msg="Welcome to Your Vue.js App" :tableData="tableData">
<el-table-column
prop="date"
label="日期"
width="180">
</el-table-column>
<el-table-column
prop="name"
label="姓名"
width="180">
</el-table-column>
<el-table-column
prop="address"
label="地址">
</el-table-column>
<el-table-column
prop="address1"
label="地址测试">
</el-table-column>
</GuipTable>
</div>
<div class="ele-item">
<label for="">文本域</label>
<GuipTextarea :styleObject="styleObject"/>
</div>
<div class="ele-item">
<label for="">单选框</label>
<el-radio v-model="radio1" :label="1">选项一</el-radio>
<el-radio v-model="radio1" :label="2">选项二</el-radio>
</div>
<div class="ele-item">
<label for="">单选框组</label>
<el-radio-group v-model="radio" @input="radioChange">
<el-radio :label="3">备选项</el-radio>
<el-radio :label="6">备选项</el-radio>
<el-radio :label="9">备选项</el-radio>
</el-radio-group>
</div>
<div class="ele-item">
<label for="">常规按钮</label>
<GuipButton >默认按钮</GuipButton>
<GuipButton type="mild" size="medium">轻度按钮</GuipButton>
<GuipButton type="primary">按钮</GuipButton>
<GuipButton type="success" :loading="false" :plain="plain">按钮</GuipButton>
<GuipButton type="info" :loading="false" :plain="plain">按钮</GuipButton>
<GuipButton type="warning" :loading="false" :plain="plain">按钮</GuipButton>
<GuipButton type="danger" :loading="false" :plain="plain">按钮</GuipButton>
</div>
<div class="ele-item">
<label for="">禁用按钮</label>
<GuipButton :disabled="true">默认按钮</GuipButton>
<GuipButton type="primary" size="medium" :disabled="true">按钮</GuipButton>
<GuipButton type="success" :disabled="true">按钮</GuipButton>
<GuipButton type="info" :disabled="true">按钮</GuipButton>
<GuipButton type="warning" :disabled="true">按钮</GuipButton>
<GuipButton type="danger" :disabled="true">按钮</GuipButton>
</div>
<div class="ele-item">
<label for="">三种尺寸按钮</label>
<GuipButton type="primary" >默认按钮</GuipButton>
<GuipButton type="primary" size="medium">中等按钮</GuipButton>
<GuipButton type="primary" size="small">小的按钮</GuipButton>
<GuipButton type="primary" size="mini">迷你按钮</GuipButton>
</div>
<div class="ele-item">
<label for="">自定义宽高按钮</label>
<GuipButton type="primary" :btnstyle="btnstyleObj">超长啊扭测试长的长的</GuipButton>
<GuipButton type="primary" :btnstyle="btnstyleObj1">随便写的</GuipButton>
</div>
<div class="ele-item">
<label for="">输入框</label>
<GuipInput :styleObject="styleObject1"/>
<!-- <el-input v-model="input" placeholder="请输入内容"></el-input> -->
</div>
<!-- <GuipRadio />
<GuipButton />
<GuipConfirm />
<GuipConfirm />
<GiupInput />
<GuipModal /> -->
</div>
</template>
<script>
// @ is an alias to /src
// import GuipRadio from '@/components/GuipRadio.vue';
import GuipButton from '@/components/GuipButton.vue';
// import GuipConfirm from '@/components/GuipConfirm.vue';
import GuipInput from '@/components/GuipInput.vue';
// import GuipModal from '@/components/GuipModal.vue';
import GuipSelect from '@/components/GuipSelect.vue';
import GuipTable from '@/components/GuipTable.vue';
import GuipTextarea from '@/components/GuipTextarea.vue'
export default {
name: 'HomeView',
components: {
GuipTextarea,
GuipTable,
// GuipRadio,
GuipButton,
// GuipConfirm,
GuipInput,
// GuipModal,
GuipSelect
},
data(){
return {
input:'hahhahah',
radio:3,
radio1:5,
btnstyleObj:{
width: '247px',
height: '44px',
background: '#F2F7FF',
borderRadius: '2px',
fontSize:'14px',
letterSpacing: '0.08em',
color: '#006AFF !important'
},
btnstyleObj1:{
width: '180px',
height: '40px',
},
styleObject:{
width:'200px',
height:'40px'
},
styleObject1:{
width:'200px',
height:'38px'
},
plain:false,
tableData: [{
date: '2016-05-03',
name: '王小虎',
address: '上海市普陀区金沙江路 1518 弄'
}, {
date: '2016-05-02',
name: '王小虎',
address: '上海市普陀区金沙江路 1518 弄'
}, {
date: '2016-05-04',
name: '王小虎',
address: '上海市普陀区金沙江路 1518 弄'
}, {
date: '2016-05-01',
name: '王小虎',
address: '上海市普陀区金沙江路 1518 弄'
}, {
date: '2016-05-08',
name: '王小虎',
address: '上海市普陀区金沙江路 1518 弄'
}, {
date: '2016-05-06',
name: '王小虎',
address: '上海市普陀区金沙江路 1518 弄'
}, {
date: '2016-05-07',
name: '王小虎',
address: '上海市普陀区金沙江路 1518 弄'
}],
options: [{
value: '选项1',
label: '黄金糕'
}, {
value: '选项2',
label: '双皮奶'
}, {
value: '选项3',
label: '蚵仔煎'
}, {
value: '选项4',
label: '龙须面'
}, {
value: '选项5',
label: '北京烤鸭'
}],
}
},
methods:{
//
radioChange() {
console.log(this.radio,'=====');
}
}
}
</script>
<style lang="scss" scoped>
.elementWrap{
/* width: 100%; */
padding: 30px 40px;
.ele-item{
display: flex;
align-items: center;
justify-content: flex-start;
margin-bottom: 30px;
label{
font-size: 16px;
font-weight: bold;
width: 100px;
margin-right: 10px;
text-align: left;
}
}
}
</style>

10
vue.config.js

@ -1,4 +1,12 @@
const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
transpileDependencies: true
transpileDependencies: true,
devServer: {
port: 8080
},
chainWebpack: config => {
config.resolve.alias
.set('@components', '@/src/components')
.set('@assets', '@/src/assets');
}
})

Loading…
Cancel
Save