新增 Modal组件输入框功能,支持文本输入和Promise返回值

This commit is contained in:
yuantao
2025-10-24 09:43:19 +08:00
parent 2eb7eb8618
commit 65a15341c9
7 changed files with 310 additions and 550 deletions

View File

@@ -13,19 +13,19 @@
</template>
<!-- 设置页面 -->
<transition
name="settings-slide"
v-show="isSettingsRoute"
appear>
<transition name="settings-slide" v-show="isSettingsRoute" appear>
<SettingsPage class="setting-page" />
</transition>
<Modal ref="modalRef" showInput />
</div>
</template>
<script setup>
import { ref, watch, computed } from 'vue'
import { ref, watch, computed, onMounted } from 'vue'
import { useRoute } from 'vue-router'
import '@/common/base.css'
import Modal from '@/components/Modal.vue'
// 导入页面组件
import NoteListPage from './pages/NoteListPage.vue'
@@ -33,6 +33,7 @@ import SettingsPage from './pages/SettingsPage.vue'
const route = useRoute()
const transitionName = ref('slide-left')
const modalRef = ref()
// 计算是否为设置页面路由
const isSettingsRoute = computed(() => {
@@ -53,15 +54,15 @@ watch(
transitionName.value = 'slide-right'
return
}
// 判断导航方向
const toDepth = toPath.split('/').length
const fromDepth = fromPath.split('/').length
// 如果是进入更深的页面(如从列表页进入编辑页),使用左滑动画
if (toDepth > fromDepth) {
transitionName.value = 'slide-left'
}
}
// 如果是返回上层页面(如从编辑页返回列表页),使用右滑动画
else if (toDepth < fromDepth) {
transitionName.value = 'slide-right'
@@ -72,8 +73,6 @@ watch(
}
}
)
// 无额外处理函数
</script>
<style lang="less" scoped>