PageSourceSearch

https://static.segmentfault.com/main_site_next/prod/_next/static/c…/pages/Questions/Edit-ec504a56aed41e44.js

js segmentfault.com collected 2026-09-24 08:36:22 UTC 10,604 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[22264],{46302:function(e,t,r){(window.__NEXT_P=window.__NEXT_P||[]).push(["/Questions/Edit",function(){return r(91871)}])},91871:function(e,t,r){"use strict";r.r(t),r.d(t,{__N_SSP:function(){return C}});var a=r(11527),i=r(7675),l=r.n(i),o=r(50959),n=r(89714),s=r(60880),d=r(37762),m=r(2016),p=r(83126),v=r(71384),c=r.n(v),u=r(82691),w=r.n(u),f=r(31223),g=r.n(f),h=r(77639),b=r(35737),x=r(18082),y=r(80773),j=r(60176),k=r(4790),_=r(3014),Z=r(73202),I=r(18825),N=r(3805);let T=N.p.Question,E=new I.Z(T),QuestionEdit=e=>{var t,r;let{location:{query:i},match:{params:{id:l,site:v}},sessionUser:u,editor:{title:f,draftInfo:I,log:N,tags:S,detail:C},dispatch:M}=e,[z,L]=(0,o.useState)({}),[P,B]=(0,o.useState)(null),[Q,q]=(0,o.useState)(""),[V,F]=(0,o.useState)([]),[G,D]=(0,o.useState)(null),[Y,H]=(0,o.useState)(!1),[R,A]=(0,o.useState)(""),saveTitle=e=>{M({type:"editor/saveTitle",payload:{value:e,isInvalid:!1,errorMsg:""}})},saveTags=e=>{M({type:"editor/saveTags",payload:{...e}})},saveLog=e=>{M({type:"editor/saveLog",payload:{...e}})},cutQuestionVersion=e=>{D({...G,...e})},onRevisionChange=e=>{let t=V.filter(t=>String(t.id)===String(e))[0];cutQuestionVersion(t)},scrollToElementById=e=>{let t=document.getElementById(e);if(t){var r,a;let t=(null===(a=document.getElementById(e))||void 0===a?void 0:null===(r=a.getBoundingClientRect())||void 0===r?void 0:r.top)||0;window.scrollBy(0,t-80)}},formVerify=()=>{var e;return f.value?f.value.match(/(\?|?)$/)?f.value.length>100?(M({type:"editor/saveTitle",payload:{value:f.value,isInvalid:!0,errorMsg:"标题请不要超过100个字符"}}),scrollToElementById("title"),!1):(null===(e=S.value)||void 0===e?void 0:e.map(e=>e.id))===0?(b.Z.confirm({title:"提示",content:"请选择标签"}),!1):Q?!N.value||!(N.value.length>256)||(M({type:"editor/saveLog",payload:{value:N.value,isInvalid:!0,errorMsg:"备注请不要超过 256 个字符"}}),!1):(b.Z.confirm({title:"提示",content:"必须填写内容"}),!1):(M({type:"editor/saveTitle",payload:{value:f.value,isInvalid:!0,errorMsg:"标题请用疑问句概述你的问题,并以问号(?)结尾"}}),scrollToElementById("title"),!1):(M({type:"editor/saveTitle",payload:{value:"",isInvalid:!0,errorMsg:"请填写标题"}}),scrollToElementById("title"),!1)},formError=e=>{if(null==e?void 0:e.isError){e.title&&M({type:"editor/saveTitle",payload:{...f,isInvalid:!0,errorMsg:e.title}}),e.tags&&b.Z.confirm({title:"提示",content:e.tags}),e.text&&b.Z.confirm({title:"提示",content:e.text}),e.created&&b.Z.confirm({title:"提示",content:e.created}),e.log&&M({type:"editor/saveLog",payload:{value:N.value,isInvalid:!0,errorMsg:e.log}});return}},handleSubmitForQuestion=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return await E.wait(),new Promise((t,r)=>{var a;if(!formVerify()){r(!1);return}let i={tags:null===(a=S.value)||void 0===a?void 0:a.map(e=>e.id),title:f.value,text:Q,draft_id:E.draftId,log:N.value,answer_text:"",has_answer:0,...e,...R?{activity_id:R}:{}};(0,_.DsN)({id:l,...i}).then(e=>{t(!0),E.confirm(),k.m8.push("/q/".concat(l)),e.msg&&(0,Z.Am)(e.msg)}).catch(e=>{formError(e),e.scene_id?r("needVerify"):r(!1)})})},init=async e=>{let t={type:T,id:l,freshman:i.freshman,site:v,draft_id:e},r=w()(C)?await (0,_.NmH)(t):C,a=null==r?void 0:r.init_tags;if(e){D({...r[T],...r.draft});return}if(w()(a)||D({tags:a}),l){var o;let{original_text:e,tags:t=[],title:a}=r[T],i=r.submission_activities,l=null==i?void 0:null===(o=i.find(e=>e.is_current_joined))||void 0===o?void 0:o.id;l&&A(l),D({...r[T],text:e,tags:t,title:a,submission_activities:i})}};return(0,o.useEffect)(()=>{let e=(0,Z.Wz)(window.location.href,"draftId")||null;e&&E.setDraftId(e),init(e),l&&Number(l)>0&&(0,_.Zh8)(l).then(e=>{F(e)})},[]),(0,o.useEffect)(()=>{var e,t;if(!Y||!f.value&&!Q&&(null===(e=S.value)||void 0===e?void 0:e.length)===1&&("酷工作"===S.value[0].name||"招聘"===S.value[0].name)||f.value===(null==G?void 0:G.title)&&g()(S.value,(null==G?void 0:G.tags)||[])&&Q===(null==G?void 0:G.text))return;let r={type:T,title:f.value,tags:null===(t=S.value)||void 0===t?void 0:t.map(e=>e.id),editorVal:Q,id:I.id||E.draftId,objectId:l};E.change(r)},[Y,f,S.value.length,Q]),(0,o.useEffect)(()=>{G&&(H(!0),M({type:"editor/saveTitle",payload:{value:G.title,isInvalid:!1,errorMsg:"",disabled:!1}}),M({type:"editor/saveTags",payload:{value:G.tags,isInvalid:!1,errorMsg:""}}),M({type:"editor/saveMarkdown",payload:{markdownContent:G.text,others:4}}),G.text&&q(G.text))},[G]),(0,o.useEffect)(()=>{(0,_.NJe)().then(e=>{(null==e?void 0:e.rows)&&L(e.rows)})},[]),(0,a.jsxs)(d.Z,{className:"pt-4 pb-5",children:[(0,a.jsx)("h4",{className:"mb-3",children:"编辑问题"}),(0,a.jsxs)(p.Z,{children:[(0,a.jsxs)(s.Z,{className:"col-12 col-xl w-0 position-relative mb-3 mb-md-0",xs:12,children:[(0,a.jsxs)(m.Z.Group,{className:"mb-3",children:[(0,a.jsx)(m.Z.Label,{children:"版本"}),(0,a.jsx)(m.Z.Select,{onChange:e=>onRevisionChange(e.target.value),children:V.map((e,t)=>{var r;let i=V.length-t;return(0,a.jsx)("option",{value:e.id,children:"版本 ".concat(i," - ").concat(null===(r=e.user)||void 0===r?void 0:r.name," - ").concat(c()(1e3*e.created).format("YYYY-MM-DD HH:mm")," - ").concat(e.log)},e.id)})})]}),(0,a.jsx)(j.K6,{title:f,onTitleChange:e=>saveTitle(e),suggestTitles:(null==P?void 0:P.suggest_title)||[],clickCallback:()=>new Promise(e=>{(0,_.ssP)({text:Q}).then(t=>{B(t),saveTags({value:null==t?void 0:t.suggest_tags}),e(!0)}).catch(t=>{(0,Z.Am)(t.text),e(!1)})})}),(0,a.jsxs)(m.Z.Group,{className:"mb-3",children:[(0,a.jsx)(m.Z.Label,{children:"标签"}),(0,a.jsx)("div",{className:"d-flex justify-content-between",children:(0,a.jsx)(y.Z,{className:"mb-0",maxTags:5,allTags:z,value:null==S?void 0:S.value,onChange:e=>{saveTags({...S,isInvalid:!1,value:e})}})})]}),(0,a.jsxs)(m.Z.Group,{className:"mb-3",children:[(0,a.jsx)(m.Z.Label,{children:"问题详情"}),(0,a.jsx)(x.MW,{className:"mb-2",moduleType:T,isSplitPreview:!0,isShowPreview:!0,isShowCodePopover:(null==u?void 0:null===(t=u.user)||void 0===t?void 0:t.rank)<30,style:{height:"304px"},value:Q,onChange:e=>{q(e)}})]}),(0,a.jsxs)(m.Z.Group,{className:"mb-3",children:[(0,a.jsx)(m.Z.Label,{children:"版本备注"}),(0,a.jsx)(m.Z.Control,{className:"me-sm-2 w-100 form-control mb-3",placeholder:"编辑备注(如:纠正语法、优化排版等)",value:N.value,
1name:"log",onChange:e=>saveLog({...N,isInvalid:!1,value:e.target.value}),required:!0,isInvalid:N.isInvalid}),(0,a.jsx)(m.Z.Control.Feedback,{type:"invalid",children:N.errorMsg})]}),!w()(null==G?void 0:G.submission_activities)&&(0,a.jsxs)(m.Z.Group,{className:"mb-3",children:[(0,a.jsx)(m.Z.Label,{children:"站内活动"}),(0,a.jsxs)(m.Z.Select,{value:R,onChange:e=>A(e.target.value),children:[(0,a.jsx)("option",{value:"",children:"不参加"}),null==G?void 0:null===(r=G.submission_activities)||void 0===r?void 0:r.map(e=>(0,a.jsx)("option",{value:e.id,children:e.name},e.id))]})]}),(0,a.jsxs)("div",{className:"mb-5",children:[(0,a.jsx)(h.Z,{onSuccess:handleSubmitForQuestion,needVerify:!!(null==C?void 0:C.need_verify),children:"提交"}),"saving"===I.status?(0,a.jsx)(n.Z,{disabled:!0,variant:"link",className:"ms-2 link-secondary",children:I.statusText}):(0,a.jsx)(n.Z,{variant:"link",className:"ms-2",onClick:()=>{b.Z.confirm({title:"提示",content:"确定要舍弃草稿么?",onSuccess:()=>{E.confirm(),E.draftId&&(0,_.gGg)(E.draftId),document.location.href="/q/".concat(l)}})},children:"舍弃草稿"})]})]}),(0,a.jsx)(s.Z,{className:"w-xl-300 d-none d-xl-block",xs:"auto",children:(0,a.jsx)(j.h9,{})})]})]})},S=(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(l(),{id:"b1cc3f89c4f8c7b8",children:'@charset "UTF-8";.fmt,.preview-wrap{line-height:1.6}.fmt .hljs,.preview-wrap .hljs{background-color:transparent!important;padding:0!important}.fmt p,.fmt address,.fmt ul,.fmt ol,.fmt dl,.fmt pre,.fmt blockquote,.fmt table,.fmt figure,.fmt hr,.preview-wrap p,.preview-wrap address,.preview-wrap ul,.preview-wrap ol,.preview-wrap dl,.preview-wrap pre,.preview-wrap blockquote,.preview-wrap table,.preview-wrap figure,.preview-wrap hr{margin-bottom:1.25rem}.fmt p,.preview-wrap p{word-wrap:break-word}.fmt p a,.preview-wrap p a{word-break:break-all}.fmt ol ol,.fmt ol ul,.fmt ul ol,.fmt ul ul,.preview-wrap ol ol,.preview-wrap ol ul,.preview-wrap ul ol,.preview-wrap ul ul{margin-bottom:0}.fmt li>p:last-of-type,.preview-wrap li>p:last-of-type{margin-bottom:0!important}.fmt h1,.preview-wrap h1{font-size:2rem;margin:2.75rem 0 1rem;padding-bottom:.5rem;border-bottom:3px double rgba(0,0,0,.1)}.fmt h2,.preview-wrap h2{font-size:1.75rem;margin:2.5rem 0 1rem;padding-bottom:.5rem;border-bottom:1px double rgba(0,0,0,.1)}.fmt>h2:first-child,.preview-wrap>h2:first-child{margin-top:0}.fmt h3,.preview-wrap h3{font-size:1.5rem;margin:2.25rem 0 1rem}.fmt h4,.preview-wrap h4{font-size:1.25rem;margin:2rem 0 1rem}.fmt h5,.preview-wrap h5{font-size:1rem;margin:1.75rem 0 1rem}.fmt h6,.preview-wrap h6{font-size:1rem;margin:1.5rem 0 .5rem}.fmt h6::before,.preview-wrap h6::before{content:"❐";margin-right:.25rem}.fmt blockquote,.preview-wrap blockquote{padding-left:1rem;border-left:.25rem solid#e9ecef}.fmt pre,.preview-wrap pre{padding:1rem;max-height:35rem;line-height:1.5;background-color:#e9ecef;overflow:auto}.fmt pre code,.preview-wrap pre code{word-wrap:normal;overflow-wrap:normal;white-space:inherit}.fmt hr,.preview-wrap hr{margin:2rem auto;max-width:160px;border-top-width:1px;background-color:rgba(0,0,0,.5)}.fmt img,.preview-wrap img{max-width:100%;height:auto}.fmt table,.preview-wrap table{border:1px solid#dee2e6;width:100%;table-layout:fixed}.fmt table td,.fmt table th,.preview-wrap table td,.preview-wrap table th{padding:.75rem;border:1px solid#dee2e6;word-wrap:break-word}.fmt table [align=center],.preview-wrap table [align=center]{text-align:center}.fmt table [align=right],.preview-wrap table [align=right]{text-align:right}.fmt table thead th,.preview-wrap table thead th{border-bottom-width:2px;background-color:#e9ecef;color:#212529;font-weight:bold}.fmt table tbody tr:hover,.preview-wrap table tbody tr:hover{background-color:rgba(0,0,0,.025)}.fmt .img-wrap,.preview-wrap .img-wrap{display:block;text-align:center}article.fmt a img{cursor:pointer}article.fmt img{cursor:-webkit-zoom-in;cursor:-moz-zoom-in;cursor:zoom-in}article.fmt p>img{display:block;margin:0 auto}'})});var C=!0;t.default=e=>(0,a.jsxs)(a.Fragment,{children:[S,(0,a.jsx)(QuestionEdit,{...e})]})}},function(e){e.O(0,[9580,62671,80773,18082,60176,49774,92888,40179],function(){return e(e.s=46302)}),_N_E=e.O()}]);

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.