Skip to content

Commit a37ad6a

Browse files
committed
init : bajian <[email protected]>
0 parents  commit a37ad6a

23 files changed

+1020
-0
lines changed

.babelrc

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"presets": ["es2015", "stage-2"],
3+
"plugins": ["transform-runtime"],
4+
"comments": false
5+
}

.editorconfig

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true

.eslintignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
build/*.js
2+
config/*.js

.gitignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.DS_Store
2+
node_modules/
3+
dist/
4+
npm-debug.log
5+
selenium-debug.log
6+
test/unit/coverage
7+
test/e2e/reports

README.md

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# slider
2+
auto banner for more function
3+
4+
> A Vue.js project
5+
6+
## Build Setup
7+
8+
``` bash
9+
# install dependencies
10+
npm install
11+
12+
# serve with hot reload at localhost:8080
13+
npm run dev
14+
15+
# build for production with minification
16+
npm run build
17+
18+
```
19+
20+
```html
21+
<slider id="swiper_horizontal"
22+
:pagination-visible="true"
23+
:slides="slides"
24+
:repeating="true"
25+
:auto="5000">
26+
<a v-for="slide in slides" track-by="$index" :href="slide.value">
27+
<img width="500" height="156" :src="slide.image" />
28+
</a>
29+
</slider>
30+
```
31+
32+
## Api
33+
### Properties
34+
| Name | Type | Default | Description |
35+
|----------------------|-----------|--------------|--------------------------------------------------------------------|
36+
| direction | `String` | `"vertical"` | Could be 'horizontal' or 'vertical' (for vertical slider). |
37+
| mousewheel-control | `Boolean` | `true` | Set to true to enable navigation through slides using mouse wheel. |
38+
| pagination-visible | `Boolean` | `false` | Toggle (hide/true) pagination container visibility when click on Slider's container |
39+
| performace-mode | `Boolean` | `false` | Disable advance effect for better performance. |
40+
| ==================== | ========= | ============ | =================== |
41+
42+
### Methods
43+
| Method | Description |
44+
|-------------------|--------------------------|
45+
| next() | Go next page. |
46+
| prev() | Go previous page. |
47+
| setPage(`Number`) | Set current page number. |
48+
49+
### Events
50+
| Name | Parameters | Description |
51+
|--------------------|------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------|
52+
| slide-change-start | `pageNumber` | Fire in the beginning of animation to other slide (next or previous). |
53+
| slide-change-end | `pageNumber` | Will be fired after animation to other slide (next or previous). |
54+
| slide-revert-start | `pageNumber` | Fire in the beginning of animation to revert slide (no change). |
55+
| slide-revert-end | `pageNumber` | Will be fired after animation to revert slide (no change). |
56+
| slider-move | `offset` | Callback function, will be executed when user touch and move finger over Swiper and move it. Receives swiper instance and 'touchmove' event as an arguments. |
57+
| ================== | ================ | ============================ |
58+
59+
base on [vue-swiper](https://github.com/weilao/vue-swiper)
60+
61+
For detailed explanation on how things work, checkout the [guide](http://vuejs-templates.github.io/webpack/) and [docs for vue-loader](http://vuejs.github.io/vue-loader).

build/build.js

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// https://github.com/shelljs/shelljs
2+
require('shelljs/global')
3+
env.NODE_ENV = 'production'
4+
5+
var path = require('path')
6+
var config = require('../config')
7+
var ora = require('ora')
8+
var webpack = require('webpack')
9+
var webpackConfig = require('./webpack.prod.conf')
10+
11+
console.log(
12+
' Tip:\n' +
13+
' Built files are meant to be served over an HTTP server.\n' +
14+
' Opening index.html over file:// won\'t work.\n'
15+
)
16+
17+
var spinner = ora('building for production...')
18+
spinner.start()
19+
20+
var assetsPath = path.join(config.build.assetsRoot, config.build.assetsSubDirectory)
21+
rm('-rf', assetsPath)
22+
mkdir('-p', assetsPath)
23+
cp('-R', 'static/', assetsPath)
24+
25+
webpack(webpackConfig, function (err, stats) {
26+
spinner.stop()
27+
if (err) throw err
28+
process.stdout.write(stats.toString({
29+
colors: true,
30+
modules: false,
31+
children: false,
32+
chunks: false,
33+
chunkModules: false
34+
}) + '\n')
35+
})

build/dev-client.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/* eslint-disable */
2+
require('eventsource-polyfill')
3+
var hotClient = require('webpack-hot-middleware/client?noInfo=true&reload=true')
4+
5+
hotClient.subscribe(function (event) {
6+
if (event.action === 'reload') {
7+
window.location.reload()
8+
}
9+
})

build/dev-server.js

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
var path = require('path')
2+
var express = require('express')
3+
var webpack = require('webpack')
4+
var config = require('../config')
5+
var proxyMiddleware = require('http-proxy-middleware')
6+
var webpackConfig = process.env.NODE_ENV === 'testing'
7+
? require('./webpack.prod.conf')
8+
: require('./webpack.dev.conf')
9+
10+
// default port where dev server listens for incoming traffic
11+
var port = process.env.PORT || config.dev.port
12+
// Define HTTP proxies to your custom API backend
13+
// https://github.com/chimurai/http-proxy-middleware
14+
var proxyTable = config.dev.proxyTable
15+
16+
var app = express()
17+
var compiler = webpack(webpackConfig)
18+
19+
var devMiddleware = require('webpack-dev-middleware')(compiler, {
20+
publicPath: webpackConfig.output.publicPath,
21+
stats: {
22+
colors: true,
23+
chunks: false
24+
}
25+
})
26+
27+
var hotMiddleware = require('webpack-hot-middleware')(compiler)
28+
// force page reload when html-webpack-plugin template changes
29+
compiler.plugin('compilation', function (compilation) {
30+
compilation.plugin('html-webpack-plugin-after-emit', function (data, cb) {
31+
hotMiddleware.publish({ action: 'reload' })
32+
cb()
33+
})
34+
})
35+
36+
// proxy api requests
37+
Object.keys(proxyTable).forEach(function (context) {
38+
var options = proxyTable[context]
39+
if (typeof options === 'string') {
40+
options = { target: options }
41+
}
42+
app.use(proxyMiddleware(context, options))
43+
})
44+
45+
// handle fallback for HTML5 history API
46+
app.use(require('connect-history-api-fallback')())
47+
48+
// serve webpack bundle output
49+
app.use(devMiddleware)
50+
51+
// enable hot-reload and state-preserving
52+
// compilation error display
53+
app.use(hotMiddleware)
54+
55+
// serve pure static assets
56+
var staticPath = path.posix.join(config.dev.assetsPublicPath, config.dev.assetsSubDirectory)
57+
app.use(staticPath, express.static('./static'))
58+
59+
module.exports = app.listen(port, function (err) {
60+
if (err) {
61+
console.log(err)
62+
return
63+
}
64+
console.log('Listening at http://localhost:' + port + '\n')
65+
})

build/utils.js

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
var path = require('path')
2+
var config = require('../config')
3+
var ExtractTextPlugin = require('extract-text-webpack-plugin')
4+
5+
exports.assetsPath = function (_path) {
6+
var assetsSubDirectory = process.env.NODE_ENV === 'production'
7+
? config.build.assetsSubDirectory
8+
: config.dev.assetsSubDirectory
9+
return path.posix.join(assetsSubDirectory, _path)
10+
}
11+
12+
exports.cssLoaders = function (options) {
13+
options = options || {}
14+
// generate loader string to be used with extract text plugin
15+
function generateLoaders (loaders) {
16+
var sourceLoader = loaders.map(function (loader) {
17+
var extraParamChar
18+
if (/\?/.test(loader)) {
19+
loader = loader.replace(/\?/, '-loader?')
20+
extraParamChar = '&'
21+
} else {
22+
loader = loader + '-loader'
23+
extraParamChar = '?'
24+
}
25+
return loader + (options.sourceMap ? extraParamChar + 'sourceMap' : '')
26+
}).join('!')
27+
28+
if (options.extract) {
29+
return ExtractTextPlugin.extract('vue-style-loader', sourceLoader)
30+
} else {
31+
return ['vue-style-loader', sourceLoader].join('!')
32+
}
33+
}
34+
35+
// http://vuejs.github.io/vue-loader/configurations/extract-css.html
36+
return {
37+
css: generateLoaders(['css']),
38+
postcss: generateLoaders(['css']),
39+
less: generateLoaders(['css', 'less']),
40+
sass: generateLoaders(['css', 'sass?indentedSyntax']),
41+
scss: generateLoaders(['css', 'sass']),
42+
stylus: generateLoaders(['css', 'stylus']),
43+
styl: generateLoaders(['css', 'stylus'])
44+
}
45+
}
46+
47+
// Generate loaders for standalone style files (outside of .vue)
48+
exports.styleLoaders = function (options) {
49+
var output = []
50+
var loaders = exports.cssLoaders(options)
51+
for (var extension in loaders) {
52+
var loader = loaders[extension]
53+
output.push({
54+
test: new RegExp('\\.' + extension + '$'),
55+
loader: loader
56+
})
57+
}
58+
return output
59+
}

build/webpack.base.conf.js

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
var path = require('path')
2+
var config = require('../config')
3+
var utils = require('./utils')
4+
var projectRoot = path.resolve(__dirname, '../')
5+
6+
module.exports = {
7+
entry: {
8+
app: './src/main.js'
9+
},
10+
output: {
11+
path: config.build.assetsRoot,
12+
publicPath: process.env.NODE_ENV === 'production' ? config.build.assetsPublicPath : config.dev.assetsPublicPath,
13+
filename: '[name].js'
14+
},
15+
resolve: {
16+
extensions: ['', '.js', '.vue'],
17+
fallback: [path.join(__dirname, '../node_modules')],
18+
alias: {
19+
'src': path.resolve(__dirname, '../src'),
20+
'assets': path.resolve(__dirname, '../src/assets'),
21+
'components': path.resolve(__dirname, '../src/components')
22+
}
23+
},
24+
resolveLoader: {
25+
fallback: [path.join(__dirname, '../node_modules')]
26+
},
27+
module: {
28+
loaders: [
29+
{
30+
test: /\.vue$/,
31+
loader: 'vue'
32+
},
33+
{
34+
test: /\.js$/,
35+
loader: 'babel',
36+
include: projectRoot,
37+
exclude: /node_modules/
38+
},
39+
{
40+
test: /\.json$/,
41+
loader: 'json'
42+
},
43+
{
44+
test: /\.html$/,
45+
loader: 'vue-html'
46+
},
47+
{
48+
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
49+
loader: 'url',
50+
query: {
51+
limit: 10000,
52+
name: utils.assetsPath('img/[name].[hash:7].[ext]')
53+
}
54+
},
55+
{
56+
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
57+
loader: 'url',
58+
query: {
59+
limit: 10000,
60+
name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
61+
}
62+
}
63+
]
64+
},
65+
vue: {
66+
loaders: utils.cssLoaders()
67+
}
68+
}

build/webpack.dev.conf.js

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
var config = require('../config')
2+
var webpack = require('webpack')
3+
var merge = require('webpack-merge')
4+
var utils = require('./utils')
5+
var baseWebpackConfig = require('./webpack.base.conf')
6+
var HtmlWebpackPlugin = require('html-webpack-plugin')
7+
8+
// add hot-reload related code to entry chunks
9+
Object.keys(baseWebpackConfig.entry).forEach(function (name) {
10+
baseWebpackConfig.entry[name] = ['./build/dev-client'].concat(baseWebpackConfig.entry[name])
11+
})
12+
13+
module.exports = merge(baseWebpackConfig, {
14+
module: {
15+
loaders: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap })
16+
},
17+
// eval-source-map is faster for development
18+
devtool: '#eval-source-map',
19+
plugins: [
20+
new webpack.DefinePlugin({
21+
'process.env': config.dev.env
22+
}),
23+
// https://github.com/glenjamin/webpack-hot-middleware#installation--usage
24+
new webpack.optimize.OccurenceOrderPlugin(),
25+
new webpack.HotModuleReplacementPlugin(),
26+
new webpack.NoErrorsPlugin(),
27+
// https://github.com/ampedandwired/html-webpack-plugin
28+
new HtmlWebpackPlugin({
29+
filename: 'index.html',
30+
template: 'index.html',
31+
inject: true
32+
})
33+
]
34+
})

0 commit comments

Comments
 (0)