Browse Source

增加跨域配置,系统优化

master
wen 2 years ago
parent
commit
8fe4621380
  1. 8
      src/router/index.js
  2. 57
      src/views/filemange/index.vue
  3. 29
      src/views/login/index.vue
  4. 15
      vue.config.js

8
src/router/index.js

@ -48,18 +48,18 @@ export const constantRoutes = [ @@ -48,18 +48,18 @@ export const constantRoutes = [
redirect: '/filemange',
children: [{
path: 'filemange',
name: 'filemange',
component: () => import('@/views/dashboard/index'),
name: 'Filemange',
component: () => import('@/views/filemange/index'),
meta: { title: '文件管理', icon: 'dashboard' }
}]
},
{
path: '/',
path: '',
component: Layout,
redirect: '/usermange',
children: [{
path: 'usermange',
name: 'usermange',
name: 'Usermange',
component: () => import('@/views/usermanage/index'),
meta: { title: '用户管理', icon: 'dashboard' }
}]

57
src/views/filemange/index.vue

@ -0,0 +1,57 @@ @@ -0,0 +1,57 @@
<template>
<div class="filemange_container">
<div class="mkdirm">
<el-button type="primary" @click="dirbox = true">创建目录</el-button>
</div>
<el-dialog title="创建目录" :visible.sync="dirbox">
<el-form :model="form">
<el-form-item label="目录名称" :label-width="formLabelWidth">
<el-input v-model="form.name" autocomplete="off"></el-input>
</el-form-item>
<el-form-item label="父级目录" :label-width="formLabelWidth">
<el-select v-model="form.region" placeholder="请选择父级目录">
<el-option label="区域一" value="shanghai"></el-option>
<el-option label="区域二" value="beijing"></el-option>
</el-select>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="dirbox = false"> </el-button>
<el-button type="primary" @click="dirbox = false"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
//import { mapGetters } from 'vuex'
export default {
data() {
return {
dirbox: false,
form: {
name: '',
region: '',
date1: '',
date2: '',
delivery: false,
type: [],
resource: '',
desc: ''
},
formLabelWidth: '120px'
}
},
methods: {
}
}
</script>
<style lang="scss" scoped>
.mkdirm{text-align:center;margin:20% 0 0 0;}
</style>

29
src/views/login/index.vue

@ -48,9 +48,7 @@ @@ -48,9 +48,7 @@
<span style="margin-right:20px;">username: admin</span>
<span> password: any</span>
</div> -->
</el-form>
</div>
</template>
@ -164,12 +162,13 @@ $cursor: #3c3535; @@ -164,12 +162,13 @@ $cursor: #3c3535;
</style>
<script>
import { validUsername } from '@/utils/validate'
//import { validUsername } from '@/utils/validate'
import axios from 'axios'
export default {
data() {
const validateUsername = (rule, value, callback) => {
if (!validUsername(value)) {
if (value.length < 3) {
callback(new Error('请输入正确的用户名'))
} else {
callback()
@ -220,14 +219,34 @@ export default { @@ -220,14 +219,34 @@ export default {
},
handleLogin() {
this.$refs.loginForm.validate(valid => {
// console.log(valid);
if (valid) {
this.loading = true;
this.loading = true
let thiss = this;
// axios.post('/api/mkdir', {
// firstName: 'Fred',
// lastName: 'Flintstone'
// })
// .then(function (response) {
// console.log(thiss.$router)
// thiss.$router.push({ path: '/usermange'})
// console.log(response + 'ffef');
// })
// .catch(function (error) {
// console.log(error);
// });
// this.$message({
// showClose: true,
// message: '',
// type: 'error'
// });
this.$store.dispatch('user/login', this.loginForm).then(() => {
this.$router.push({ path: this.redirect || '/' })
this.loading = false
}).catch(() => {
this.loading = false
})
} else {
console.log('error submit!!')
return false

15
vue.config.js

@ -6,7 +6,7 @@ function resolve(dir) { @@ -6,7 +6,7 @@ function resolve(dir) {
return path.join(__dirname, dir)
}
const name = defaultSettings.title || 'vue Admin Template' // page title
const name = defaultSettings.title || '嘉洛马' // page title
// If your port is set to 80,
// use administrator privileges to execute the command line.
@ -38,7 +38,18 @@ module.exports = { @@ -38,7 +38,18 @@ module.exports = {
errors: true
},
inline: false,
before: require('./mock/mock-server.js')
//before: require('./mock/mock-server.js'),
proxy: {
'/api': {
target: 'http://192.168.1.8:1080',// 你要请求的后端接口ip+port
changeOrigin: true,// 允许跨域,在本地会创建一个虚拟服务端,然后发送请求的数据,并同时接收请求的数据,这样服务端和服务端进行数据的交互就不会有跨域问题
ws: true,// 开启webSocket
pathRewrite: {
'^/api': '/api'// 替换成target中的地址
}
}
}
},
configureWebpack: {
// provide the app's title in webpack's name field, so that

Loading…
Cancel
Save