perf: 申请试用后 初始化权限列表
This commit is contained in:
10
src/App.vue
10
src/App.vue
@ -8,12 +8,12 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useUserStore } from '@/stores';
|
import { useUserStore } from '@/stores';
|
||||||
import { useEnterpriseStore } from '@/stores/modules/enterprise';
|
import { useEnterpriseStore } from '@/stores/modules/enterprise';
|
||||||
import { useSidebarStore } from '@/stores/modules/side-bar';
|
|
||||||
|
import { getUserEnterpriseInfo } from '@/utils/user';
|
||||||
|
|
||||||
import zhCN from '@arco-design/web-vue/es/locale/lang/zh-cn';
|
import zhCN from '@arco-design/web-vue/es/locale/lang/zh-cn';
|
||||||
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const enterpriseStore = useEnterpriseStore();
|
|
||||||
|
|
||||||
const redTheme = {
|
const redTheme = {
|
||||||
token: {
|
token: {
|
||||||
@ -25,14 +25,10 @@ const redTheme = {
|
|||||||
|
|
||||||
const init = async () => {
|
const init = async () => {
|
||||||
const { isLogin, getUserInfo } = userStore;
|
const { isLogin, getUserInfo } = userStore;
|
||||||
const { getUserEnterpriseInfo } = enterpriseStore;
|
|
||||||
const sidebarStore = useSidebarStore();
|
|
||||||
|
|
||||||
if (isLogin) {
|
if (isLogin) {
|
||||||
await getUserInfo(); // 初始化用户信息
|
await getUserInfo(); // 初始化用户信息
|
||||||
await getUserEnterpriseInfo(); // 初始化企业信息
|
await getUserEnterpriseInfo();
|
||||||
sidebarStore.getUserNavbarMenuList(); // 初始化navbar菜单
|
|
||||||
userStore.getUserAllowAccessRoutes(); // 初始化允许访问的路由
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -45,7 +45,7 @@ export const useEnterpriseStore = defineStore('enterprise', {
|
|||||||
this.enterpriseInfo.used_sub_account_count++;
|
this.enterpriseInfo.used_sub_account_count++;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async getUserEnterpriseInfo() {
|
async getEnterpriseInfo() {
|
||||||
if (this.enterpriseInfo) {
|
if (this.enterpriseInfo) {
|
||||||
const { code, data } = await fetchEnterpriseInfo(this.enterpriseInfo!.id);
|
const { code, data } = await fetchEnterpriseInfo(this.enterpriseInfo!.id);
|
||||||
if (code === 200) {
|
if (code === 200) {
|
||||||
|
|||||||
@ -12,17 +12,23 @@ import { useSidebarStore } from '@/stores/modules/side-bar';
|
|||||||
export function goUserLogin(query?: any) {
|
export function goUserLogin(query?: any) {
|
||||||
router.push({ name: 'UserLogin', query });
|
router.push({ name: 'UserLogin', query });
|
||||||
}
|
}
|
||||||
|
// 初始化企业信息、navbar菜单、允许访问的路由
|
||||||
|
export const getUserEnterpriseInfo = async () => {
|
||||||
|
const enterpriseStore = useEnterpriseStore();
|
||||||
|
const sidebarStore = useSidebarStore();
|
||||||
|
const userStore = useUserStore();
|
||||||
|
|
||||||
|
await enterpriseStore.getEnterpriseInfo();
|
||||||
|
sidebarStore.getUserNavbarMenuList(); // 初始化navbar菜单
|
||||||
|
userStore.getUserAllowAccessRoutes(); // 初始化允许访问的路由
|
||||||
|
};
|
||||||
|
|
||||||
// 登录处理
|
// 登录处理
|
||||||
export async function handleUserLogin() {
|
export async function handleUserLogin() {
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const enterpriseStore = useEnterpriseStore();
|
|
||||||
const sidebarStore = useSidebarStore();
|
|
||||||
|
|
||||||
await userStore.getUserInfo(); // 初始化用户信息
|
await userStore.getUserInfo(); // 初始化用户信息
|
||||||
await enterpriseStore.getUserEnterpriseInfo(); // 初始化企业信息
|
await getUserEnterpriseInfo();
|
||||||
sidebarStore.getUserNavbarMenuList(); // 初始化navbar菜单
|
|
||||||
userStore.getUserAllowAccessRoutes(); // 初始化允许访问的路由
|
|
||||||
|
|
||||||
handleUserHome();
|
handleUserHome();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -70,8 +70,11 @@ import { trialProduct } from '@/api/all';
|
|||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
import CustomerServiceModal from '@/components/customer-service-modal.vue';
|
import CustomerServiceModal from '@/components/customer-service-modal.vue';
|
||||||
import { appRoutes } from '@/router/routes';
|
import { appRoutes } from '@/router/routes';
|
||||||
|
|
||||||
import { useSidebarStore } from '@/stores/modules/side-bar';
|
import { useSidebarStore } from '@/stores/modules/side-bar';
|
||||||
import { useEnterpriseStore } from '@/stores/modules/enterprise';
|
import { useEnterpriseStore } from '@/stores/modules/enterprise';
|
||||||
|
import { useUserStore } from '@/stores';
|
||||||
|
import { getUserEnterpriseInfo } from '@/utils/user';
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
product: Product;
|
product: Product;
|
||||||
@ -98,11 +101,14 @@ interface Product {
|
|||||||
const visible = ref(false);
|
const visible = ref(false);
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const enterpriseStore = useEnterpriseStore();
|
const enterpriseStore = useEnterpriseStore();
|
||||||
|
const userStore = useUserStore();
|
||||||
|
const sidebarStore = useSidebarStore();
|
||||||
|
|
||||||
const handleTrial = async (id: any) => {
|
const handleTrial = async (id: any) => {
|
||||||
const { code } = await trialProduct(id);
|
const { code } = await trialProduct(id);
|
||||||
if (code === 200) {
|
if (code === 200) {
|
||||||
enterpriseStore.getUserEnterpriseInfo();
|
getUserEnterpriseInfo();
|
||||||
|
|
||||||
AMessage.success('试用成功!');
|
AMessage.success('试用成功!');
|
||||||
emit('refresh');
|
emit('refresh');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user