Edan233 commited on
Commit
c00a054
·
1 Parent(s): 9495981

fix: 增加前端小红书逻辑

Browse files
sau_frontend/src/api/account.js CHANGED
@@ -13,8 +13,8 @@ export const accountApi = {
13
  },
14
 
15
  // 更新账号
16
- updateAccount(id, data) {
17
- return http.put(`/account/${id}`, data)
18
  },
19
 
20
  // 删除账号
 
13
  },
14
 
15
  // 更新账号
16
+ updateAccount(data) {
17
+ return http.post('/updateUserinfo', data)
18
  },
19
 
20
  // 删除账号
sau_frontend/src/views/AccountManagement.vue CHANGED
@@ -338,7 +338,7 @@
338
  v-model="accountForm.platform"
339
  placeholder="请选择平台"
340
  style="width: 100%"
341
- :disabled="sseConnecting"
342
  >
343
  <el-option label="快手" value="快手" />
344
  <el-option label="抖音" value="抖音" />
@@ -376,7 +376,7 @@
376
  </el-form>
377
  <template #footer>
378
  <span class="dialog-footer">
379
- <el-button @click="dialogVisible = false" :disabled="sseConnecting && !loginStatus">取消</el-button>
380
  <el-button
381
  type="primary"
382
  @click="submitAccountForm"
@@ -630,42 +630,31 @@ const connectSSE = (platform, name) => {
630
  else if (data === '200' || data === '500') {
631
  loginStatus.value = data
632
 
633
- // 如果登录成功,添加账号到状态管理
634
  if (data === '200') {
635
  setTimeout(() => {
636
- const newId = accountStore.accounts.length > 0 ?
637
- Math.max(...accountStore.accounts.map(a => a.id)) + 1 : 1
638
-
639
- const newAccount = {
640
- id: newId,
641
- name: accountForm.name,
642
- platform: accountForm.platform,
643
- status: '正常',
644
- avatar: '/vite.svg' // 默认头像
645
- }
646
-
647
- // 添加到状态管理
648
- accountStore.addAccount(newAccount)
649
-
650
  // 关闭连接
651
  closeSSEConnection()
652
 
653
- // 1秒后关闭对话框
654
  setTimeout(() => {
655
  dialogVisible.value = false
656
  sseConnecting.value = false
657
  ElMessage.success('账号添加成功')
658
 
659
- // 显示更新账号信息提示并刷新账号列表
660
  ElMessage({
661
  type: 'info',
662
- message: '更新账号信息中...',
663
- duration: 2000
664
  })
665
 
666
  // 触发刷新操作
667
- isRefreshing.value = true
668
- fetchAccounts()
 
 
 
669
  }, 1000)
670
  }, 1000)
671
  } else {
@@ -699,12 +688,23 @@ const submitAccountForm = () => {
699
  // 建立SSE连接
700
  connectSSE(accountForm.platform, accountForm.name)
701
  } else {
702
- // 编辑账号逻辑保持不变
703
  try {
704
- // 更新状态管理中的账号
705
- accountStore.updateAccount(accountForm.id, accountForm)
706
- ElMessage.success('更新成功')
707
- dialogVisible.value = false
 
 
 
 
 
 
 
 
 
 
 
708
  } catch (error) {
709
  console.error('更新账号失败:', error)
710
  ElMessage.error('更新账号失败')
@@ -805,6 +805,7 @@ onBeforeUnmount(() => {
805
  max-width: 200px;
806
  max-height: 200px;
807
  border: 1px solid #ebeef5;
 
808
  }
809
  }
810
 
 
338
  v-model="accountForm.platform"
339
  placeholder="请选择平台"
340
  style="width: 100%"
341
+ :disabled="dialogType === 'edit' || sseConnecting"
342
  >
343
  <el-option label="快手" value="快手" />
344
  <el-option label="抖音" value="抖音" />
 
376
  </el-form>
377
  <template #footer>
378
  <span class="dialog-footer">
379
+ <el-button @click="dialogVisible = false">取消</el-button>
380
  <el-button
381
  type="primary"
382
  @click="submitAccountForm"
 
630
  else if (data === '200' || data === '500') {
631
  loginStatus.value = data
632
 
633
+ // 如果登录成功
634
  if (data === '200') {
635
  setTimeout(() => {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
636
  // 关闭连接
637
  closeSSEConnection()
638
 
639
+ // 1秒后关闭对话框并开始刷新
640
  setTimeout(() => {
641
  dialogVisible.value = false
642
  sseConnecting.value = false
643
  ElMessage.success('账号添加成功')
644
 
645
+ // 显示更新账号信息提示
646
  ElMessage({
647
  type: 'info',
648
+ message: '正在同步账号信息...',
649
+ duration: 0
650
  })
651
 
652
  // 触发刷新操作
653
+ fetchAccounts().then(() => {
654
+ // 刷新完成后关闭提示
655
+ ElMessage.closeAll()
656
+ ElMessage.success('账号信息已更新')
657
+ })
658
  }, 1000)
659
  }, 1000)
660
  } else {
 
688
  // 建立SSE连接
689
  connectSSE(accountForm.platform, accountForm.name)
690
  } else {
691
+ // 编辑账号逻辑
692
  try {
693
+ const res = await accountApi.updateAccount({
694
+ id: accountForm.id,
695
+ type: Number(accountForm.platform === '快手' ? 1 : accountForm.platform === '抖音' ? 2 : accountForm.platform === '视频号' ? 3 : 4),
696
+ userName: accountForm.name
697
+ })
698
+ if (res.code === 200) {
699
+ // 更新状态管理中的账号
700
+ accountStore.updateAccount(accountForm.id, accountForm)
701
+ ElMessage.success('更新成功')
702
+ dialogVisible.value = false
703
+ // 刷新账号列表
704
+ fetchAccounts()
705
+ } else {
706
+ ElMessage.error(res.msg || '更新账号失败')
707
+ }
708
  } catch (error) {
709
  console.error('更新账号失败:', error)
710
  ElMessage.error('更新账号失败')
 
805
  max-width: 200px;
806
  max-height: 200px;
807
  border: 1px solid #ebeef5;
808
+ background-color: black;
809
  }
810
  }
811
 
sau_frontend/src/views/PublishCenter.vue CHANGED
@@ -43,16 +43,6 @@
43
  </div>
44
  </div>
45
 
46
- <!-- 批量发布状态提示 -->
47
- <div v-if="batchPublishMessage" class="batch-publish-status">
48
- <el-alert
49
- :title="batchPublishMessage"
50
- :type="batchPublishType"
51
- :closable="false"
52
- show-icon
53
- />
54
- </div>
55
-
56
  <!-- 内容区域 -->
57
  <div class="publish-content">
58
  <div class="tab-content-wrapper">
@@ -62,6 +52,16 @@
62
  v-show="activeTab === tab.name"
63
  class="tab-content"
64
  >
 
 
 
 
 
 
 
 
 
 
65
  <!-- 视频上传区域 -->
66
  <div class="upload-section">
67
  <h3>视频</h3>
@@ -134,6 +134,59 @@
134
  </el-upload>
135
  </el-dialog>
136
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
137
  <!-- 素材库选择弹窗 -->
138
  <el-dialog
139
  v-model="materialLibraryVisible"
@@ -431,10 +484,10 @@ const batchPublishType = ref('info')
431
 
432
  // 平台列表 - 对应后端type字段
433
  const platforms = [
434
- { key: 1, name: '抖音' },
435
  { key: 4, name: '快手' },
436
  { key: 2, name: '视频号' },
437
- { key: 3, name: '小红书' }
438
  ]
439
 
440
  // tab页数据 - 默认只有一个tab
@@ -451,7 +504,8 @@ const tabs = reactive([
451
  scheduleEnabled: false, // 定时发布开关
452
  videosPerDay: 1, // 每天发布视频数量
453
  dailyTimes: ['10:00'], // 每天发布时间点列表
454
- startDays: 0 // 从今天开始计算的发布天数,0表示明天,1表示后天
 
455
  }
456
  ])
457
 
@@ -466,9 +520,9 @@ const accountStore = useAccountStore()
466
  // 根据选择的平台获取可用账号列表
467
  const availableAccounts = computed(() => {
468
  const platformMap = {
469
- 1: '抖音',
470
  2: '视频号',
471
- 3: '小红书',
472
  4: '快手'
473
  }
474
  const currentPlatform = currentTab.value ? platformMap[currentTab.value.selectedPlatform] : null
@@ -501,7 +555,8 @@ const addTab = () => {
501
  scheduleEnabled: false,
502
  videosPerDay: 1,
503
  dailyTimes: ['10:00'],
504
- startDays: 0
 
505
  }
506
  tabs.push(newTab)
507
  activeTab.value = newTab.name
@@ -654,68 +709,87 @@ const cancelPublish = (tab) => {
654
  }
655
 
656
  // 确认发布
657
- const confirmPublish = (tab) => {
658
- // 数据验证
659
- if (tab.fileList.length === 0) {
660
- ElMessage.warning('请先上传视频文件')
661
- return
662
- }
663
- if (!tab.title.trim()) {
664
- ElMessage.warning('请输入标题')
665
- return
666
- }
667
- if (!tab.selectedPlatform) {
668
- ElMessage.warning('请选择发布平台')
669
- return
670
- }
671
- if (tab.selectedAccounts.length === 0) {
672
- ElMessage.warning('请选择发布账号')
673
- return
674
- }
675
-
676
- // 构造发布数据,符合后端API格式
677
- const publishData = {
678
- type: tab.selectedPlatform,
679
- title: tab.title,
680
- tags: tab.selectedTopics, // 不带#号的话题列表
681
- fileList: tab.fileList.map(file => file.path), // 只发送文件路径
682
- accountList: tab.selectedAccounts.map(accountId => {
683
- const account = accountStore.accounts.find(acc => acc.id === accountId)
684
- return account ? account.filePath : accountId
685
- }), // 发送账号的文件路径
686
- category: tab.scheduleEnabled ? 1 : 0, // 是否启用定时发布,开启传1,不开启传0
687
- videosPerDay: tab.scheduleEnabled ? tab.videosPerDay || 1 : 1, // 每天发布视频数量,1-55
688
- dailyTimes: tab.scheduleEnabled ? tab.dailyTimes || ['10:00'] : ['10:00'], // 每天发布时间点
689
- startDays: tab.scheduleEnabled ? tab.startDays || 0 : 0, // 从今天开始计算的发布天数,0表示明天,1表示后天
690
- }
691
-
692
- // 调用后端发布API
693
- fetch(`${apiBaseUrl}/postVideo`, {
694
- method: 'POST',
695
- headers: {
696
- 'Content-Type': 'application/json',
697
- ...authHeaders.value
698
- },
699
- body: JSON.stringify(publishData)
700
- })
701
- .then(response => response.json())
702
- .then(data => {
703
- if (data.code === 200) {
704
- ElMessage.success('发布成功')
705
- // 清空当前tab的数据
706
- tab.fileList = []
707
- tab.displayFileList = []
708
- tab.title = ''
709
- tab.selectedTopics = []
710
- tab.selectedAccounts = []
711
- tab.scheduleEnabled = false
712
- } else {
713
- ElMessage.error(data.msg || '发布失败')
714
  }
715
- })
716
- .catch(error => {
717
- console.error('发布错误:', error)
718
- ElMessage.error('发布失败,请检查网络连接')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
719
  })
720
  }
721
 
@@ -798,92 +872,86 @@ const confirmMaterialSelection = () => {
798
  ElMessage.success(`已添加 ${addedCount} 个素材`)
799
  }
800
 
 
 
 
 
 
 
 
 
 
 
 
 
 
801
  // 批量发布方法
802
  const batchPublish = async () => {
803
  if (batchPublishing.value) return
804
 
805
  batchPublishing.value = true
806
- batchPublishMessage.value = '开始批量发布...'
807
- batchPublishType.value = 'info'
 
 
 
808
 
809
  try {
810
  for (let i = 0; i < tabs.length; i++) {
811
- const tab = tabs[i]
812
- batchPublishMessage.value = `正在发布第 ${i + 1} 个Tab: ${tab.label}`
813
-
814
- // 数据验证
815
- if (tab.fileList.length === 0) {
816
- batchPublishMessage.value = `Tab "${tab.label}" 发布失败:请先上传视频文件`
817
- batchPublishType.value = 'error'
818
- break
819
- }
820
- if (!tab.title.trim()) {
821
- batchPublishMessage.value = `Tab "${tab.label}" 发布失败:请输入标题`
822
- batchPublishType.value = 'error'
823
- break
824
- }
825
- if (!tab.selectedPlatform) {
826
- batchPublishMessage.value = `Tab "${tab.label}" 发布失败:请选择发布平台`
827
- batchPublishType.value = 'error'
828
- break
829
- }
830
- if (tab.selectedAccounts.length === 0) {
831
- batchPublishMessage.value = `Tab "${tab.label}" 发布失败:请选择发布账号`
832
- batchPublishType.value = 'error'
833
- break
834
- }
835
-
836
- // 构造发布数据
837
- const publishData = {
838
- type: tab.selectedPlatform,
839
- title: tab.title,
840
- tags: tab.selectedTopics,
841
- fileList: tab.fileList.map(file => file.path),
842
- accounts: tab.selectedAccounts,
843
- scheduleEnabled: tab.scheduleEnabled,
844
- videosPerDay: tab.videosPerDay,
845
- dailyTimes: tab.dailyTimes,
846
- startDays: tab.startDays
847
  }
 
 
 
 
848
 
849
  try {
850
- // 这里应该调用实际的发布API
851
- // const response = await publishApi.publish(publishData)
852
- // 模拟API调用
853
- await new Promise(resolve => setTimeout(resolve, 1000))
854
-
855
- // 模拟随机失败(用于测试)
856
- if (Math.random() < 0.1) {
857
- throw new Error('网络错误')
858
- }
859
-
860
- batchPublishMessage.value = `Tab "${tab.label}" 发布成功`
861
- batchPublishType.value = 'success'
862
-
863
  } catch (error) {
864
- console.error('发布失败:', error)
865
- batchPublishMessage.value = `Tab "${tab.label}" 发布失败:${error.message || '网络错误'}`
866
- batchPublishType.value = 'error'
867
- break
 
 
868
  }
869
  }
870
 
871
- if (batchPublishType.value === 'success') {
872
- batchPublishMessage.value = '所有Tab发布完成!'
873
- ElMessage.success('批量发布完成')
 
 
 
 
 
 
 
 
 
 
 
 
 
874
  }
875
 
876
  } catch (error) {
877
  console.error('批量发布出错:', error)
878
- batchPublishMessage.value = '批量发布出错,请重试'
879
- batchPublishType.value = 'error'
880
  } finally {
881
  batchPublishing.value = false
882
-
883
- // 5秒后自动清除消息
884
- setTimeout(() => {
885
- batchPublishMessage.value = ''
886
- }, 5000)
887
  }
888
  }
889
  </script>
@@ -981,13 +1049,59 @@ const batchPublish = async () => {
981
  }
982
  }
983
 
984
- // 批量发布状态提示区域
985
- .batch-publish-status {
986
- margin: 10px 20px;
987
 
988
- .el-alert {
989
- border-radius: 6px;
 
 
990
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
991
  }
992
 
993
  // 内容区域
 
43
  </div>
44
  </div>
45
 
 
 
 
 
 
 
 
 
 
 
46
  <!-- 内容区域 -->
47
  <div class="publish-content">
48
  <div class="tab-content-wrapper">
 
52
  v-show="activeTab === tab.name"
53
  class="tab-content"
54
  >
55
+ <!-- 发布状态提示 -->
56
+ <div v-if="tab.publishStatus" class="publish-status">
57
+ <el-alert
58
+ :title="tab.publishStatus.message"
59
+ :type="tab.publishStatus.type"
60
+ :closable="false"
61
+ show-icon
62
+ />
63
+ </div>
64
+
65
  <!-- 视频上传区域 -->
66
  <div class="upload-section">
67
  <h3>视频</h3>
 
134
  </el-upload>
135
  </el-dialog>
136
 
137
+ <!-- 批量发布进度对话框 -->
138
+ <el-dialog
139
+ v-model="batchPublishDialogVisible"
140
+ title="批量发布进度"
141
+ width="500px"
142
+ :close-on-click-modal="false"
143
+ :close-on-press-escape="false"
144
+ :show-close="false"
145
+ >
146
+ <div class="publish-progress">
147
+ <el-progress
148
+ :percentage="publishProgress"
149
+ :status="publishProgress === 100 ? 'success' : ''"
150
+ />
151
+ <div v-if="currentPublishingTab" class="current-publishing">
152
+ 正在发布:{{ currentPublishingTab.label }}
153
+ </div>
154
+
155
+ <!-- 发布结果列表 -->
156
+ <div class="publish-results" v-if="publishResults.length > 0">
157
+ <div
158
+ v-for="(result, index) in publishResults"
159
+ :key="index"
160
+ :class="['result-item', result.status]"
161
+ >
162
+ <el-icon v-if="result.status === 'success'"><Check /></el-icon>
163
+ <el-icon v-else-if="result.status === 'error'"><Close /></el-icon>
164
+ <el-icon v-else><InfoFilled /></el-icon>
165
+ <span class="label">{{ result.label }}</span>
166
+ <span class="message">{{ result.message }}</span>
167
+ </div>
168
+ </div>
169
+ </div>
170
+
171
+ <template #footer>
172
+ <div class="dialog-footer">
173
+ <el-button
174
+ @click="cancelBatchPublish"
175
+ :disabled="publishProgress === 100"
176
+ >
177
+ 取消发布
178
+ </el-button>
179
+ <el-button
180
+ type="primary"
181
+ @click="batchPublishDialogVisible = false"
182
+ v-if="publishProgress === 100"
183
+ >
184
+ 关闭
185
+ </el-button>
186
+ </div>
187
+ </template>
188
+ </el-dialog>
189
+
190
  <!-- 素材库选择弹窗 -->
191
  <el-dialog
192
  v-model="materialLibraryVisible"
 
484
 
485
  // 平台列表 - 对应后端type字段
486
  const platforms = [
487
+ { key: 3, name: '抖音' },
488
  { key: 4, name: '快手' },
489
  { key: 2, name: '视频号' },
490
+ { key: 1, name: '小红书' }
491
  ]
492
 
493
  // tab页数据 - 默认只有一个tab
 
504
  scheduleEnabled: false, // 定时发布开关
505
  videosPerDay: 1, // 每天发布视频数量
506
  dailyTimes: ['10:00'], // 每天发布时间点列表
507
+ startDays: 0, // 从今天开始计算的发布天数,0表示明天,1表示后天
508
+ publishStatus: null // 发布状态,包含message和type
509
  }
510
  ])
511
 
 
520
  // 根据选择的平台获取可用账号列表
521
  const availableAccounts = computed(() => {
522
  const platformMap = {
523
+ 3: '抖音',
524
  2: '视频号',
525
+ 1: '小红书',
526
  4: '快手'
527
  }
528
  const currentPlatform = currentTab.value ? platformMap[currentTab.value.selectedPlatform] : null
 
555
  scheduleEnabled: false,
556
  videosPerDay: 1,
557
  dailyTimes: ['10:00'],
558
+ startDays: 0,
559
+ publishStatus: null
560
  }
561
  tabs.push(newTab)
562
  activeTab.value = newTab.name
 
709
  }
710
 
711
  // 确认发布
712
+ const confirmPublish = async (tab) => {
713
+ return new Promise((resolve, reject) => {
714
+ // 数据验证
715
+ if (tab.fileList.length === 0) {
716
+ ElMessage.error('请先上传视频文件')
717
+ reject(new Error('请先上传视频文件'))
718
+ return
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
719
  }
720
+ if (!tab.title.trim()) {
721
+ ElMessage.error('请输入标题')
722
+ reject(new Error('请输入标题'))
723
+ return
724
+ }
725
+ if (!tab.selectedPlatform) {
726
+ ElMessage.error('请选择发布平台')
727
+ reject(new Error('请选择发布平台'))
728
+ return
729
+ }
730
+ if (tab.selectedAccounts.length === 0) {
731
+ ElMessage.error('请选择发布账号')
732
+ reject(new Error('请选择发布账号'))
733
+ return
734
+ }
735
+
736
+ // 构造发布数据,符合后端API格式
737
+ const publishData = {
738
+ type: tab.selectedPlatform,
739
+ title: tab.title,
740
+ tags: tab.selectedTopics, // 不带#号的话题列表
741
+ fileList: tab.fileList.map(file => file.path), // 只发送文件路径
742
+ accountList: tab.selectedAccounts.map(accountId => {
743
+ const account = accountStore.accounts.find(acc => acc.id === accountId)
744
+ return account ? account.filePath : accountId
745
+ }), // 发送账号的文件路径
746
+ enableTimer: tab.scheduleEnabled ? 1 : 0, // 是否启用定时发布,开启传1,不开启传0
747
+ videosPerDay: tab.scheduleEnabled ? tab.videosPerDay || 1 : 1, // 每天发布视频数量,1-55
748
+ dailyTimes: tab.scheduleEnabled ? tab.dailyTimes || ['10:00'] : ['10:00'], // 每天发布时间点
749
+ startDays: tab.scheduleEnabled ? tab.startDays || 0 : 0, // 从今天开始计算的发布天数,0表示明天,1表示后天
750
+ category: 0 //表示非原创
751
+ }
752
+
753
+ // 调用后端发布API
754
+ fetch(`${apiBaseUrl}/postVideo`, {
755
+ method: 'POST',
756
+ headers: {
757
+ 'Content-Type': 'application/json',
758
+ ...authHeaders.value
759
+ },
760
+ body: JSON.stringify(publishData)
761
+ })
762
+ .then(response => response.json())
763
+ .then(data => {
764
+ if (data.code === 200) {
765
+ tab.publishStatus = {
766
+ message: '发布成功',
767
+ type: 'success'
768
+ }
769
+ // 清空当前tab的数据
770
+ tab.fileList = []
771
+ tab.displayFileList = []
772
+ tab.title = ''
773
+ tab.selectedTopics = []
774
+ tab.selectedAccounts = []
775
+ tab.scheduleEnabled = false
776
+ resolve()
777
+ } else {
778
+ tab.publishStatus = {
779
+ message: `发布失败:${data.msg || '发布失败'}`,
780
+ type: 'error'
781
+ }
782
+ reject(new Error(data.msg || '发布失败'))
783
+ }
784
+ })
785
+ .catch(error => {
786
+ console.error('发布错误:', error)
787
+ tab.publishStatus = {
788
+ message: '发布失败,请检查网络连接',
789
+ type: 'error'
790
+ }
791
+ reject(error)
792
+ })
793
  })
794
  }
795
 
 
872
  ElMessage.success(`已添加 ${addedCount} 个素材`)
873
  }
874
 
875
+ // 批量发布对话框状态
876
+ const batchPublishDialogVisible = ref(false)
877
+ const currentPublishingTab = ref(null)
878
+ const publishProgress = ref(0)
879
+ const publishResults = ref([])
880
+ const isCancelled = ref(false)
881
+
882
+ // 取消批量发布
883
+ const cancelBatchPublish = () => {
884
+ isCancelled.value = true
885
+ ElMessage.info('正在取消发布...')
886
+ }
887
+
888
  // 批量发布方法
889
  const batchPublish = async () => {
890
  if (batchPublishing.value) return
891
 
892
  batchPublishing.value = true
893
+ currentPublishingTab.value = null
894
+ publishProgress.value = 0
895
+ publishResults.value = []
896
+ isCancelled.value = false
897
+ batchPublishDialogVisible.value = true
898
 
899
  try {
900
  for (let i = 0; i < tabs.length; i++) {
901
+ if (isCancelled.value) {
902
+ publishResults.value.push({
903
+ label: tabs[i].label,
904
+ status: 'cancelled',
905
+ message: '已取消'
906
+ })
907
+ continue
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
908
  }
909
+
910
+ const tab = tabs[i]
911
+ currentPublishingTab.value = tab
912
+ publishProgress.value = Math.floor((i / tabs.length) * 100)
913
 
914
  try {
915
+ await confirmPublish(tab)
916
+ publishResults.value.push({
917
+ label: tab.label,
918
+ status: 'success',
919
+ message: '发布成功'
920
+ })
 
 
 
 
 
 
 
921
  } catch (error) {
922
+ publishResults.value.push({
923
+ label: tab.label,
924
+ status: 'error',
925
+ message: error.message
926
+ })
927
+ // 不立即返回,继续显示发布结果
928
  }
929
  }
930
 
931
+ publishProgress.value = 100
932
+
933
+ // 统计发布结果
934
+ const successCount = publishResults.value.filter(r => r.status === 'success').length
935
+ const failCount = publishResults.value.filter(r => r.status === 'error').length
936
+ const cancelCount = publishResults.value.filter(r => r.status === 'cancelled').length
937
+
938
+ if (isCancelled.value) {
939
+ ElMessage.warning(`发布已取消:${successCount}个成功,${failCount}个失败,${cancelCount}个未执行`)
940
+ } else if (failCount > 0) {
941
+ ElMessage.error(`发布完成:${successCount}个成功,${failCount}个失败`)
942
+ } else {
943
+ ElMessage.success('所有Tab发布成功')
944
+ setTimeout(() => {
945
+ batchPublishDialogVisible.value = false
946
+ }, 1000)
947
  }
948
 
949
  } catch (error) {
950
  console.error('批量发布出错:', error)
951
+ ElMessage.error('批量发布出错,请重试')
 
952
  } finally {
953
  batchPublishing.value = false
954
+ isCancelled.value = false
 
 
 
 
955
  }
956
  }
957
  </script>
 
1049
  }
1050
  }
1051
 
1052
+ // 批量发布进度对话框样式
1053
+ .publish-progress {
1054
+ padding: 20px;
1055
 
1056
+ .current-publishing {
1057
+ margin: 15px 0;
1058
+ text-align: center;
1059
+ color: #606266;
1060
  }
1061
+
1062
+ .publish-results {
1063
+ margin-top: 20px;
1064
+ border-top: 1px solid #EBEEF5;
1065
+ padding-top: 15px;
1066
+ max-height: 300px;
1067
+ overflow-y: auto;
1068
+
1069
+ .result-item {
1070
+ display: flex;
1071
+ align-items: center;
1072
+ padding: 8px 0;
1073
+ color: #606266;
1074
+
1075
+ .el-icon {
1076
+ margin-right: 8px;
1077
+ }
1078
+
1079
+ .label {
1080
+ margin-right: 10px;
1081
+ font-weight: 500;
1082
+ }
1083
+
1084
+ .message {
1085
+ color: #909399;
1086
+ }
1087
+
1088
+ &.success {
1089
+ color: #67C23A;
1090
+ }
1091
+
1092
+ &.error {
1093
+ color: #F56C6C;
1094
+ }
1095
+
1096
+ &.cancelled {
1097
+ color: #909399;
1098
+ }
1099
+ }
1100
+ }
1101
+ }
1102
+
1103
+ .dialog-footer {
1104
+ text-align: right;
1105
  }
1106
 
1107
  // 内容区域