增加前端格式检查配置

This commit is contained in:
yml2213
2026-06-08 06:40:33 +08:00
parent 79ea3a476c
commit 500f511185
150 changed files with 7254 additions and 4013 deletions
@@ -1,6 +1,12 @@
import { computed, type Ref } from 'vue'
import type { ChargeMode, ListingPublishOptions, PublishSalePriceConfig, QuantityKey, ScreenshotKey } from '@/features/listings/api/listingOptions'
import type {
ChargeMode,
ListingPublishOptions,
PublishSalePriceConfig,
QuantityKey,
ScreenshotKey,
} from '@/features/listings/api/listingOptions'
import type { PublishForm } from '@/types/publish'
import {
buildDepositBreakdownItems,
@@ -39,15 +45,21 @@ export function usePricingCalculator(options: {
const quantityItems = computed(() => options.publishOptions.value.quantity_items)
const screenshotSlots = computed(() => options.publishOptions.value.screenshot_slots)
const priceConfig = computed(() => options.publishOptions.value.price_config)
const depositRecommendConfig = computed(() => options.publishOptions.value.deposit_recommend_config)
const depositRecommendConfig = computed(
() => options.publishOptions.value.deposit_recommend_config
)
const fireLevelMin = computed(() => options.publishOptions.value.fire_level_min || 38)
const fireLevelPlaceholder = computed(() => `等级低于${fireLevelMin.value}级的号无法发布`)
const coinMAmount = computed(() => Number(options.form.haf_coin_amount || 0))
const coinWanAmount = computed(() => coinMAmount.value * 100)
const dailyLossMAmount = computed(() => Number(options.form.daily_loss_m || 10))
const dailyLossRatioAdjustment = computed(() => calculateDailyLossRatioAdjustment(dailyLossMAmount.value))
const dailyLossRatioAdjustment = computed(() =>
calculateDailyLossRatioAdjustment(dailyLossMAmount.value)
)
const screenshotUrls = computed(() =>
screenshotSlots.value.flatMap((item) => options.screenshotFiles?.[item.key] || []).filter((url) => Boolean(url)),
screenshotSlots.value
.flatMap(item => options.screenshotFiles?.[item.key] || [])
.filter(url => Boolean(url))
)
function hasAcceleratedSaleRatioInput() {
@@ -67,18 +79,18 @@ export function usePricingCalculator(options: {
selectedSkins: options.selectedSkins.value,
levelOptions: levelOptions.value,
dailyLossRatioAdjustment: dailyLossRatioAdjustment.value,
}),
})
)
const calculatedDefaultSaleRatio = computed(() => calculatedSellerReferenceRatio.value)
const maxAcceleratedSaleRatio = computed(() =>
calculatedDefaultSaleRatio.value > 0 ? roundRatio(calculatedDefaultSaleRatio.value + 10) : 0,
calculatedDefaultSaleRatio.value > 0 ? roundRatio(calculatedDefaultSaleRatio.value + 10) : 0
)
const calculatedRatio = computed(() =>
readFinalSaleRatio(
calculatedDefaultSaleRatio.value,
options.form.accelerated_sale_ratio,
maxAcceleratedSaleRatio.value,
),
maxAcceleratedSaleRatio.value
)
)
const calculatedCoinBasePrice = computed(() => {
if (calculatedRatio.value <= 0) return 0
@@ -90,10 +102,12 @@ export function usePricingCalculator(options: {
quantityValues: options.quantityValues,
quantityModes: options.quantityModes,
seasonInsurance: options.form.season_insurance,
}),
})
)
const calculatedSellerPrice = computed(() =>
calculatedRatio.value > 0 ? roundMoney(calculatedCoinBasePrice.value + calculatedConsumablePrice.value) : 0,
calculatedRatio.value > 0
? roundMoney(calculatedCoinBasePrice.value + calculatedConsumablePrice.value)
: 0
)
const calculatedPlatformPricing = computed(() =>
calculatePlatformPricing({
@@ -104,12 +118,16 @@ export function usePricingCalculator(options: {
sellerTotalPrice: calculatedSellerPrice.value,
consumablePrice: calculatedConsumablePrice.value,
salePriceConfig: options.salePriceConfig.value,
}),
})
)
const calculatedFinalPrice = computed(() => calculatedPlatformPricing.value.buyerTotalPrice)
const calculatedRatioText = computed(() => (calculatedRatio.value > 0 ? `1:${formatNumber(calculatedRatio.value)}` : '--'))
const calculatedRatioText = computed(() =>
calculatedRatio.value > 0 ? `1:${formatNumber(calculatedRatio.value)}` : '--'
)
const calculatedDefaultSaleRatioText = computed(() =>
calculatedDefaultSaleRatio.value > 0 ? `1:${formatNumber(calculatedDefaultSaleRatio.value)}` : '--',
calculatedDefaultSaleRatio.value > 0
? `1:${formatNumber(calculatedDefaultSaleRatio.value)}`
: '--'
)
const saleRatioRangeText = computed(() => {
if (calculatedDefaultSaleRatio.value <= 0) return '完成基础信息后自动计算参考比例'
@@ -124,14 +142,14 @@ export function usePricingCalculator(options: {
depositRecommendConfig: depositRecommendConfig.value,
skinGroups: skinGroups.value,
selectedSkins: options.selectedSkins.value,
}),
})
)
const depositBreakdownItems = computed(() =>
buildDepositBreakdownItems({
depositRecommendConfig: depositRecommendConfig.value,
skinGroups: skinGroups.value,
selectedSkins: options.selectedSkins.value,
}),
})
)
const platformRuleLabel = computed(() => {
const labels: Record<string, string> = {
@@ -139,7 +157,9 @@ export function usePricingCalculator(options: {
ratio_subtract: '比例修正',
none: '无加价',
}
return labels[calculatedPlatformPricing.value.ruleType] || calculatedPlatformPricing.value.ruleType
return (
labels[calculatedPlatformPricing.value.ruleType] || calculatedPlatformPricing.value.ruleType
)
})
const publishTitle = computed(() => {
const parts = [
@@ -1,63 +1,62 @@
import { onUnmounted, ref } from "vue";
import { showToast } from "vant";
import { sendSmsCode } from "@/features/auth/api/auth";
import { onUnmounted, ref } from 'vue'
import { showToast } from 'vant'
import { sendSmsCode } from '@/features/auth/api/auth'
export function useSmsCountdown() {
const countDown = ref(0);
const sending = ref(false);
let timer: ReturnType<typeof setInterval> | null = null;
const countDown = ref(0)
const sending = ref(false)
let timer: ReturnType<typeof setInterval> | null = null
function startCountDown() {
countDown.value = 60;
countDown.value = 60
timer = setInterval(() => {
countDown.value--;
countDown.value--
if (countDown.value <= 0) {
clearInterval(timer!);
timer = null;
clearInterval(timer!)
timer = null
}
}, 1000);
}, 1000)
}
onUnmounted(() => {
if (timer) {
clearInterval(timer);
timer = null;
clearInterval(timer)
timer = null
}
});
})
async function handleSendCode(phone: string) {
if (!phone.trim()) {
showToast({ message: "请输入手机号", icon: "warning-o" });
return false;
showToast({ message: '请输入手机号', icon: 'warning-o' })
return false
}
sending.value = true;
sending.value = true
try {
await sendSmsCode(phone);
await sendSmsCode(phone)
showToast({
message: "验证码已发送,请注意查收",
icon: "passed",
});
startCountDown();
return true;
message: '验证码已发送,请注意查收',
icon: 'passed',
})
startCountDown()
return true
} catch (error) {
showToast({
message: readError(error, "验证码发送失败,请稍后重试"),
icon: "cross",
});
return false;
message: readError(error, '验证码发送失败,请稍后重试'),
icon: 'cross',
})
return false
} finally {
sending.value = false;
sending.value = false
}
}
function readError(error: unknown, fallback: string) {
if (typeof error === "object" && error && "response" in error) {
const response = (error as { response?: { data?: { message?: string } } })
.response;
return response?.data?.message || fallback;
if (typeof error === 'object' && error && 'response' in error) {
const response = (error as { response?: { data?: { message?: string } } }).response
return response?.data?.message || fallback
}
return fallback;
return fallback
}
return {
@@ -65,5 +64,5 @@ export function useSmsCountdown() {
sending,
handleSendCode,
readError,
};
}
}