future #16

Merged
袁涛 merged 2 commits from future into main 2025-11-04 11:23:03 +08:00
14 changed files with 2226 additions and 2515 deletions

View File

@@ -2,7 +2,7 @@
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<!-- 透明 -->
@@ -93,12 +93,13 @@
--confirmBg: rgba(0, 0, 0, 0.15);
--confirmBtnColor: #000000cc;
}
html {
background-color: var(--note-title);
}
body {
margin: 0;
padding: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
background-color: white;
background: url('/assets/icons/drawable-xxhdpi/note_setting_bg.png');
color: var(--text-primary);
/* 适配iPhone X及更新机型的刘海屏 */

View File

@@ -114,6 +114,12 @@ onUnmounted(() => {
position: relative;
overflow: hidden;
background-color: #f5f5f5; // 设置默认背景色,防止闪烁
touch-action: pan-y;
-webkit-touch-callout: none;
-webkit-user-select: none;
-ms-touch-action: none;
-ms-user-select: none;
user-select: none;
}
// 网络状态指示器
@@ -131,17 +137,17 @@ onUnmounted(() => {
.offline-indicator {
background-color: #ff6b6b;
padding: 8px 16px;
border-radius: 0 0 4px 4px;
font-size: 14px;
color: white;
padding: 0.5rem 1rem;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
border-radius: 0 0 0.25rem 0.25rem;
font-size: 0.875rem;
display: flex;
margin-right: 8px;
align-items: center;
box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.2);

View File

@@ -4,11 +4,23 @@
************************************************************/
html {
font-size: 16px;
font-size: 18px;
user-select: none;
-webkit-user-drag: none;
-webkit-tap-highlight-color: transparent;
touch-action: none;
touch-action: pan-y;
overflow: hidden;
}
/* 禁止页面整体滚动 */
body {
overflow: hidden;
position: fixed;
width: 100%;
height: 100%;
-webkit-overflow-scrolling: touch;
overscroll-behavior: none;
touch-action: pan-y;
}
body {

View File

@@ -210,7 +210,7 @@ const handleTitlePress = () => {
flex-direction: column;
align-items: flex-end;
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 {
display: flex;
justify-content: space-between;

View File

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

View File

@@ -27,12 +27,10 @@
<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>
</template>
<script setup>
import { computed, ref } from 'vue'
import { getRootFontSize } from '@/utils/sizeUtils'
const emit = defineEmits(['update:modelValue'])
const props = defineProps({
content: {
type: String,
@@ -71,7 +69,6 @@ const props = defineProps({
default: () => {},
},
})
// 滑动相关状态
const slideOffset = ref(0)
const startX = ref(0)
@@ -79,13 +76,11 @@ const startY = ref(0) // 记录起始Y坐标
const isSliding = ref(false)
const isSlided = ref(false) // 是否已经滑动到阈值
const isScrolling = ref(false) // 是否正在滚动
const formattedDate = computed(() => {
// 直接返回已经格式化的日期字符串
// 日期格式化已在父组件中完成
return props.date
})
// 处理显示内容过滤HTML标签并只显示第一行
// 用于在便签列表中显示便签的预览内容
const displayContent = computed(() => {
@@ -93,14 +88,11 @@ const displayContent = computed(() => {
let text = props.content.replace(/<[^>]*>/g, '')
// 处理换行符,统一为\n
text = text.replace(/\\n/g, '\n')
// 按换行符分割并获取第一行
const lines = text.split('\n')
// 返回第一行内容,如果为空则显示默认文本
return lines[0]?.trim() || '无内容'
})
// 计算删除按钮的样式
const deleteButtonStyle = computed(() => {
return {
@@ -108,10 +100,10 @@ const deleteButtonStyle = computed(() => {
pointerEvents: isSlided.value ? 'auto' : 'none',
}
})
// 滑动阈值(删除按钮宽度)
// 当滑动距离超过此值时,显示删除按钮
const SLIDE_THRESHOLD = 64 // 4rem 转换为 px
const scaleNum = getRootFontSize() / 16
const SLIDE_THRESHOLD = 64 * scaleNum
// 容器触摸事件处理函数
const handleContainerTouchStart = e => {
@@ -120,21 +112,18 @@ const handleContainerTouchStart = e => {
// 阻止父级滚动容器的滚动行为
e.stopImmediatePropagation()
}
const handleContainerTouchMove = e => {
// 阻止事件冒泡到父组件
e.stopPropagation()
// 阻止父级滚动容器的滚动行为
e.stopImmediatePropagation()
}
const handleContainerTouchEnd = e => {
// 阻止事件冒泡到父组件
e.stopPropagation()
// 阻止父级滚动容器的滚动行为
e.stopImmediatePropagation()
}
// 处理便签点击事件
// 只有在未滑动状态下才触发点击事件,避免与滑动操作冲突
const handlePress = () => {
@@ -146,7 +135,6 @@ const handlePress = () => {
resetSlideState()
}
}
// 处理星标切换事件
// 点击星标图标时调用父组件传递的回调函数
const handleStarToggle = () => {
@@ -154,7 +142,6 @@ const handleStarToggle = () => {
props.onStarToggle()
}
}
// 处理置顶切换事件
// 点击置顶图标时调用父组件传递的回调函数
const handleTopToggle = () => {
@@ -162,7 +149,6 @@ const handleTopToggle = () => {
props.onTopToggle()
}
}
// 处理删除事件
// 点击删除按钮时调用父组件传递的回调函数
const handleDelete = () => {
@@ -173,22 +159,18 @@ const handleDelete = () => {
isSliding.value = false
isSlided.value = false
}
// 重置滑动状态
const resetSlideState = () => {
slideOffset.value = 0
isSliding.value = false
isSlided.value = false
}
// 获取滑动状态
const getSlideState = () => {
return isSlided.value
}
// 暴露方法给父组件
defineExpose({ resetSlideState, getSlideState })
// 触摸开始事件处理函数
// 记录触摸开始时的X坐标用于计算滑动距离
const handleTouchStart = e => {
@@ -203,24 +185,20 @@ const handleTouchStart = e => {
isSlided.value = false
isScrolling.value = false // 重置滚动状态
}
// 触摸移动事件处理函数
// 根据手指移动距离计算便签条的水平偏移量
const handleTouchMove = e => {
if (!startX.value || !startY.value) return
const currentX = e.touches[0].clientX
const currentY = e.touches[0].clientY
const diffX = currentX - startX.value
const diffY = currentY - startY.value
// 如果已经确定是滚动,则不再处理
if (isScrolling.value) {
// 阻止事件冒泡到父组件,防止页面滚动时触发便签滑动
e.stopPropagation()
return
}
// 判断是滚动还是滑动操作
// 如果Y轴移动距离大于X轴移动距离则认为是滚动
if (Math.abs(diffY) > Math.abs(diffX)) {
@@ -229,22 +207,18 @@ const handleTouchMove = e => {
e.stopPropagation()
return
}
// 只处理右滑动(正值)
if (diffX > 0) {
// 阻止事件冒泡到父组件,防止页面滚动时触发便签滑动
e.stopPropagation()
// 阻止父级滚动容器的滚动行为
e.stopImmediatePropagation()
// 只有当滑动达到一定距离时才阻止页面滚动
if (diffX > 5) {
e.preventDefault() // 防止页面滚动
}
// 设置滑动状态
isSliding.value = true
// 应用阻尼效果,使超过阈值后的滑动更加困难
let offset = 0
if (diffX <= SLIDE_THRESHOLD) {
@@ -255,7 +229,6 @@ const handleTouchMove = e => {
const excess = diffX - SLIDE_THRESHOLD
offset = SLIDE_THRESHOLD + excess * 0.03 // 0.03 为阻尼系数
}
slideOffset.value = offset
isSlided.value = offset >= SLIDE_THRESHOLD
} else if (diffX < 0) {
@@ -263,22 +236,18 @@ const handleTouchMove = e => {
const offset = Math.max(0, slideOffset.value + diffX)
slideOffset.value = offset
isSlided.value = offset >= SLIDE_THRESHOLD
// 更新 startX 以确保连续滑动的正确性
startX.value = currentX
}
}
// 触摸结束事件处理函数
// 根据滑动距离决定便签条的最终位置
const handleTouchEnd = e => {
if (!startX.value) return
// 阻止事件冒泡到父组件,防止页面滚动时触发便签滑动
e?.stopPropagation()
// 阻止父级滚动容器的滚动行为
e?.stopImmediatePropagation()
// 如果滑动超过阈值,保持滑出状态;否则回弹
if (slideOffset.value >= SLIDE_THRESHOLD) {
// 保持滑出状态,显示删除按钮
@@ -290,14 +259,12 @@ const handleTouchEnd = e => {
isSliding.value = false
isSlided.value = false
}
// 重置起始位置和滚动状态
startX.value = 0
startY.value = 0
isScrolling.value = false
}
</script>
<style lang="less" scoped>
.mt-17-5 {
margin-top: -1rem;
@@ -334,9 +301,9 @@ const handleTouchEnd = e => {
background: linear-gradient(to bottom, #fffdf6, #f3eee4);
z-index: 2;
padding: 0.44rem 0.69rem 0.88rem 2.09rem;
box-shadow: 0 2px 2px 1px rgb(0 0 0 / 15%);
box-shadow: 0 0.125rem 0.125rem 0.0625rem rgb(0 0 0 / 15%);
transition: transform 0.2s ease-out;
border-radius: 3px;
border-radius: 0.1875rem;
&:before {
content: '';
width: 1.5rem;

File diff suppressed because it is too large Load Diff

View File

@@ -74,7 +74,7 @@ defineExpose({
padding: 0.25rem 0.5rem;
border-radius: 2rem;
background: #f6f9fa;
border: 1px solid #ccb8a3;
border: 0.0625rem solid #ccb8a3;
display: flex;
flex-direction: row;
align-items: center;

View File

@@ -33,7 +33,7 @@ defineProps({
overflow: hidden;
margin: 0 auto;
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;
}

View File

@@ -116,6 +116,7 @@ const setSearchQuery = value => {
.folder-page-container {
padding: 0.625rem;
background-color: var(--background);
touch-action: pan-y;
}
.search-container {

View File

@@ -438,9 +438,12 @@ onBeforeUnmount(async () => {
flex-direction: column;
height: 100vh;
background-color: var(--background);
overflow: hidden;
section {
width: 100%;
height: 100%;
overflow-y: auto;
-webkit-overflow-scrolling: touch;
}
}
.offline-banner {
@@ -451,24 +454,31 @@ onBeforeUnmount(async () => {
left: 0;
padding: 8px 16px;
right: 0;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
z-index: 10000;
background-color: #ff6b6b;
color: white;
font-size: 14px;
padding: 0.5rem 1rem;
text-align: center;
margin-right: 8px;
box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.2);
}
overflow-y: scroll;
.offline-content {
display: flex;
align-items: center;
justify-content: center;
font-size: 0.875rem;
font-weight: 500;

View File

@@ -395,21 +395,21 @@ const notes = computed(() => store.notes)
z-index: 10000;
background-color: #ff6b6b;
color: white;
padding: 8px 16px;
padding: 0.5rem 1rem;
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 {
display: flex;
align-items: center;
justify-content: center;
font-size: 14px;
font-size: 0.875rem;
font-weight: 500;
}
.offline-icon {
margin-right: 8px;
margin-right: 0.5rem;
}
.folder-list {
@@ -421,7 +421,7 @@ const notes = computed(() => store.notes)
background-color: var(--background-card);
border-radius: 0.5rem;
box-shadow: 0 0.125rem 0.25rem var(--shadow);
border: 1px solid #f0ece7;
border: 0.0625rem solid #f0ece7;
overflow: hidden;
}
@@ -447,6 +447,8 @@ const notes = computed(() => store.notes)
.notes-container {
flex: 1;
position: relative;
overflow: hidden;
touch-action: pan-y;
}
.notes-list {
@@ -466,7 +468,7 @@ const notes = computed(() => store.notes)
.note-list-leave-to {
transform: translateX(-30px);
opacity: 0;
transform: translateX(-1.875rem);
@@ -486,7 +488,7 @@ const notes = computed(() => store.notes)
.folder-slide-leave-active {
transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
transform: scale(0.8) translateY(-20px);
.folder-slide-enter-from {
opacity: 0;
@@ -501,6 +503,6 @@ const notes = computed(() => store.notes)
opacity: 1;
transform: scale(0.8) translateY(-20px);
transform: scale(1) translateY(0);
}

View File

@@ -115,16 +115,8 @@ const settings = computed(() => store.settings)
background: url('/assets/icons/drawable-xxhdpi/note_setting_bg.png');
width: 100%;
height: 100vh;
overflow-y: scroll;
.item-text-primary {
font-size: 1rem;
color: #8e8e8e;
}
.item-text-tertiary {
font-size: 0.9375rem;
color: #b4b4b4;
}
overflow-y: auto;
touch-action: pan-y;
-webkit-overflow-scrolling: touch;
}
</style>

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`;
}