1111import {onBeforeMount , reactive , toRaw } from " vue"
1212import copy from " copy-to-clipboard"
1313import {JsonUtil , StrUtil } from " zhi-common"
14- import {showMessage } from " siyuan"
14+ import {showMessage , confirm } from " siyuan"
1515import {createAppLogger } from " ../utils/appLogger.ts"
1616import {useSiyuanApi } from " ../composables/useSiyuanApi.ts"
1717import {getAllIps } from " ../utils/urlUtil.ts"
@@ -31,7 +31,7 @@ const {getSetting, updateSetting} = useSettingStore()
3131const {blogApi, kernelApi} = useSiyuanApi ()
3232const {handleMethod} = useMethod (props .pluginInstance )
3333const {handleMethodAsync} = useMethodAsync (props .pluginInstance )
34- const {openStaticShare, closeStaticShare, updateStaticShare} = useStaticShare ()
34+ const {openStaticShare, closeStaticShare, updateStaticShare, clearSharePages } = useStaticShare ()
3535
3636const basePath = " /plugins/siyuan-blog/app/#"
3737// datas
@@ -201,6 +201,21 @@ const handleExpiresTime = async () => {
201201 )
202202}
203203
204+ const handleClearAllShares = async (event : Event ) => {
205+ // 阻止事件冒泡
206+ event .stopPropagation ()
207+ // 清除所有分享
208+ await clearSharePages ()
209+ // 更新当前页面的分享状态
210+ formData .shared = false
211+ await kernelApi .setBlockAttrs (props .id , {
212+ " custom-publish-status" : " draft" ,
213+ " custom-publish-time" : " " ,
214+ })
215+ // 操作完成后再显示成功提示
216+ showMessage (props .pluginInstance .i18n [" share.clear.all.success" ])
217+ }
218+
204219onBeforeMount (async () => {
205220 formData .setting = await getSetting ()
206221 formData .post = await blogApi .getPost (props .id , false , false )
@@ -284,6 +299,18 @@ logger.debug("share inited", props)
284299 <input class =" b3-switch fn__flex-center" type =" checkbox" v-model =" formData.isHome" @change =" handleSetHome" >
285300 </div >
286301 </div >
302+
303+ <div class =" divider" />
304+
305+ <div class =" setting-row" >
306+ <span class =" setting-label" >
307+ {{ pluginInstance.i18n["share.clear.all"] }}
308+ </span >
309+ <div class =" input-group" >
310+ <div class =" danger-text" >{{ pluginInstance.i18n["share.clear.all.tip"] }}</div >
311+ <button class =" danger-button" @click =" handleClearAllShares" >{{ pluginInstance.i18n["share.clear.all"] }}</button >
312+ </div >
313+ </div >
287314 </div >
288315</template >
289316
@@ -458,4 +485,14 @@ html[data-theme-mode="dark"]
458485
459486 .info-text
460487 color #ff 78 75
488+
489+ .danger-button
490+ background-color #ff 4d 4f
491+ & :hover
492+ background-color #ff 78 75
493+
494+ .danger-text
495+ color #ff 4d 4f
496+ font-size 12px
497+ margin-right 8px
461498 </style >
0 commit comments