-
Notifications
You must be signed in to change notification settings - Fork 258
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
400 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<template> | ||
<div v-if="isExternal" :style="styleExternalIcon" class="svg-external-icon svg-icon" v-on="$listeners" /> | ||
<svg v-else :class="svgClass" aria-hidden="true" v-on="$listeners"> | ||
<use :xlink:href="iconName" /> | ||
</svg> | ||
</template> | ||
|
||
<script> | ||
import { isExternal } from '../../utils/validate' | ||
export default { | ||
name: 'SvgIcon', | ||
props: { | ||
iconClass: { | ||
type: String, | ||
required: true | ||
}, | ||
className: { | ||
type: String, | ||
default: '' | ||
} | ||
}, | ||
computed: { | ||
isExternal() { | ||
return isExternal(this.iconClass) | ||
}, | ||
iconName() { | ||
return `#icon-${this.iconClass}` | ||
}, | ||
svgClass() { | ||
if (this.className) { | ||
return 'svg-icon ' + this.className | ||
} else { | ||
return 'svg-icon' | ||
} | ||
}, | ||
styleExternalIcon() { | ||
return { | ||
mask: `url(${this.iconClass}) no-repeat 50% 50%`, | ||
'-webkit-mask': `url(${this.iconClass}) no-repeat 50% 50%` | ||
} | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
.svg-icon { | ||
width: 1em; | ||
height: 1em; | ||
vertical-align: -0.15em; | ||
fill: currentColor; | ||
overflow: hidden; | ||
} | ||
.svg-external-icon { | ||
background-color: currentColor; | ||
mask-size: cover!important; | ||
display: inline-block; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import Vue from 'vue' | ||
import SvgIcon from '../components/SvgIcon'// svg component | ||
|
||
// register globally | ||
Vue.component('svg-icon', SvgIcon) | ||
|
||
const req = require.context('./svg', false, /\.svg$/) | ||
const requireAll = requireContext => requireContext.keys().map(requireContext) | ||
requireAll(req) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# replace default config | ||
|
||
# multipass: true | ||
# full: true | ||
|
||
plugins: | ||
|
||
# - name | ||
# | ||
# or: | ||
# - name: false | ||
# - name: true | ||
# | ||
# or: | ||
# - name: | ||
# param1: 1 | ||
# param2: 2 | ||
|
||
- removeAttrs: | ||
attrs: | ||
- 'fill' | ||
- 'fill-rule' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/** | ||
* @param {string} path | ||
* @returns {Boolean} | ||
*/ | ||
export function isExternal(path) { | ||
return /^(https?:|mailto:|tel:)/.test(path) | ||
} | ||
|
||
/** | ||
* @param {string} str | ||
* @returns {Boolean} | ||
*/ | ||
export function validUsername(str) { | ||
const valid_map = ['admin', 'editor'] | ||
return valid_map.indexOf(str.trim()) >= 0 | ||
} | ||
|
||
/** | ||
* @param {string} url | ||
* @returns {Boolean} | ||
*/ | ||
export function validURL(url) { | ||
const reg = /^(https?|ftp):\/\/([a-zA-Z0-9.-]+(:[a-zA-Z0-9.&%$-]+)*@)*((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}|([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(:[0-9]+)*(\/($|[a-zA-Z0-9.,?'\\+&%$#=~_-]+))*$/ | ||
return reg.test(url) | ||
} | ||
|
||
/** | ||
* @param {string} str | ||
* @returns {Boolean} | ||
*/ | ||
export function validLowerCase(str) { | ||
const reg = /^[a-z]+$/ | ||
return reg.test(str) | ||
} | ||
|
||
/** | ||
* @param {string} str | ||
* @returns {Boolean} | ||
*/ | ||
export function validUpperCase(str) { | ||
const reg = /^[A-Z]+$/ | ||
return reg.test(str) | ||
} | ||
|
||
/** | ||
* @param {string} str | ||
* @returns {Boolean} | ||
*/ | ||
export function validAlphabets(str) { | ||
const reg = /^[A-Za-z]+$/ | ||
return reg.test(str) | ||
} | ||
|
||
/** | ||
* @param {string} email | ||
* @returns {Boolean} | ||
*/ | ||
export function validEmail(email) { | ||
const reg = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/ | ||
return reg.test(email) | ||
} | ||
|
||
/** | ||
* @param {string} str | ||
* @returns {Boolean} | ||
*/ | ||
export function isString(str) { | ||
if (typeof str === 'string' || str instanceof String) { | ||
return true | ||
} | ||
return false | ||
} | ||
|
||
/** | ||
* @param {Array} arg | ||
* @returns {Boolean} | ||
*/ | ||
export function isArray(arg) { | ||
if (typeof Array.isArray === 'undefined') { | ||
return Object.prototype.toString.call(arg) === '[object Array]' | ||
} | ||
return Array.isArray(arg) | ||
} | ||
|
||
// 是否空字符串 | ||
/** | ||
* @param {string} str | ||
* @returns {Boolean} | ||
*/ | ||
export function isEmptyInput(str) { | ||
return str.trim().length > 0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.