update to webpack4.0 (#136)
* dev * update * fix * refine * add ScriptExtHtmlWebpackPlugin * update * format * refine * typo * format * docs * docs
This commit is contained in:
		@@ -1,5 +1,5 @@
 | 
			
		||||
import Vue from 'vue'
 | 
			
		||||
import SvgIcon from '@/components/SvgIcon'// svg组件
 | 
			
		||||
import SvgIcon from '@/components/SvgIcon' // svg组件
 | 
			
		||||
 | 
			
		||||
// register globally
 | 
			
		||||
Vue.component('svg-icon', SvgIcon)
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
import Vue from 'vue'
 | 
			
		||||
 | 
			
		||||
import 'normalize.css/normalize.css'// A modern alternative to CSS resets
 | 
			
		||||
import 'normalize.css/normalize.css' // A modern alternative to CSS resets
 | 
			
		||||
 | 
			
		||||
import ElementUI from 'element-ui'
 | 
			
		||||
import 'element-ui/lib/theme-chalk/index.css'
 | 
			
		||||
 
 | 
			
		||||
@@ -25,7 +25,7 @@ export function parseTime(time, cFormat) {
 | 
			
		||||
  }
 | 
			
		||||
  const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => {
 | 
			
		||||
    let value = formatObj[key]
 | 
			
		||||
    if (key === 'a') return ['一', '二', '三', '四', '五', '六', '日'][value - 1]
 | 
			
		||||
    if (key === 'a') { return ['一', '二', '三', '四', '五', '六', '日'][value - 1] }
 | 
			
		||||
    if (result.length > 0 && value < 10) {
 | 
			
		||||
      value = '0' + value
 | 
			
		||||
    }
 | 
			
		||||
@@ -43,7 +43,8 @@ export function formatTime(time, option) {
 | 
			
		||||
 | 
			
		||||
  if (diff < 30) {
 | 
			
		||||
    return '刚刚'
 | 
			
		||||
  } else if (diff < 3600) { // less 1 hour
 | 
			
		||||
  } else if (diff < 3600) {
 | 
			
		||||
    // less 1 hour
 | 
			
		||||
    return Math.ceil(diff / 60) + '分钟前'
 | 
			
		||||
  } else if (diff < 3600 * 24) {
 | 
			
		||||
    return Math.ceil(diff / 3600) + '小时前'
 | 
			
		||||
@@ -53,6 +54,16 @@ export function formatTime(time, option) {
 | 
			
		||||
  if (option) {
 | 
			
		||||
    return parseTime(time, option)
 | 
			
		||||
  } else {
 | 
			
		||||
    return d.getMonth() + 1 + '月' + d.getDate() + '日' + d.getHours() + '时' + d.getMinutes() + '分'
 | 
			
		||||
    return (
 | 
			
		||||
      d.getMonth() +
 | 
			
		||||
      1 +
 | 
			
		||||
      '月' +
 | 
			
		||||
      d.getDate() +
 | 
			
		||||
      '日' +
 | 
			
		||||
      d.getHours() +
 | 
			
		||||
      '时' +
 | 
			
		||||
      d.getMinutes() +
 | 
			
		||||
      '分'
 | 
			
		||||
    )
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -10,23 +10,26 @@ const service = axios.create({
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
// request拦截器
 | 
			
		||||
service.interceptors.request.use(config => {
 | 
			
		||||
  if (store.getters.token) {
 | 
			
		||||
    config.headers['X-Token'] = getToken() // 让每个请求携带自定义token 请根据实际情况自行修改
 | 
			
		||||
service.interceptors.request.use(
 | 
			
		||||
  config => {
 | 
			
		||||
    if (store.getters.token) {
 | 
			
		||||
      config.headers['X-Token'] = getToken() // 让每个请求携带自定义token 请根据实际情况自行修改
 | 
			
		||||
    }
 | 
			
		||||
    return config
 | 
			
		||||
  },
 | 
			
		||||
  error => {
 | 
			
		||||
    // Do something with request error
 | 
			
		||||
    console.log(error) // for debug
 | 
			
		||||
    Promise.reject(error)
 | 
			
		||||
  }
 | 
			
		||||
  return config
 | 
			
		||||
}, error => {
 | 
			
		||||
  // Do something with request error
 | 
			
		||||
  console.log(error) // for debug
 | 
			
		||||
  Promise.reject(error)
 | 
			
		||||
})
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// respone拦截器
 | 
			
		||||
service.interceptors.response.use(
 | 
			
		||||
  response => {
 | 
			
		||||
  /**
 | 
			
		||||
  * code为非20000是抛错 可结合自己业务进行修改
 | 
			
		||||
  */
 | 
			
		||||
    /**
 | 
			
		||||
     * code为非20000是抛错 可结合自己业务进行修改
 | 
			
		||||
     */
 | 
			
		||||
    const res = response.data
 | 
			
		||||
    if (res.code !== 20000) {
 | 
			
		||||
      Message({
 | 
			
		||||
@@ -37,13 +40,17 @@ service.interceptors.response.use(
 | 
			
		||||
 | 
			
		||||
      // 50008:非法的token; 50012:其他客户端登录了;  50014:Token 过期了;
 | 
			
		||||
      if (res.code === 50008 || res.code === 50012 || res.code === 50014) {
 | 
			
		||||
        MessageBox.confirm('你已被登出,可以取消继续留在该页面,或者重新登录', '确定登出', {
 | 
			
		||||
          confirmButtonText: '重新登录',
 | 
			
		||||
          cancelButtonText: '取消',
 | 
			
		||||
          type: 'warning'
 | 
			
		||||
        }).then(() => {
 | 
			
		||||
        MessageBox.confirm(
 | 
			
		||||
          '你已被登出,可以取消继续留在该页面,或者重新登录',
 | 
			
		||||
          '确定登出',
 | 
			
		||||
          {
 | 
			
		||||
            confirmButtonText: '重新登录',
 | 
			
		||||
            cancelButtonText: '取消',
 | 
			
		||||
            type: 'warning'
 | 
			
		||||
          }
 | 
			
		||||
        ).then(() => {
 | 
			
		||||
          store.dispatch('FedLogOut').then(() => {
 | 
			
		||||
            location.reload()// 为了重新实例化vue-router对象 避免bug
 | 
			
		||||
            location.reload() // 为了重新实例化vue-router对象 避免bug
 | 
			
		||||
          })
 | 
			
		||||
        })
 | 
			
		||||
      }
 | 
			
		||||
@@ -53,7 +60,7 @@ service.interceptors.response.use(
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  error => {
 | 
			
		||||
    console.log('err' + error)// for debug
 | 
			
		||||
    console.log('err' + error) // for debug
 | 
			
		||||
    Message({
 | 
			
		||||
      message: error.message,
 | 
			
		||||
      type: 'error',
 | 
			
		||||
 
 | 
			
		||||
@@ -30,4 +30,3 @@ export function validatAlphabets(str) {
 | 
			
		||||
  const reg = /^[A-Za-z]+$/
 | 
			
		||||
  return reg.test(str)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -2,10 +2,10 @@
 | 
			
		||||
  <div class="wscn-http404-container">
 | 
			
		||||
    <div class="wscn-http404">
 | 
			
		||||
      <div class="pic-404">
 | 
			
		||||
        <img class="pic-404__parent" :src="img_404" alt="404">
 | 
			
		||||
        <img class="pic-404__child left" :src="img_404_cloud" alt="404">
 | 
			
		||||
        <img class="pic-404__child mid" :src="img_404_cloud" alt="404">
 | 
			
		||||
        <img class="pic-404__child right" :src="img_404_cloud" alt="404">
 | 
			
		||||
        <img class="pic-404__parent" src="@/assets/404_images/404.png" alt="404">
 | 
			
		||||
        <img class="pic-404__child left" src="@/assets/404_images/404_cloud.png" alt="404">
 | 
			
		||||
        <img class="pic-404__child mid" src="@/assets/404_images/404_cloud.png" alt="404">
 | 
			
		||||
        <img class="pic-404__child right" src="@/assets/404_images/404_cloud.png" alt="404">
 | 
			
		||||
      </div>
 | 
			
		||||
      <div class="bullshit">
 | 
			
		||||
        <div class="bullshit__oops">OOPS!</div>
 | 
			
		||||
@@ -21,17 +21,9 @@
 | 
			
		||||
</template>
 | 
			
		||||
 | 
			
		||||
<script>
 | 
			
		||||
import img_404 from '@/assets/404_images/404.png'
 | 
			
		||||
import img_404_cloud from '@/assets/404_images/404_cloud.png'
 | 
			
		||||
 | 
			
		||||
export default {
 | 
			
		||||
  name: 'page404',
 | 
			
		||||
  data() {
 | 
			
		||||
    return {
 | 
			
		||||
      img_404,
 | 
			
		||||
      img_404_cloud
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  computed: {
 | 
			
		||||
    message() {
 | 
			
		||||
      return '网管说这个页面你不能进......'
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user