1
0
mirror of https://github.com/PanJiaChen/vue-element-admin.git synced 2025-04-06 03:57:53 +08:00

Merge 78a4d3a15dbb357ebc3f6516f3407ae46310774e into a14547aaf9f68d99354d75a7ae11506e74944b67

This commit is contained in:
leij1ang 2017-09-17 06:39:34 +00:00 committed by GitHub
commit 888050318b
7 changed files with 387 additions and 353 deletions

View File

@ -1,6 +1,6 @@
<template> <template>
<a href="https://github.com/PanJiaChen/vue-element-admin" target="_blank" class="github-corner" aria-label="View source on Github"> <a href="https://github.com/PanJiaChen/vue-element-admin" target="_blank" class="github-corner" aria-label="View source on Github">
<svg width="80" height="80" viewBox="0 0 250 250" style="fill:#4AB7BD; color:#fff; position: absolute; top: 50px; border: 0; right: 0;" <svg width="80" height="80" viewBox="0 0 250 250" style="fill:#4AB7BD; color:#fff; position: absolute; top: 0px; border: 0; right: 0;"
aria-hidden="true"> aria-hidden="true">
<path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path> <path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path>
<path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" <path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2"

View File

@ -1,147 +1,132 @@
<template> <template>
<div class="material-input__component" :class="computedClasses"> <div class="material-input__component" :class="computedClasses">
<input v-if="type === 'email'" type="email" class="material-input" :name="name" :id="id" :placeholder="placeholder" v-model="valueCopy" <div :class="{iconClass:icon}">
:readonly="readonly" :disabled="disabled" :autocomplete="autocomplete" :required="required" @focus="handleFocus(true)" <i class="el-input__icon material-input__icon" :class="['el-icon-' + icon]" v-if="icon"></i>
@blur="handleFocus(false)" @input="handleModelInput"> <input v-if="type === 'email'" type="email" class="material-input" :name="name"
<input v-if="type === 'url'" type="url" class="material-input" :name="name" :id="id" :placeholder="placeholder" v-model="valueCopy" :placeholder="fillPlaceHolder" v-model="currentValue"
:readonly="readonly" :disabled="disabled" :autocomplete="autocomplete" :required="required" @focus="handleFocus(true)" :readonly="readonly" :disabled="disabled" :autoComplete="autoComplete" :required="required"
@blur="handleFocus(false)" @input="handleModelInput"> @focus="handleMdFocus"
<input v-if="type === 'number'" type="number" class="material-input" :name="name" :id="id" :placeholder="placeholder" v-model="valueCopy" @blur="handleMdBlur" @input="handleModelInput">
:readonly="readonly" :disabled="disabled" :autocomplete="autocomplete" :max="max" :min="min" :minlength="minlength" :maxlength="maxlength" <input v-if="type === 'url'" type="url" class="material-input" :name="name"
:required="required" @focus="handleFocus(true)" @blur="handleFocus(false)" @input="handleModelInput"> :placeholder="fillPlaceHolder"
<input v-if="type === 'password'" type="password" class="material-input" :name="name" :id="id" :placeholder="placeholder" v-model="currentValue"
v-model="valueCopy" :readonly="readonly" :disabled="disabled" :autocomplete="autocomplete" :max="max" :min="min" :required="required" :readonly="readonly" :disabled="disabled" :autoComplete="autoComplete" :required="required"
@focus="handleFocus(true)" @blur="handleFocus(false)" @input="handleModelInput"> @focus="handleMdFocus"
<input v-if="type === 'tel'" type="tel" class="material-input" :name="name" :id="id" :placeholder="placeholder" v-model="valueCopy" @blur="handleMdBlur" @input="handleModelInput">
:readonly="readonly" :disabled="disabled" :autocomplete="autocomplete" :required="required" @focus="handleFocus(true)" <input v-if="type === 'number'" type="number" class="material-input" :name="name"
@blur="handleFocus(false)" @input="handleModelInput"> :placeholder="fillPlaceHolder" v-model="currentValue" :step="step"
<input v-if="type === 'text'" type="text" class="material-input" :name="name" :id="id" :placeholder="placeholder" v-model="valueCopy" :readonly="readonly" :disabled="disabled" :autoComplete="autoComplete" :max="max" :min="min"
:readonly="readonly" :disabled="disabled" :autocomplete="autocomplete" :minlength="minlength" :maxlength="maxlength" :minlength="minlength" :maxlength="maxlength"
:required="required" @focus="handleFocus(true)" @blur="handleFocus(false)" @input="handleModelInput"> :required="required" @focus="handleMdFocus" @blur="handleMdBlur" @input="handleModelInput">
<input v-if="type === 'password'" type="password" class="material-input" :name="name"
:placeholder="fillPlaceHolder"
v-model="currentValue" :readonly="readonly" :disabled="disabled" :autoComplete="autoComplete" :max="max"
:min="min" :required="required"
@focus="handleMdFocus" @blur="handleMdBlur" @input="handleModelInput">
<input v-if="type === 'tel'" type="tel" class="material-input" :name="name"
:placeholder="fillPlaceHolder"
v-model="currentValue"
:readonly="readonly" :disabled="disabled" :autoComplete="autoComplete" :required="required"
@focus="handleMdFocus"
@blur="handleMdBlur" @input="handleModelInput">
<input v-if="type === 'text'" type="text" class="material-input" :name="name"
:placeholder="fillPlaceHolder" v-model="currentValue"
:readonly="readonly" :disabled="disabled" :autoComplete="autoComplete" :minlength="minlength"
:maxlength="maxlength"
:required="required" @focus="handleMdFocus" @blur="handleMdBlur" @input="handleModelInput">
<span class="material-input-bar"></span> <span class="material-input-bar"></span>
<label class="material-label"> <label class="material-label">
<slot></slot> <slot></slot>
</label> </label>
<div v-if="errorMessages" class="material-errors">
<div v-for="error in computedErrors" class="material-error" :key='error'>
{{ error }}
</div>
</div> </div>
</div> </div>
</template> </template>
<script> <script>
// source:https://github.com/wemake-services/vue-material-input/blob/master/src/components/MaterialInput.vue // source:https://github.com/wemake-services/vue-material-input/blob/master/src/components/MaterialInput.vue
export default {
name: 'material-input', export default {
name: 'md-input',
computed: { computed: {
computedErrors() {
return typeof this.errorMessages === 'string'
? [this.errorMessages] : this.errorMessages
},
computedClasses() { computedClasses() {
return { return {
'material--active': this.focus, 'material--active': this.focus,
'material--disabled': this.disabled, 'material--disabled': this.disabled,
'material--has-errors': Boolean(!this.valid || (this.errorMessages && this.errorMessages.length)), 'material--raised': Boolean(this.focus || this.currentValue) // has value
'material--raised': Boolean(this.focus || this.valueCopy || // has value
(this.placeholder && !this.valueCopy)) // has placeholder
} }
} }
}, },
data() { data() {
return { return {
valueCopy: null, currentValue: this.value,
focus: false, focus: false,
valid: true fillPlaceHolder: null
} }
}, },
beforeMount() {
// Here we are following the Vue2 convention on custom v-model:
// https://github.com/vuejs/vue/issues/2873#issuecomment-223759341
this.copyValue(this.value)
},
methods: { methods: {
handleModelInput(event) { handleModelInput(event) {
this.$emit('input', event.target.value, event) const value = event.target.value
this.handleValidation() this.$emit('input', value)
if (this.$parent.$options.componentName === 'ElFormItem') {
if (this.validateEvent) {
this.$parent.$emit('el.form.change', [value])
}
}
this.$emit('change', value)
// this.handleValidation()
}, },
handleFocus(focused) { handleMdFocus(event) {
this.focus = focused this.focus = true
}, this.$emit('focus', event)
handleValidation() { if (this.placeholder && this.placeholder !== '') {
this.valid = this.$el ? this.$el.querySelector('.material-input').validity.valid : this.valid this.fillPlaceHolder = this.placeholder
},
copyValue(value) {
this.valueCopy = value
this.handleValidation()
} }
}, },
watch: { handleMdBlur(event) {
value(newValue) { this.focus = false
this.copyValue(newValue) this.$emit('blur', event)
this.fillPlaceHolder = null
if (this.$parent.$options.componentName === 'ElFormItem') {
if (this.validateEvent) {
this.$parent.$emit('el.form.blur', [this.currentValue])
}
}
} }
}, },
props: { props: {
id: { icon: String,
type: String, name: String,
default: null
},
name: {
type: String,
default: null
},
type: { type: {
type: String, type: String,
default: 'text' default: 'text'
}, },
value: { value: [String, Number],
default: null placeholder: String,
}, readonly: Boolean,
placeholder: { disabled: Boolean,
type: String, min: String,
default: null max: String,
}, step: String,
readonly: { minlength: Number,
type: Boolean, maxlength: Number,
default: false
},
disabled: {
type: Boolean,
default: false
},
min: {
type: String,
default: null
},
max: {
type: String,
default: null
},
minlength: {
type: Number,
default: null
},
maxlength: {
type: Number,
default: null
},
required: { required: {
type: Boolean, type: Boolean,
default: true default: true
}, },
autocomplete: { autoComplete: {
type: String, type: String,
default: 'off' default: 'off'
}, },
errorMessages: { validateEvent: {
type: [Array, String], type: Boolean,
default: null default: true
}
} }
} }
}
</script> </script>
<style rel="stylesheet/scss" lang="scss" scoped> <style rel="stylesheet/scss" lang="scss" scoped>
@ -150,9 +135,20 @@ export default {
$font-size-small: 18px; $font-size-small: 18px;
$font-size-smallest: 12px; $font-size-smallest: 12px;
$font-weight-normal: normal; $font-weight-normal: normal;
$font-weight-bold: bold;
$apixel: 1px;
// Utils // Utils
$spacer: 12px; $spacer: 12px;
$transition: 0.2s ease all; $transition: 0.2s ease all;
$index: 0px;
$index-has-icon: 30px;
// Theme:
$color-white: white;
$color-grey: #9E9E9E;
$color-grey-light: #E0E0E0;
$color-blue: #2196F3;
$color-red: #F44336;
$color-black: black;
// Base clases: // Base clases:
%base-bar-pseudo { %base-bar-pseudo {
content: ''; content: '';
@ -165,23 +161,45 @@ export default {
// Mixins: // Mixins:
@mixin slided-top() { @mixin slided-top() {
top: -2 * $spacer; top: - ($font-size-base + $spacer);
font-size: $font-size-small; left: 0;
font-size: $font-size-base;
font-weight: $font-weight-bold;
} }
// Component: // Component:
.material-input__component { .material-input__component {
/*margin-top: 30px;*/ margin-top: 36px;
position: relative; position: relative;
* { * {
box-sizing: border-box; box-sizing: border-box;
} }
.iconClass {
.material-input__icon {
position: absolute;
left: 0;
color: $color-blue;
top: $spacer;
width: $index-has-icon;
height: $font-size-base;
font-size: $font-size-base;
font-weight: $font-weight-normal;
pointer-events: none;
}
.material-label {
left: $index-has-icon;
}
.material-input {
text-indent: $index-has-icon;
}
}
.material-input { .material-input {
font-size: $font-size-base; font-size: $font-size-base;
padding: $spacer $spacer $spacer $spacer / 2; padding: $spacer $spacer $spacer - $apixel * 10 $spacer / 2;
display: block; display: block;
width: 100%; width: 100%;
border: none; border: none;
line-height: 1;
border-radius: 0; border-radius: 0;
&:focus { &:focus {
outline: none; outline: none;
@ -190,13 +208,13 @@ export default {
} }
} }
.material-label { .material-label {
font-size: $font-size-base;
font-weight: $font-weight-normal; font-weight: $font-weight-normal;
position: absolute; position: absolute;
pointer-events: none; pointer-events: none;
left: 0; left: $index;
top: $spacer; top: 0;
transition: $transition; transition: $transition;
font-size: $font-size-small;
} }
.material-input-bar { .material-input-bar {
position: relative; position: relative;
@ -232,35 +250,14 @@ export default {
} }
} }
} }
// Errors:
.material-errors {
position: relative;
overflow: hidden;
.material-error {
font-size: $font-size-smallest;
line-height: $font-size-smallest + 2px;
overflow: hidden;
margin-top: 0;
padding-top: $spacer / 2;
padding-right: $spacer / 2;
padding-left: 0;
}
}
} }
// Theme:
$color-white: white;
$color-grey: #9E9E9E;
$color-grey-light: #E0E0E0;
$color-blue: #2196F3;
$color-red: #F44336;
$color-black: black;
.material-input__component { .material-input__component {
background: $color-white; background: $color-white;
.material-input { .material-input {
background: none; background: none;
color: $color-black; color: $color-black;
text-indent: 30px; text-indent: $index;
border-bottom: 1px solid $color-grey-light; border-bottom: 1px solid $color-grey-light;
} }
.material-label { .material-label {
@ -286,12 +283,9 @@ export default {
.material-input-bar { .material-input-bar {
&:before, &:before,
&:after { &:after {
background: $color-red; background: transparent;
} }
} }
.material-errors {
color: $color-red;
}
} }
} }
</style> </style>

View File

@ -1,9 +1,11 @@
<template> <template>
<div class="components-container"> <div class="components-container">
<div class='component-item'> <div class='component-item'>
<md-input name="name" v-model="title" required :maxlength="100"> <el-form :model="demo" :rules="demoRules">
标题 <el-form-item prop="title">
</md-input> <md-input icon="search" name="title" placeholder="输入标题" v-model="demo.title">标题</md-input>
</el-form-item>
</el-form>
<code class='code-part'>Material Design 的input</code> <code class='code-part'>Material Design 的input</code>
</div> </div>
@ -22,18 +24,33 @@
</template> </template>
<script> <script>
import MdInput from '@/components/MDinput'
import PanThumb from '@/components/PanThumb' import PanThumb from '@/components/PanThumb'
import MdInput from '@/components/MDinput'
import waves from '@/directive/waves.js' // import waves from '@/directive/waves.js' //
export default { export default {
components: { MdInput, PanThumb }, components: {
PanThumb,
MdInput
},
directives: { directives: {
waves waves
}, },
data() { data() {
const validate = (rule, value, callback) => {
if (value.length !== 6) {
callback(new Error('请输入六个字符'))
} else {
callback()
}
}
return { return {
demo: {
title: '' title: ''
},
demoRules: {
title: [{ required: true, trigger: 'change', validator: validate }]
}
} }
} }
} }

View File

@ -98,7 +98,6 @@ export default {
<style rel="stylesheet/scss" lang="scss" scoped> <style rel="stylesheet/scss" lang="scss" scoped>
.dashboard-editor-container { .dashboard-editor-container {
margin: 30px;
.btn-group { .btn-group {
margin-bottom: 60px; margin-bottom: 60px;
} }

View File

@ -1,5 +1,5 @@
<template> <template>
<div class="dashboard-container"> <div class="dashboard-container" style="padding:20px;">
<component :is="currentRole"></component> <component :is="currentRole"></component>
</div> </div>
</template> </template>

View File

@ -1,5 +1,5 @@
<template> <template>
<section class="app-main" style="min-height: 100%"> <section class="app-main" style="min-height: 100%;margin-top:50px;">
<transition name="fade" mode="out-in"> <transition name="fade" mode="out-in">
<router-view :key="key"></router-view> <router-view :key="key"></router-view>
</transition> </transition>

View File

@ -1,4 +1,5 @@
<template> <template>
<div class="nav-container">
<el-menu class="navbar" mode="horizontal"> <el-menu class="navbar" mode="horizontal">
<hamburger class="hamburger-container" :toggleClick="toggleSideBar" :isActive="sidebar.opened"></hamburger> <hamburger class="hamburger-container" :toggleClick="toggleSideBar" :isActive="sidebar.opened"></hamburger>
<levelbar></levelbar> <levelbar></levelbar>
@ -25,6 +26,7 @@
</el-dropdown-menu> </el-dropdown-menu>
</el-dropdown> </el-dropdown>
</el-menu> </el-menu>
</div>
</template> </template>
<script> <script>
@ -70,10 +72,31 @@ export default {
</script> </script>
<style rel="stylesheet/scss" lang="scss" scoped> <style rel="stylesheet/scss" lang="scss" scoped>
.nav-container {
position:fixed;
top:0;
z-index:102;
width:100%;
box-shadow: 0 0 15px rgba(0, 0, 0, 0.3);
&::before{
content:'';
display: block;
width:100%;
z-index:-1;
filter:blur(10px);
background: rgba(238,241,246,0.8);
height:50px;
position:fixed;
left:0;
right:0;
top:0;
bottom:0;
}
.navbar { .navbar {
height: 50px; height: 50px;
line-height: 50px; line-height: 50px;
border-radius: 0px !important; border-radius: 0px !important;
background-color: rgba(238,241,246,0.8);
.hamburger-container { .hamburger-container {
line-height: 58px; line-height: 58px;
height: 50px; height: 50px;
@ -82,11 +105,11 @@ export default {
} }
.errLog-container { .errLog-container {
display: inline-block; display: inline-block;
position: absolute; position: fixed;
right: 150px; right: 150px;
} }
.screenfull { .screenfull {
position: absolute; position: fixed;
right: 90px; right: 90px;
top: 16px; top: 16px;
color: red; color: red;
@ -94,7 +117,7 @@ export default {
.avatar-container { .avatar-container {
height: 50px; height: 50px;
display: inline-block; display: inline-block;
position: absolute; position: fixed;
right: 35px; right: 35px;
.avatar-wrapper { .avatar-wrapper {
cursor: pointer; cursor: pointer;
@ -114,6 +137,7 @@ export default {
} }
} }
} }
}
</style> </style>