Pārlūkot izejas kodu

增加单独更新pdd cookie的action

dodo hold 1 gadu atpakaļ
vecāks
revīzija
e123ef5766
3 mainītis faili ar 119 papildinājumiem un 2 dzēšanām
  1. 3 1
      .gitignore
  2. 9 0
      src/api/pdd.ts
  3. 107 1
      src/views/pdd/list.vue

+ 3 - 1
.gitignore

@@ -8,4 +8,6 @@ node_modules
 dist
 dist-ssr
 *.local
-yarn-error.log
+yarn-error.log
+CLAUDE.md
+claude/*

+ 9 - 0
src/api/pdd.ts

@@ -21,10 +21,19 @@ export interface UpdateCookieModel {
     cookie: string;
 }
 
+export interface UpdateCookieWithIdModel {
+    id: number;
+    cookie: string;
+}
+
 export function updateCookies(data: UpdateCookieModel) {
     return axios.post<FormRes>('/api/PddUnion/updateCookies', data);
 }
 
+export function updateCookiesWithId(data: UpdateCookieWithIdModel) {
+    return axios.post<FormRes>('/api/PddUnion/updateCookies', data);
+}
+
 // list
 export interface PddPoolRecord {
     id: number;

+ 107 - 1
src/views/pdd/list.vue

@@ -181,6 +181,26 @@
                             优惠券
                         </a-tag>
                     </span>
+                    <span style="margin: 5px;">
+                        <a-tag v-if="record.enable_sync_revenue" size="small" bordered color="blue"
+                            @click="changeAttr(record.id, 'enable_sync_revenue', false)">
+                            同步收益
+                        </a-tag>
+                        <a-tag v-else size="small" bordered color=""
+                            @click="changeAttr(record.id, 'enable_sync_revenue', true)">
+                            同步收益
+                        </a-tag>
+                    </span>
+                    <span style="margin: 5px;">
+                        <a-tag v-if="record.enable_sync_order" size="small" bordered color="blue"
+                            @click="changeAttr(record.id, 'enable_sync_order', false)">
+                            同步订单
+                        </a-tag>
+                        <a-tag v-else size="small" bordered color=""
+                            @click="changeAttr(record.id, 'enable_sync_order', true)">
+                            同步订单
+                        </a-tag>
+                    </span>
                 </template>
                 <template #time="{ record }">
                     <div style="color:gray;">
@@ -190,6 +210,11 @@
                             登录:{{ dayjs(record.login_time).format('MM-DD HH:mm') }}</div>
                     </div>
                 </template>
+                <template #action="{ record }">
+                    <a-button type="text" size="small" @click="openCookieModal(record)">
+                        更新cookie
+                    </a-button>
+                </template>
                 <template #summary-cell="{ column, record }">
                     <div style="margin:10px auto" v-if="column.slotName == 'hourly_calls_limit'">
                         {{ numberFormat(record.current_hourly_calls) }}
@@ -240,6 +265,29 @@
 
             </a-table>
         </a-card>
+
+        <!-- Cookie 更新 Modal -->
+        <a-modal 
+            v-model:visible="cookieModalVisible" 
+            title="更新Cookie" 
+            @ok="handleCookieUpdate"
+            @cancel="handleCookieCancel"
+            :confirm-loading="cookieLoading"
+        >
+            <a-form ref="cookieFormRef" :model="cookieFormData">
+                <a-form-item 
+                    field="cookie" 
+                    label="Cookie" 
+                    :rules="[{ required: true, message: '请输入Cookie' }]"
+                >
+                    <a-textarea 
+                        v-model="cookieFormData.cookie" 
+                        placeholder="请粘贴Cookie内容"
+                        :auto-size="{ minRows: 10, maxRows: 20 }"
+                    />
+                </a-form-item>
+            </a-form>
+        </a-modal>
     </div>
 </template>
 
@@ -249,11 +297,12 @@ import { computed, ref, reactive, watch, nextTick } from 'vue';
 import { useI18n } from 'vue-i18n';
 import dayjs from 'dayjs';
 import useLoading from '@/hooks/loading';
-import { queryPddPool, PddPoolRecord, PddPoolParams, PddUpdateAccountModel, PddUpdateAccount } from '@/api/pdd';
+import { queryPddPool, PddPoolRecord, PddPoolParams, PddUpdateAccountModel, PddUpdateAccount, UpdateCookieWithIdModel, updateCookiesWithId } from '@/api/pdd';
 import { Pagination } from '@/types/global';
 import { Modal, Message } from '@arco-design/web-vue';
 import type { SelectOptionData } from '@arco-design/web-vue/es/select/interface';
 import type { TableColumnData } from '@arco-design/web-vue/es/table/interface';
+import { FormInstance } from '@arco-design/web-vue/es/form';
 import cloneDeep from 'lodash/cloneDeep';
 import Sortable from 'sortablejs';
 import { numberFormat, amountFormat } from '@/utils/util';
@@ -285,6 +334,16 @@ const showColumns = ref<Column[]>([]);
 
 const size = ref<SizeProps>('small');
 
+// Cookie modal related data
+const cookieModalVisible = ref(false);
+const cookieLoading = ref(false);
+const cookieFormRef = ref<FormInstance>();
+const cookieFormData = ref<UpdateCookieWithIdModel>({
+    id: 0,
+    cookie: '',
+});
+const currentRecord = ref<PddPoolRecord | null>(null);
+
 const basePagination: Pagination = {
     current: 1,
     pageSize: 500,
@@ -377,6 +436,11 @@ const columns = computed<TableColumnData[]>(() => [
         slotName: 'time',
         width: 170,
     },
+    {
+        title: '操作',
+        slotName: 'action',
+        width: 120,
+    },
 ]);
 
 const statusOptions = computed<SelectOptionData[]>(() => [
@@ -578,6 +642,48 @@ const popupVisibleChange = (val: boolean) => {
     }
 };
 
+// Cookie modal methods
+const openCookieModal = (record: PddPoolRecord) => {
+    currentRecord.value = record;
+    cookieFormData.value = {
+        id: record.id,
+        cookie: '',
+    };
+    cookieModalVisible.value = true;
+};
+
+const handleCookieUpdate = async () => {
+    const res = await cookieFormRef.value?.validate();
+    if (!res) {
+        cookieLoading.value = true;
+        try {
+            const { data } = await updateCookiesWithId(cookieFormData.value);
+            const msg = data.msg || '更新成功!';
+            if (data.success) {
+                Message.success(msg);
+                cookieModalVisible.value = false;
+                fetchData(); // 刷新列表
+            } else {
+                Message.error(data.msg);
+            }
+        } catch (err) {
+            console.error(err);
+            Message.error('更新失败');
+        } finally {
+            cookieLoading.value = false;
+        }
+    }
+};
+
+const handleCookieCancel = () => {
+    cookieModalVisible.value = false;
+    cookieFormData.value = {
+        id: 0,
+        cookie: '',
+    };
+    cookieFormRef.value?.resetFields();
+};
+
 watch(
     () => columns.value,
     (val) => {