Просмотр исходного кода

feat(web-admin): open feedback/suggestion attachments via auth proxy

Replace direct MinIO links with JWT blob download so private objects
are not anonymously readable.

Co-authored-by: Cursor <cursoragent@cursor.com>
wuzilong 2 месяцев назад
Родитель
Сommit
7a760545e8

+ 15 - 0
web-admin/src/api/admin.ts

@@ -1,3 +1,4 @@
+import axios from 'axios'
 import http from '@/utils/http'
 
 export function fetchDashboard() {
@@ -56,6 +57,20 @@ export function uploadAdminFile(file: File, folder = 'admin') {
   })
 }
 
+/** 经 JWT 代理打开私有附件(返回原始字节,不用统一 JSON 拦截器) */
+export async function openAdminAttachment(url: string) {
+  const token = localStorage.getItem('ajyy_token')
+  const base = import.meta.env.VITE_API_BASE_URL || '/api'
+  const res = await axios.get(`${base}/web/admin/attachment/file`, {
+    params: { url },
+    headers: token ? { Authorization: `Bearer ${token}` } : {},
+    responseType: 'blob'
+  })
+  const blobUrl = URL.createObjectURL(res.data)
+  window.open(blobUrl, '_blank', 'noopener,noreferrer')
+  setTimeout(() => URL.revokeObjectURL(blobUrl), 60_000)
+}
+
 export function fetchUsers() {
   return http.get('/web/admin/users')
 }

+ 9 - 6
web-admin/src/views/feedback/index.vue

@@ -50,16 +50,19 @@
           </el-descriptions-item>
           <el-descriptions-item label="内容">{{ detail.content }}</el-descriptions-item>
           <el-descriptions-item label="举报人">
-            {{ detail.reporterName || '匿名' }} {{ detail.reporterPhone || '' }}
+            {{ detail.reporterName || '匿名' }}
+            <template v-if="detail.reporterUnit || detail.reporterPost">
+              ({{ detail.reporterUnit || '-' }} / {{ detail.reporterPost || '-' }})
+            </template>
+            {{ detail.reporterPhone || '' }}
           </el-descriptions-item>
           <el-descriptions-item label="附件">
-            <div v-if="detail.attachmentUrls?.length">
+            <div v-if="detail.attachmentUrls?.length" class="att-list">
               <a
                 v-for="(u, i) in detail.attachmentUrls"
                 :key="i"
-                :href="u"
-                target="_blank"
-                rel="noreferrer"
+                href="#"
+                @click.prevent="openAdminAttachment(u)"
                 >附件{{ i + 1 }}</a
               >
             </div>
@@ -91,7 +94,7 @@
 <script setup lang="ts">
   import { computed, onMounted, reactive, ref } from 'vue'
   import { ElMessage } from 'element-plus'
-  import { fetchFeedback, fetchFeedbacks, updateFeedbackStatus } from '@/api/admin'
+  import { fetchFeedback, fetchFeedbacks, openAdminAttachment, updateFeedbackStatus } from '@/api/admin'
   import { useUserStore } from '@/stores/user'
 
   const userStore = useUserStore()

+ 22 - 1
web-admin/src/views/suggestion/index.vue

@@ -45,6 +45,18 @@
             {{ detail.contactPost || '-' }}
           </el-descriptions-item>
           <el-descriptions-item label="联系方式">{{ detail.contactPhone || '-' }}</el-descriptions-item>
+          <el-descriptions-item label="附件">
+            <div v-if="detail.attachmentUrls?.length" class="att-list">
+              <a
+                v-for="(u, i) in detail.attachmentUrls"
+                :key="i"
+                href="#"
+                @click.prevent="openAdminAttachment(u)"
+                >附件{{ i + 1 }}</a
+              >
+            </div>
+            <span v-else>无</span>
+          </el-descriptions-item>
         </el-descriptions>
         <div v-if="canHandle" class="handle-box">
           <h4>办理</h4>
@@ -71,7 +83,12 @@
 <script setup lang="ts">
   import { computed, onMounted, reactive, ref } from 'vue'
   import { ElMessage } from 'element-plus'
-  import { fetchSuggestion, fetchSuggestions, updateSuggestionStatus } from '@/api/admin'
+  import {
+    fetchSuggestion,
+    fetchSuggestions,
+    openAdminAttachment,
+    updateSuggestionStatus
+  } from '@/api/admin'
   import { useUserStore } from '@/stores/user'
 
   const userStore = useUserStore()
@@ -142,4 +159,8 @@
   .handle-box {
     margin-top: 20px;
   }
+  .att-list a {
+    display: block;
+    color: #a51f23;
+  }
 </style>