mirror of
https://github.com/pipipi-pikachu/PPTist.git
synced 2025-04-15 02:20:00 +08:00
refactor: 替换Input、Message
This commit is contained in:
parent
8498b0786b
commit
0444f4c56e
@ -11,12 +11,15 @@
|
|||||||
</span>
|
</span>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
|
ref="inputRef"
|
||||||
:disabled="disabled"
|
:disabled="disabled"
|
||||||
:value="value"
|
:value="value"
|
||||||
:placeholder="placeholder"
|
:placeholder="placeholder"
|
||||||
@input="$event => handleInput($event)"
|
@input="$event => handleInput($event)"
|
||||||
@focus="focused = true"
|
@focus="$event => handleFocus($event)"
|
||||||
@blur="focused = false"
|
@blur="$event => handleBlur($event)"
|
||||||
|
@change="$event => emit('change', $event)"
|
||||||
|
@keydown.enter="$event => emit('enter', $event)"
|
||||||
/>
|
/>
|
||||||
<span class="suffix">
|
<span class="suffix">
|
||||||
<slot name="suffix"></slot>
|
<slot name="suffix"></slot>
|
||||||
@ -38,13 +41,36 @@ withDefaults(defineProps<{
|
|||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
(event: 'update:value', payload: string): void
|
(event: 'update:value', payload: string): void
|
||||||
|
(event: 'input', payload: Event): void
|
||||||
|
(event: 'change', payload: Event): void
|
||||||
|
(event: 'blur', payload: Event): void
|
||||||
|
(event: 'focus', payload: Event): void
|
||||||
|
(event: 'enter', payload: Event): void
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const focused = ref(false)
|
const focused = ref(false)
|
||||||
|
|
||||||
const handleInput = (e: Event) => {
|
const handleInput = (e: Event) => {
|
||||||
emit('update:value', (e.target as HTMLInputElement).value)
|
emit('update:value', (e.target as HTMLInputElement).value)
|
||||||
|
emit('input', e)
|
||||||
}
|
}
|
||||||
|
const handleBlur = (e: Event) => {
|
||||||
|
focused.value = false
|
||||||
|
emit('blur', e)
|
||||||
|
}
|
||||||
|
const handleFocus = (e: Event) => {
|
||||||
|
focused.value = true
|
||||||
|
emit('focus', e)
|
||||||
|
}
|
||||||
|
|
||||||
|
const inputRef = ref<HTMLInputElement>()
|
||||||
|
const focus = () => {
|
||||||
|
if (inputRef.value) inputRef.value.focus()
|
||||||
|
}
|
||||||
|
|
||||||
|
defineExpose({
|
||||||
|
focus,
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
@ -55,7 +81,7 @@ const handleInput = (e: Event) => {
|
|||||||
border-radius: $borderRadius;
|
border-radius: $borderRadius;
|
||||||
transition: border-color .25s;
|
transition: border-color .25s;
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
display: inline-flex;
|
display: flex;
|
||||||
|
|
||||||
input {
|
input {
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
|
@ -15,8 +15,11 @@
|
|||||||
:disabled="disabled"
|
:disabled="disabled"
|
||||||
v-model="number"
|
v-model="number"
|
||||||
:placeholder="placeholder"
|
:placeholder="placeholder"
|
||||||
@focus="focused = true"
|
@input="$event => emit('input', $event)"
|
||||||
@blur="focused = false"
|
@focus="$event => handleFocus($event)"
|
||||||
|
@blur="$event => handleBlur($event)"
|
||||||
|
@change="$event => emit('change', $event)"
|
||||||
|
@keydown.enter="$event => emit('enter', $event)"
|
||||||
/>
|
/>
|
||||||
<div class="handlers">
|
<div class="handlers">
|
||||||
<span class="handler" @click="number += step">
|
<span class="handler" @click="number += step">
|
||||||
@ -53,6 +56,11 @@ const props = withDefaults(defineProps<{
|
|||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
(event: 'update:value', payload: number): void
|
(event: 'update:value', payload: number): void
|
||||||
|
(event: 'input', payload: Event): void
|
||||||
|
(event: 'change', payload: Event): void
|
||||||
|
(event: 'blur', payload: Event): void
|
||||||
|
(event: 'focus', payload: Event): void
|
||||||
|
(event: 'enter', payload: Event): void
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const number = ref(0)
|
const number = ref(0)
|
||||||
@ -73,6 +81,15 @@ watch(number, () => {
|
|||||||
number.value = value
|
number.value = value
|
||||||
emit('update:value', number.value)
|
emit('update:value', number.value)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const handleBlur = (e: Event) => {
|
||||||
|
focused.value = false
|
||||||
|
emit('blur', e)
|
||||||
|
}
|
||||||
|
const handleFocus = (e: Event) => {
|
||||||
|
focused.value = true
|
||||||
|
emit('focus', e)
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
@ -51,7 +51,7 @@ const message: Message = (options: MessageOptions) => {
|
|||||||
position: fixed;
|
position: fixed;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
z-index: 1010;
|
z-index: 6000;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
@ -47,10 +47,10 @@ import useLink from '@/hooks/useLink'
|
|||||||
|
|
||||||
import ThumbnailSlide from '@/views/components/ThumbnailSlide/index.vue'
|
import ThumbnailSlide from '@/views/components/ThumbnailSlide/index.vue'
|
||||||
import Tabs from '@/components/Tabs.vue'
|
import Tabs from '@/components/Tabs.vue'
|
||||||
|
import Input from '@/components/Input.vue'
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
Select,
|
Select,
|
||||||
Input,
|
|
||||||
} from 'ant-design-vue'
|
} from 'ant-design-vue'
|
||||||
const SelectOption = Select.Option
|
const SelectOption = Select.Option
|
||||||
|
|
||||||
|
@ -26,12 +26,10 @@
|
|||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import {
|
import { Button } from 'ant-design-vue'
|
||||||
Button,
|
import message from '@/utils/message'
|
||||||
Input,
|
|
||||||
message,
|
|
||||||
} from 'ant-design-vue'
|
|
||||||
import Tabs from '@/components/Tabs.vue'
|
import Tabs from '@/components/Tabs.vue'
|
||||||
|
import Input from '@/components/Input.vue'
|
||||||
|
|
||||||
type TypeKey = 'video' | 'audio'
|
type TypeKey = 'video' | 'audio'
|
||||||
interface TabItem {
|
interface TabItem {
|
||||||
|
@ -53,10 +53,10 @@
|
|||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
|
import message from '@/utils/message'
|
||||||
import {
|
import {
|
||||||
InputNumber,
|
InputNumber,
|
||||||
Button,
|
Button,
|
||||||
message,
|
|
||||||
} from 'ant-design-vue'
|
} from 'ant-design-vue'
|
||||||
|
|
||||||
interface InsertData {
|
interface InsertData {
|
||||||
|
@ -85,9 +85,9 @@ import HotkeyDoc from './HotkeyDoc.vue'
|
|||||||
import FileInput from '@/components/FileInput.vue'
|
import FileInput from '@/components/FileInput.vue'
|
||||||
import FullscreenSpin from '@/components/FullscreenSpin.vue'
|
import FullscreenSpin from '@/components/FullscreenSpin.vue'
|
||||||
import Drawer from '@/components/Drawer.vue'
|
import Drawer from '@/components/Drawer.vue'
|
||||||
|
import Input from '@/components/Input.vue'
|
||||||
import {
|
import {
|
||||||
Popover,
|
Popover,
|
||||||
Input,
|
|
||||||
} from 'ant-design-vue'
|
} from 'ant-design-vue'
|
||||||
|
|
||||||
const mainStore = useMainStore()
|
const mainStore = useMainStore()
|
||||||
@ -179,7 +179,7 @@ const setDialogForExport = (type: DialogForExportTypes) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.title {
|
.title {
|
||||||
height: 30px;
|
height: 32px;
|
||||||
margin-left: 2px;
|
margin-left: 2px;
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
|
|
||||||
@ -193,8 +193,8 @@ const setDialogForExport = (type: DialogForExportTypes) => {
|
|||||||
.title-text {
|
.title-text {
|
||||||
min-width: 20px;
|
min-width: 20px;
|
||||||
max-width: 400px;
|
max-width: 400px;
|
||||||
line-height: 30px;
|
line-height: 32px;
|
||||||
padding: 0 6px;
|
padding: 0 8px;
|
||||||
border-radius: $borderRadius;
|
border-radius: $borderRadius;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<div class="content" :class="type" @mousedown.stop>
|
<div class="content" :class="type" @mousedown.stop>
|
||||||
<Input class="input" v-model:value="searchWord" placeholder="输入查找内容" @keydown.enter="searchNext()" ref="searchInpRef">
|
<Input class="input" v-model:value="searchWord" placeholder="输入查找内容" @enter="searchNext()" ref="searchInpRef">
|
||||||
<template #suffix>
|
<template #suffix>
|
||||||
<span class="count">{{searchIndex + 1}}/{{searchResults.length}}</span>
|
<span class="count">{{searchIndex + 1}}/{{searchResults.length}}</span>
|
||||||
<Divider type="vertical" />
|
<Divider type="vertical" />
|
||||||
@ -21,7 +21,7 @@
|
|||||||
<IconRight class="next-btn right" @click="searchNext()" />
|
<IconRight class="next-btn right" @click="searchNext()" />
|
||||||
</template>
|
</template>
|
||||||
</Input>
|
</Input>
|
||||||
<Input class="input" v-model:value="replaceWord" placeholder="输入替换内容" @keydown.enter="replace()" v-if="type === 'replace'"></Input>
|
<Input class="input" v-model:value="replaceWord" placeholder="输入替换内容" @enter="replace()" v-if="type === 'replace'"></Input>
|
||||||
<div class="footer" v-if="type === 'replace'">
|
<div class="footer" v-if="type === 'replace'">
|
||||||
<Button :disabled="!searchWord" style="margin-left: 5px;" @click="replace()">替换</Button>
|
<Button :disabled="!searchWord" style="margin-left: 5px;" @click="replace()">替换</Button>
|
||||||
<Button :disabled="!searchWord" type="primary" style="margin-left: 5px;" @click="replaceAll()">全部替换</Button>
|
<Button :disabled="!searchWord" type="primary" style="margin-left: 5px;" @click="replaceAll()">全部替换</Button>
|
||||||
@ -37,9 +37,9 @@ import useSearch from '@/hooks/useSearch'
|
|||||||
import MoveablePanel from '@/components/MoveablePanel.vue'
|
import MoveablePanel from '@/components/MoveablePanel.vue'
|
||||||
import Tabs from '@/components/Tabs.vue'
|
import Tabs from '@/components/Tabs.vue'
|
||||||
import Divider from '@/components/Divider.vue'
|
import Divider from '@/components/Divider.vue'
|
||||||
|
import Input from '@/components/Input.vue'
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
Input,
|
|
||||||
} from 'ant-design-vue'
|
} from 'ant-design-vue'
|
||||||
|
|
||||||
type TypeKey = 'search' | 'replace'
|
type TypeKey = 'search' | 'replace'
|
||||||
@ -97,6 +97,7 @@ watch(type, () => {
|
|||||||
}
|
}
|
||||||
.count {
|
.count {
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
|
margin-right: 8px;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
}
|
}
|
||||||
.next-btn {
|
.next-btn {
|
||||||
@ -124,7 +125,7 @@ watch(type, () => {
|
|||||||
height: 32px;
|
height: 32px;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 8px;
|
top: 8px;
|
||||||
right: 0;
|
right: 3px;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
@ -309,6 +309,7 @@ import emitter, { EmitterEvents, type RichTextAction } from '@/utils/emitter'
|
|||||||
import { WEB_FONTS } from '@/configs/font'
|
import { WEB_FONTS } from '@/configs/font'
|
||||||
import useHistorySnapshot from '@/hooks/useHistorySnapshot'
|
import useHistorySnapshot from '@/hooks/useHistorySnapshot'
|
||||||
import useTextFormatPainter from '@/hooks/useTextFormatPainter'
|
import useTextFormatPainter from '@/hooks/useTextFormatPainter'
|
||||||
|
import message from '@/utils/message'
|
||||||
|
|
||||||
import ElementOpacity from '../common/ElementOpacity.vue'
|
import ElementOpacity from '../common/ElementOpacity.vue'
|
||||||
import ElementOutline from '../common/ElementOutline.vue'
|
import ElementOutline from '../common/ElementOutline.vue'
|
||||||
@ -319,17 +320,17 @@ import CheckboxButton from '@/components/CheckboxButton.vue'
|
|||||||
import CheckboxButtonGroup from '@/components/ButtonGroup.vue'
|
import CheckboxButtonGroup from '@/components/ButtonGroup.vue'
|
||||||
import ColorPicker from '@/components/ColorPicker/index.vue'
|
import ColorPicker from '@/components/ColorPicker/index.vue'
|
||||||
import Divider from '@/components/Divider.vue'
|
import Divider from '@/components/Divider.vue'
|
||||||
|
import Input from '@/components/Input.vue'
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
Popover,
|
Popover,
|
||||||
Select,
|
Select,
|
||||||
Radio,
|
Radio,
|
||||||
Input,
|
Input as AntInput,
|
||||||
message,
|
|
||||||
} from 'ant-design-vue'
|
} from 'ant-design-vue'
|
||||||
const { Group: RadioGroup, Button: RadioButton } = Radio
|
const { Group: RadioGroup, Button: RadioButton } = Radio
|
||||||
const { OptGroup: SelectOptGroup, Option: SelectOption } = Select
|
const { OptGroup: SelectOptGroup, Option: SelectOption } = Select
|
||||||
const InputGroup = Input.Group
|
const InputGroup = AntInput.Group
|
||||||
const ButtonGroup = Button.Group
|
const ButtonGroup = Button.Group
|
||||||
|
|
||||||
// 注意,存在一个未知原因的BUG,如果文本加粗后文本框高度增加,画布的可视区域定位会出现错误
|
// 注意,存在一个未知原因的BUG,如果文本加粗后文本框高度增加,画布的可视区域定位会出现错误
|
||||||
@ -491,10 +492,9 @@ const openLinkPopover = () => {
|
|||||||
linkPopoverVisible.value = true
|
linkPopoverVisible.value = true
|
||||||
}
|
}
|
||||||
const updateLink = (link?: string) => {
|
const updateLink = (link?: string) => {
|
||||||
if (link) {
|
|
||||||
const linkRegExp = /^(https?):\/\/[\w\-]+(\.[\w\-]+)+([\w\-.,@?^=%&:\/~+#]*[\w\-@?^=%&\/~+#])?$/
|
const linkRegExp = /^(https?):\/\/[\w\-]+(\.[\w\-]+)+([\w\-.,@?^=%&:\/~+#]*[\w\-@?^=%&\/~+#])?$/
|
||||||
if (!linkRegExp.test(link)) return message.error('不是正确的网页链接地址')
|
if (!link || !linkRegExp.test(link)) return message.error('不是正确的网页链接地址')
|
||||||
}
|
|
||||||
emitRichTextCommand('link', link)
|
emitRichTextCommand('link', link)
|
||||||
linkPopoverVisible.value = false
|
linkPopoverVisible.value = false
|
||||||
}
|
}
|
||||||
|
@ -23,8 +23,9 @@ import { useSlidesStore } from '@/store'
|
|||||||
import type { TurningMode } from '@/types/slides'
|
import type { TurningMode } from '@/types/slides'
|
||||||
import { SLIDE_ANIMATIONS } from '@/configs/animation'
|
import { SLIDE_ANIMATIONS } from '@/configs/animation'
|
||||||
import useHistorySnapshot from '@/hooks/useHistorySnapshot'
|
import useHistorySnapshot from '@/hooks/useHistorySnapshot'
|
||||||
|
import message from '@/utils/message'
|
||||||
|
|
||||||
import { Button, message } from 'ant-design-vue'
|
import { Button } from 'ant-design-vue'
|
||||||
|
|
||||||
const slidesStore = useSlidesStore()
|
const slidesStore = useSlidesStore()
|
||||||
const { slides, currentSlide } = storeToRefs(slidesStore)
|
const { slides, currentSlide } = storeToRefs(slidesStore)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user