PageSourceSearch

https://ai-tw.manus.space/assets/BatchSeo-DsBHmU1l.js

js ai-tw.manus.space collected 2026-10-03 05:00:06 UTC 10,600 bytes, 1 lines download raw bytes

1import{r as B,t as u,k as r,j as e,l as n,m as i,n as d,o,S as D,ab as G,B as v,Q as C,R as M,K as N,a_ as T,y as x,A as R,b1 as E,bj as W,D as Q}from"./index-CDydTNgN.js";function F(){const[l,h]=B.useState([]),[g,f]=B.useState(!1),[p,b]=B.useState([]),{data:t,isLoading:w,refetch:O}=u.blog.getPostsWithoutSeo.useQuery(),{data:I}=u.blog.getAllPosts.useQuery(),k=u.blog.batchGenerateSeo.useMutation({onSuccess:s=>{b(s.results);const a=s.results.filter(j=>j.success).length,c=s.results.filter(j=>!j.success).length;a>0&&c===0?r.success(`成功為 ${a} 篇文章生成 SEO 設定`):a>0&&c>0?r.warning(`成功 ${a} 篇,失敗 ${c} 篇`):r.error("所有文章都生成失敗"),h([]),O()},onError:s=>{r.error(`批次生成失敗:${s.message}`)},onSettled:()=>{f(!1)}}),A=()=>{t&&(l.length===t.length?h([]):h(t.map(s=>s.post.id)))},P=s=>{h(a=>a.includes(s)?a.filter(c=>c!==s):[...a,s])},$=()=>{if(l.length===0){r.error("請先選擇要生成 SEO 的文章");return}f(!0),b([]),k.mutate({postIds:l})},m=I?.filter(s=>s.post.status==="published")||[],y=m.filter(s=>s.post.metaTitle&&s.post.metaDescription),S=m.length>0?Math.round(y.length/m.length*100):0;return e.jsxs("div",{"data-loc":"client/src/pages/admin/BatchSeo.tsx:84",className:"space-y-6",children:[e.jsxs("div",{"data-loc":"client/src/pages/admin/BatchSeo.tsx:86",children:[e.jsx("h1",{"data-loc":"client/src/pages/admin/BatchSeo.tsx:87",className:"text-2xl font-bold text-gray-900",children:"批次 SEO 更新"}),e.jsx("p",{"data-loc":"client/src/pages/admin/BatchSeo.tsx:88",className:"text-gray-600 mt-1",children:"使用 AI 為已發布的文章批次生成 SEO 標題、描述和關鍵字"})]}),e.jsxs("div",{"data-loc":"client/src/pages/admin/BatchSeo.tsx:94",className:"grid gap-4 md:grid-cols-3",children:[e.jsxs(n,{"data-loc":"client/src/pages/admin/BatchSeo.tsx:95",children:[e.jsx(i,{"data-loc":"client/src/pages/admin/BatchSeo.tsx:96",className:"pb-2",children:e.jsx(d,{"data-loc":"client/src/pages/admin/BatchSeo.tsx:97",className:"text-sm font-medium text-gray-600",children:"已發布文章"})}),e.jsx(o,{"data-loc":"client/src/pages/admin/BatchSeo.tsx:99",children:e.jsx("div",{"data-loc":"client/src/pages/admin/BatchSeo.tsx:100",className:"text-2xl font-bold",children:m.length})})]}),e.jsxs(n,{"data-loc":"client/src/pages/admin/BatchSeo.tsx:103",children:[e.jsx(i,{"data-loc":"client/src/pages/admin/BatchSeo.tsx:104",className:"pb-2",children:e.jsx(d,{"data-loc":"client/src/pages/admin/BatchSeo.tsx:105",className:"text-sm font-medium text-gray-600",children:"已設定 SEO"})}),e.jsx(o,{"data-loc":"client/src/pages/admin/BatchSeo.tsx:107",children:e.jsx("div",{"data-loc":"client/src/pages/admin/BatchSeo.tsx:108",className:"text-2xl font-bold text-green-600",children:y.length})})]}),e.jsxs(n,{"data-loc":"client/src/pages/admin/BatchSeo.tsx:111",children:[e.jsx(i,{"data-loc":"client/src/pages/admin/BatchSeo.tsx:112",className:"pb-2",children:e.jsx(d,{"data-loc":"client/src/pages/admin/BatchSeo.tsx:113",className:"text-sm font-medium text-gray-600",children:"SEO 完成率"})}),e.jsx(o,{"data-loc":"client/src/pages/admin/BatchSeo.tsx:115",children:e.jsx("div",{"data-loc":"client/src/pages/admin/BatchSeo.tsx:116",className:"text-2xl font-bold",children:e.jsxs("span",{"data-loc":"client/src/pages/admin/BatchSeo.tsx:117",className:S>=80?"text-green-600":S>=50?"text-yellow-600":"text-red-600",children:[S,"%"]})})})]})]}),e.jsxs(n,{"data-loc":"client/src/pages/admin/BatchSeo.tsx:126",children:[e.jsx(i,{"data-loc":"client/src/pages/admin/BatchSeo.tsx:127",children:e.jsxs("div",{"data-loc":"client/src/pages/admin/BatchSeo.tsx:128",className:"flex items-center justify-between",children:[e.jsxs("div",{"data-loc":"client/src/pages/admin/BatchSeo.tsx:129",children:[e.jsxs(d,{"data-loc":"client/src/pages/admin/BatchSeo.tsx:130",className:"flex items-center gap-2",children:[e.jsx(D,{"data-loc":"client/src/pages/admin/BatchSeo.tsx:131",className:"h-5 w-5"}),"待設定 SEO 的文章"]}),e.jsx(G,{"data-loc":"client/src/pages/admin/BatchSeo.tsx:134",children:"以下文章尚未設定 SEO 標題或描述"})]}),e.jsxs("div",{"data-loc":"client/src/pages/admin/BatchSeo.tsx:138",className:"flex items-center gap-2",children:[e.jsx(v,{"data-loc":"client/src/pages/admin/BatchSeo.tsx:139",variant:"outline",size:"sm",onClick:A,disabled:!t||t.length===0,children:l.length===t?.length?"取消全選":"全選"}),e.jsx(v,{"data-loc":"client/src/pages/admin/BatchSeo.tsx:147",onClick:$,disabled:l.length===0||g,children:g?e.jsxs(e.Fragment,{children:[e.jsx(C,{"data-loc":"client/src/pages/admin/BatchSeo.tsx:153",className:"mr-2 h-4 w-4 animate-spin"}),"生成中..."]}):e.jsxs(e.Fragment,{children:[e.jsx(M,{"data-loc":"client/src/pages/admin/BatchSeo.tsx:158",className:"mr-2 h-4 w-4"}),"批次生成 SEO (",l.length,")"]})})]})]})}),e.jsx(o,{"data-loc":"client/src/pages/admin/BatchSeo.tsx:166",children:w?e.jsx("div",{"data-loc":"client/src/pages/admin/BatchSeo.tsx:168",className:"flex items-center justify-center py-8",children:e.jsx(C,{"data-loc":"client/src/pages/admin/BatchSeo.tsx:169",className:"h-8 w-8 animate-spin text-gray-400"})}):!t||t.length===0?e.jsxs("div",{"data-loc":"client/src/pages/admin/BatchSeo.tsx:172",className:"text-center py-8 text-gray-500",children:[e.jsx(N,{"data-loc":"client/src/pages/admin/BatchSeo.tsx:173",className:"h-12 w-12 mx-auto mb-4 text-green-500"}),e.jsx("p",{"data-loc":"client/src/pages/admin/BatchSeo.tsx:174",className:"text-lg font-medium",children:"所有文章都已設定 SEO!"}),e.jsx("p",{"data-loc":"client/src/pages/admin/BatchSeo.tsx:175",className:"text-sm",children:"您的網站 SEO 設定已完成"})]}):e.jsx("div",{"data-loc":"client/src/pages/admin/BatchSeo.tsx:178",className:"space-y-2",children:t.map(s=>{const a=p.find(c=>c.postId===s.post.id);return e.jsxs("div",{"data-loc":"client/src/pages/admin/BatchSeo.tsx:182",className:`flex items-center gap-4 p-4 rounded-lg border transition-colors ${l.includes(s.post.id)?"bg-blue-50 border-blue-200":"bg-white hover:bg-gray-50"}`,children:[e.jsx(T,{"data-loc":"client/src/pages/admin/BatchSeo.tsx:190",checked:l.includes(s.post.id),onCheckedChange:()=>P(s.post.id),disabled:g}),e.jsxs("div",{"data-loc":"client/src/pages/admin/BatchSeo.tsx:195",className:"flex-1 min-w-0",children:[e.jsx("h3",{"data-loc":"client/src/pages/admin/BatchSeo.tsx:196",className:"font-medium text-gray-900 truncate",children:s.post.title}),e.jsxs("div",{"data-loc":"client/src/pages/admin/BatchSeo.tsx:199",className:"flex items-center gap-2 mt-1 text-sm text-gray-500",children:[s.category&&e.jsx(x,{"data-loc":"client/src/pages/admin/BatchSeo.tsx:201",variant:"secondary",className:"text-xs",children:s.category.name}),e.jsx("span",{"data-loc":"client/src/pages/admin/BatchSeo.tsx:205",children:s.post.publishedAt?R(new Date(s.post.publishedAt),"yyyy/MM/dd",{locale:Q}):"未發布"})]})]}),e.jsxs("div",{"data-loc":"client/src/pages/admin/BatchSeo.tsx:213",className:"flex items-center gap-2",children:[!s.post.metaTitle&&e.jsx(x,{"data-loc":"client/src/pages/admin/BatchSeo.tsx:215",variant:"outline",className:"text-xs text-orange-600 border-orange-300",children:"缺少標題"}),!s.post.metaDescription&&e.jsx(x,{"data-loc":"client/src/pages/admin/BatchSeo.tsx:220",variant:"outline",className:"text-xs text-orange-600 border-orange-300",children:"缺少描述"}),a&&(a.success?e.jsxs(x,{"data-loc":"client/src/pages/admin/BatchSeo.tsx:226",className:"bg-green-100 text-green-700",children:[e.jsx(N,{"data-loc":"client/src/pages/admin/BatchSeo.tsx:227",className:"h-3 w-3 mr-1"}),"已生成"]}):e.jsxs(x,{"data-loc":"client/src/pages/admin/BatchSeo.tsx:231",className:"bg-red-100 text-red-700",children:[e.jsx(E,{"data-loc":"client/src/pages/admin/BatchSeo.tsx:232",className:"h-3 w-3 mr-1"}),"失敗"]}))]})]},s.post.id)})})})]}),p.length>0&&e.jsxs(n,{"data-loc":"client/src/pages/admin/BatchSeo.tsx:248",children:[e.jsx(i,{"data-loc":"client/src/pages/admin/BatchSeo.tsx:249",children:e.jsxs(d,{"data-loc":"client/src/pages/admin/BatchSeo.tsx:250",className:"flex items-center gap-2",children:[e.jsx(W,{"data-loc":"client/src/pages/admin/BatchSeo.tsx:251",className:"h-5 w-5"}),"生成結果"]}
1)}),e.jsx(o,{"data-loc":"client/src/pages/admin/BatchSeo.tsx:255",children:e.jsx("div",{"data-loc":"client/src/pages/admin/BatchSeo.tsx:256",className:"space-y-2",children:p.map(s=>{const a=t?.find(c=>c.post.id===s.postId);return e.jsxs("div",{"data-loc":"client/src/pages/admin/BatchSeo.tsx:260",className:`flex items-center gap-4 p-3 rounded-lg ${s.success?"bg-green-50":"bg-red-50"}`,children:[s.success?e.jsx(N,{"data-loc":"client/src/pages/admin/BatchSeo.tsx:267",className:"h-5 w-5 text-green-600"}):e.jsx(E,{"data-loc":"client/src/pages/admin/BatchSeo.tsx:269",className:"h-5 w-5 text-red-600"}),e.jsxs("div",{"data-loc":"client/src/pages/admin/BatchSeo.tsx:271",className:"flex-1",children:[e.jsx("span",{"data-loc":"client/src/pages/admin/BatchSeo.tsx:272",className:"font-medium",children:a?.post.title||`文章 ID: ${s.postId}`}),s.error&&e.jsx("p",{"data-loc":"client/src/pages/admin/BatchSeo.tsx:276",className:"text-sm text-red-600 mt-1",children:s.error})]})]},s.postId)})})})]}),e.jsxs(n,{"data-loc":"client/src/pages/admin/BatchSeo.tsx:288",children:[e.jsx(i,{"data-loc":"client/src/pages/admin/BatchSeo.tsx:289",children:e.jsx(d,{"data-loc":"client/src/pages/admin/BatchSeo.tsx:290",children:"使用說明"})}),e.jsxs(o,{"data-loc":"client/src/pages/admin/BatchSeo.tsx:292",className:"prose prose-sm max-w-none",children:[e.jsxs("ol",{"data-loc":"client/src/pages/admin/BatchSeo.tsx:293",className:"list-decimal list-inside space-y-2 text-gray-600",children:[e.jsx("li",{"data-loc":"client/src/pages/admin/BatchSeo.tsx:294",children:"勾選要生成 SEO 的文章(或點擊「全選」選擇所有文章)"}),e.jsx("li",{"data-loc":"client/src/pages/admin/BatchSeo.tsx:295",children:"點擊「批次生成 SEO」按鈕開始生成"}),e.jsx("li",{"data-loc":"client/src/pages/admin/BatchSeo.tsx:296",children:"AI 會根據文章內容自動生成 SEO 標題、描述和關鍵字"}),e.jsx("li",{"data-loc":"client/src/pages/admin/BatchSeo.tsx:297",children:"生成完成後,您可以在文章編輯頁面查看和修改 SEO 設定"})]}),e.jsxs("p",{"data-loc":"client/src/pages/admin/BatchSeo.tsx:299",className:"mt-4 text-sm text-gray-500",children:[e.jsx("strong",{"data-loc":"client/src/pages/admin/BatchSeo.tsx:300",children:"提示:"}),"批次生成可能需要一些時間,請耐心等待。每篇文章的 SEO 設定都會根據其內容獨立生成。"]})]})]})]})}export{F as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.