2
0

fix:home界面组件更新联动

This commit is contained in:
zhongzm
2024-12-25 18:51:47 +08:00
parent 8edc1e19c7
commit 1c81fa2ec0
5 changed files with 24 additions and 3 deletions

View File

@@ -1,5 +1,5 @@
<script setup lang="ts">
import { ref, computed, onMounted, onUnmounted } from 'vue';
import { ref, computed, onMounted, onUnmounted, inject } from 'vue';
import { useBillingStore } from '@/store/modules/billing/billing';
import { useI18n } from 'vue-i18n';
import { submitOrder } from '@/service/api/auth';
@@ -7,6 +7,8 @@ import { message } from 'ant-design-vue';
import type { Ref } from 'vue';
const { t } = useI18n();
// 注入更新仪表盘的方法
const updateDashboard = inject('updateDashboard') as () => Promise<void>;
interface RechargeOption {
amount: number;
@@ -95,6 +97,8 @@ const handleRecharge = async () => {
// 更新余额,传入充值金额
await billingStore.updateBalance(paymentAmount.value);
// 更新仪表盘数据
await updateDashboard();
} catch (error) {
message.error('充值失败,请重试!');
console.error('Failed to submit recharge order:', error);

View File

@@ -1,10 +1,12 @@
<script setup lang="ts">
import { useI18n } from 'vue-i18n';
import { ref, onMounted } from 'vue';
import { ref, onMounted, inject } from 'vue';
import { fetchPackageList, submitOrder } from '@/service/api/auth';
import { message } from 'ant-design-vue';
const { t } = useI18n();
// 注入更新仪表盘的方法
const updateDashboard = inject('updateDashboard') as () => Promise<void>;
interface PackageOption {
id: string;
@@ -127,6 +129,8 @@ const handleSubmitOrder = async () => {
packageId: selectedPackage.value.id
});
message.success('套餐办理成功!');
// 更新仪表盘数据
await updateDashboard();
} catch (error) {
message.error('套餐办理失败,请重试!');
console.error('Failed to submit order:', error);