优化 cloudtentacles 多账号管理与任务展示
This commit is contained in:
@@ -90,6 +90,10 @@ export function mapKuaishouCloudFulfillmentContext(value: unknown): JsonRecord |
|
||||
binding: {
|
||||
prepareStatus: String(binding.prepareStatus || 'pending').trim() || 'pending',
|
||||
cloudSourceKey: String(binding.cloudSourceKey || '').trim(),
|
||||
cloudSourceKeyFallbacks: Array.isArray(binding.cloudSourceKeyFallbacks)
|
||||
? binding.cloudSourceKeyFallbacks.map((value) => String(value || '').trim()).filter(Boolean)
|
||||
: [],
|
||||
resolvedSourceKey: String(binding.resolvedSourceKey || '').trim(),
|
||||
skuId: Number(binding.skuId || 0) || 0,
|
||||
skuName: String(binding.skuName || '').trim(),
|
||||
vnKey: String(binding.vnKey || '').trim(),
|
||||
|
||||
@@ -8,10 +8,12 @@ import {
|
||||
} from "../../platforms/cloudtentacles/source-config-service.js";
|
||||
import {
|
||||
clearCloudtentaclesSessionStateByKey,
|
||||
deleteCloudtentaclesSessionStateByKey,
|
||||
getCloudtentaclesSessionFilePath,
|
||||
getCloudtentaclesSessionStateByKey,
|
||||
saveCloudtentaclesSessionStateByKey,
|
||||
getAllCloudtentaclesSessionStates,
|
||||
pruneCloudtentaclesSessionStates,
|
||||
} from "../../platforms/cloudtentacles/session-state-service.js";
|
||||
import {
|
||||
loginCloudtentaclesSession,
|
||||
@@ -102,7 +104,9 @@ export function updateAdminCloudtentaclesSourceConfig(
|
||||
enabled: payload.enabled !== false,
|
||||
sources: normalizedList,
|
||||
});
|
||||
const sessions = getAllCloudtentaclesSessionStates();
|
||||
const sessions = pruneCloudtentaclesSessionStates(
|
||||
normalizedList.map((item) => item.key)
|
||||
);
|
||||
|
||||
const sources = Array.isArray(savedList.sources)
|
||||
? savedList.sources.map((s) => mapAdminCloudtentaclesSourceConfig(s))
|
||||
@@ -151,7 +155,7 @@ export function deleteAdminCloudtentaclesSource(sourceKey: string) {
|
||||
if (!key) {
|
||||
throw new Error("sourceKey is required for deletion");
|
||||
}
|
||||
clearCloudtentaclesSessionStateByKey(key);
|
||||
deleteCloudtentaclesSessionStateByKey(key);
|
||||
deleteCloudtentaclesSourceByKey(key);
|
||||
}
|
||||
|
||||
|
||||
@@ -190,3 +190,23 @@ test('buildAdminCloudtentaclesValidateResult assembles validate response payload
|
||||
},
|
||||
)
|
||||
})
|
||||
|
||||
test('buildAdminCloudtentaclesSessionSummary preserves sourceKey', () => {
|
||||
assert.deepEqual(
|
||||
buildAdminCloudtentaclesSessionSummary(
|
||||
{
|
||||
token: 'abcdef1234567890',
|
||||
permissions: [],
|
||||
},
|
||||
{},
|
||||
'account2',
|
||||
),
|
||||
{
|
||||
sourceKey: 'account2',
|
||||
tokenMasked: 'abcdef****567890',
|
||||
permissionCount: 0,
|
||||
permissions: [],
|
||||
persisted: false,
|
||||
},
|
||||
)
|
||||
})
|
||||
|
||||
@@ -104,6 +104,7 @@ test('mapAdminKuaishouCloudFulfillmentSource normalizes items and defaults', ()
|
||||
externalSkuName: '',
|
||||
resolvedSkuName: '',
|
||||
cloudSourceKey: 'default',
|
||||
cloudSourceKeyFallbacks: [],
|
||||
cloudSkuId: 0,
|
||||
cloudSkuName: '',
|
||||
vnKey: '',
|
||||
|
||||
@@ -77,6 +77,11 @@ export function mapAdminKuaishouCloudFulfillmentItem(item: JsonObject = {}) {
|
||||
resolvedSkuName: String(item.resolvedSkuName || "").trim(),
|
||||
cloudSourceKey:
|
||||
String(item.cloudSourceKey || "default").trim() || "default",
|
||||
cloudSourceKeyFallbacks: Array.isArray(item.cloudSourceKeyFallbacks)
|
||||
? item.cloudSourceKeyFallbacks
|
||||
.map((value) => String(value || "").trim())
|
||||
.filter(Boolean)
|
||||
: [],
|
||||
cloudSkuId: Number(item.cloudSkuId || 0) || 0,
|
||||
cloudSkuName: String(item.cloudSkuName || "").trim(),
|
||||
vnKey: String(item.vnKey || "").trim(),
|
||||
|
||||
Reference in New Issue
Block a user