路由简化

移除接口设置页面
master
toesbieya 6 years ago
parent 39a253d476
commit 60325225ec
  1. 4
      vue/src/api/system/resource.js
  2. 9
      vue/src/layout/component/Navbar/index.vue
  3. 2
      vue/src/router/authority/module/purchase.js
  4. 2
      vue/src/router/authority/module/sell.js
  5. 6
      vue/src/router/authority/module/system.js
  6. 15
      vue/src/router/constant/module/app.js
  7. 18
      vue/src/router/constant/module/example.js
  8. 2
      vue/src/router/index.js
  9. 31
      vue/src/router/util.js
  10. 8
      vue/src/view/app/redirect.vue
  11. 96
      vue/src/view/system/resource/EditDialog.vue
  12. 73
      vue/src/view/system/resource/index.vue

@ -6,7 +6,3 @@ export const baseUrl = `${BASE}/resource`
export function getAllResources() {
return request.get(`${baseUrl}/getAll`).then(({data}) => data.data)
}
export function updateResource(data) {
return request.post(`${baseUrl}/update`, data).then(({data}) => data)
}

@ -33,9 +33,6 @@
<el-dropdown-item class="hidden-xs" icon="el-icon-guide" @click.native="()=>$guide(0,guideSteps)">
新手指引
</el-dropdown-item>
<router-link v-if="showSystemResource" to="/system/resource">
<el-dropdown-item icon="el-icon-setting">接口设置</el-dropdown-item>
</router-link>
<el-dropdown-item divided icon="el-icon-switch-button" @click.native="logout">
退出登录
</el-dropdown-item>
@ -73,11 +70,7 @@ export default {
computed: {
...mapState('user', ['avatar', 'name', 'prepareLogout']),
...mapState('setting', ['sidebarCollapse', 'showBreadcrumb']),
showSystemResource() {
return auth('/system/resource')
}
...mapState('setting', ['sidebarCollapse', 'showBreadcrumb'])
},
methods: {

@ -15,7 +15,6 @@ const router = {
},
{
path: 'order/detail/:type(see|add|edit)/:id?',
name: 'purchaseOrderDetail',
props: true,
component: lazyLoadView(import('@/view/purchase/order/detail')),
meta: {
@ -43,7 +42,6 @@ const router = {
},
{
path: 'inbound/detail/:type(see|add|edit)/:id?',
name: 'purchaseInboundDetail',
props: true,
component: lazyLoadView(import('@/view/purchase/inbound/detail')),
meta: {

@ -15,7 +15,6 @@ const router = {
},
{
path: 'order/detail/:type(see|add|edit)/:id?',
name: 'sellOrderDetail',
props: true,
component: lazyLoadView(import('@/view/sell/order/detail')),
meta: {
@ -43,7 +42,6 @@ const router = {
},
{
path: 'outbound/detail/:type(see|add|edit)/:id?',
name: 'purchaseOutboundDetail',
props: true,
component: lazyLoadView(import('@/view/sell/outbound/detail')),
meta: {

@ -42,12 +42,6 @@ const router = {
name: 'supplierManagement',
component: lazyLoadView(import('@/view/system/supplier')),
meta: {title: '供应商管理'}
},
{
path: 'resource',
name: 'resourceManagement',
component: lazyLoadView(import('@/view/system/resource')),
meta: {title: '接口设置', hidden: true}
}
]
}

@ -23,10 +23,6 @@ const router = [
name: 'userCenter',
component: lazyLoadView(import('@/view/userCenter')),
meta: {title: '个人中心', noCache: true, icon: 'user', hidden: true},
},
{
path: 'redirect/:path(.*)',
component: Redirect
}
]
},
@ -34,6 +30,17 @@ const router = [
path: 'https://doc.toesbieya.cn',
meta: {title: '文档', icon: 'documentation', sort: 1}
},
{
path: '/redirect',
component: Layout,
children: [
{
path: ':path(.*)',
props: true,
component: Redirect
}
]
},
{
path: '/login',
alias: '/register',

@ -9,19 +9,16 @@ const router = {
children: [
{
path: 'stylePage',
name: 'stylePage',
component: lazyLoadView(import('@/view/example/stylePage')),
meta: {title: '样 式'}
},
{
path: 'icons',
name: 'icons',
path: 'icon',
component: lazyLoadView(import('@/view/example/icon')),
meta: {title: '图 标'}
},
{
path: 'taobao',
name: 'taobao',
meta: {title: '淘宝iframe', iframe: 'https://www.taobao.com'}
},
{
@ -31,13 +28,11 @@ const router = {
children: [
{
path: 'fluid',
name: 'fluid',
component: lazyLoadView(import('@/view/example/cool/fluid')),
meta: {title: '流体动画'}
},
{
path: 'l2d',
name: 'l2d',
component: lazyLoadView(import('@/view/example/cool/l2d')),
meta: {title: '看板娘'}
},
@ -50,37 +45,31 @@ const router = {
children: [
{
path: 'uploadExample',
name: 'uploadExample',
component: lazyLoadView(import('@/view/example/component/uploadExample')),
meta: {title: '上传文件'}
},
{
path: 'skeletonExample',
name: 'skeletonExample',
component: lazyLoadView(import('@/view/example/component/skeletonExample')),
meta: {title: '骨架屏'}
},
{
path: 'rippleExample',
name: 'rippleExample',
component: lazyLoadView(import('@/view/example/component/rippleExample')),
meta: {title: '波纹'}
},
{
path: 'signatureExample',
name: 'signatureExample',
component: lazyLoadView(import('@/view/example/component/signatureExample')),
meta: {title: '手写签名'}
},
{
path: 'regionSelectorExample',
name: 'regionSelectorExample',
component: lazyLoadView(import('@/view/example/component/regionSelectorExample')),
meta: {title: '行政区划选择'}
},
{
path: 'treeSelectExample',
name: 'treeSelectExample',
component: lazyLoadView(import('@/view/example/component/treeSelectExample')),
meta: {title: '树选择'}
}
@ -88,28 +77,23 @@ const router = {
},
{
path: 'developingTest',
name: 'developingTest',
component: lazyLoadView(import('@/view/example/developingTest')),
meta: {title: '开发测试'}
},
{
path: 'detailPage1',
name: 'detailPage1',
component: lazyLoadView(import('@/view/example/detailPage')),
meta: {
title: '详情页缓存1',
noCache: false,
usePathKey: true,
commonModule: '@/view/example/detailPage'
}
},
{
path: 'detailPage2',
name: 'detailPage2',
component: lazyLoadView(import('@/view/example/detailPage')),
meta: {
title: '详情页缓存2',
noCache: false,
usePathKey: true,
commonModule: '@/view/example/detailPage'
}

@ -36,7 +36,7 @@ NProgress.configure({showSpinner: false})
metaExtend(constantRoutes)
metaExtend(authorityRoutes)
const endRoute = [{path: '*', redirect: '/404', meta: {hidden: true}}]
const endRoute = [{path: '*', redirect: '/404'}]
const whiteList = transformWhiteList(['/login', '/register', '/404', '/403'])

@ -12,30 +12,35 @@ export function setPageTitle(route) {
//确定路由的标题
export function specifyRouteTitle(to, from) {
if (typeof to.meta.dynamicTitle === 'function') {
to.meta.title = to.meta.dynamicTitle(to, from)
const {meta} = to
if (typeof meta.dynamicTitle === 'function') {
meta.title = meta.dynamicTitle(to, from)
}
}
//将给定的白名单url转换为正则
export function transformWhiteList(list) {
return list.map(url => pathToRegexp(url))
return list.map(pathToRegexp)
}
//子路由继承父路由meta上的{affix,noAuth,noCache},优先使用子路由的值
export function metaExtend(routes, meta) {
//子路由继承父路由meta上的{noAuth,noCache},优先使用子路由的值
export function metaExtend(routes, parentMeta) {
const keys = ['noAuth', 'noCache']
routes.forEach(route => {
if (meta) {
const keys = ['affix', 'noAuth', 'noCache']
Object.keys(meta).forEach(key => {
if (keys.includes(key) && !isEmpty(meta[key]) && isEmpty(route.meta[key])) {
route.meta[key] = meta[key]
if (parentMeta) {
Object.keys(parentMeta).forEach(key => {
const value = parentMeta[key]
if (keys.includes(key) && !isEmpty(value)) {
if (!route.meta) {
route.meta = {[key]: value}
}
else if (isEmpty(route.meta[key])) {
route.meta[key] = value
}
}
})
}
if (route.children) {
metaExtend(route.children, route.meta)
}
route.children && metaExtend(route.children, route.meta)
})
}

@ -1,13 +1,17 @@
<script>
export default {
props: {
path: {type: String, default: ''}
},
created() {
const {params, query} = this.$route
const {query} = this.$route
//使name+params
if ('params' in query) {
const {name, params} = JSON.parse(query.params)
this.$router.replace({name, params})
}
else this.$router.replace({path: `/${params.path}`, query})
else this.$router.replace({path: `/${this.path}`, query})
},
render: h => h()

@ -1,96 +0,0 @@
<template>
<form-dialog :loading="loading" title="编辑" :value="value" @close="cancel" @open="open">
<abstract-form :model="form" :rules="rules" size="">
<el-form-item label="名 称" prop="name">
<el-input :value="form.fullname" readonly/>
</el-form-item>
<el-form-item label="访问路径" prop="url">
<el-input :value="form.url" readonly/>
</el-form-item>
<el-form-item label="总频率" prop="totalRate">
<el-input-number
v-model="form.totalRate"
controls-position="right"
:min="1"
:step="1"
step-strictly size="small"
/>
</el-form-item>
<el-form-item label="单个IP频率" prop="ipRate">
<el-input-number
v-model="form.ipRate"
controls-position="right"
:min="1"
:step="1"
step-strictly size="small"
/>
</el-form-item>
</abstract-form>
<template v-slot:footer>
<el-button plain size="small" @click="closeDialog"> </el-button>
<el-button size="small" type="primary" @click="confirm"> </el-button>
</template>
</form-dialog>
</template>
<script>
import dialogMixin from "@/mixin/dialogMixin"
import AbstractForm from "@/component/AbstractForm"
import FormDialog from '@/component/FormDialog'
import {updateResource} from "@/api/system/resource"
import {mergeObj, resetObj} from '@/util'
export default {
name: "EditDialog",
mixins: [dialogMixin],
components: {AbstractForm, FormDialog},
props: {
value: {type: Boolean, default: false},
data: {type: Object, default: () => ({})},
},
data() {
return {
loading: false,
form: {
id: null,
fullname: null,
url: null,
totalRate: 0,
ipRate: 0
},
rules: {
totalRate: [{required: true, message: '总频率不能为空', trigger: 'change'}],
ipRate: [{required: true, message: '单个ip的频率不能为空', trigger: 'change'}],
}
}
},
methods: {
open() {
this.$nextTick(() => mergeObj(this.form, this.data))
},
cancel() {
this.closeDialog()
resetObj(this.form)
this.$nextTick(() => this.$refs.form.clearValidate())
},
confirm() {
if (this.loading) return
this.$refs.form.validate(v => {
if (!v) return
this.loading = true
updateResource(this.form)
.then(({msg}) => this.$emit('success', msg))
.finally(() => this.loading = false)
})
}
}
}
</script>

@ -1,73 +0,0 @@
<template>
<el-card v-loading="config.operating">
<el-row>
<el-button icon="el-icon-search" size="small" type="success" @click="search"> </el-button>
<el-button v-if="canUpdate" icon="el-icon-edit" size="small" type="primary" @click="edit"> </el-button>
</el-row>
<el-row v-loading="config.loading" class="table-container">
<abstract-table :data="tableData" @row-click="rowClick">
<el-table-column label="名称" prop="fullname" show-overflow-tooltip/>
<el-table-column label="访问路径" prop="url" show-overflow-tooltip/>
<el-table-column label="总频率" prop="totalRate" show-overflow-tooltip/>
<el-table-column label="单个IP频率" prop="ipRate" show-overflow-tooltip/>
</abstract-table>
</el-row>
<edit-dialog v-model="editDialog" :data="row" :type="type" @success="success"/>
</el-card>
</template>
<script>
import tableMixin from '@/mixin/tablePageMixin'
import EditDialog from './EditDialog'
import SearchForm from "@/component/SearchForm"
import SearchFormItem from "@/component/SearchForm/SearchFormItem"
import {baseUrl, getAllResources} from "@/api/system/resource"
import {auth} from "@/util/auth"
import {elError, elSuccess} from "@/util/message"
import {createTreeByWorker} from "@/util/tree"
export default {
name: "resourceManagement",
mixins: [tableMixin],
components: {EditDialog, SearchForm, SearchFormItem},
data() {
return {
editDialog: false
}
},
computed: {
canUpdate() {
return auth(`${baseUrl}/update`)
}
},
methods: {
search() {
if (this.config.loading) return
this.config.loading = true
this.row = null
getAllResources()
.then(data => createTreeByWorker(data))
.then(data => this.tableData = data)
.finally(() => this.config.loading = false)
},
edit() {
if (!this.row) return elError('请选择要编辑的资源')
this.editDialog = true
},
success(msg) {
elSuccess(msg)
this.editDialog = false
this.search()
}
}
}
</script>
Loading…
Cancel
Save