first commit

master
bibi 3 years ago
parent 90a4ce5fd3
commit c9f437c3ee

@ -0,0 +1,3 @@
NODE_ENV = 'development'
VUE_APP_URL = ''
VUE_APP_CDN = ''

@ -0,0 +1,3 @@
NODE_ENV = 'production'
VUE_APP_URL = ''
VUE_APP_CDN = ''

2248
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -8,7 +8,10 @@
"lint": "vue-cli-service lint" "lint": "vue-cli-service lint"
}, },
"dependencies": { "dependencies": {
"axios": "^0.21.1",
"core-js": "^3.6.5", "core-js": "^3.6.5",
"element-ui": "^2.4.5",
"node-sass": "^4.14.1",
"vue": "^2.6.11", "vue": "^2.6.11",
"vue-router": "^3.2.0", "vue-router": "^3.2.0",
"vuex": "^3.4.0" "vuex": "^3.4.0"
@ -27,6 +30,8 @@
"eslint-plugin-promise": "^4.2.1", "eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.0", "eslint-plugin-standard": "^4.0.0",
"eslint-plugin-vue": "^6.2.2", "eslint-plugin-vue": "^6.2.2",
"sass-loader": "^7.0.3",
"vue-cli-plugin-element": "^1.0.1",
"vue-template-compiler": "^2.6.11" "vue-template-compiler": "^2.6.11"
} }
} }

@ -1,32 +1,31 @@
<template> <template>
<div id="app"> <div id="app">
<div id="nav"> <router-view></router-view>
<router-link to="/">Home</router-link> |
<router-link to="/about">About</router-link>
</div>
<router-view/>
</div> </div>
</template> </template>
<style> <script>
#app { export default {
font-family: Avenir, Helvetica, Arial, sans-serif; // mounted () {
-webkit-font-smoothing: antialiased; // // localStorage
-moz-osx-font-smoothing: grayscale; // window.onbeforeunload = function (e) {
text-align: center; // var storage = window.localStorage
color: #2c3e50; // storage.clear()
// }
// }
} }
</script>
#nav { <style >
padding: 30px; #app{
height: 100%;
} }
*{
#nav a { margin: 0px;
font-weight: bold; padding: 0px;
color: #2c3e50;
} }
html,body{
#nav a.router-link-exact-active { margin: 0px;
color: #42b983; height: 100%;
} }
</style> </style>

@ -0,0 +1,38 @@
import { GetAxios } from '@/utils/request'
import router from '../router'
router.beforeEach((to, from, next) => {
// 全局前置守卫
if (to.path === '/about' || to.path === '/register') {
next()
} else {
// 验证token
if (localStorage.getItem('manage-token') !== null) {
next()
} else {
next({
path: '/about'
})
}
}
})
export const axios = GetAxios((config) => {
// 在发送请求之前做些什么
config.headers['device-type'] = 'web'
config.headers['manage-token'] = localStorage.getItem('manage-token')
return config
}, process.env.VUE_APP_URL, response => {
if (response.status === 200) {
if (response.headers['content-type'].indexOf('application/json') !== -1) {
if (response.data.code === 10000) {
// 登录失败 跳转到登陆页面
// 跳转到登录页
router.push({ path: 'about' })
} else {
return response.data
}
} else {
// 文件流
}
}
return response.data
})

@ -0,0 +1,10 @@
import { axios } from './auth'
// 项目列表
export const login = (params) => {
return axios({
url: '/login',
method: 'post',
data: params
})
}

@ -0,0 +1,9 @@
export const imagePath = process.env.VUE_APP_URL + '/file/image'
export const filePath = process.env.VUE_APP_URL + '/file/file'
export const cdnImage = (imagePath) => { return imagePath === '' ? '' : process.env.VUE_APP_CDN + imagePath }
export const upHeaders = () => {
return {
'device-type': 'web',
'manage-token': localStorage.getItem('manage-token')
}
}

@ -0,0 +1,11 @@
/*
* 接口统一集成模块
*/
import * as file from './file'
import * as basic from './basic'
// 默认全部导出
export const api = {
basic,
file
}

@ -0,0 +1,11 @@
/*
Write your variables here. All available variables can be
found in element-ui/packages/theme-chalk/src/common/var.scss.
For example, to overwrite the theme color:
*/
$--color-primary: teal;
/* icon font path, required */
$--font-path: '~element-ui/lib/theme-chalk/fonts';
@import "~element-ui/packages/theme-chalk/src/index";

@ -1,34 +1,7 @@
<template> <template>
<div class="hello"> <div class="hello">
<h1>{{ msg }}</h1> <h1>{{ msg }}</h1>
<p> <a href="/#/About" target="_blank" rel="noopener">about</a>
For a guide and recipes on how to configure / customize this project,<br>
check out the
<a href="https://cli.vuejs.org" target="_blank" rel="noopener">vue-cli documentation</a>.
</p>
<h3>Installed CLI Plugins</h3>
<ul>
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-babel" target="_blank" rel="noopener">babel</a></li>
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-router" target="_blank" rel="noopener">router</a></li>
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-vuex" target="_blank" rel="noopener">vuex</a></li>
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-eslint" target="_blank" rel="noopener">eslint</a></li>
</ul>
<h3>Essential Links</h3>
<ul>
<li><a href="https://vuejs.org" target="_blank" rel="noopener">Core Docs</a></li>
<li><a href="https://forum.vuejs.org" target="_blank" rel="noopener">Forum</a></li>
<li><a href="https://chat.vuejs.org" target="_blank" rel="noopener">Community Chat</a></li>
<li><a href="https://twitter.com/vuejs" target="_blank" rel="noopener">Twitter</a></li>
<li><a href="https://news.vuejs.org" target="_blank" rel="noopener">News</a></li>
</ul>
<h3>Ecosystem</h3>
<ul>
<li><a href="https://router.vuejs.org" target="_blank" rel="noopener">vue-router</a></li>
<li><a href="https://vuex.vuejs.org" target="_blank" rel="noopener">vuex</a></li>
<li><a href="https://github.com/vuejs/vue-devtools#vue-devtools" target="_blank" rel="noopener">vue-devtools</a></li>
<li><a href="https://vue-loader.vuejs.org" target="_blank" rel="noopener">vue-loader</a></li>
<li><a href="https://github.com/vuejs/awesome-vue" target="_blank" rel="noopener">awesome-vue</a></li>
</ul>
</div> </div>
</template> </template>

@ -2,8 +2,11 @@ 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 * as utils from './utils/index'
import './plugins/element.js'
Vue.config.productionTip = false Vue.config.productionTip = false
Vue.use(utils)
new Vue({ new Vue({
router, router,

@ -0,0 +1,5 @@
import Vue from 'vue'
import Element from 'element-ui'
import '@/assets/css/element-variables.scss'
Vue.use(Element)

@ -4,7 +4,7 @@ import Home from '../views/Home.vue'
Vue.use(VueRouter) Vue.use(VueRouter)
const routes = [ export const routes = [
{ {
path: '/', path: '/',
name: 'Home', name: 'Home',

@ -0,0 +1,29 @@
import { api } from '@/api'
export const utils = {
api: api,
formatDate: (time, fmt) => {
if (time > 0) {
const date = new Date(time * 1000)
if (/(y+)/.test(fmt)) {
fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length))
}
const o = {
'M+': date.getMonth() + 1,
'd+': date.getDate(),
'h+': date.getHours(),
'm+': date.getMinutes(),
's+': date.getSeconds()
}
for (const k in o) {
if (new RegExp(`(${k})`).test(fmt)) {
const str = o[k] + ''
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? str : ('00' + str).substr(str.length))
}
}
return fmt
} else {
return ''
}
}
}

@ -0,0 +1,28 @@
import axios from 'axios'
export const GetAxios = (config, baseUrl, toResponse) => {
const instance = axios.create({
headers: {
'content-type': 'application/json'
}
})
instance.defaults.baseURL = baseUrl
instance.defaults.withCredentials = true
// 添加请求拦截器
instance.interceptors.request.use(config, function (error) {
// 对请求错误做些什么
return Promise.reject(error)
})
// 添加响应拦截器
instance.interceptors.response.use(function (response) {
// 对响应数据做点什么
// console.log(response)
return toResponse(response)
}, function (error) {
// 对响应错误做点什么
return Promise.reject(error)
})
return instance
}

@ -1,5 +1,20 @@
<template> <template>
<div class="about"> <div class="about">
<h1>This is an about page</h1> <h1>{{msg}}</h1>
</div> </div>
</template> </template>
<script>
import { api } from '@/api'
export default ({
data () {
return {
msg: ''
}
},
created () {
api.basic.login({ userName: 'admin', password: '123456' }).then(res => {
console.log(res)
})
}
})
</script>

Loading…
Cancel
Save