mirror of
https://github.com/doocs/md.git
synced 2025-01-22 20:04:39 +08:00
feat: update post slider (#481)
This commit is contained in:
parent
828b92ac21
commit
b00b940d44
14
README.md
14
README.md
@ -76,19 +76,19 @@ Markdown 文档自动即时渲染为微信图文,让你不再为微信文章
|
|||||||
示例代码:
|
示例代码:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const { file, util, okCb, errCb } = CUSTOM_ARG;
|
const { file, util, okCb, errCb } = CUSTOM_ARG
|
||||||
const param = new FormData();
|
const param = new FormData()
|
||||||
param.append(`file`, file);
|
param.append(`file`, file)
|
||||||
util.axios
|
util.axios
|
||||||
.post(`http://127.0.0.1:9000/upload`, param, {
|
.post(`http://127.0.0.1:9000/upload`, param, {
|
||||||
headers: { "Content-Type": `multipart/form-data` },
|
headers: { 'Content-Type': `multipart/form-data` },
|
||||||
})
|
})
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
okCb(res.url);
|
okCb(res.url)
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
errCb(err);
|
errCb(err)
|
||||||
});
|
})
|
||||||
|
|
||||||
// 提供的可用参数:
|
// 提供的可用参数:
|
||||||
// CUSTOM_ARG = {
|
// CUSTOM_ARG = {
|
||||||
|
@ -77,10 +77,12 @@ section {
|
|||||||
position: relative;
|
position: relative;
|
||||||
margin: 0 -20px;
|
margin: 0 -20px;
|
||||||
width: 375px;
|
width: 375px;
|
||||||
|
min-height: 100vh;
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
outline: none;
|
outline: none;
|
||||||
|
word-wrap: break-word;
|
||||||
}
|
}
|
||||||
|
|
||||||
.preview table {
|
.preview table {
|
||||||
|
@ -40,7 +40,7 @@ function renamePost() {
|
|||||||
}
|
}
|
||||||
store.renamePost(editTarget.value, renamePostInputVal.value)
|
store.renamePost(editTarget.value, renamePostInputVal.value)
|
||||||
isOpenEditDialog.value = false
|
isOpenEditDialog.value = false
|
||||||
toast.success(`文章更名成功`)
|
toast.success(`文章重命名成功`)
|
||||||
}
|
}
|
||||||
|
|
||||||
const isOpenDelPostConfirmDialog = ref(false)
|
const isOpenDelPostConfirmDialog = ref(false)
|
||||||
@ -90,9 +90,10 @@ function delPost() {
|
|||||||
:key="post.title"
|
:key="post.title"
|
||||||
href="#"
|
href="#"
|
||||||
:class="{
|
:class="{
|
||||||
'bg-primary text-primary-foreground': store.currentPostIndex === index,
|
'bg-primary text-primary-foreground shadow-lg border-2 border-primary': store.currentPostIndex === index,
|
||||||
|
'dark:bg-primary-dark dark:text-primary-foreground-dark dark:border-primary-dark': store.currentPostIndex === index,
|
||||||
}"
|
}"
|
||||||
class="hover:bg-primary/90 hover:text-primary-foreground dark:bg-muted dark:hover:bg-muted h-8 w-full inline-flex items-center justify-start gap-2 whitespace-nowrap rounded px-2 text-sm transition-colors dark:text-white dark:hover:text-white"
|
class="hover:bg-primary/90 hover:text-primary-foreground dark:bg-muted dark:hover:bg-muted dark:hover:border-primary-dark h-8 w-full inline-flex items-center justify-start gap-2 whitespace-nowrap rounded px-2 text-sm transition-colors dark:text-white dark:hover:text-white"
|
||||||
@click="store.currentPostIndex = index"
|
@click="store.currentPostIndex = index"
|
||||||
>
|
>
|
||||||
<span class="line-clamp-1">{{ post.title }}</span>
|
<span class="line-clamp-1">{{ post.title }}</span>
|
||||||
@ -105,9 +106,9 @@ function delPost() {
|
|||||||
<DropdownMenuContent>
|
<DropdownMenuContent>
|
||||||
<DropdownMenuItem @click.stop="startRenamePost(index)">
|
<DropdownMenuItem @click.stop="startRenamePost(index)">
|
||||||
<Edit3 class="mr-2 size-4" />
|
<Edit3 class="mr-2 size-4" />
|
||||||
更名
|
重命名
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
<DropdownMenuItem @click.stop="startDelPost(index)">
|
<DropdownMenuItem v-if="store.posts.length > 1" @click.stop="startDelPost(index)">
|
||||||
<Trash class="mr-2 size-4" />
|
<Trash class="mr-2 size-4" />
|
||||||
删除
|
删除
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
|
@ -63,7 +63,7 @@ export const useStore = defineStore(`store`, () => {
|
|||||||
const addPost = (title: string) => {
|
const addPost = (title: string) => {
|
||||||
currentPostIndex.value = posts.value.push({
|
currentPostIndex.value = posts.value.push({
|
||||||
title,
|
title,
|
||||||
content: DEFAULT_CONTENT,
|
content: `# ${title}`,
|
||||||
}) - 1
|
}) - 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ export const useStore = defineStore(`store`, () => {
|
|||||||
|
|
||||||
const delPost = (index: number) => {
|
const delPost = (index: number) => {
|
||||||
posts.value.splice(index, 1)
|
posts.value.splice(index, 1)
|
||||||
currentPostIndex.value = 0
|
currentPostIndex.value = posts.value.length - 1
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(currentPostIndex, () => {
|
watch(currentPostIndex, () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user