统一前后端代码格式化配置
This commit is contained in:
@@ -3,10 +3,7 @@ import type { JsonObject } from '../../types/json.js'
|
||||
|
||||
import { APP_CONFIG_KEYS } from '../../config/app-config-keys.js'
|
||||
import { PROJECT_ROOT } from '../../config/runtime.js'
|
||||
import {
|
||||
readAppConfigEntry,
|
||||
saveAppConfigEntry,
|
||||
} from '../config/app-config-store.js'
|
||||
import { readAppConfigEntry, saveAppConfigEntry } from '../config/app-config-store.js'
|
||||
import { normalizeCloudtentaclesMatchName } from './cloudtentacles-match-utils.js'
|
||||
|
||||
const CLOUDTENTACLES_OVERRIDE_RULE_FILE_PATH = path.join(
|
||||
@@ -49,7 +46,9 @@ export function getCloudtentaclesOverrideRuleConfig(): CloudtentaclesOverrideRul
|
||||
})
|
||||
}
|
||||
|
||||
export function saveCloudtentaclesOverrideRuleConfig(rawValue: unknown): Promise<CloudtentaclesOverrideRuleConfig> {
|
||||
export function saveCloudtentaclesOverrideRuleConfig(
|
||||
rawValue: unknown,
|
||||
): Promise<CloudtentaclesOverrideRuleConfig> {
|
||||
return saveAppConfigEntry({
|
||||
configKey: APP_CONFIG_KEYS.cloudtentaclesOverrideRules,
|
||||
legacyFilePath: CLOUDTENTACLES_OVERRIDE_RULE_FILE_PATH,
|
||||
@@ -69,14 +68,19 @@ export function resolveCloudtentaclesOverrideRule(productName: unknown) {
|
||||
return null
|
||||
}
|
||||
|
||||
return config.rules.find((rule) =>
|
||||
rule.enabled !== false &&
|
||||
rule.normalizedProductName === normalizedProductName &&
|
||||
rule.deliveryItems.length > 0
|
||||
) || null
|
||||
return (
|
||||
config.rules.find(
|
||||
(rule) =>
|
||||
rule.enabled !== false &&
|
||||
rule.normalizedProductName === normalizedProductName &&
|
||||
rule.deliveryItems.length > 0,
|
||||
) || null
|
||||
)
|
||||
}
|
||||
|
||||
export function normalizeCloudtentaclesOverrideRuleConfig(rawValue: unknown): CloudtentaclesOverrideRuleConfig {
|
||||
export function normalizeCloudtentaclesOverrideRuleConfig(
|
||||
rawValue: unknown,
|
||||
): CloudtentaclesOverrideRuleConfig {
|
||||
const source = isPlainObject(rawValue) ? rawValue : {}
|
||||
const rules = Array.isArray(source.rules) ? source.rules : []
|
||||
|
||||
@@ -142,7 +146,10 @@ function mergeDeliveryItems(items: CloudtentaclesOverrideDeliveryItem[]) {
|
||||
const merged = new Map<string, CloudtentaclesOverrideDeliveryItem>()
|
||||
|
||||
for (const item of items) {
|
||||
const key = item.cloudSkuId > 0 ? `id:${item.cloudSkuId}` : `name:${normalizeCloudtentaclesMatchName(item.cloudSkuName)}`
|
||||
const key =
|
||||
item.cloudSkuId > 0
|
||||
? `id:${item.cloudSkuId}`
|
||||
: `name:${normalizeCloudtentaclesMatchName(item.cloudSkuName)}`
|
||||
const existing = merged.get(key)
|
||||
if (existing) {
|
||||
existing.quantity += item.quantity
|
||||
|
||||
Reference in New Issue
Block a user