cloudroam
2025-06-26 03fbf454453daf7b3a45064ea781cf4bdcc76832
pages/film/filmset.vue
文件名从 pages/content/filmset.vue 修改
@@ -189,9 +189,70 @@
              limitSize: 2,
              limit: 1,
              tipText: '大小不超过2M',
              valueType: 'string',
              // valueType: 'string',
            },
            forceDisabled: true,
            inputFormat: (row) => {
              if ('coverUrl' in row) {
                if (typeof row.coverUrl === 'string' && row.coverUrl) {
                  let url = row.coverUrl
                  if (url.includes('doubanio')) {
                    url = `https://images.weserv.nl/?url=${encodeURIComponent(url)}`
                  }
                  return [{ url }]
                }
                if (Array.isArray(row.coverUrl)) {
                  return row.coverUrl
                }
                return []
              }
            },
            outputFormat: (fileList) => {
              if (Array.isArray(fileList) && fileList.length > 0) {
                let url = fileList[0].url
                const proxyPrefix = 'https://images.weserv.nl/?url='
                if (url.startsWith(proxyPrefix)) {
                  url = decodeURIComponent(url.replace(proxyPrefix, ''))
                }
                return url
              }
              return ''
            }
            // outputFormat: (fileList) => {
            //   if (Array.isArray(fileList) && fileList.length > 0) {
            //     return fileList[0].url
            //   }
            //   return ''
            // }
            // inputFormat: (row) => {
            //   if ('coverUrl' in row) {
            //     // 封面图片是字符串
            //     if (typeof row.coverUrl === 'string' && row.coverUrl) {
            //       let url = row.coverUrl
            //       console.log("我进来了",url)
            //       // 代理 doubanio 图片
            //       if (url.includes('doubanio')) {
            //         url = `https://images.weserv.nl/?url=${encodeURIComponent(url)}`
            //         console.log("我处理了",url)
            //       }
            //       return [{ url }]
            //     }
            //     // 已经是数组
            //     if (Array.isArray(row.coverUrl)) {
            //       // 这里也可以做一遍代理处理,防止后端返回的数组里有 doubanio
            //       return row.coverUrl.map(item => {
            //         let url = item.url || item
            //         if (url.includes('doubanio')) {
            //           url = `https://images.weserv.nl/?url=${encodeURIComponent(url)}`
            //         }
            //         return { ...item, url }
            //       })
            //     }
            //     return []
            //   }
            // },
            // formatter: (url) => this.formatImageUrl(url)
          },
          {
            label: '封面图片描述:',
@@ -316,6 +377,24 @@
                await this.$elBusUtil.confirm(`确定要${action}吗?`)
                const { code } = await this.$elBusHttp.request(
                  'flower/api/filmWorks/changeStatus',
                  { params: { id: row.id } }
                )
                if (code === 0) {
                  this.$message.success(`${action}成功`)
                }
              } catch (e) {
                return false
              }
            },
          },
          {
            text: (row) => ( row.status === 'pending_create' ? '取消生成' : '重新生成'),
            atClick: async (row) => {
              const action = row.status === 'pending_create'  ? '取消生成' : '重新生成'
              try {
                await this.$elBusUtil.confirm(`确定要${action}吗?`)
                const { code } = await this.$elBusHttp.request(
                  'flower/api/filmWorks/changeCreateStatus',
                  { params: { id: row.id } }
                )
                if (code === 0) {
@@ -495,13 +574,44 @@
    }
  },
  methods: {
    formatterImage(row) {
      if (row.coverUrl) {
        // 使用第三方镜像服务(示例)
        const proxyUrl = `https://images.weserv.nl/?url=${encodeURIComponent(row.coverUrl)}`;
        return <el-bus-image src={proxyUrl} preview-src-list={[proxyUrl]} style="width:150px" />
    // formatterImage(row) {
    //   if (row.coverUrl) {
    //     if (row.coverUrl.includes('doubanio')) {
    //       const proxyUrl = `https://images.weserv.nl/?url=${encodeURIComponent(row.coverUrl)}`;
    //       return <el-bus-image src={proxyUrl} preview-src-list={[proxyUrl]} style="width:150px" />
    //     } else {
    //       return <el-bus-image src={row.coverUrl} preview-src-list={[row.coverUrl]} style="width:150px" />
    //     }
    //   }
    //   return '无封面';
    // }
    formatImageUrl(url) {
      if (!url) return '';
      if (url.includes('doubanio')) {
        return `https://images.weserv.nl/?url=${encodeURIComponent(url)}`;
      }
      return '无封面';
      return url;
    },
    // formatterImage(row) {
    //   if (!row.coverUrl) return '无封面';
    //   const displayUrl = this.formatImageUrl(row.coverUrl);
    //   return <el-bus-image src={displayUrl} preview-src-list={[displayUrl]} style="width:150px" />;
    // }
    formatterImage(row) {
      if (!row.coverUrl) return '无封面';
      // 统一处理路径:doubanio路径使用代理,其他直接使用
      const displayUrl = row.coverUrl.includes('doubanio')
        ? `https://images.weserv.nl/?url=${encodeURIComponent(row.coverUrl)}`
        : row.coverUrl;
      return (
        <el-bus-image
          src={displayUrl}
          preview-src-list={[displayUrl]}
          style="width:150px"
        />
      );
    }
  },
}