菜单逻辑修改

This commit is contained in:
Leo_Ding 2025-09-30 19:20:50 +08:00
parent cda200998e
commit 77446544f6
10 changed files with 105 additions and 102 deletions

View File

@ -10,4 +10,4 @@ export const updateUser = (_, params) => request.basic.put(`/api/v1/current/user
// 更新用户密码 // 更新用户密码
export const updatePassword = (_, params) => request.basic.put(`/api/v1/current/password`, params) export const updatePassword = (_, params) => request.basic.put(`/api/v1/current/password`, params)
// 用户权限菜单 // 用户权限菜单
export const getUserMenu = () => request.basic.get('/api/v1/current/menus') export const getUserMenu = (params) => request.basic.get('/api/v1/current/menus', params)

View File

@ -3,7 +3,7 @@ import * as layouts from '@/layouts'
* 白名单 * 白名单
* @type {string[]} * @type {string[]}
*/ */
export const whiteList = ['login', 'logout', '404', 'users','plateform'] // no redirect whitelist export const whiteList = ['login', 'logout', '404', 'users','platform'] // no redirect whitelist
/** /**
* 未找到页面路由 * 未找到页面路由
@ -48,8 +48,8 @@ export const constantRoutes = [
component: () => import('@/views/exception/404.vue'), component: () => import('@/views/exception/404.vue'),
}, },
{ {
path: '/plateform', path: '/platform',
name: 'plateform', name: 'platform',
component: () => import('@/views/login/platForm.vue'), component: () => import('@/views/login/platForm.vue'),
meta: { meta: {
title: '平台选择', title: '平台选择',

View File

@ -6,6 +6,7 @@ import home from './home'
// import exception from './exception' // import exception from './exception'
// import admin from './admin' // import admin from './admin'
import system from './system' import system from './system'
import platform from './platform'
// import link from './link' // import link from './link'
// import iframe from './iframe' // import iframe from './iframe'
// import other from './other' // import other from './other'
@ -19,6 +20,7 @@ export default [
// ...exception, // ...exception,
// ...admin, // ...admin,
...system, ...system,
...platform,
// ...link, // ...link,
// ...iframe, // ...iframe,
// ...other, // ...other,

View File

@ -0,0 +1,10 @@
export default [
{
path: '/platform',
name: 'platform',
component: () => import('@/views/login/platForm.vue'),
meta: {
title: '平台选择',
},
},
]

View File

@ -37,10 +37,10 @@ const useAppStore = defineStore('app', {
* 初始化 * 初始化
* @returns {Promise} * @returns {Promise}
*/ */
init() { init(params) {
const routerStore = useRouterStore() const routerStore = useRouterStore()
return new Promise((resolve) => { return new Promise((resolve) => {
Promise.all([routerStore.getRouterList()]) Promise.all([routerStore.getRouterList(params)])
.then(() => { .then(() => {
this.complete = true this.complete = true
resolve() resolve()

View File

@ -20,11 +20,12 @@ const useRouterStore = defineStore('router', {
* 获取路由列表 * 获取路由列表
* @returns {Promise} * @returns {Promise}
*/ */
getRouterList() { getRouterList(params) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
;(async () => { ;(async () => {
try { try {
const { success, data } = await apis.user.getUserMenu().catch(() => {
const { success, data } = await apis.user.getUserMenu(params).catch(() => {
throw new Error() throw new Error()
}) })
if (config('http.code.success') === success) { if (config('http.code.success') === success) {
@ -42,6 +43,7 @@ const useRouterStore = defineStore('router', {
}) })
this.routes = routes this.routes = routes
this.menuList = menuList this.menuList = menuList
console.log(indexRoute)
this.indexRoute = indexRoute this.indexRoute = indexRoute
resolve() resolve()
} }

View File

@ -117,13 +117,7 @@ async function handleLogin() {
}) })
loading.value = false loading.value = false
if (config('http.code.success') === success) { if (config('http.code.success') === success) {
// router.push('/platform')
if (appStore.complete) {
goIndex()
} else {
await appStore.init()
goIndex()
}
} }
}) })
} }
@ -150,10 +144,13 @@ function getFirstValidRoute() {
* 去首页 * 去首页
*/ */
function goIndex() { function goIndex() {
console.log('goIndex')
// router.replace({path:'/platform'})
if (redirect.value) { if (redirect.value) {
location.href = redirect.value location.href = redirect.value
} else { } else {
const indexRoute = getFirstValidRoute() const indexRoute = getFirstValidRoute()
console.log(indexRoute)
if (!indexRoute) return if (!indexRoute) return
router.push(indexRoute) router.push(indexRoute)
} }

View File

@ -39,15 +39,15 @@
</div> </div>
<p>呼叫中心</p> <p>呼叫中心</p>
</div> </div>
<div value="SUPERVISION" class="paltform_icon"> <div value="SUPERVISION" class="paltform_icon" @click="handleSelect('jianguan')">
<div class="paltform_icon_1"> <div class="paltform_icon_1">
<img :src="jianguan" alt="" srcset="" width="70" height="70" > <img :src="jianguan" alt="" srcset="" width="70" height="70">
</div> </div>
<p>监管平台</p> <p>监管平台</p>
</div> </div>
<div value="HOME_BED" class="paltform_icon"> <div value="HOME_BED" class="paltform_icon">
<div class="paltform_icon_1"> <div class="paltform_icon_1">
<img :src="yunying" alt="" srcset="" width="76" height="76"> <img :src="yunying" alt="" srcset="" width="76" height="76">
</div> </div>
<p>运营平台</p> <p>运营平台</p>
</div> </div>
@ -60,23 +60,64 @@
</div> </div>
</template> </template>
<script setup> <script setup>
import { Modal, notification } from 'ant-design-vue'
import { computed, onMounted, ref, onBeforeMount } from 'vue' import { computed, onMounted, ref, onBeforeMount } from 'vue'
import StarBackground from '@/components/StartBackground/index.vue' import StarBackground from '@/components/StartBackground/index.vue'
import tel from '@/assets/imgs/tel2.png' import tel from '@/assets/imgs/tel2.png'
import jianguan from '@/assets/imgs/jianguan3.png' import jianguan from '@/assets/imgs/jianguan3.png'
import yunying from '@/assets/imgs/yunying.png' import yunying from '@/assets/imgs/yunying.png'
import { useAppStore, useRouterStore, useUserStore } from '@/store'
import { template } from 'lodash-es'
import { useRoute, useRouter } from 'vue-router'
import storage from '@/utils/storage'
defineOptions({ defineOptions({
name: 'login', name: 'PlatForm',
}) })
const appStore = useAppStore()
const routerStore = useRouterStore()
const router = useRouter()
// body // body
onBeforeMount(() => { onBeforeMount(() => {
document.body.className = 'body-bg' document.body.className = 'body-bg'
}) })
const plateformList = ref([ async function handleSelect(type) {
{ title: '呼叫中心', icon: tel }, storage.local.setItem('platform', type)
{ title: '监管平台', icon: jianguan }, //
{ title: '运营平台', icon: yunying }, if (appStore.complete) {
]) goIndex()
} else {
await appStore.init({ platform: type })
goIndex()
}
}
async function goIndex() {
console.log('goIndex')
const indexRoute = getFirstValidRoute()
console.log(indexRoute)
if (!indexRoute) return
router.push(indexRoute)
notification.success({
message: t('welcome'),
description: `${timeFix()}${t('home')}`,
})
}
/**
* 获取首页路由
* @return {*}
*/
function getFirstValidRoute() {
const indexRoute = routerStore.indexRoute
if (!indexRoute) {
Modal.warning({
title: '系统提示',
content: '没有任何权限,请联系系统管理员',
onOk: () => {
window.location.reload()
},
})
}
return indexRoute
}
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
.body-bg { .body-bg {

View File

@ -1,50 +1,27 @@
<template> <template>
<a-modal <a-modal :width="640" :open="modal.open" :title="modal.title" :confirm-loading="modal.confirmLoading"
:width="640" :after-close="onAfterClose" :cancel-text="cancelText" :ok-text="okText" @ok="handleOk" @cancel="handleCancel">
:open="modal.open" <a-form layout="vertical" ref="formRef" :model="formData" :rules="formRules">
:title="modal.title"
:confirm-loading="modal.confirmLoading"
:after-close="onAfterClose"
:cancel-text="cancelText"
:ok-text="okText"
@ok="handleOk"
@cancel="handleCancel">
<a-form
layout="vertical"
ref="formRef"
:model="formData"
:rules="formRules">
<a-card class="mb-8-2"> <a-card class="mb-8-2">
<a-row :gutter="12"> <a-row :gutter="12">
<a-col :span="12"> <a-col :span="12">
<a-form-item <a-form-item :label="$t('pages.system.menu.form.parent_name')" name="parent_id">
:label="$t('pages.system.menu.form.parent_name')" <a-tree-select v-model:value="formData.parent_id" tree-default-expand-all></a-tree-select>
name="parent_id">
<a-tree-select
v-model:value="formData.parent_id"
tree-default-expand-all></a-tree-select>
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="12"> <a-col :span="12">
<a-form-item <a-form-item :label="$t('pages.system.menu.form.type')" name="type">
:label="$t('pages.system.menu.form.type')" <a-radio-group v-model:value="formData.type"
name="type">
<a-radio-group
v-model:value="formData.type"
:options="menuTypeEnum.getOptions()"></a-radio-group> :options="menuTypeEnum.getOptions()"></a-radio-group>
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="12"> <a-col :span="12">
<a-form-item <a-form-item :label="$t('pages.system.menu.form.name')" name="name">
:label="$t('pages.system.menu.form.name')"
name="name">
<a-input v-model:value="formData.name"></a-input> <a-input v-model:value="formData.name"></a-input>
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="12"> <a-col :span="12">
<a-form-item <a-form-item :label="$t('pages.system.menu.resource.form.path')" name="path">
:label="$t('pages.system.menu.resource.form.path')"
name="path">
<a-input v-model:value="formData.path"></a-input> <a-input v-model:value="formData.path"></a-input>
</a-form-item> </a-form-item>
</a-col> </a-col>
@ -61,70 +38,44 @@
</a-col> </a-col>
<a-col :span="12"> <a-col :span="12">
<a-form-item <a-form-item :label="$t('pages.system.menu.form.status')" name="status">
:label="$t('pages.system.menu.form.status')" <a-radio-group v-model:value="formData.status"
name="status">
<a-radio-group
v-model:value="formData.status"
:options="statusTypeEnum.getOptions()"></a-radio-group> :options="statusTypeEnum.getOptions()"></a-radio-group>
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="12"> <a-col :span="12">
<a-form-item <a-form-item style="width: 200px" :label="$t('pages.system.menu.form.sequence')"
style="width: 200px"
:label="$t('pages.system.menu.form.sequence')"
name="sequence"> name="sequence">
<a-input <a-input :defaultValue="0" type="number" v-model:value="formData.sequence"></a-input>
:defaultValue="0"
type="number"
v-model:value="formData.sequence"></a-input>
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="12"> <a-col :span="12">
<a-form-item <a-form-item :label="$t('pages.system.menu.form.description')" name="description">
:label="$t('pages.system.menu.form.description')"
name="description">
<a-input v-model:value="formData.description"></a-input> <a-input v-model:value="formData.description"></a-input>
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="24"> <a-col :span="24">
<a-form-item <a-form-item :label="$t('pages.system.menu.form.properties')" name="properties">
:label="$t('pages.system.menu.form.properties')"
name="properties">
<a-textarea v-model:value="formData.properties"></a-textarea> <a-textarea v-model:value="formData.properties"></a-textarea>
</a-form-item> </a-form-item>
</a-col> </a-col>
</a-row> </a-row>
</a-card> </a-card>
<a-card :title="$t('pages.system.menu.resource.form.title')"> <a-card :title="$t('pages.system.menu.resource.form.title')">
<a-table <a-table :columns="columns" :data-source="formData.resources" :pagination="false" row-key="id">
:columns="columns"
:data-source="formData.resources"
:pagination="false"
row-key="id">
<template #bodyCell="{ column, record, index }"> <template #bodyCell="{ column, record, index }">
<template v-if="column.key === 'types'"> <template v-if="column.key === 'types'">
<a-form-item :label="$t('pages.system.menu.resource.form.method')"> <a-form-item :label="$t('pages.system.menu.resource.form.method')">
<a-input-group <a-input-group style="display: inline-block; vertical-align: middle" :compact="true">
style="display: inline-block; vertical-align: middle"
:compact="true">
<a-form-item-rest> <a-form-item-rest>
<a-select <a-select v-model:value="record.method" :default-value="record.method || 'GET'"
v-model:value="record.method"
:default-value="record.method || 'GET'"
style="width: 100px"> style="width: 100px">
<a-select-option <a-select-option v-for="item of reqType" :key="item" :value="item">{{ item
v-for="item of reqType" }}</a-select-option>
:key="item"
:value="item"
>{{ item }}</a-select-option
>
</a-select> </a-select>
</a-form-item-rest> </a-form-item-rest>
<a-input <a-input v-model:value="record.path" :style="{ width: 'calc(100% - 100px)' }" />
v-model:value="record.path"
:style="{ width: 'calc(100% - 100px)' }" />
</a-input-group> </a-input-group>
</a-form-item> </a-form-item>
</template> </template>
@ -134,11 +85,7 @@
</template> </template>
</a-table> </a-table>
<a-button <a-button @click="handleAddApi" block class="mt-8-2" type="dashed">
@click="handleAddApi"
block
class="mt-8-2"
type="dashed">
<template #icon> <template #icon>
<plus-outlined></plus-outlined> <plus-outlined></plus-outlined>
</template> </template>
@ -160,6 +107,7 @@ import { menuTypeEnum, statusTypeEnum } from '@/enums/system'
import { ref } from 'vue' import { ref } from 'vue'
import { config } from '@/config' import { config } from '@/config'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import storage from '@/utils/storage'
const emit = defineEmits(['ok']) const emit = defineEmits(['ok'])
const { t } = useI18n() // t const { t } = useI18n() // t
const { modal, showModal, hideModal, showLoading, hideLoading } = useModal() const { modal, showModal, hideModal, showLoading, hideLoading } = useModal()
@ -236,6 +184,7 @@ function handleOk() {
let result = null let result = null
switch (modal.value.type) { switch (modal.value.type) {
case 'create': case 'create':
params.platform=storage.local.getItem('platform')
result = await apis.menu.createMenu(params).catch(() => { result = await apis.menu.createMenu(params).catch(() => {
throw new Error() throw new Error()
}) })

View File

@ -36,8 +36,7 @@
</template> </template>
</x-search-bar> </x-search-bar>
<a-card> <a-card>
<i class="iconfont icon-gonggao" style="color: red;"></i>
<span>引入阿里巴巴图标</span>
<x-action-bar class="mb-8-2"> <x-action-bar class="mb-8-2">
<a-button v-action="'add'" type="primary" @click="$refs.editDialogRef.handleCreate()"> <a-button v-action="'add'" type="primary" @click="$refs.editDialogRef.handleCreate()">
<template #icon> <template #icon>
@ -113,6 +112,7 @@ import { usePagination, useForm } from '@/hooks'
import { formatUtcDateTime } from '@/utils/util' import { formatUtcDateTime } from '@/utils/util'
import EditDialog from './components/EditDialog.vue' import EditDialog from './components/EditDialog.vue'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import storage from '@/utils/storage'
defineOptions({ defineOptions({
// eslint-disable-next-line vue/no-reserved-component-names // eslint-disable-next-line vue/no-reserved-component-names
name: 'menu', name: 'menu',
@ -143,9 +143,11 @@ async function getMenuList() {
try { try {
showLoading() showLoading()
// const { current } = paginationState // const { current } = paginationState
const platform=storage.local.getItem('platform')
const { data, success, total } = await apis.menu const { data, success, total } = await apis.menu
.getMenuList({ .getMenuList({
...searchFormData.value, ...searchFormData.value,
platform
}) })
.catch(() => { .catch(() => {
throw new Error() throw new Error()
@ -166,7 +168,7 @@ async function getMenuList() {
* 搜索 * 搜索
*/ */
function handleSearch() { function handleSearch() {
resetForm() // resetForm()
resetPagination() resetPagination()
getMenuList() getMenuList()
} }