Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
haozi committed Mar 18, 2017
1 parent 235c91f commit 023fb0e
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 6 deletions.
28 changes: 28 additions & 0 deletions .config/webpack.prod.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ const merge = require('webpack-merge')
const baseWebpackConfig = require('./webpack.base.conf')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const Manifest = require('webpack-manifest')

const env = process.env.NODE_ENV === 'testing'
? require('config/test.env')
: config.build.env
Expand Down Expand Up @@ -73,6 +75,32 @@ const webpackConfig = merge(baseWebpackConfig, {
},
chunksSortMode: 'dependency'
}),

new Manifest({
cache: [
'/[hash:3].js',
'https://s4.cnzz.com/z_stat.php?id=1261523779&web_id=1261523779'
],
// Add time in comments.
timestamp: true,
// 生成的文件名字,选填
// The generated file name, optional.
filename: 'cache.manifest',
// 注意*星号前面用空格隔开
network: [
'*'
// 'http://api.map.baidu.com/ *',
// 'http://p.ssl.qhimg.com/ *',
// 'https://p.ssl.qhimg.com/ *'
],
// 注意中间用空格隔开
// fallback: ['/ /404.html'],
// manifest 文件中添加注释
// Add notes to manifest file.
headcomment: pkg.name + ' v' + pkg.version,
master: ['index/index.html']
}),

config.build.vendor && new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks: function (module, count) {
Expand Down
8 changes: 7 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
<!doctype html><body>
<!doctype html>
<html manifest="/cache.manifest">
<head>
<meta charset="utf-8">
<title>alert(1)</title>
</head>
<body>
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
"webpack": "^1.13.3",
"webpack-dev-middleware": "^1.8.4",
"webpack-hot-middleware": "^2.13.2",
"webpack-manifest": "^1.0.8",
"webpack-merge": "^1.0.2",
"webpack-notifier": "^1.5.0"
}
Expand Down
13 changes: 12 additions & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
<template>
<div id="app">
<div v-if="isWeixin" style="display:none"><img src="//p.ssl.qhimg.com/dm/500_500_/t01a98be2ae4a0c95bf.jpg"></div>
<router-view></router-view>
</div>
</template>
</template>

<script>
export default {
data () {
return {
isWeixin: navigator.userAgent.toLowerCase().includes('micromessenger')
}
}
}
</script>
10 changes: 6 additions & 4 deletions src/Exam.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@

<template>
<div class="i-main">
<pre style="display:none">
{{curData}}
</pre>
<div class="i-fe">
<div class="i-browser">
<div class="hd">
Expand Down Expand Up @@ -52,6 +49,7 @@

<script>
const buble = require('buble')
import cookie from 'browser-cookies'
import merge from 'lodash.merge'
import { ls, clone, escapeJS, compile } from './lib/util'
import codeMirror from './components/codemirror'
Expand Down Expand Up @@ -87,12 +85,16 @@
mounted () {
this.updateCurData()
let timer
top.addEventListener('message', e => {
const data = e.data
if (!(e.origin === top.location.origin && data.src === 'sandbox' && data.success === true)) return
window._czc && window._czc.push(['_trackEvent', this.$route.params.id, this.curData.beCode, this.curData.feCode])
this.curData.success = true
this.showSuccess = true
clearTimeout(timer)
timer = setTimeout(() => {
window._czc && window._czc.push(['_trackEvent', ((cookie.get('uid') || '').replace('|', '-')), this.curData.beCode, this.curData.feCode])
}, 200)
})
},
Expand Down
10 changes: 10 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@
document.body.appendChild(s)
})(document)

const applicationCache = window.applicationCache
if (applicationCache) {
applicationCache.addEventListener('updateready', () => {
if (applicationCache.status === applicationCache.UPDATEREADY) {
applicationCache.swapCache()
window.location.reload()
}
})
}

import cookie from 'browser-cookies'
import 'babel-polyfill'
import Vue from 'vue'
Expand Down

0 comments on commit 023fb0e

Please sign in to comment.