优化 将项目中的px单位转换为rem和em单位以提高响应式设计的一致性

This commit is contained in:
yuantao
2025-11-03 18:29:26 +08:00
parent cb9488ec05
commit 80caa0712d
11 changed files with 969 additions and 1288 deletions

View File

@@ -134,20 +134,20 @@ onUnmounted(() => {
pointer-events: none; pointer-events: none;
} }
.offline-indicator { .offline-indicator {
background-color: #ff6b6b;
color: white; background-color: #ff6b6b;
padding: 8px 16px;
border-radius: 0 0 4px 4px; color: white;
font-size: 14px;
display: flex; padding: 0.5rem 1rem;
align-items: center;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); border-radius: 0 0 0.25rem 0.25rem;
pointer-events: auto;
} font-size: 0.875rem;
.offline-icon { display: flex;
margin-right: 8px;
align-items: center; align-items: center;
box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.2); box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.2);

View File

@@ -3,24 +3,24 @@
** 否则页面将无法正常显示 ** ** 否则页面将无法正常显示 **
************************************************************/ ************************************************************/
html { html {
font-size: 16px; font-size: 18px;
user-select: none; user-select: none;
-webkit-user-drag: none; -webkit-user-drag: none;
-webkit-tap-highlight-color: transparent; -webkit-tap-highlight-color: transparent;
touch-action: pan-y; touch-action: pan-y;
overflow: hidden; overflow: hidden;
} }
/* 禁止页面整体滚动 */ /* 禁止页面整体滚动 */
body { body {
overflow: hidden; overflow: hidden;
position: fixed; position: fixed;
width: 100%; width: 100%;
height: 100%; height: 100%;
-webkit-overflow-scrolling: touch; -webkit-overflow-scrolling: touch;
overscroll-behavior: none; overscroll-behavior: none;
touch-action: pan-y; touch-action: pan-y;
} }
body { body {

View File

@@ -1,257 +1,257 @@
<template> <template>
<div class="component"> <div class="component">
<div class="inner code-fun-flex-row code-fun-items-center"> <div class="inner code-fun-flex-row code-fun-items-center">
<!-- 左侧图标 --> <!-- 左侧图标 -->
<img class="left-icon" :src="leftIconSource" @click="handleLeftAction" /> <img class="left-icon" :src="leftIconSource" @click="handleLeftAction" />
<!-- 标题区域 --> <!-- 标题区域 -->
<div class="title-container"> <div class="title-container">
<span class="text" @click="handleTitlePress">{{ title }}</span> <span class="text" @click="handleTitlePress">{{ title }}</span>
<!-- 文件夹展开图标 --> <!-- 文件夹展开图标 -->
<img v-if="showFolderIcon" class="folder-icon" :src="folderExpanded ? '/assets/icons/drawable-xxhdpi/folder_title_arrow_pressed.png' : '/assets/icons/drawable-xxhdpi/folder_title_arrow_normal.png'" @click.stop="handleFolderToggle" /> <img v-if="showFolderIcon" class="folder-icon" :src="folderExpanded ? '/assets/icons/drawable-xxhdpi/folder_title_arrow_pressed.png' : '/assets/icons/drawable-xxhdpi/folder_title_arrow_normal.png'" @click.stop="handleFolderToggle" />
</div> </div>
<!-- 右侧操作按钮 --> <!-- 右侧操作按钮 -->
<!-- 新建便签 --> <!-- 新建便签 -->
<img v-if="actionIcon === 'create'" class="image_4" src="/assets/icons/drawable-xxhdpi/btn_create.png" @click="handleAction('create')" /> <img v-if="actionIcon === 'create'" class="image_4" src="/assets/icons/drawable-xxhdpi/btn_create.png" @click="handleAction('create')" />
<!-- 编辑模式 --> <!-- 编辑模式 -->
<div v-else-if="actionIcon === 'edit'" class="code-fun-flex-row code-fun-items-center right-group"> <div v-else-if="actionIcon === 'edit'" class="code-fun-flex-row code-fun-items-center right-group">
<!-- 插入图片 --> <!-- 插入图片 -->
<img class="image_4" src="/assets/icons/drawable-xxhdpi/btn_pic.png" @click="handleAction('insertImage')" /> <img class="image_4" src="/assets/icons/drawable-xxhdpi/btn_pic.png" @click="handleAction('insertImage')" />
<!-- 保存便签 --> <!-- 保存便签 -->
<img class="image_4" src="/assets/icons/drawable-xxhdpi/btn_save_notes.png" @click="handleAction('save')" /> <img class="image_4" src="/assets/icons/drawable-xxhdpi/btn_save_notes.png" @click="handleAction('save')" />
</div> </div>
<!-- 预览模式 --> <!-- 预览模式 -->
<div v-else-if="actionIcon === 'preview'" class="code-fun-flex-row code-fun-items-center right-group"> <div v-else-if="actionIcon === 'preview'" class="code-fun-flex-row code-fun-items-center right-group">
<!-- 删除便签 --> <!-- 删除便签 -->
<img <img
ref="deleteButtonRef" ref="deleteButtonRef"
class="image_4" class="image_4"
:src="deleteButtonFrame" :src="deleteButtonFrame"
@click="handleAction('delete')" @click="handleAction('delete')"
/> />
<!-- 分享便签 --> <!-- 分享便签 -->
<img class="image_4" src="/assets/icons/drawable-xxhdpi/btn_share_notes.png" @click="handleAction('share')" /> <img class="image_4" src="/assets/icons/drawable-xxhdpi/btn_share_notes.png" @click="handleAction('share')" />
</div> </div>
<!-- 占位符 --> <!-- 占位符 -->
<div v-else class="image_4-placeholder"></div> <div v-else class="image_4-placeholder"></div>
</div> </div>
</div> </div>
</template> </template>
<script setup> <script setup>
import { ref, computed, defineExpose } from 'vue' import { ref, computed, defineExpose } from 'vue'
const props = defineProps({ const props = defineProps({
title: { title: {
type: String, type: String,
default: '', default: '',
}, },
onBack: { onBack: {
type: Function, type: Function,
default: null, default: null,
}, },
onAction: { onAction: {
type: Function, type: Function,
default: null, default: null,
}, },
actionText: { actionText: {
type: String, type: String,
default: '', default: '',
}, },
actionIcon: { actionIcon: {
type: String, type: String,
default: '', default: '',
}, },
leftIcon: { leftIcon: {
type: String, type: String,
default: '', default: '',
}, },
leftType: { leftType: {
type: String, type: String,
default: 'back', default: 'back',
}, },
onLeftAction: { onLeftAction: {
type: Function, type: Function,
default: null, default: null,
}, },
onFolderToggle: { onFolderToggle: {
type: Function, type: Function,
default: null, default: null,
}, },
isFolderExpanded: { isFolderExpanded: {
type: Boolean, type: Boolean,
default: undefined, default: undefined,
}, },
onTitlePress: { onTitlePress: {
type: Function, type: Function,
default: null, default: null,
}, },
background: { background: {
type: String, type: String,
default: 'url(/assets/icons/drawable-xxhdpi/action_bar_default.png)', default: 'url(/assets/icons/drawable-xxhdpi/action_bar_default.png)',
}, },
color: { color: {
type: String, type: String,
default: 'white', default: 'white',
}, },
}) })
const localFolderExpanded = ref(false) const localFolderExpanded = ref(false)
const deleteButtonRef = ref(null) const deleteButtonRef = ref(null)
const deleteButtonFrame = ref('/assets/icons/drawable-xxhdpi/btn_delete_notes.png') const deleteButtonFrame = ref('/assets/icons/drawable-xxhdpi/btn_delete_notes.png')
const isDeleteAnimating = ref(false) const isDeleteAnimating = ref(false)
const folderExpanded = computed(() => { const folderExpanded = computed(() => {
// 优先使用父组件传递的isFolderExpanded状态否则使用本地状态 // 优先使用父组件传递的isFolderExpanded状态否则使用本地状态
return props.isFolderExpanded !== undefined ? props.isFolderExpanded : localFolderExpanded.value return props.isFolderExpanded !== undefined ? props.isFolderExpanded : localFolderExpanded.value
}) })
const showFolderIcon = computed(() => { const showFolderIcon = computed(() => {
// 只有当leftType为settings且有onFolderToggle回调时才显示文件夹图标 // 只有当leftType为settings且有onFolderToggle回调时才显示文件夹图标
return props.leftType === 'settings' && props.onFolderToggle return props.leftType === 'settings' && props.onFolderToggle
}) })
const leftIconSource = computed(() => { const leftIconSource = computed(() => {
// 根据leftType属性返回对应的图标路径 // 根据leftType属性返回对应的图标路径
if (props.leftType === 'settings') { if (props.leftType === 'settings') {
return '/assets/icons/drawable-xxhdpi/btn_settings.png' return '/assets/icons/drawable-xxhdpi/btn_settings.png'
} else { } else {
if (props.color !== 'white') { if (props.color !== 'white') {
return '/assets/icons/drawable-xxhdpi/btn_back_black.png' return '/assets/icons/drawable-xxhdpi/btn_back_black.png'
} else { } else {
return '/assets/icons/drawable-xxhdpi/btn_back.png' return '/assets/icons/drawable-xxhdpi/btn_back.png'
} }
} }
}) })
const handleFolderToggle = () => { const handleFolderToggle = () => {
// 切换文件夹展开状态 // 切换文件夹展开状态
if (props.isFolderExpanded === undefined) { if (props.isFolderExpanded === undefined) {
// 如果父组件没有传递isFolderExpanded则使用本地状态 // 如果父组件没有传递isFolderExpanded则使用本地状态
localFolderExpanded.value = !localFolderExpanded.value localFolderExpanded.value = !localFolderExpanded.value
} }
// 调用父组件传递的回调函数 // 调用父组件传递的回调函数
if (props.onFolderToggle) { if (props.onFolderToggle) {
props.onFolderToggle() props.onFolderToggle()
} }
} }
// 播放删除按钮动画(只使用存在的帧) // 播放删除按钮动画(只使用存在的帧)
const playDeleteAnimation = () => { const playDeleteAnimation = () => {
if (isDeleteAnimating.value) return if (isDeleteAnimating.value) return
isDeleteAnimating.value = true isDeleteAnimating.value = true
// 只使用存在的帧编号 // 只使用存在的帧编号
const frames = [1, 6, 9, 10, 13, 16, 19, 21, 23, 25, 26, 27, 28, 29, 30] const frames = [1, 6, 9, 10, 13, 16, 19, 21, 23, 25, 26, 27, 28, 29, 30]
let currentFrameIndex = 0 let currentFrameIndex = 0
const playFrame = () => { const playFrame = () => {
if (currentFrameIndex < frames.length) { if (currentFrameIndex < frames.length) {
// 格式化帧编号(补零) // 格式化帧编号(补零)
const frameNumber = frames[currentFrameIndex].toString().padStart(4, '0') const frameNumber = frames[currentFrameIndex].toString().padStart(4, '0')
deleteButtonFrame.value = `/assets/icons/drawable-xxhdpi/title_bar_del_btn_mov_${frameNumber}.png` deleteButtonFrame.value = `/assets/icons/drawable-xxhdpi/title_bar_del_btn_mov_${frameNumber}.png`
currentFrameIndex++ currentFrameIndex++
// 使用setTimeout控制动画播放速度 // 使用setTimeout控制动画播放速度
setTimeout(playFrame, 50) // 约20fps调整速度以适应帧数 setTimeout(playFrame, 50) // 约20fps调整速度以适应帧数
} else { } else {
// 动画播放完成,重置为默认图标 // 动画播放完成,重置为默认图标
setTimeout(() => { setTimeout(() => {
deleteButtonFrame.value = '/assets/icons/drawable-xxhdpi/btn_delete_notes.png' deleteButtonFrame.value = '/assets/icons/drawable-xxhdpi/btn_delete_notes.png'
isDeleteAnimating.value = false isDeleteAnimating.value = false
}, 100) }, 100)
} }
} }
// 开始播放动画 // 开始播放动画
playFrame() playFrame()
} }
// 暴露播放删除动画的方法给父组件 // 暴露播放删除动画的方法给父组件
defineExpose({ defineExpose({
playDeleteAnimation playDeleteAnimation
}) })
const handleLeftAction = () => { const handleLeftAction = () => {
// 处理左侧图标点击事件 // 处理左侧图标点击事件
if (props.onLeftAction) { if (props.onLeftAction) {
props.onLeftAction() props.onLeftAction()
} else if (props.leftType !== 'settings' && props.onBack) { } else if (props.leftType !== 'settings' && props.onBack) {
// 兼容旧版本的onBack属性 // 兼容旧版本的onBack属性
props.onBack() props.onBack()
} }
} }
const handleAction = actionType => { const handleAction = actionType => {
// 处理右侧操作按钮点击事件 // 处理右侧操作按钮点击事件
if (props.onAction) { if (props.onAction) {
props.onAction(actionType) props.onAction(actionType)
} }
} }
const handleTitlePress = () => { const handleTitlePress = () => {
// 处理标题点击事件 // 处理标题点击事件
if (props.onTitlePress) { if (props.onTitlePress) {
props.onTitlePress() props.onTitlePress()
} }
} }
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
.component { .component {
padding: 2.5rem 0.72rem 0.35rem; padding: 2.5rem 0.72rem 0.35rem;
background: v-bind(background); background: v-bind(background);
background-size: 100% 100%; background-size: 100% 100%;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: flex-end; align-items: flex-end;
position: relative; position: relative;
box-shadow: 0 0 30px 5px rgba(0, 0, 0, 0.2); box-shadow: 0 0 1.875rem 0.3125rem rgba(0, 0, 0, 0.2);
.inner { .inner {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
width: 100%; width: 100%;
} }
.left-icon, .left-icon,
.image_4 { .image_4 {
width: 1.9rem; width: 1.9rem;
height: 1.9rem; height: 1.9rem;
cursor: pointer; cursor: pointer;
} }
.right-group { .right-group {
gap: 0.6rem; gap: 0.6rem;
} }
.image_4-placeholder { .image_4-placeholder {
width: 1.9rem; width: 1.9rem;
height: 1.9rem; height: 1.9rem;
} }
.title-container { .title-container {
display: flex; display: flex;
align-items: center; align-items: center;
cursor: pointer; cursor: pointer;
flex: 1; flex: 1;
justify-content: center; justify-content: center;
.folder-icon { .folder-icon {
width: 0.8rem; width: 0.8rem;
height: 0.8rem; height: 0.8rem;
margin-left: 0.2rem; margin-left: 0.2rem;
cursor: pointer; cursor: pointer;
} }
.text { .text {
color: v-bind(color); color: v-bind(color);
font-size: 1.01rem; font-size: 1.01rem;
line-height: 1.01rem; line-height: 1.01rem;
letter-spacing: 0.05em; letter-spacing: 0.05em;
text-indent: 0.05em; text-indent: 0.05em;
} }
} }
} }
</style> </style>

View File

@@ -246,8 +246,8 @@ defineExpose({ show })
font-size: var(--confirmFontSize, 1rem); font-size: var(--confirmFontSize, 1rem);
max-width: 75vw; max-width: 75vw;
min-width: 20em; min-width: 20em;
box-shadow: 0px 35px 35px -10px rgba(0, 0, 0, 0.33); box-shadow: 0rem 2.1875rem 2.1875rem -0.625rem rgba(0, 0, 0, 0.33);
border-radius: 10px;
border-radius: 0.625rem; border-radius: 0.625rem;
position: relative; position: relative;
white-space: break-spaces; white-space: break-spaces;
@@ -288,13 +288,13 @@ defineExpose({ show })
.pd-input { .pd-input {
width: 100%; width: 100%;
padding: 0.8em; padding: 0.8em;
border: 1px solid var(--confirmBtnBorder, #f1f1f1); font-size: 1em;
border-radius: 4px; border: 0.0625rem solid var(--confirmBtnBorder, #f1f1f1);
border-radius: 0.25rem; border-radius: 0.25rem;
box-sizing: border-box; box-sizing: border-box;
outline: none; outline: none;
background: var(--confirmTheme, #fff); background: var(--confirmTheme, #fff);
box-shadow: 0px 0px 4px inset rgba(0, 0, 0, 0.12); color: var(--confirmColor, #636363);
box-shadow: 0rem 0rem 0.25rem inset rgba(0, 0, 0, 0.12); box-shadow: 0rem 0rem 0.25rem inset rgba(0, 0, 0, 0.12);
} }

View File

@@ -1,411 +1,378 @@
<template> <template>
<div class="code-fun-flex-row code-fun-justify-center code-fun-relative list-item_7" @touchstart="handleContainerTouchStart" @touchmove="handleContainerTouchMove" @touchend="handleContainerTouchEnd"> <div class="code-fun-flex-row code-fun-justify-center code-fun-relative list-item_7" @touchstart="handleContainerTouchStart" @touchmove="handleContainerTouchMove" @touchend="handleContainerTouchEnd">
<!-- 删除按钮 --> <!-- 删除按钮 -->
<button class="btn_delete" @click.stop="handleDelete" :style="deleteButtonStyle"> <button class="btn_delete" @click.stop="handleDelete" :style="deleteButtonStyle">
<span>删除</span> <span>删除</span>
</button> </button>
<!-- 便签条 --> <!-- 便签条 -->
<div class="code-fun-flex-col code-fun-relative section_17" @click="handlePress" @touchstart="handleTouchStart" @touchmove="handleTouchMove" @touchend="handleTouchEnd" :style="{ transform: `translateX(${slideOffset}px)` }"> <div class="code-fun-flex-col code-fun-relative section_17" @click="handlePress" @touchstart="handleTouchStart" @touchmove="handleTouchMove" @touchend="handleTouchEnd" :style="{ transform: `translateX(${slideOffset}px)` }">
<div class="code-fun-flex-row code-fun-justify-between"> <div class="code-fun-flex-row code-fun-justify-between">
<!-- 便签编辑时间 --> <!-- 便签编辑时间 -->
<span class="font_2 text_18">{{ formattedDate }}</span> <span class="font_2 text_18">{{ formattedDate }}</span>
<div class="code-fun-flex-row group_3"> <div class="code-fun-flex-row group_3">
<!-- 是否置顶状态&置顶按钮 --> <!-- 是否置顶状态&置顶按钮 -->
<img class="image_11 image_29" :src="isTop ? '/assets/icons/drawable-xxhdpi/icon_top_checked.png' : '/assets/icons/drawable-xxhdpi/icon_top_normal.png'" @click.stop="handleTopToggle" /> <img class="image_11 image_29" :src="isTop ? '/assets/icons/drawable-xxhdpi/icon_top_checked.png' : '/assets/icons/drawable-xxhdpi/icon_top_normal.png'" @click.stop="handleTopToggle" />
<!-- 是否收藏状态&收藏按钮 --> <!-- 是否收藏状态&收藏按钮 -->
<img class="image_26 ml-5" :src="isStarred ? '/assets/icons/drawable-xxhdpi/icon_detail_star_checked.png' : '/assets/icons/drawable-xxhdpi/icon_detail_star_unchecked.png'" @click.stop="handleStarToggle" /> <img class="image_26 ml-5" :src="isStarred ? '/assets/icons/drawable-xxhdpi/icon_detail_star_checked.png' : '/assets/icons/drawable-xxhdpi/icon_detail_star_unchecked.png'" @click.stop="handleStarToggle" />
</div> </div>
</div> </div>
<div class="code-fun-flex-row code-fun-justify-between mt-17-5"> <div class="code-fun-flex-row code-fun-justify-between mt-17-5">
<!-- 便签正文第一行 --> <!-- 便签正文第一行 -->
<span class="font_3 text_19">{{ displayContent }}</span> <span class="font_3 text_19">{{ displayContent }}</span>
<!-- 便签中是否存在图片 --> <!-- 便签中是否存在图片 -->
<img v-if="hasImage" class="image_28" src="/assets/icons/drawable-xxhdpi/list_item_image_icon.png" /> <img v-if="hasImage" class="image_28" src="/assets/icons/drawable-xxhdpi/list_item_image_icon.png" />
</div> </div>
</div> </div>
<!-- 便签夹未滑动状态 --> <!-- 便签夹未滑动状态 -->
<img class="image_27 pos_18" :src="isSliding ? '/assets/icons/drawable-xxhdpi/note_item_clip_up.png' : '/assets/icons/drawable-xxhdpi/note_item_clip_normal.png'" /> <img class="image_27 pos_18" :src="isSliding ? '/assets/icons/drawable-xxhdpi/note_item_clip_up.png' : '/assets/icons/drawable-xxhdpi/note_item_clip_normal.png'" />
</div> </div>
</template> </template>
<script setup>
<script setup> import { computed, ref } from 'vue'
import { computed, ref } from 'vue' import { getRootFontSize } from '@/utils/sizeUtils'
const emit = defineEmits(['update:modelValue'])
const emit = defineEmits(['update:modelValue']) const props = defineProps({
content: {
const props = defineProps({ type: String,
content: { required: true,
type: String, },
required: true, date: {
}, type: String,
date: { required: true,
type: String, },
required: true, isStarred: {
}, type: Boolean,
isStarred: { default: false,
type: Boolean, },
default: false, isTop: {
}, type: Boolean,
isTop: { default: false,
type: Boolean, },
default: false, hasImage: {
}, type: Boolean,
hasImage: { default: false,
type: Boolean, },
default: false, onPress: {
}, type: Function,
onPress: { default: () => {},
type: Function, },
default: () => {}, onStarToggle: {
}, type: Function,
onStarToggle: { default: () => {},
type: Function, },
default: () => {}, onTopToggle: {
}, type: Function,
onTopToggle: { default: () => {},
type: Function, },
default: () => {}, onDelete: {
}, type: Function,
onDelete: { default: () => {},
type: Function, },
default: () => {}, })
}, // 滑动相关状态
}) const slideOffset = ref(0)
const startX = ref(0)
// 滑动相关状态 const startY = ref(0) // 记录起始Y坐标
const slideOffset = ref(0) const isSliding = ref(false)
const startX = ref(0) const isSlided = ref(false) // 是否已经滑动到阈值
const startY = ref(0) // 记录起始Y坐标 const isScrolling = ref(false) // 是否正在滚动
const isSliding = ref(false) const formattedDate = computed(() => {
const isSlided = ref(false) // 是否已经滑动到阈值 // 直接返回已经格式化的日期字符串
const isScrolling = ref(false) // 是否正在滚动 // 日期格式化已在父组件中完成
return props.date
const formattedDate = computed(() => { })
// 直接返回已经格式化的日期字符串 // 处理显示内容过滤HTML标签并只显示第一行
// 日期格式化已在父组件中完成 // 用于在便签列表中显示便签的预览内容
return props.date const displayContent = computed(() => {
}) // 过滤HTML标签只保留纯文本内容
let text = props.content.replace(/<[^>]*>/g, '')
// 处理显示内容过滤HTML标签并只显示第一行 // 处理换行符,统一为\n
// 用于在便签列表中显示便签的预览内容 text = text.replace(/\\n/g, '\n')
const displayContent = computed(() => { // 按换行符分割并获取第一行
// 过滤HTML标签只保留纯文本内容 const lines = text.split('\n')
let text = props.content.replace(/<[^>]*>/g, '') // 返回第一行内容,如果为空则显示默认文本
// 处理换行符,统一为\n return lines[0]?.trim() || '无内容'
text = text.replace(/\\n/g, '\n') })
// 计算删除按钮的样式
// 按换行符分割并获取第一行 const deleteButtonStyle = computed(() => {
const lines = text.split('\n') return {
opacity: isSlided.value ? 1 : 0,
// 返回第一行内容,如果为空则显示默认文本 pointerEvents: isSlided.value ? 'auto' : 'none',
return lines[0]?.trim() || '无内容' }
}) })
// 滑动阈值(删除按钮宽度)
// 计算删除按钮的样式 // 当滑动距离超过此值时,显示删除按钮
const deleteButtonStyle = computed(() => { const scaleNum = getRootFontSize() / 16
return { const SLIDE_THRESHOLD = 64 * scaleNum
opacity: isSlided.value ? 1 : 0,
pointerEvents: isSlided.value ? 'auto' : 'none', // 容器触摸事件处理函数
} const handleContainerTouchStart = e => {
}) // 阻止事件冒泡到父组件
e.stopPropagation()
// 滑动阈值(删除按钮宽度) // 阻止父级滚动容器的滚动行为
// 当滑动距离超过此值时,显示删除按钮 e.stopImmediatePropagation()
const SLIDE_THRESHOLD = 64 // 4rem 转换为 px }
const handleContainerTouchMove = e => {
// 容器触摸事件处理函数 // 阻止事件冒泡到父组件
const handleContainerTouchStart = e => { e.stopPropagation()
// 阻止事件冒泡到父组件 // 阻止父级滚动容器的滚动行为
e.stopPropagation() e.stopImmediatePropagation()
// 阻止父级滚动容器的滚动行为 }
e.stopImmediatePropagation() const handleContainerTouchEnd = e => {
} // 阻止事件冒泡到父组件
e.stopPropagation()
const handleContainerTouchMove = e => { // 阻止父级滚动容器的滚动行为
// 阻止事件冒泡到父组件 e.stopImmediatePropagation()
e.stopPropagation() }
// 阻止父级滚动容器的滚动行为 // 处理便签点击事件
e.stopImmediatePropagation() // 只有在未滑动状态下才触发点击事件,避免与滑动操作冲突
} const handlePress = () => {
// 只有在未滑动状态下才触发点击事件
const handleContainerTouchEnd = e => { if (slideOffset.value === 0 && props.onPress) {
// 阻止事件冒泡到父组件 props.onPress()
e.stopPropagation() } else if (slideOffset.value !== 0) {
// 阻止父级滚动容器的滚动行为 // 如果当前处于滑动状态,重置滑动状态(收回便签条)
e.stopImmediatePropagation() resetSlideState()
} }
}
// 处理便签点击事件 // 处理星标切换事件
// 只有在未滑动状态下才触发点击事件,避免与滑动操作冲突 // 点击星标图标时调用父组件传递的回调函数
const handlePress = () => { const handleStarToggle = () => {
// 只有在未滑动状态下才触发点击事件 if (props.onStarToggle) {
if (slideOffset.value === 0 && props.onPress) { props.onStarToggle()
props.onPress() }
} else if (slideOffset.value !== 0) { }
// 如果当前处于滑动状态,重置滑动状态(收回便签条) // 处理置顶切换事件
resetSlideState() // 点击置顶图标时调用父组件传递的回调函数
} const handleTopToggle = () => {
} if (props.onTopToggle) {
props.onTopToggle()
// 处理星标切换事件 }
// 点击星标图标时调用父组件传递的回调函数 }
const handleStarToggle = () => { // 处理删除事件
if (props.onStarToggle) { // 点击删除按钮时调用父组件传递的回调函数
props.onStarToggle() const handleDelete = () => {
} // 阻止事件冒泡,避免触发便签条的点击事件
} props.onDelete()
// 重置滑动状态
// 处理置顶切换事件 slideOffset.value = 0
// 点击置顶图标时调用父组件传递的回调函数 isSliding.value = false
const handleTopToggle = () => { isSlided.value = false
if (props.onTopToggle) { }
props.onTopToggle() // 重置滑动状态
} const resetSlideState = () => {
} slideOffset.value = 0
isSliding.value = false
// 处理删除事件 isSlided.value = false
// 点击删除按钮时调用父组件传递的回调函数 }
const handleDelete = () => { // 获取滑动状态
// 阻止事件冒泡,避免触发便签条的点击事件 const getSlideState = () => {
props.onDelete() return isSlided.value
// 重置滑动状态 }
slideOffset.value = 0 // 暴露方法给父组件
isSliding.value = false defineExpose({ resetSlideState, getSlideState })
isSlided.value = false // 触摸开始事件处理函数
} // 记录触摸开始时的X坐标用于计算滑动距离
const handleTouchStart = e => {
// 重置滑动状态 // 阻止事件冒泡到父组件,防止页面滚动时触发便签滑动
const resetSlideState = () => { e.stopPropagation()
slideOffset.value = 0 // 阻止父级滚动容器的滚动行为
isSliding.value = false e.stopImmediatePropagation()
isSlided.value = false // 重置滑动状态
} startX.value = e.touches[0].clientX
startY.value = e.touches[0].clientY // 记录起始Y坐标
// 获取滑动状态 isSliding.value = false
const getSlideState = () => { isSlided.value = false
return isSlided.value isScrolling.value = false // 重置滚动状态
} }
// 触摸移动事件处理函数
// 暴露方法给父组件 // 根据手指移动距离计算便签条的水平偏移量
defineExpose({ resetSlideState, getSlideState }) const handleTouchMove = e => {
if (!startX.value || !startY.value) return
// 触摸开始事件处理函数 const currentX = e.touches[0].clientX
// 记录触摸开始时的X坐标用于计算滑动距离 const currentY = e.touches[0].clientY
const handleTouchStart = e => { const diffX = currentX - startX.value
// 阻止事件冒泡到父组件,防止页面滚动时触发便签滑动 const diffY = currentY - startY.value
e.stopPropagation() // 如果已经确定是滚动,则不再处理
// 阻止父级滚动容器的滚动行为 if (isScrolling.value) {
e.stopImmediatePropagation() // 阻止事件冒泡到父组件,防止页面滚动时触发便签滑动
// 重置滑动状态 e.stopPropagation()
startX.value = e.touches[0].clientX return
startY.value = e.touches[0].clientY // 记录起始Y坐标 }
isSliding.value = false // 判断是滚动还是滑动操作
isSlided.value = false // 如果Y轴移动距离大于X轴移动距离则认为是滚动
isScrolling.value = false // 重置滚动状态 if (Math.abs(diffY) > Math.abs(diffX)) {
} isScrolling.value = true
// 阻止事件冒泡到父组件,防止页面滚动时触发便签滑动
// 触摸移动事件处理函数 e.stopPropagation()
// 根据手指移动距离计算便签条的水平偏移量 return
const handleTouchMove = e => { }
if (!startX.value || !startY.value) return // 只处理右滑动(正值)
if (diffX > 0) {
const currentX = e.touches[0].clientX // 阻止事件冒泡到父组件,防止页面滚动时触发便签滑动
const currentY = e.touches[0].clientY e.stopPropagation()
const diffX = currentX - startX.value // 阻止父级滚动容器的滚动行为
const diffY = currentY - startY.value e.stopImmediatePropagation()
// 只有当滑动达到一定距离时才阻止页面滚动
// 如果已经确定是滚动,则不再处理 if (diffX > 5) {
if (isScrolling.value) { e.preventDefault() // 防止页面滚动
// 阻止事件冒泡到父组件,防止页面滚动时触发便签滑动 }
e.stopPropagation() // 设置滑动状态
return isSliding.value = true
} // 应用阻尼效果,使超过阈值后的滑动更加困难
let offset = 0
// 判断是滚动还是滑动操作 if (diffX <= SLIDE_THRESHOLD) {
// 如果Y轴移动距离大于X轴移动距离则认为是滚 // 线性滑动,在阈值内正常滑
if (Math.abs(diffY) > Math.abs(diffX)) { offset = diffX
isScrolling.value = true } else {
// 阻止事件冒泡到父组件,防止页面滚动时触发便签滑动 // 超过阈值后应用阻尼效果,增加滑动阻力
e.stopPropagation() const excess = diffX - SLIDE_THRESHOLD
return offset = SLIDE_THRESHOLD + excess * 0.03 // 0.03 为阻尼系数
} }
slideOffset.value = offset
// 只处理右滑动(正值) isSlided.value = offset >= SLIDE_THRESHOLD
if (diffX > 0) { } else if (diffX < 0) {
// 阻止事件冒泡到父组件,防止页面滚动时触发便签滑动 // 左滑动,将便签条移回原位
e.stopPropagation() const offset = Math.max(0, slideOffset.value + diffX)
// 阻止父级滚动容器的滚动行为 slideOffset.value = offset
e.stopImmediatePropagation() isSlided.value = offset >= SLIDE_THRESHOLD
// 更新 startX 以确保连续滑动的正确性
// 只有当滑动达到一定距离时才阻止页面滚动 startX.value = currentX
if (diffX > 5) { }
e.preventDefault() // 防止页面滚动 }
} // 触摸结束事件处理函数
// 根据滑动距离决定便签条的最终位置
// 设置滑动状态 const handleTouchEnd = e => {
isSliding.value = true if (!startX.value) return
// 阻止事件冒泡到父组件,防止页面滚动时触发便签滑动
// 应用阻尼效果,使超过阈值后的滑动更加困难 e?.stopPropagation()
let offset = 0 // 阻止父级滚动容器的滚动行为
if (diffX <= SLIDE_THRESHOLD) { e?.stopImmediatePropagation()
// 线性滑动,在阈值内正常滑动 // 如果滑动超过阈值,保持滑出状态;否则回弹
offset = diffX if (slideOffset.value >= SLIDE_THRESHOLD) {
} else { // 保持滑出状态,显示删除按钮
// 超过阈值后应用阻尼效果,增加滑动阻力 slideOffset.value = SLIDE_THRESHOLD
const excess = diffX - SLIDE_THRESHOLD isSlided.value = true
offset = SLIDE_THRESHOLD + excess * 0.03 // 0.03 为阻尼系数 } else {
} // 回弹到初始位置
slideOffset.value = 0
slideOffset.value = offset isSliding.value = false
isSlided.value = offset >= SLIDE_THRESHOLD isSlided.value = false
} else if (diffX < 0) { }
// 左滑动,将便签条移回原位 // 重置起始位置和滚动状态
const offset = Math.max(0, slideOffset.value + diffX) startX.value = 0
slideOffset.value = offset startY.value = 0
isSlided.value = offset >= SLIDE_THRESHOLD isScrolling.value = false
}
// 更新 startX 以确保连续滑动的正确性 </script>
startX.value = currentX <style lang="less" scoped>
} .mt-17-5 {
} margin-top: -1rem;
}
// 触摸结束事件处理函数 .btn_delete {
// 根据滑动距离决定便签条的最终位置 background: url(/assets/icons/drawable-xxhdpi/btn_slide_delete_normal.png);
const handleTouchEnd = e => { background-size: cover;
if (!startX.value) return width: 4rem;
height: 2rem;
// 阻止事件冒泡到父组件,防止页面滚动时触发便签滑动 position: absolute;
e?.stopPropagation() top: 50%;
// 阻止父级滚动容器的滚动行为 left: 1rem;
e?.stopImmediatePropagation() z-index: 1;
transform: translate(0, -50%);
// 如果滑动超过阈值,保持滑出状态;否则回弹 color: white;
if (slideOffset.value >= SLIDE_THRESHOLD) { text-align: right;
// 保持滑出状态,显示删除按钮 border: none;
slideOffset.value = SLIDE_THRESHOLD padding: 0;
isSlided.value = true transition: opacity 0.2s ease;
} else { span {
// 回弹到初始位置 margin-right: 0.7rem;
slideOffset.value = 0 font-size: 0.6rem;
isSliding.value = false display: block;
isSlided.value = false }
} }
.list-item_7 {
// 重置起始位置和滚动状态 width: 100%;
startX.value = 0 height: 3.16rem;
startY.value = 0 touch-action: pan-y; /* 只允许垂直滚动,禁止水平滑动 */
isScrolling.value = false .section_17 {
} box-sizing: border-box;
</script> width: 95%;
height: 100%;
<style lang="less" scoped> background: linear-gradient(to bottom, #fffdf6, #f3eee4);
.mt-17-5 { z-index: 2;
margin-top: -1rem; padding: 0.44rem 0.69rem 0.88rem 2.09rem;
} box-shadow: 0 0.125rem 0.125rem 0.0625rem rgb(0 0 0 / 15%);
.btn_delete { transition: transform 0.2s ease-out;
background: url(/assets/icons/drawable-xxhdpi/btn_slide_delete_normal.png); border-radius: 0.1875rem;
background-size: cover; &:before {
width: 4rem; content: '';
height: 2rem; width: 1.5rem;
position: absolute; height: 100%;
top: 50%; position: absolute;
left: 1rem; left: 0;
z-index: 1; top: 0;
transform: translate(0, -50%); background: linear-gradient(to bottom, #f9f5ee, #eee6dc);
color: white; }
text-align: right; .font_2 {
border: none; font-size: 0.71rem;
padding: 0; line-height: 0.71rem;
transition: opacity 0.2s ease; color: #c2bdb1;
span { }
margin-right: 0.7rem; .text_18 {
font-size: 0.6rem; margin-top: 0.061rem;
display: block; color: #c3beb4;
} }
} .group_3 {
.list-item_7 { margin-right: 0.19rem;
width: 100%; margin-bottom: 0.063rem;
height: 3.16rem; .image_11 {
touch-action: pan-y; /* 只允许垂直滚动,禁止水平滑动 */ width: 2.2rem;
.section_17 { height: 2.2rem;
box-sizing: border-box; object-fit: contain;
width: 95%; position: relative;
height: 100%; top: -0.15rem;
background: linear-gradient(to bottom, #fffdf6, #f3eee4); }
z-index: 2; .image_29 {
padding: 0.44rem 0.69rem 0.88rem 2.09rem; margin-top: 0.063rem;
box-shadow: 0 2px 2px 1px rgb(0 0 0 / 15%); }
transition: transform 0.2s ease-out; .image_26 {
border-radius: 3px; width: 1.2rem;
&:before { height: 1.2rem;
content: ''; }
width: 1.5rem; }
height: 100%; .font_3 {
position: absolute; font-size: 0.88rem;
left: 0; line-height: 0.88rem;
top: 0; }
background: linear-gradient(to bottom, #f9f5ee, #eee6dc); .text_19 {
} margin-bottom: 0.065rem;
.font_2 { color: #816d61;
font-size: 0.71rem; font-size: 0.9rem;
line-height: 0.71rem; line-height: 0.9rem;
color: #c2bdb1; word-break: break-all;
} text-overflow: ellipsis;
.text_18 { display: -webkit-box;
margin-top: 0.061rem; -webkit-box-orient: vertical;
color: #c3beb4; overflow: hidden;
} -webkit-line-clamp: 1;
.group_3 { }
margin-right: 0.19rem; .image_28 {
margin-bottom: 0.063rem; width: 1.06rem;
.image_11 { height: 0.91rem;
width: 2.2rem; }
height: 2.2rem; }
object-fit: contain; .image_27 {
position: relative; width: 1.7rem;
top: -0.15rem; height: 1.7rem;
} object-fit: cover;
.image_29 { }
margin-top: 0.063rem; .pos_18 {
} position: absolute;
.image_26 { left: 0;
width: 1.2rem; top: 50%;
height: 1.2rem; transform: translate(0, -50%);
} z-index: 3;
} transition: transform 0.3s ease-out;
.font_3 { }
font-size: 0.88rem; }
line-height: 0.88rem; </style>
}
.text_19 {
margin-bottom: 0.065rem;
color: #816d61;
font-size: 0.9rem;
line-height: 0.9rem;
word-break: break-all;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-box-orient: vertical;
overflow: hidden;
-webkit-line-clamp: 1;
}
.image_28 {
width: 1.06rem;
height: 0.91rem;
}
}
.image_27 {
width: 1.7rem;
height: 1.7rem;
object-fit: cover;
}
.pos_18 {
position: absolute;
left: 0;
top: 50%;
transform: translate(0, -50%);
z-index: 3;
transition: transform 0.3s ease-out;
}
}
</style>

File diff suppressed because it is too large Load Diff

View File

@@ -1,104 +1,104 @@
<template> <template>
<div class="code-fun-flex-col code-fun-justify-start section_3"> <div class="code-fun-flex-col code-fun-justify-start section_3">
<div class="view"> <div class="view">
<div class="image-wrapper"> <div class="image-wrapper">
<!-- 搜索图标 --> <!-- 搜索图标 -->
<img class="image_7" :src="`assets/icons/drawable-xxhdpi/search_bar_left_icon.png`" /> <img class="image_7" :src="`assets/icons/drawable-xxhdpi/search_bar_left_icon.png`" />
<!-- 搜索输入框 --> <!-- 搜索输入框 -->
<input ref="searchInput" type="input" placeholder="搜索便签..." :value="modelValue" @input="handleInput" @keydown.enter="handleSearch" @focus="handleFocus" @blur="handleBlur" /> <input ref="searchInput" type="input" placeholder="搜索便签..." :value="modelValue" @input="handleInput" @keydown.enter="handleSearch" @focus="handleFocus" @blur="handleBlur" />
<!-- 清除按钮 --> <!-- 清除按钮 -->
<img v-if="modelValue && modelValue.length > 0" class="clear-button" :src="`assets/icons/drawable-xxhdpi/search_clear_normal.png`" @click="handleClear" /> <img v-if="modelValue && modelValue.length > 0" class="clear-button" :src="`assets/icons/drawable-xxhdpi/search_clear_normal.png`" @click="handleClear" />
</div> </div>
</div> </div>
</div> </div>
</template> </template>
<script setup> <script setup>
import { ref } from 'vue' import { ref } from 'vue'
const props = defineProps({ const props = defineProps({
modelValue: { modelValue: {
type: String, type: String,
default: '', default: '',
}, },
}) })
const emit = defineEmits(['update:modelValue', 'search', 'clear', 'focus', 'blur']) const emit = defineEmits(['update:modelValue', 'search', 'clear', 'focus', 'blur'])
const searchInput = ref(null) const searchInput = ref(null)
const handleInput = event => { const handleInput = event => {
emit('update:modelValue', event.target.value) emit('update:modelValue', event.target.value)
} }
const handleSearch = event => { const handleSearch = event => {
emit('search', event.target.value) emit('search', event.target.value)
} }
const handleClear = () => { const handleClear = () => {
emit('update:modelValue', '') emit('update:modelValue', '')
emit('clear') emit('clear')
if (searchInput.value) { if (searchInput.value) {
searchInput.value.focus() searchInput.value.focus()
} }
} }
const handleFocus = event => { const handleFocus = event => {
emit('focus', event) emit('focus', event)
} }
const handleBlur = event => { const handleBlur = event => {
emit('blur', event) emit('blur', event)
} }
// 暴露方法给父组件 // 暴露方法给父组件
defineExpose({ defineExpose({
focus: () => { focus: () => {
if (searchInput.value) { if (searchInput.value) {
searchInput.value.focus() searchInput.value.focus()
} }
}, },
blur: () => { blur: () => {
if (searchInput.value) { if (searchInput.value) {
searchInput.value.blur() searchInput.value.blur()
} }
}, },
}) })
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
.section_3 { .section_3 {
.view { .view {
.image-wrapper { .image-wrapper {
position: relative; position: relative;
padding: 0.25rem 0.5rem; padding: 0.25rem 0.5rem;
border-radius: 2rem; border-radius: 2rem;
background: #f6f9fa; background: #f6f9fa;
border: 1px solid #ccb8a3; border: 0.0625rem solid #ccb8a3;
display: flex; display: flex;
flex-direction: row; flex-direction: row;
align-items: center; align-items: center;
.image_7, .image_7,
.clear-button { .clear-button {
width: 1.2rem; width: 1.2rem;
height: 1.2rem; height: 1.2rem;
object-fit: contain; object-fit: contain;
margin-right: 0.1rem; margin-right: 0.1rem;
} }
input { input {
flex: 1; flex: 1;
height: 1.2rem; height: 1.2rem;
line-height: 1.2rem; line-height: 1.2rem;
background: transparent; background: transparent;
border: none; border: none;
outline: none; outline: none;
font-size: 0.75rem; font-size: 0.75rem;
color: #333; color: #333;
padding: 0; padding: 0;
} }
} }
} }
} }
</style> </style>

View File

@@ -1,75 +1,75 @@
<template> <template>
<div class="setting-group"> <div class="setting-group">
<div class="section-header">{{ title }}</div> <div class="section-header">{{ title }}</div>
<div class="settings-section"> <div class="settings-section">
<slot></slot> <slot></slot>
</div> </div>
</div> </div>
</template> </template>
<script setup> <script setup>
defineProps({ defineProps({
title: { title: {
type: String, type: String,
required: true, required: true,
}, },
}) })
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
.setting-group { .setting-group {
.section-header { .section-header {
font-size: 0.75rem; font-size: 0.75rem;
color: rgb(95 95 95); color: rgb(95 95 95);
padding: 0.3125rem 0.5rem; padding: 0.3125rem 0.5rem;
width: 95%; width: 95%;
margin: 0.75rem auto 0 auto; margin: 0.75rem auto 0 auto;
box-sizing: border-box; box-sizing: border-box;
} }
.settings-section { .settings-section {
width: 95%; width: 95%;
border-radius: 0.625rem; border-radius: 0.625rem;
overflow: hidden; overflow: hidden;
margin: 0 auto; margin: 0 auto;
border: 1px solid var(--divider); border: 1px solid var(--divider);
box-shadow: 0 1.25rem 3.125rem 0px rgb(0 0 0 / 5%); box-shadow: 0 1.25rem 3.125rem 0rem rgb(0 0 0 / 5%);
/* 确保不会阻止事件传播 */ /* 确保不会阻止事件传播 */
pointer-events: auto; pointer-events: auto;
} }
} }
:global(.settings-item) { :global(.settings-item) {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
background: linear-gradient(to bottom, #fefdfe, #fcfbfb); background: linear-gradient(to bottom, #fefdfe, #fcfbfb);
padding: 0.875rem 1rem; padding: 0.875rem 1rem;
} }
:global(.settings-item-border) { :global(.settings-item-border) {
border-top: 1px solid var(--divider); border-top: 1px solid var(--divider);
border-bottom: 1px solid var(--divider); border-bottom: 1px solid var(--divider);
} }
:global(.settings-item-border:first-child) { :global(.settings-item-border:first-child) {
border: none; border: none;
} }
:global(.settings-item-border:last-child) { :global(.settings-item-border:last-child) {
border: none; border: none;
} }
:global(.settings-item-clickable) { :global(.settings-item-clickable) {
cursor: pointer; cursor: pointer;
} }
:global(.settings-item-clickable .item-text-primary) { :global(.settings-item-clickable .item-text-primary) {
flex: 1; flex: 1;
} }
:global(.settings-item-clickable) { :global(.settings-item-clickable) {
display: flex; display: flex;
align-items: center; align-items: center;
} }
</style> </style>

View File

@@ -446,27 +446,27 @@ onBeforeUnmount(async () => {
-webkit-overflow-scrolling: touch; -webkit-overflow-scrolling: touch;
} }
} }
.offline-banner { .offline-banner {
position: fixed;
top: 0; position: fixed;
left: 0;
right: 0; top: 0;
z-index: 10000;
background-color: #ff6b6b; left: 0;
color: white;
padding: 8px 16px; right: 0;
text-align: center;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); z-index: 10000;
}
.offline-content { background-color: #ff6b6b;
display: flex;
align-items: center; color: white;
justify-content: center;
font-size: 14px; padding: 0.5rem 1rem;
font-weight: 500;
} text-align: center;
.offline-icon {
margin-right: 8px; box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.2);
} }

View File

@@ -395,21 +395,21 @@ const notes = computed(() => store.notes)
z-index: 10000; z-index: 10000;
background-color: #ff6b6b; background-color: #ff6b6b;
color: white; color: white;
padding: 8px 16px; padding: 0.5rem 1rem;
text-align: center; text-align: center;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.2);
} }
.offline-content { .offline-content {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
font-size: 14px; font-size: 0.875rem;
font-weight: 500; font-weight: 500;
} }
.offline-icon { .offline-icon {
margin-right: 8px; margin-right: 0.5rem;
} }
.folder-list { .folder-list {
@@ -421,7 +421,7 @@ const notes = computed(() => store.notes)
background-color: var(--background-card); background-color: var(--background-card);
border-radius: 0.5rem; border-radius: 0.5rem;
box-shadow: 0 0.125rem 0.25rem var(--shadow); box-shadow: 0 0.125rem 0.25rem var(--shadow);
border: 1px solid #f0ece7; border: 0.0625rem solid #f0ece7;
overflow: hidden; overflow: hidden;
} }
@@ -466,9 +466,9 @@ const notes = computed(() => store.notes)
transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94); transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
} }
.note-list-leave-to { .note-list-leave-to {
opacity: 0;
transform: translateX(-30px); opacity: 0;
transform: translateX(-1.875rem); transform: translateX(-1.875rem);
@@ -486,23 +486,23 @@ const notes = computed(() => store.notes)
/* 文件夹列表动画 */ /* 文件夹列表动画 */
.folder-slide-enter-active, .folder-slide-enter-active,
.folder-slide-leave-active { .folder-slide-leave-active {
.folder-slide-enter-from { transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
opacity: 0; }
transform: scale(0.8) translateY(-20px);
} .folder-slide-enter-from {
.folder-slide-enter-to { opacity: 0;
opacity: 1;
transform: scale(1) translateY(0); transform: scale(0.8) translateY(-1.25rem);
}
}
.folder-slide-leave-from {
opacity: 1;
transform: scale(1) translateY(0);
} .folder-slide-enter-to {
.folder-slide-leave-to { opacity: 1;
opacity: 0;
transform: scale(0.8) translateY(-20px); transform: scale(1) translateY(0);
} }

29
src/utils/sizeUtils.js Normal file
View File

@@ -0,0 +1,29 @@
/**
* 获取根元素的字体大小(以像素为单位)
* @returns {number} 根元素的字体大小(像素)
*/
export function getRootFontSize() {
return parseFloat(getComputedStyle(document.documentElement).fontSize);
}
/**
* 将像素值转换为rem值
* @param {number} px - 像素值
* @param {number} [rootFontSize] - 根字体大小,如果不提供则自动获取
* @returns {number} rem值
*/
export function pxToRem(px, rootFontSize = null) {
const fontSize = rootFontSize || getRootFontSize();
return px / fontSize;
}
/**
* 将像素值转换为rem字符串带rem单位
* @param {number} px - 像素值
* @param {number} [rootFontSize] - 根字体大小,如果不提供则自动获取
* @returns {string} rem字符串
*/
export function pxToRemStr(px, rootFontSize = null) {
const remValue = pxToRem(px, rootFontSize);
return `${remValue}rem`;
}