价格来源:
@@ -159,7 +158,7 @@
-
+
编辑
@@ -637,16 +636,14 @@ const handleImport = () => {
const lines = importText.value.trim().split('\n')
const newRows = lines.map(line => {
- // 使用正则表达式匹配,考虑引号内的内容作为整体
- const matches = line.trim().match(/("[^"]+"|[^\s]+)/g)
- if (!matches || matches.length < 6) {
+ // 使用正则表达式匹配制表符或多个空格作为分隔符
+ const parts = line.trim().split(/\t+|\s{2,}/)
+ if (!parts || parts.length < 6) {
ElMessage.warning(`行格式不正确:${line}`)
return null
}
- const [model, billingType, providerNameRaw, currency, inputPrice, outputPrice] = matches
- // 去除可能存在的引号
- const providerName = providerNameRaw.replace(/^"|"$/g, '')
+ const [model, billingType, providerName, currency, inputPrice, outputPrice] = parts
// 查找模型厂商ID
const provider = providers.value.find(p => p.name === providerName)
@@ -672,7 +669,7 @@ const handleImport = () => {
}
return {
- model: model.replace(/^"|"$/g, ''),
+ model,
billing_type,
channel_type: provider.id.toString(),
currency: currencyCode,