fix:home界面组件更新联动
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user