feat: 初步建立好页面

This commit is contained in:
宁宁 2019-06-25 13:30:32 +08:00
parent 984616f297
commit a6adc50ac8
13 changed files with 8342 additions and 0 deletions

21
.gitignore vendored Normal file
View File

@ -0,0 +1,21 @@
.DS_Store
node_modules
/dist
# local env files
.env.local
.env.*.local
# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

5
babel.config.js Normal file
View File

@ -0,0 +1,5 @@
module.exports = {
presets: [
'@vue/app'
]
}

45
package.json Normal file
View File

@ -0,0 +1,45 @@
{
"name": "any-rule",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"core-js": "^2.6.5",
"node-sass": "^4.12.0",
"sass-loader": "^7.1.0",
"vue": "^2.6.10"
},
"devDependencies": {
"@vue/cli-plugin-babel": "^3.8.0",
"@vue/cli-plugin-eslint": "^3.8.0",
"@vue/cli-service": "^3.8.0",
"vue-template-compiler": "^2.6.10"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/essential",
"eslint:recommended"
],
"rules": {},
"parserOptions": {
"parser": "babel-eslint"
}
},
"postcss": {
"plugins": {
"autoprefixer": {}
}
},
"browserslist": [
"> 1%",
"last 2 versions"
]
}

8
prettier.config.js Normal file
View File

@ -0,0 +1,8 @@
// prettier.config.js or .prettierrc.js
module.exports = {
tabWidth: 4,
semi: true,
singleQuote: true,
arrowParens: 'always',
printWidth: 120
};

BIN
public/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

34
public/index.html Normal file
View File

@ -0,0 +1,34 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title>any-rule</title>
<style>
* {
padding: 0;
margin: 0;
}
input{
outline: none;
border:0 none;
}
li {
list-style-type: none;
}
</style>
</head>
<body>
<noscript>
<strong>We're sorry but any-rule doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>

152
src/App.vue Normal file
View File

@ -0,0 +1,152 @@
<template>
<main>
<header>
<h1>正则大全</h1>
</header>
<article>
<ul class="list">
<li v-for="({title, rule, events}, index) in RULES" :key="title" class="row">
<h2>{{title}}</h2>
<p class="rule">{{rule}}</p>
<section class="verification">
<label>
<input
v-model="list[index].value"
@blur="check(index, 'blur')"
@keyup="check(index, 'keyup')"
>
</label>
<template v-if="undefined !== list[index].isOk">
<span v-if="list[index].isOk" class="success">通过</span>
<span v-else class="error">不通过</span>
</template>
</section>
<section class="trigger">
<h3>验证时机</h3>
<label>
<input v-model="list[index].events.blur" type="checkbox"> blur
</label>
<label>
<input v-model="list[index].events.keyup" type="checkbox"> keyup
</label>
</section>
</li>
</ul>
</article>
</main>
</template>
<script>
import RULES from '@/RULES';
export default {
name: 'app',
components: {},
data() {
Object.freeze(RULES);
return {
RULES,
list: RULES.map(() => ({
value: '',
isOk: undefined,
events: {
blur: true,
keyup: false
}
}))
};
},
methods: {
reset(index) {
this.list[index].isOk = undefined;
},
check(index, type) {
const { events } = this.list[index];
if (events[type]) {
const { rule } = this.RULES[index];
const row = this.list[index];
row.isOk = rule.test(row.value);
}
}
}
};
</script>
<style lang="scss" scoped>
$radius: 4px;
main {
font-family: 'Avenir', Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
header {
padding: 15px;
}
ul.list {
padding:15px;
li {
border-radius: $radius;
margin-top:15px;
padding: 15px;
border-color: #eee;
border-width:1px;
border-style: solid;
will-change: auto;
&:hover{
transition: box-shadow 500ms, transform 500ms;
box-shadow: 1px 2px 15px rgba(0,0,0,0.21);
border-radius: $radius;
border-color: #eee;
transform:scale(1.01);
}
> p.rule {
margin-top: 15px;
padding: 5px 15px;
background: #eee;
border-radius: $radius;
}
> section.verification {
margin-top: 15px;
display: flex;
overflow: hidden;
> label {
display: block;
> input {
padding: 5px 15px;
border-radius: $radius;
border: 1px solid #ddd;
}
+ span {
margin-left:5px;
&.success {
color: #4caf50;
}
&.error {
color: #ff5722;
}
}
}
}
>section.trigger{
margin-top: 15px;
display: flex;
align-items: center;
align-content: center;
h3{font-size: 14px;}
>label{padding:0 10px;}
}
}
}
}
</style>

7
src/RULES.js Normal file
View File

@ -0,0 +1,7 @@
export default [{
title: '是否手机号',
rule: /^((13[0-9])|(15[^4,\D])|(18[0-9]))\d{8}$/,
}, {
title: '只能输入大写字母',
rule: /^[A-Z]+$/,
}];

3
src/Untitled-1 Normal file
View File

@ -0,0 +1,3 @@
5. 开发的技术路线选择前后端分离的方式进行开发,后端java提供接口,前端通过http请求方式获取数据, 然后进行页面内容渲染和交互逻辑设计. 具体使用vue2的单页模式技术来开发, 其中包含了webpack / sass / canvas / axios / 字体图标等工具. 开发阶段的mock选择了webpack的反向代理, 用来实现局域网内的模拟测试.
6. 开发中使用的工具有vscode/蓝湖平台/禅道.

BIN
src/assets/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

View File

@ -0,0 +1,58 @@
<template>
<div class="hello">
<h1>{{ msg }}</h1>
<p>
For a guide and recipes on how to configure / customize this project,<br>
check out the
<a href="https://cli.vuejs.org" target="_blank" rel="noopener">vue-cli documentation</a>.
</p>
<h3>Installed CLI Plugins</h3>
<ul>
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-babel" target="_blank" rel="noopener">babel</a></li>
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-eslint" target="_blank" rel="noopener">eslint</a></li>
</ul>
<h3>Essential Links</h3>
<ul>
<li><a href="https://vuejs.org" target="_blank" rel="noopener">Core Docs</a></li>
<li><a href="https://forum.vuejs.org" target="_blank" rel="noopener">Forum</a></li>
<li><a href="https://chat.vuejs.org" target="_blank" rel="noopener">Community Chat</a></li>
<li><a href="https://twitter.com/vuejs" target="_blank" rel="noopener">Twitter</a></li>
<li><a href="https://news.vuejs.org" target="_blank" rel="noopener">News</a></li>
</ul>
<h3>Ecosystem</h3>
<ul>
<li><a href="https://router.vuejs.org" target="_blank" rel="noopener">vue-router</a></li>
<li><a href="https://vuex.vuejs.org" target="_blank" rel="noopener">vuex</a></li>
<li><a href="https://github.com/vuejs/vue-devtools#vue-devtools" target="_blank" rel="noopener">vue-devtools</a></li>
<li><a href="https://vue-loader.vuejs.org" target="_blank" rel="noopener">vue-loader</a></li>
<li><a href="https://github.com/vuejs/awesome-vue" target="_blank" rel="noopener">awesome-vue</a></li>
</ul>
</div>
</template>
<script>
export default {
name: 'HelloWorld',
props: {
msg: String
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h3 {
margin: 40px 0 0;
}
ul {
list-style-type: none;
padding: 0;
}
li {
display: inline-block;
margin: 0 10px;
}
a {
color: #42b983;
}
</style>

8
src/main.js Normal file
View File

@ -0,0 +1,8 @@
import Vue from 'vue'
import App from './App.vue'
Vue.config.productionTip = false
new Vue({
render: h => h(App),
}).$mount('#app')

8001
yarn.lock Normal file

File diff suppressed because it is too large Load Diff