diff --git a/.env.mac-docker.example b/.env.mac-docker.example index baa39b49..d12af4db 100644 --- a/.env.mac-docker.example +++ b/.env.mac-docker.example @@ -28,3 +28,7 @@ ADMIN_DEFAULT_USERS_JSON=[{"username":"admin","password":"dev-admin-123456","rol # 91Kaquan KAQUAN91_USER_ID= KAQUAN91_SECRET= + +# Cloudtentacles +CLOUDTENTACLES_DEVICE_ID=08bc9d8c-fd15-48ea-bc00-8d754076cafc +CLOUDTENTACLES_DEVICE_TYPE=1 diff --git a/.env.server.example b/.env.server.example index 9aef4e82..dd1e4cfe 100644 --- a/.env.server.example +++ b/.env.server.example @@ -27,3 +27,7 @@ ADMIN_DEFAULT_USERS_JSON=[{"username":"admin","password":"change-me-admin-passwo # 91Kaquan KAQUAN91_USER_ID= KAQUAN91_SECRET= + +# Cloudtentacles +CLOUDTENTACLES_DEVICE_ID=08bc9d8c-fd15-48ea-bc00-8d754076cafc +CLOUDTENTACLES_DEVICE_TYPE=1 diff --git a/apps/backend/data/cloudtentacles-sources.example.json b/apps/backend/data/cloudtentacles-sources.example.json index 74445179..3e5b3f88 100644 --- a/apps/backend/data/cloudtentacles-sources.example.json +++ b/apps/backend/data/cloudtentacles-sources.example.json @@ -9,8 +9,8 @@ "username": "", "password": "", "phone": "", - "deviceId": "-", - "deviceType": 0 + "deviceId": "08bc9d8c-fd15-48ea-bc00-8d754076cafc", + "deviceType": 1 } ] } diff --git a/apps/backend/src/config/defaults.ts b/apps/backend/src/config/defaults.ts index 1991a58c..07f4f4f2 100644 --- a/apps/backend/src/config/defaults.ts +++ b/apps/backend/src/config/defaults.ts @@ -79,8 +79,8 @@ export function createDefaultRuntimeConfig(projectRoot: string): RuntimeConfig { bindUrlProbeReferer: "https://gp.qq.com/", bindUrlProbeExtraCookie: "", clientSource: "ct-client", - deviceId: "-", - deviceType: 0, + deviceId: "08bc9d8c-fd15-48ea-bc00-8d754076cafc", + deviceType: 1, publicKeyPem: `-----BEGIN PUBLIC KEY----- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsSzjk+9st2f8IpYqYaM5 F7K27ZR2IvzxTr2w4zgZAS2+BRdgMvXUOITdFQT+ytYF/r3pIgTkL7MF9UQuylmb diff --git a/apps/backend/src/config/env-overrides.test.ts b/apps/backend/src/config/env-overrides.test.ts index db4a5e12..eb1fc7d2 100644 --- a/apps/backend/src/config/env-overrides.test.ts +++ b/apps/backend/src/config/env-overrides.test.ts @@ -142,8 +142,8 @@ function createRuntimeConfig(): RuntimeConfig { bindUrlProbeExtraCookie: '', publicKeyPem: '', clientSource: 'ct-client', - deviceId: '-', - deviceType: 0, + deviceId: '08bc9d8c-fd15-48ea-bc00-8d754076cafc', + deviceType: 1, }, }, } diff --git a/apps/backend/src/config/runtime-validation.test.ts b/apps/backend/src/config/runtime-validation.test.ts index ba403a20..e59d47e9 100644 --- a/apps/backend/src/config/runtime-validation.test.ts +++ b/apps/backend/src/config/runtime-validation.test.ts @@ -182,8 +182,8 @@ function createRuntimeConfig(overrides: Record = {}): RuntimeCo bindUrlProbeExtraCookie: '', publicKeyPem: '', clientSource: 'ct-client', - deviceId: '-', - deviceType: 0, + deviceId: '08bc9d8c-fd15-48ea-bc00-8d754076cafc', + deviceType: 1, }, }, }, overrides) as RuntimeConfig diff --git a/apps/backend/src/services/admin/platform-config/cloudtentacles/context.ts b/apps/backend/src/services/admin/platform-config/cloudtentacles/context.ts index 81d6d8fd..80bf3f03 100644 --- a/apps/backend/src/services/admin/platform-config/cloudtentacles/context.ts +++ b/apps/backend/src/services/admin/platform-config/cloudtentacles/context.ts @@ -43,6 +43,10 @@ export function resolveKuaishouEticketAdminContext(payload: JsonObject = {}, opt import { getCloudtentaclesSourceByKey } from "../../../platforms/cloudtentacles/source-config-service.js"; import { getCloudtentaclesSessionStateByKey } from "../../../platforms/cloudtentacles/session-state-service.js"; +import { + normalizeCloudtentaclesDeviceId, + normalizeCloudtentaclesDeviceType, +} from "../../../platforms/cloudtentacles/defaults.js"; export function resolveCloudtentaclesAdminContext(payload: JsonObject = {}, options: JsonObject = {}) { const sourceKey = String( @@ -63,16 +67,16 @@ export function resolveCloudtentaclesAdminContext(payload: JsonObject = {}, opti defaultBaseUrl, ]), token: pickFirstNonEmpty([payload.token, persistedSession.token]), - deviceId: pickFirstNonEmpty([ - payload.deviceId, - savedSource.deviceId, - persistedSession.deviceId, - "-", - ]), - deviceType: - payload.deviceType ?? - savedSource.deviceType ?? - persistedSession.deviceType, + deviceId: normalizeCloudtentaclesDeviceId( + pickFirstNonEmpty([ + payload.deviceId, + savedSource.deviceId, + persistedSession.deviceId, + ]) + ), + deviceType: normalizeCloudtentaclesDeviceType( + payload.deviceType ?? savedSource.deviceType ?? persistedSession.deviceType + ), }; } diff --git a/apps/backend/src/services/admin/platform-config/cloudtentacles/mappers.ts b/apps/backend/src/services/admin/platform-config/cloudtentacles/mappers.ts index e52fc50d..494f4b3a 100644 --- a/apps/backend/src/services/admin/platform-config/cloudtentacles/mappers.ts +++ b/apps/backend/src/services/admin/platform-config/cloudtentacles/mappers.ts @@ -2,6 +2,10 @@ import { maskPhone as maskPhoneValue, maskSecret as maskSecretValue, } from "../../../../utils/masking.js"; +import { + normalizeCloudtentaclesDeviceId, + normalizeCloudtentaclesDeviceType, +} from "../../../platforms/cloudtentacles/defaults.js"; type JsonObject = Record @@ -42,8 +46,8 @@ export function mapAdminCloudtentaclesSourceConfig(config: JsonObject = {}) { username: String(config.username || "").trim(), password: String(config.password || "").trim(), phone: String(config.phone || "").trim(), - deviceId: String(config.deviceId || "-").trim() || "-", - deviceType: Number(config.deviceType || 0), + deviceId: normalizeCloudtentaclesDeviceId(config.deviceId), + deviceType: normalizeCloudtentaclesDeviceType(config.deviceType), }; } @@ -55,8 +59,8 @@ export function mapAdminCloudtentaclesSession(session: JsonObject = {}) { username: String(session.username || "").trim(), phoneMasked: maskPhone(session.phone), loggedInAt: String(session.loggedInAt || "").trim(), - deviceId: String(session.deviceId || "-").trim() || "-", - deviceType: Number(session.deviceType || 0), + deviceId: normalizeCloudtentaclesDeviceId(session.deviceId), + deviceType: normalizeCloudtentaclesDeviceType(session.deviceType), hasToken: Boolean(String(session.token || "").trim()), }; } diff --git a/apps/backend/src/services/admin/platform-config/cloudtentacles/payloads.ts b/apps/backend/src/services/admin/platform-config/cloudtentacles/payloads.ts index 6b1e7eb9..56b6bfa3 100644 --- a/apps/backend/src/services/admin/platform-config/cloudtentacles/payloads.ts +++ b/apps/backend/src/services/admin/platform-config/cloudtentacles/payloads.ts @@ -1,5 +1,9 @@ import { getCloudtentaclesSourceByKey } from "../../../platforms/cloudtentacles/source-config-service.js"; import { getCloudtentaclesSessionStateByKey } from "../../../platforms/cloudtentacles/session-state-service.js"; +import { + normalizeCloudtentaclesDeviceId, + normalizeCloudtentaclesDeviceType, +} from "../../../platforms/cloudtentacles/defaults.js"; import { pickFirstNonEmpty, resolveCloudtentaclesAdminContext, @@ -34,8 +38,12 @@ export function resolveAdminCloudtentaclesCredentialPayload( username: pickFirstNonEmpty([payload.username, savedSource.username]), password: pickFirstNonEmpty([payload.password, savedSource.password]), phone: pickFirstNonEmpty([payload.phone, savedSource.phone]), - deviceId: pickFirstNonEmpty([payload.deviceId, savedSource.deviceId, "-"]), - deviceType: payload.deviceType ?? savedSource.deviceType, + deviceId: normalizeCloudtentaclesDeviceId( + pickFirstNonEmpty([payload.deviceId, savedSource.deviceId]) + ), + deviceType: normalizeCloudtentaclesDeviceType( + payload.deviceType ?? savedSource.deviceType + ), }; } @@ -67,8 +75,12 @@ export function buildAdminCloudtentaclesPersistedSessionPayload( username: pickFirstNonEmpty([options.username, session.username]), phone: pickFirstNonEmpty([options.phone, session.phone]), loggedInAt: String(session.loggedInAt || "").trim(), - deviceId: pickFirstNonEmpty([options.deviceId, session.deviceId, "-"]), - deviceType: options.deviceType ?? session.deviceType, + deviceId: normalizeCloudtentaclesDeviceId( + pickFirstNonEmpty([options.deviceId, session.deviceId]) + ), + deviceType: normalizeCloudtentaclesDeviceType( + options.deviceType ?? session.deviceType + ), }; } diff --git a/apps/backend/src/services/admin/platform-config/cloudtentacles/writes.ts b/apps/backend/src/services/admin/platform-config/cloudtentacles/writes.ts index 070fd78e..d72de37a 100644 --- a/apps/backend/src/services/admin/platform-config/cloudtentacles/writes.ts +++ b/apps/backend/src/services/admin/platform-config/cloudtentacles/writes.ts @@ -1,3 +1,8 @@ +import { + normalizeCloudtentaclesDeviceId, + normalizeCloudtentaclesDeviceType, +} from "../../../platforms/cloudtentacles/defaults.js"; + type JsonObject = Record; export function normalizeAdminCloudtentaclesSourceConfigPayload( @@ -13,7 +18,7 @@ export function normalizeAdminCloudtentaclesSourceConfigPayload( username: String(payload.username || "").trim(), password: String(payload.password || "").trim(), phone: String(payload.phone || "").trim(), - deviceId: String(payload.deviceId || "-").trim() || "-", - deviceType: Number(payload.deviceType || 0), + deviceId: normalizeCloudtentaclesDeviceId(payload.deviceId), + deviceType: normalizeCloudtentaclesDeviceType(payload.deviceType), }; } diff --git a/apps/backend/src/services/fulfillment/kuaishou-cloud/cloudtentacles-context.ts b/apps/backend/src/services/fulfillment/kuaishou-cloud/cloudtentacles-context.ts index ea13b759..50d0e000 100644 --- a/apps/backend/src/services/fulfillment/kuaishou-cloud/cloudtentacles-context.ts +++ b/apps/backend/src/services/fulfillment/kuaishou-cloud/cloudtentacles-context.ts @@ -1,4 +1,8 @@ import { createHttpError } from "../../../utils/http.js"; +import { + normalizeCloudtentaclesDeviceId, + normalizeCloudtentaclesDeviceType, +} from "../../platforms/cloudtentacles/defaults.js"; import { getCloudtentaclesSourceByKey } from "../../platforms/cloudtentacles/source-config-service.js"; import { getCloudtentaclesSessionStateByKey } from "../../platforms/cloudtentacles/session-state-service.js"; import { normalizeStringArray } from "./domain.js"; @@ -53,9 +57,12 @@ export function resolvePersistedCloudtentaclesContextBySourceKeys( String(session.baseUrl || source.baseUrl || "").trim() || "https://123.207.217.176", token, - deviceId: - String(session.deviceId || source.deviceId || "-").trim() || "-", - deviceType: Number(session.deviceType ?? source.deviceType ?? 0), + deviceId: normalizeCloudtentaclesDeviceId( + session.deviceId || source.deviceId + ), + deviceType: normalizeCloudtentaclesDeviceType( + session.deviceType ?? source.deviceType + ), resolvedSourceKey: sourceKey, }; } diff --git a/apps/backend/src/services/order/cloudtentacles-name-match-service.ts b/apps/backend/src/services/order/cloudtentacles-name-match-service.ts index de66cd6e..ba57a025 100644 --- a/apps/backend/src/services/order/cloudtentacles-name-match-service.ts +++ b/apps/backend/src/services/order/cloudtentacles-name-match-service.ts @@ -4,6 +4,10 @@ import { import { getCloudtentaclesSessionStateByKey, } from '../platforms/cloudtentacles/session-state-service.js' +import { + normalizeCloudtentaclesDeviceId, + normalizeCloudtentaclesDeviceType, +} from '../platforms/cloudtentacles/defaults.js' import { listCloudtentaclesSku, } from '../platforms/cloudtentacles/catalog-service.js' @@ -167,8 +171,8 @@ function buildCloudtentaclesSourceContext( sourceKey, baseUrl: String(session?.baseUrl || source.baseUrl || '').trim(), token, - deviceId: String(session?.deviceId || source.deviceId || '-').trim() || '-', - deviceType: Number(session?.deviceType ?? source.deviceType ?? 0), + deviceId: normalizeCloudtentaclesDeviceId(session?.deviceId || source.deviceId), + deviceType: normalizeCloudtentaclesDeviceType(session?.deviceType ?? source.deviceType), } } diff --git a/apps/backend/src/services/platforms/cloudtentacles/defaults.test.ts b/apps/backend/src/services/platforms/cloudtentacles/defaults.test.ts new file mode 100644 index 00000000..80b56534 --- /dev/null +++ b/apps/backend/src/services/platforms/cloudtentacles/defaults.test.ts @@ -0,0 +1,21 @@ +import test from 'node:test' +import assert from 'node:assert/strict' + +import { + DEFAULT_CLOUDTENTACLES_DEVICE_ID, + DEFAULT_CLOUDTENTACLES_DEVICE_TYPE, + normalizeCloudtentaclesDeviceId, + normalizeCloudtentaclesDeviceType, +} from './defaults.js' + +test('normalizeCloudtentaclesDeviceId maps empty and legacy placeholder to default device', () => { + assert.equal(normalizeCloudtentaclesDeviceId(''), DEFAULT_CLOUDTENTACLES_DEVICE_ID) + assert.equal(normalizeCloudtentaclesDeviceId('-'), DEFAULT_CLOUDTENTACLES_DEVICE_ID) + assert.equal(normalizeCloudtentaclesDeviceId(' custom-device '), 'custom-device') +}) + +test('normalizeCloudtentaclesDeviceType maps empty and legacy zero to default type', () => { + assert.equal(normalizeCloudtentaclesDeviceType(undefined), DEFAULT_CLOUDTENTACLES_DEVICE_TYPE) + assert.equal(normalizeCloudtentaclesDeviceType(0), DEFAULT_CLOUDTENTACLES_DEVICE_TYPE) + assert.equal(normalizeCloudtentaclesDeviceType('2'), 2) +}) diff --git a/apps/backend/src/services/platforms/cloudtentacles/defaults.ts b/apps/backend/src/services/platforms/cloudtentacles/defaults.ts new file mode 100644 index 00000000..784759e2 --- /dev/null +++ b/apps/backend/src/services/platforms/cloudtentacles/defaults.ts @@ -0,0 +1,17 @@ +export const DEFAULT_CLOUDTENTACLES_DEVICE_ID = + "08bc9d8c-fd15-48ea-bc00-8d754076cafc"; +export const DEFAULT_CLOUDTENTACLES_DEVICE_TYPE = 1; + +export function normalizeCloudtentaclesDeviceId(value: unknown) { + const normalized = String(value || "").trim(); + return normalized && normalized !== "-" + ? normalized + : DEFAULT_CLOUDTENTACLES_DEVICE_ID; +} + +export function normalizeCloudtentaclesDeviceType(value: unknown) { + const parsed = Number(value); + return Number.isInteger(parsed) && parsed > 0 + ? parsed + : DEFAULT_CLOUDTENTACLES_DEVICE_TYPE; +} diff --git a/apps/backend/src/services/platforms/cloudtentacles/helpers.ts b/apps/backend/src/services/platforms/cloudtentacles/helpers.ts index 3676db98..a97ffcc9 100644 --- a/apps/backend/src/services/platforms/cloudtentacles/helpers.ts +++ b/apps/backend/src/services/platforms/cloudtentacles/helpers.ts @@ -1,6 +1,12 @@ import { runtimeConfig } from '../../../config/runtime.js' import type { RuntimeConfig } from '../../../types/runtime-config.js' +import { + DEFAULT_CLOUDTENTACLES_DEVICE_ID, + DEFAULT_CLOUDTENTACLES_DEVICE_TYPE, + normalizeCloudtentaclesDeviceId, + normalizeCloudtentaclesDeviceType, +} from './defaults.js' type CloudtentaclesRuntimeConfig = RuntimeConfig['platforms']['cloudtentacles'] type JsonObject = Record @@ -40,8 +46,8 @@ export function resolveCloudtentaclesConfig(overrides: Partial
- + diff --git a/apps/frontend/src/views/admin/platform-shops/composables/cloudtentaclesDefaults.ts b/apps/frontend/src/views/admin/platform-shops/composables/cloudtentaclesDefaults.ts new file mode 100644 index 00000000..392fa915 --- /dev/null +++ b/apps/frontend/src/views/admin/platform-shops/composables/cloudtentaclesDefaults.ts @@ -0,0 +1,13 @@ +export const DEFAULT_CLOUDTENTACLES_DEVICE_ID = + '08bc9d8c-fd15-48ea-bc00-8d754076cafc' +export const DEFAULT_CLOUDTENTACLES_DEVICE_TYPE = 1 + +export function normalizeCloudtentaclesDeviceId(value: unknown) { + const normalized = String(value || '').trim() + return normalized && normalized !== '-' ? normalized : DEFAULT_CLOUDTENTACLES_DEVICE_ID +} + +export function normalizeCloudtentaclesDeviceType(value: unknown) { + const parsed = Number(value) + return Number.isInteger(parsed) && parsed > 0 ? parsed : DEFAULT_CLOUDTENTACLES_DEVICE_TYPE +} diff --git a/apps/frontend/src/views/admin/platform-shops/composables/useAdminCloudtentaclesPlatform.ts b/apps/frontend/src/views/admin/platform-shops/composables/useAdminCloudtentaclesPlatform.ts index 06ab61f9..61213af8 100644 --- a/apps/frontend/src/views/admin/platform-shops/composables/useAdminCloudtentaclesPlatform.ts +++ b/apps/frontend/src/views/admin/platform-shops/composables/useAdminCloudtentaclesPlatform.ts @@ -20,6 +20,12 @@ import type { } from '@/types/admin' import type { CloudtentaclesForm } from './useCloudtentaclesDebugActions' +import { + DEFAULT_CLOUDTENTACLES_DEVICE_ID, + DEFAULT_CLOUDTENTACLES_DEVICE_TYPE, + normalizeCloudtentaclesDeviceId, + normalizeCloudtentaclesDeviceType, +} from './cloudtentaclesDefaults' import { useCloudtentaclesDebugActions } from './useCloudtentaclesDebugActions' export function useAdminCloudtentaclesPlatform() { @@ -41,8 +47,8 @@ export function useAdminCloudtentaclesPlatform() { vnId: 0, skuId: 5, skuCount: 1, - deviceId: '-', - deviceType: 0, + deviceId: DEFAULT_CLOUDTENTACLES_DEVICE_ID, + deviceType: DEFAULT_CLOUDTENTACLES_DEVICE_TYPE, }) const cloudtentaclesSaving = ref(false) const cloudtentaclesSendingSms = ref(false) @@ -109,8 +115,8 @@ export function useAdminCloudtentaclesPlatform() { username: '', password: '', phone: '', - deviceId: '-', - deviceType: 0, + deviceId: DEFAULT_CLOUDTENTACLES_DEVICE_ID, + deviceType: DEFAULT_CLOUDTENTACLES_DEVICE_TYPE, } satisfies AdminCloudtentaclesSourceItem } @@ -129,8 +135,8 @@ export function useAdminCloudtentaclesPlatform() { source.username = cloudtentaclesForm.value.username.trim() source.password = cloudtentaclesForm.value.password.trim() source.phone = cloudtentaclesForm.value.phone.trim() - source.deviceId = cloudtentaclesForm.value.deviceId.trim() || '-' - source.deviceType = Number(cloudtentaclesForm.value.deviceType || 0) + source.deviceId = normalizeCloudtentaclesDeviceId(cloudtentaclesForm.value.deviceId) + source.deviceType = normalizeCloudtentaclesDeviceType(cloudtentaclesForm.value.deviceType) } function selectFallbackSource(preferredKey = '') { @@ -170,8 +176,8 @@ export function useAdminCloudtentaclesPlatform() { vnId: 0, skuId: 5, skuCount: 1, - deviceId: source.deviceId || '-', - deviceType: source.deviceType || 0, + deviceId: normalizeCloudtentaclesDeviceId(source.deviceId), + deviceType: normalizeCloudtentaclesDeviceType(source.deviceType), } } cloudtentaclesPersistedSession.value = session || null @@ -288,8 +294,8 @@ export function useAdminCloudtentaclesPlatform() { username: cloudtentaclesForm.value.username.trim(), password: cloudtentaclesForm.value.password.trim(), phone: cloudtentaclesForm.value.phone.trim(), - deviceId: cloudtentaclesForm.value.deviceId.trim() || '-', - deviceType: Number(cloudtentaclesForm.value.deviceType || 0), + deviceId: normalizeCloudtentaclesDeviceId(cloudtentaclesForm.value.deviceId), + deviceType: normalizeCloudtentaclesDeviceType(cloudtentaclesForm.value.deviceType), sourceKey: selectedSourceKey.value, } } @@ -383,8 +389,8 @@ export function useAdminCloudtentaclesPlatform() { username: response.data.username, phoneMasked: response.data.phoneMasked, loggedInAt: response.data.loggedInAt, - deviceId: cloudtentaclesForm.value.deviceId.trim() || '-', - deviceType: Number(cloudtentaclesForm.value.deviceType || 0), + deviceId: normalizeCloudtentaclesDeviceId(cloudtentaclesForm.value.deviceId), + deviceType: normalizeCloudtentaclesDeviceType(cloudtentaclesForm.value.deviceType), hasToken: Boolean(response.data.token), } // Update sessions map @@ -413,8 +419,8 @@ export function useAdminCloudtentaclesPlatform() { const response = await validateAdminCloudtentaclesSession({ baseUrl: cloudtentaclesForm.value.baseUrl.trim() || 'https://123.207.217.176', token, - deviceId: cloudtentaclesForm.value.deviceId.trim() || '-', - deviceType: Number(cloudtentaclesForm.value.deviceType || 0), + deviceId: normalizeCloudtentaclesDeviceId(cloudtentaclesForm.value.deviceId), + deviceType: normalizeCloudtentaclesDeviceType(cloudtentaclesForm.value.deviceType), sourceKey: selectedSourceKey.value, }) cloudtentaclesValidateResult.value = response.data @@ -427,8 +433,8 @@ export function useAdminCloudtentaclesPlatform() { cloudtentaclesForm.value.username.trim(), phoneMasked: cloudtentaclesPersistedSession.value?.phoneMasked || '', loggedInAt: response.data.loggedInAt, - deviceId: cloudtentaclesForm.value.deviceId.trim() || '-', - deviceType: Number(cloudtentaclesForm.value.deviceType || 0), + deviceId: normalizeCloudtentaclesDeviceId(cloudtentaclesForm.value.deviceId), + deviceType: normalizeCloudtentaclesDeviceType(cloudtentaclesForm.value.deviceType), hasToken: Boolean(token), } // Update sessions map diff --git a/apps/frontend/src/views/admin/platform-shops/composables/useCloudtentaclesDebugActions.ts b/apps/frontend/src/views/admin/platform-shops/composables/useCloudtentaclesDebugActions.ts index e869c52f..fd1ff836 100644 --- a/apps/frontend/src/views/admin/platform-shops/composables/useCloudtentaclesDebugActions.ts +++ b/apps/frontend/src/views/admin/platform-shops/composables/useCloudtentaclesDebugActions.ts @@ -17,6 +17,11 @@ import { verifyAdminCloudtentaclesVnCode, } from '@/services/admin' +import { + normalizeCloudtentaclesDeviceId, + normalizeCloudtentaclesDeviceType, +} from './cloudtentaclesDefaults' + export type CloudtentaclesForm = { baseUrl: string username: string @@ -44,8 +49,8 @@ export function useCloudtentaclesDebugActions( return { baseUrl: cloudtentaclesForm.value.baseUrl.trim() || 'https://123.207.217.176', token: cloudtentaclesForm.value.token.trim(), - deviceId: cloudtentaclesForm.value.deviceId.trim() || '-', - deviceType: Number(cloudtentaclesForm.value.deviceType || 0), + deviceId: normalizeCloudtentaclesDeviceId(cloudtentaclesForm.value.deviceId), + deviceType: normalizeCloudtentaclesDeviceType(cloudtentaclesForm.value.deviceType), sourceKey: selectedSourceKey.value, } }