feat: 重构sidebar菜单块逻辑

This commit is contained in:
rd
2025-07-07 18:17:31 +08:00
parent 0fe45bb2b3
commit bd4c338f35
11 changed files with 163 additions and 122 deletions

View File

@ -26,7 +26,7 @@
v-if="props.product.status === Status.Enable || props.product.status === Status.ON_TRIAL"
class="primary-button"
type="primary"
@click="gotoModule(props.product.menu_id)"
@click="gotoModule(props.product.id)"
>
进入模块
</a-button>
@ -71,12 +71,12 @@ import { useRouter } from 'vue-router';
import CustomerServiceModal from '@/components/customer-service-modal.vue';
import { appRoutes } from '@/router/routes';
import { useSidebarStore } from '@/stores/modules/side-bar';
import { useEnterpriseStore } from '@/stores/modules/enterprise';
const props = defineProps<{
product: Product;
}>();
const emit = defineEmits(['refresh']);
const sidebarStore = useSidebarStore();
enum Status {
Disable = 0, // 禁用
@ -87,30 +87,34 @@ enum Status {
}
interface Product {
id: number;
status: Status;
name: string;
image: string;
desc: string;
menu_id: number;
id: number;
expired_at?: number;
}
const visible = ref(false);
const router = useRouter();
const enterpriseStore = useEnterpriseStore();
const handleTrial = async (id: any) => {
await trialProduct(id);
AMessage.success('试用成功!');
emit('refresh');
const { code } = await trialProduct(id);
if (code === 200) {
enterpriseStore.updateEnterpriseInfo();
AMessage.success('试用成功!');
emit('refresh');
}
};
const gotoModule = (menuId: number) => {
const _target = appRoutes.find((v) => v.meta.id === menuId);
if (_target) {
console.log({ _target });
router.push({ name: _target.name });
}
const routeMap: Record<number, string> = {
'1': 'DataEngineHotTranslation',
'2': 'RepositoryBrandMaterials',
};
console.log(routeMap[menuId]);
router.push({ name: routeMap[menuId] });
};
</script>
<style scoped lang="less">