Browse Source

first

master
syui 2 years ago
commit
d73f9398de
No known key found for this signature in database GPG Key ID: ED2A0F5F1DA25512
  1. 7
      .babelrc
  2. 3
      .gitignore
  3. BIN
      img/0.png
  4. BIN
      img/1.png
  5. BIN
      img/2.png
  6. 49
      package.json
  7. BIN
      public-vue/img/01.png
  8. BIN
      public-vue/img/02.png
  9. BIN
      public-vue/img/03.png
  10. 10
      readme.md
  11. 0
      src/App.vue
  12. 143
      src/index.html
  13. 93
      src/main.js
  14. 114
      webpack.config.js

7
.babelrc

@ -0,0 +1,7 @@
{
"presets": [
["latest", {
"es2015": { "modules": false }
}]
]
}

3
.gitignore

@ -0,0 +1,3 @@
.DS_Store
yarn.lock
node_modules

BIN
img/0.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

BIN
img/1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

BIN
img/2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

49
package.json

@ -0,0 +1,49 @@
{
"name": "vue-example",
"description": "example vue",
"version": "0.0.1",
"author": "syui <syui@syui.cf>",
"license": "MIT",
"scripts": {
"dev": "cross-env NODE_ENV=development webpack-dev-server --open --hot --host 0.0.0.0 --port 7000",
"build": "cross-env NODE_ENV=production webpack --progress --hide-modules",
"build:watch": "cross-env NODE_ENV=production WEBPACK_WATCH=true webpack --progress --hide-modules",
"demo:index": "mv public/index.html public/main.html && sed -i 's/index\\.html/main\\.html/' public/demo.html && mv public/demo.html public/index.html",
"deploy": "npm run demo:index && ghpages -p public"
},
"dependencies": {
"onsenui": "^2.10.10",
"vue": "^2.6.10",
"vue-onsenui": "^2.6.2",
"vuex": "^3.1.1"
},
"devDependencies": {
"@babel/cli": "^7.7.0",
"@babel/core": "^7.7.2",
"@babel/node": "^7.7.0",
"@babel/preset-env": "^7.7.1",
"axios": "^0.19.0",
"babel-core": "^6.26.3",
"babel-loader": "^8.0.6",
"babel-preset-env": "^1.7.0",
"babel-preset-latest": "^6.0.0",
"copy-webpack-plugin": "^4.0.1",
"cross-env": "^3.0.0",
"css-loader": "^0.28.7",
"extract-text-webpack-plugin": "^4.0.0-beta.0",
"file-loader": "^0.11.2",
"html-webpack-plugin": "^3",
"postcss": "^6.0.11",
"postcss-base64": "^0.7.1",
"postcss-cssnext": "^3.0.2",
"postcss-loader": "^2.0.6",
"postcss-smart-import": "^0.7.5",
"postcss-url": "^7.1.2",
"style-loader": "^0.18.2",
"vue-loader": "^12.0.4",
"vue-template-compiler": "^2.4.2",
"webpack": "^4.41.2",
"webpack-cli": "^3.3.10",
"webpack-dev-server": "^3.9.0"
}
}

BIN
public-vue/img/01.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

BIN
public-vue/img/02.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

BIN
public-vue/img/03.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

10
readme.md

@ -0,0 +1,10 @@
## comic.page
This simple image viewer pages created with vue.js.
```sh
$ yarn install
$ yarn dev
$ yarn build
```

0
src/App.vue

143
src/index.html

@ -0,0 +1,143 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>comic.page</title>
<style>
img {
width: 100%;
max-width: 700px;
margin-left:55px;
}
body {
font-family: Helvetica Neue, Arial, sans-serif;
font-size: 14px;
color: #444;
}
table {
border: 2px solid #42b983;
border-radius: 3px;
background-color: #fff;
}
th {
background-color: #42b983;
color: rgba(255,255,255,0.66);
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
td {
background-color: #f9f9f9;
}
th, td {
min-width: 120px;
padding: 10px 20px;
}
th.active {
color: #fff;
}
th.active .arrow {
opacity: 1;
}
.arrow {
display: inline-block;
vertical-align: middle;
width: 0;
height: 0;
margin-left: 5px;
opacity: 0.66;
}
.arrow.asc {
border-left: 4px solid transparent;
border-right: 4px solid transparent;
border-bottom: 4px solid #fff;
}
.arrow.dsc {
border-left: 4px solid transparent;
border-right: 4px solid transparent;
border-top: 4px solid #fff;
}
.slide-enter-active, .slide-leave-active {
transition: transform .5s
}
.slide-enter {
transform: translateX(300px)
}
.slide-leave-active {
transform: translateX(-300px);
}
button#start-stop {
display:none;
width: 148px;
height: 30px;
background-color: #008fc7;
border: 1px #ccc solid;
margin-bottom: 15px;
color: #fff;
}
button#next-comic {
width: 50px;
position: absolute;
top: 0px;
left: 0px;
z-index: 2;
height: 950px;
max-height: 950px;
background-color: #008fc7c9;
color: #fff;
}
@media screen and (max-width: 1000px){
img {
margin-left:0px;
}
}
</style>
</head>
<body>
<script type="text/x-template" id="grid-template">
<table>
<thead>
<tr>
<th v-for="key in columns"
@click="sortBy(key)"
:class="{ active: sortKey == key }">
{{ key | capitalize }}
<span class="arrow" :class="sortOrders[key] > 0 ? 'asc' : 'dsc'">
</span>
</th>
</tr>
</thead>
<tbody>
<tr v-for="entry in filteredData">
<td v-for="key in columns">
{{entry[key]}}
</td>
</tr>
</tbody>
</table>
</script>
<div id="app">
<transition name="slide">
<img v-bind:src="'/img/' + products[product] + '.png'"/>
</transition>
<div class="image-button">
<button id="next-comic" @click="nextSlide">&gt;</button> <button id="start-stop" @click="offTimer">{{ btnString }}</button>
</div>
</div>
</body>
</html>

93
src/main.js

@ -0,0 +1,93 @@
import Vue from 'vue'
import axios from 'axios'
var page = 3;
Vue.component('demo-grid', {
template: '#grid-template',
props: {
data: Array,
columns: Array,
filterKey: String
},
data: function () {
var sortOrders = {}
this.columns.forEach(function (key) {
sortOrders[key] = 1
})
return {
sortKey: '',
sortOrders: sortOrders
}
},
computed: {
filteredData: function () {
var sortKey = this.sortKey
var filterKey = this.filterKey && this.filterKey.toLowerCase()
var order = this.sortOrders[sortKey] || 1
var data = this.data
if (filterKey) {
data = data.filter(function (row) {
return Object.keys(row).some(function (key) {
return String(row[key]).toLowerCase().indexOf(filterKey) > -1
})
})
}
if (sortKey) {
data = data.slice().sort(function (a, b) {
a = a[sortKey]
b = b[sortKey]
return (a === b ? 0 : a > b ? 1 : -1) * order
})
}
return data
}
},
filters: {
capitalize: function (str) {
return str.charAt(0).toUpperCase() + str.slice(1)
}
},
methods: {
sortBy: function (key) {
this.sortKey = key
this.sortOrders[key] = this.sortOrders[key] * -1
}
}
})
var app = new Vue({
el: '#app',
data: {
product: 0,
products: [...Array(page).keys()],
timer: 1
},
computed: {
btnString: function() {
return this.timer === null ? "▶" : "■";
}
},
mounted: function() {
//this.onTimer();
},
methods: {
nextSlide: function() {
this.product = this.product < this.products.length - 1 ? this.product += 1 : 0;
},
onTimer: function () {
this.timer = setInterval(() => {
this.nextSlide();
}, 1000)
},
offTimer: function () {
if(this.timer === null) {
this.onTimer();
} else {
clearInterval(this.timer);
this.timer = null;
}
}
}
});

114
webpack.config.js

@ -0,0 +1,114 @@
var path = require('path');
var webpack = require('webpack');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var CopyWebpackPlugin = require('copy-webpack-plugin');
module.exports = {
mode: 'production',
watch: process.env.WEBPACK_WATCH === 'true',
entry: './src/main.js',
output: {
path: path.resolve(__dirname, './public-vue'),
publicPath: '',
filename: 'build.js'
},
module: {
rules: [
{
test: /\.vue$/,
loader: 'vue-loader',
options: {
loaders: {
}
// other vue-loader options go here
}
},
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/
},
{
test: /\.(png|jpe?g|gif|svg|woff|woff2|ttf|eot|ico)$/,
loader: 'file-loader',
options: {
name: '[name].[ext]?[hash]'
}
},
{
test: /\.css$/,
loader: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
{
loader: 'css-loader',
options: { importLoaders: 1 }
},
{
loader: 'postcss-loader',
options: {
plugins: [
require('postcss-smart-import')(),
require('postcss-url')(),
require('postcss-base64')({
extensions: ['.svg'],
root: 'src'
}),
require('postcss-cssnext')({
browsers: ['> 1%', 'last 2 versions', 'Firefox ESR', 'Opera 12.1'],
features: { autoprefixer: { remove: false } } // 'background-image: radial-gradient' broken in autoprefixer
})
]
}
}
]
})
}
]
},
plugins: [
new ExtractTextPlugin('[name].css'),
new HtmlWebpackPlugin({
template: 'src/index.html'
})
],
resolve: {
alias: {
'vue$': 'vue/dist/vue.esm.js',
//// For development:
// 'vue-onsenui$': path.join(__dirname, '..', 'OnsenUI', 'bindings', 'vue', 'dist', 'vue-onsenui'),
// 'onsenui$': path.join(__dirname, '..', 'OnsenUI', 'build', 'js', 'onsenui'),
// 'onsenui': path.join(__dirname, '..', 'OnsenUI', 'build'),
}
},
devServer: {
historyApiFallback: true,
noInfo: true
},
performance: {
hints: false
},
devtool: '#eval-source-map'
};
if (process.env.NODE_ENV === 'production') {
module.exports.devtool = '#source-map';
// http://vue-loader.vuejs.org/en/workflow/production.html
module.exports.plugins = (module.exports.plugins || []).concat([
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"production"'
}
}),
//new webpack.optimize.UglifyJsPlugin({
// sourceMap: true,
// compress: {
// warnings: false
// }
//}),
new webpack.LoaderOptionsPlugin({
minimize: true
})
]);
}
Loading…
Cancel
Save