Browse Source

Import nprogress style

pull/9/head
johnniang 6 years ago
parent
commit
d7ff1382ef
  1. 6
      src/main.js
  2. 7
      src/utils/service.js
  3. 12
      src/utils/util.js

6
src/main.js

@ -3,9 +3,7 @@ import Vue from 'vue'
import App from './App.vue' import App from './App.vue'
import router from './router' import router from './router'
import store from './store/' import store from './store/'
import { import { VueAxios } from '@/utils/request' // axios 不建议引入到 Vue 原型链上
VueAxios
} from '@/utils/request' // axios 不建议引入到 Vue 原型链上
import './core/use' import './core/use'
import bootstrap from './core/bootstrap' import bootstrap from './core/bootstrap'
@ -19,7 +17,7 @@ Vue.use(VueAxios, router)
new Vue({ new Vue({
router, router,
store, store,
created () { created() {
bootstrap() bootstrap()
}, },
render: h => h(App) render: h => h(App)

7
src/utils/service.js

@ -1,12 +1,11 @@
import axios from 'axios' import axios from 'axios'
import NProgress from 'nprogress' import NProgress from 'nprogress'
import Vue from 'vue' import Vue from 'vue'
import 'nprogress/nprogress.css'
const service = axios.create({ const service = axios.create({
baseURL: baseURL: process.env.NODE_ENV === 'production' ? 'https://ryanc.cc/' : 'http://localhost:8090',
process.env.NODE_ENV === 'production' timeout: 5000
? 'https://ryanc.cc/'
: 'http://localhost:8090'
}) })
service.interceptors.request.use( service.interceptors.request.use(

12
src/utils/util.js

@ -1,19 +1,19 @@
export function timeFix () { export function timeFix() {
const time = new Date() const time = new Date()
const hour = time.getHours() const hour = time.getHours()
return hour < 9 ? '早上好' : (hour <= 11 ? '上午好' : (hour <= 13 ? '中午好' : (hour < 20 ? '下午好' : '晚上好'))) return hour < 9 ? '早上好' : hour <= 11 ? '上午好' : hour <= 13 ? '中午好' : hour < 20 ? '下午好' : '晚上好'
} }
export function welcome () { export function welcome() {
const arr = ['休息一会儿吧', '准备吃什么呢?', '要不要打一把 DOTA', '我猜你可能累了'] const arr = ['休息一会儿吧', '准备吃什么呢?', '要不要打一把 DOTA', '我猜你可能累了']
const index = Math.floor((Math.random() * arr.length)) const index = Math.floor(Math.random() * arr.length)
return arr[index] return arr[index]
} }
/** /**
* 触发 window.resize * 触发 window.resize
*/ */
export function triggerWindowResizeEvent () { export function triggerWindowResizeEvent() {
const event = document.createEvent('HTMLEvents') const event = document.createEvent('HTMLEvents')
event.initEvent('resize', true, true) event.initEvent('resize', true, true)
event.eventType = 'message' event.eventType = 'message'
@ -25,7 +25,7 @@ export function triggerWindowResizeEvent () {
* @param id parent element id or class * @param id parent element id or class
* @param timeout * @param timeout
*/ */
export function removeLoadingAnimate (id = '', timeout = 1500) { export function removeLoadingAnimate(id = '', timeout = 1500) {
if (id === '') { if (id === '') {
return return
} }

Loading…
Cancel
Save