feat(jd-order): 优化Cookie批量导入功能
- 修改输入格式为每行一个Cookie - 添加账户前缀和统一备注设置 - 调整文本框最小和最大行数 - 更新输入提示和标签文本 - 修改数据解析逻辑以适应新格式 - 强制要求输入账户前缀 - 清理表单重置逻辑 - 更新相关图标引入 - 调整样式以适应新表单元素
This commit is contained in:
@@ -111,7 +111,9 @@ The project uses a dual API approach:
|
|||||||
API clients are configured in `src/api/index.ts`:
|
API clients are configured in `src/api/index.ts`:
|
||||||
|
|
||||||
- `apiClient` - DefaultApi for main backend operations
|
- `apiClient` - DefaultApi for main backend operations
|
||||||
- `apiCkClient` - CkApi for CK-related operations
|
- `jdCookieClient` - JDCookieManagementApi for JD cookie management
|
||||||
|
- `jdHistoryClient` - JDHistoryApi for JD order history
|
||||||
|
- `jdOrderClient` - JDOrderManagementApi for JD order management
|
||||||
|
|
||||||
API base URL is configured via environment variables:
|
API base URL is configured via environment variables:
|
||||||
|
|
||||||
@@ -187,7 +189,7 @@ Development settings in `.env.development`, production in `.env.production`
|
|||||||
|
|
||||||
**Note**: All linting tools are configured to run automatically via lint-staged on pre-commit hooks.
|
**Note**: All linting tools are configured to run automatically via lint-staged on pre-commit hooks.
|
||||||
|
|
||||||
## Common Patterns
|
## Development Patterns
|
||||||
|
|
||||||
### API Calls
|
### API Calls
|
||||||
|
|
||||||
|
|||||||
@@ -65,16 +65,17 @@
|
|||||||
输入数据
|
输入数据
|
||||||
</h3>
|
</h3>
|
||||||
<div class="input-tips">
|
<div class="input-tips">
|
||||||
<a-tag size="small" color="blue">格式:Cookie 账号 备注</a-tag>
|
<a-tag size="small" color="blue">格式:每行一个Cookie</a-tag>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Cookie批量输入 -->
|
||||||
<a-textarea
|
<a-textarea
|
||||||
v-model="formModel.cookieData"
|
v-model="formModel.cookieData"
|
||||||
placeholder="请输入Cookie数据,每行一个 格式:Cookie值 账号名称 备注信息 示例: pt_key=AAJo8JBBADCehYF-0KP6YtweybQUPaGlc16tyfEAS7JIh81ncH9J4Fz8hckodXgnrGKk4YCxV64;pt_pin=jd_UGRblnTjugEH; 账号1 测试账号1 pt_key=xxx;pt_pin=yyy; 账号2 测试账号2"
|
placeholder="请输入Cookie数据,每行一个 示例: pt_key=AAJo8JBBADCehYF-0KP6YtweybQUPaGlc16tyfEAS7JIh81ncH9J4Fz8hckodXgnrGKk4YCxV64;pt_pin=jd_UGRblnTjugEH; pt_key=xxx;pt_pin=yyy;"
|
||||||
:auto-size="{
|
:auto-size="{
|
||||||
minRows: isFullscreen ? 20 : 8,
|
minRows: isFullscreen ? 15 : 6,
|
||||||
maxRows: isFullscreen ? 30 : 15
|
maxRows: isFullscreen ? 25 : 12
|
||||||
}"
|
}"
|
||||||
class="batch-textarea"
|
class="batch-textarea"
|
||||||
@input="handleInputChange"
|
@input="handleInputChange"
|
||||||
@@ -82,8 +83,36 @@
|
|||||||
@keyup="handleInputChange"
|
@keyup="handleInputChange"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<!-- 账户前缀设置 -->
|
||||||
|
<div class="form-item">
|
||||||
|
<div class="form-label">
|
||||||
|
<icon-user />
|
||||||
|
账户前缀
|
||||||
|
</div>
|
||||||
|
<a-input
|
||||||
|
v-model="formModel.accountPrefix"
|
||||||
|
placeholder="请输入账户前缀,如:京东账号"
|
||||||
|
class="form-input"
|
||||||
|
@input="handleInputChange"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 统一备注设置 -->
|
||||||
|
<div class="form-item">
|
||||||
|
<div class="form-label">
|
||||||
|
<icon-message />
|
||||||
|
统一备注
|
||||||
|
</div>
|
||||||
|
<a-input
|
||||||
|
v-model="formModel.unifiedRemark"
|
||||||
|
placeholder="请输入统一备注(可选)"
|
||||||
|
class="form-input"
|
||||||
|
@input="handleInputChange"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="input-stats">
|
<div class="input-stats">
|
||||||
<span>行数:{{ lineCount }}</span>
|
<span>Cookie数量:{{ lineCount }}</span>
|
||||||
<span>有效数据:{{ parsedData.length }}</span>
|
<span>有效数据:{{ parsedData.length }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -196,7 +225,10 @@ import {
|
|||||||
IconEye,
|
IconEye,
|
||||||
IconImport,
|
IconImport,
|
||||||
IconClose,
|
IconClose,
|
||||||
IconEdit
|
IconEdit,
|
||||||
|
IconUser,
|
||||||
|
IconMessage,
|
||||||
|
IconFile
|
||||||
} from '@arco-design/web-vue/es/icon';
|
} from '@arco-design/web-vue/es/icon';
|
||||||
import { jdCookieClient } from '@/api';
|
import { jdCookieClient } from '@/api';
|
||||||
|
|
||||||
@@ -225,7 +257,9 @@ const isFullscreen = ref(false);
|
|||||||
|
|
||||||
// 表单数据
|
// 表单数据
|
||||||
const formModel = reactive({
|
const formModel = reactive({
|
||||||
cookieData: ''
|
cookieData: '',
|
||||||
|
accountPrefix: '',
|
||||||
|
unifiedRemark: ''
|
||||||
});
|
});
|
||||||
|
|
||||||
// 解析后的数据
|
// 解析后的数据
|
||||||
@@ -247,31 +281,24 @@ const parseCookieData = (): void => {
|
|||||||
.filter(line => line.trim());
|
.filter(line => line.trim());
|
||||||
|
|
||||||
const parsed: ParsedCookieItem[] = lines.map((line, index) => {
|
const parsed: ParsedCookieItem[] = lines.map((line, index) => {
|
||||||
// 使用单个空格作为分隔符
|
// 提取Cookie值(整行作为Cookie)
|
||||||
let parts = line
|
let cookieValue = line.trim();
|
||||||
.split(' ')
|
|
||||||
.map(part => part.trim())
|
|
||||||
.filter(part => part);
|
|
||||||
|
|
||||||
let cookieValue = '';
|
|
||||||
let accountName = '';
|
let accountName = '';
|
||||||
let remark = '';
|
let remark = '';
|
||||||
let isValid = false;
|
let isValid = false;
|
||||||
|
|
||||||
if (parts.length === 1) {
|
// 生成账户名称:前缀 + 数字序号
|
||||||
// 只有一部分,整个作为Cookie值
|
if (formModel.accountPrefix.trim()) {
|
||||||
cookieValue = parts[0];
|
accountName = `${formModel.accountPrefix.trim()}${index + 1}`;
|
||||||
|
} else {
|
||||||
accountName = `账号${index + 1}`;
|
accountName = `账号${index + 1}`;
|
||||||
remark = '';
|
|
||||||
} else if (parts.length >= 2) {
|
|
||||||
// 多个部分,第一部分是Cookie,第二部分是账号,第三部分是备注
|
|
||||||
cookieValue = parts[0];
|
|
||||||
accountName = parts[1] || `账号${index + 1}`;
|
|
||||||
remark = parts[2] || '';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 验证Cookie格式 - 只要包含pt_key=就认为是有效的
|
// 使用统一备注
|
||||||
isValid = cookieValue.includes('pt_key=');
|
remark = formModel.unifiedRemark.trim() || '';
|
||||||
|
|
||||||
|
// 所有输入的Cookie都认为是有效的
|
||||||
|
isValid = true;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
cookieValue,
|
cookieValue,
|
||||||
@@ -301,6 +328,8 @@ const toggleFullscreen = (): void => {
|
|||||||
const handleCancel = (): void => {
|
const handleCancel = (): void => {
|
||||||
emit('update:visible', false);
|
emit('update:visible', false);
|
||||||
formModel.cookieData = '';
|
formModel.cookieData = '';
|
||||||
|
formModel.accountPrefix = '';
|
||||||
|
formModel.unifiedRemark = '';
|
||||||
parsedData.value = [];
|
parsedData.value = [];
|
||||||
isFullscreen.value = false;
|
isFullscreen.value = false;
|
||||||
};
|
};
|
||||||
@@ -311,6 +340,11 @@ const handleSubmit = async (): Promise<boolean> => {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!formModel.accountPrefix.trim()) {
|
||||||
|
Message.warning('请输入账户前缀');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// 重新解析数据
|
// 重新解析数据
|
||||||
parseCookieData();
|
parseCookieData();
|
||||||
|
|
||||||
@@ -525,6 +559,28 @@ const handleSubmit = async (): Promise<boolean> => {
|
|||||||
border-color: rgb(var(--primary-6));
|
border-color: rgb(var(--primary-6));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.form-item {
|
||||||
|
margin-top: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-label {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 500;
|
||||||
|
color: var(--color-text-2);
|
||||||
|
margin-bottom: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-input {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cookie-input-item {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.input-stats {
|
.input-stats {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
|
|||||||
Reference in New Issue
Block a user