fix(cloudtentacles): 第三轮 Bug 修复 + 体验改进 — Vue3 emit 多参数处理、SKU 刷新空缓存、新增账号改用 ElMessageBox.prompt

This commit is contained in:
yml
2026-05-20 01:36:57 +08:00
parent b4bb53f307
commit 5474d77799
4 changed files with 112 additions and 38 deletions
@@ -12,7 +12,7 @@ import { useKuaishouCloudSku } from './composables/useKuaishouCloudSku'
const config = useKuaishouCloudConfig()
const ninetyone = useKuaishouCloudNinetyone(config)
const cloudSku = useKuaishouCloudSku()
const cloudSku = useKuaishouCloudSku(config.cloudtentaclesSourceOptions)
onMounted(config.loadConfigs)
</script>
@@ -73,9 +73,9 @@ onMounted(config.loadConfigs)
@add-item="config.addItem()"
@save-configs="config.saveConfigs()"
@toggle-collapsed="config.toggleCollapsed($event)"
@handle-cloud-sku-selected="cloudSku.handleCloudSkuSelected($event.item, $event.value)"
@handle-cloud-sku-selected="(item, value) => cloudSku.handleCloudSkuSelected(item, value)"
@handle-cloud-sku-dropdown-visible="
cloudSku.handleCloudSkuDropdownVisible($event.item, $event.visible)
(item, visible) => cloudSku.handleCloudSkuDropdownVisible(item, visible)
"
@handle-kuaishou-consume-shop-selected="config.handleKuaishouConsumeShopSelected($event)"
@remove-item="config.removeItem($event)"
@@ -6,7 +6,7 @@ import type { AdminCloudtentaclesSkuItem } from '@/types/admin'
import type { EditableItem } from './types'
export function useKuaishouCloudSku() {
export function useKuaishouCloudSku(cloudtentaclesSourceOptions?: { value: { key: string }[] }) {
const cloudSkuCatalogLoadingBySourceKey = ref<Record<string, boolean>>({})
const cloudSkuCatalogErrorMessage = ref('')
const cloudSkuCatalogBySourceKey = ref<Record<string, AdminCloudtentaclesSkuItem[]>>({})
@@ -26,7 +26,9 @@ export function useKuaishouCloudSku() {
try {
const response = await fetchAdminCloudtentaclesSkuList({ sourceKey })
cloudSkuCatalogBySourceKey.value[sourceKey] = Array.isArray(response.data.items) ? response.data.items : []
cloudSkuCatalogBySourceKey.value[sourceKey] = Array.isArray(response.data.items)
? response.data.items
: []
return cloudSkuCatalogBySourceKey.value[sourceKey]
} catch (error) {
cloudSkuCatalogBySourceKey.value[sourceKey] = []
@@ -147,12 +149,26 @@ export function useKuaishouCloudSku() {
const count = cloudSkuCatalogBySourceKey.value[sourceKey]?.length ?? 0
showSuccess(`cloud SKU 列表(${sourceKey})已刷新,共 ${count}`)
} else {
// No item provided — refresh all loaded caches
const keys = Object.keys(cloudSkuCatalogBySourceKey.value)
for (const key of keys) {
await ensureCloudSkuCatalogLoaded({ cloudSourceKey: key, localId: '' } as EditableItem, true)
// No item provided — refresh all configured sourceKeys, or at least 'default'
const cachedKeys = Object.keys(cloudSkuCatalogBySourceKey.value)
const configuredKeys = cloudtentaclesSourceOptions?.value?.map((s) => s.key) || []
const keysToRefresh =
cachedKeys.length > 0
? cachedKeys
: configuredKeys.length > 0
? configuredKeys
: ['default']
for (const key of keysToRefresh) {
await ensureCloudSkuCatalogLoaded(
{ cloudSourceKey: key, localId: '' } as EditableItem,
true,
)
}
const total = Object.values(cloudSkuCatalogBySourceKey.value).reduce((sum, list) => sum + list.length, 0)
const total = Object.values(cloudSkuCatalogBySourceKey.value).reduce(
(sum, list) => sum + list.length,
0,
)
showSuccess(`cloud SKU 列表已全部刷新,共 ${total}`)
}
} catch (error) {
@@ -164,7 +180,9 @@ export function useKuaishouCloudSku() {
// Maintain backward-compat: derive a combined loading state
// The template uses cloudSkuCatalogLoading for the refresh button spinner
function syncCloudSkuCatalogLoading() {
cloudSkuCatalogLoading.value = Object.values(cloudSkuCatalogLoadingBySourceKey.value).some(Boolean)
cloudSkuCatalogLoading.value = Object.values(cloudSkuCatalogLoadingBySourceKey.value).some(
Boolean,
)
}
return {