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

@@ -1,126 +1,127 @@
<!DOCTYPE html>
<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="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<!-- 透明 -->
<meta name="apple-mobile-web-app-orientation" content="portrait" />
<!-- 纵向 -->
<title>锤子便签</title>
<style>
/* Smartisan Notes Color Scheme - Based on Original Design */
:root {
/* Primary colors - Original Smartisan Notes brown/gold palette */
--primary: #5c3c2a; /* Main brown color for UI elements */
--primary-dark: #4a3224; /* Darker shade of primary */
--primary-light: #f5f0e6; /* Light background tone */
/* Editor typography - Consistent font size and line height */
--editor-font-size: 1.4375rem; /* Base font size for editor */
--editor-line-height: 1.1; /* Line height for editor */
/* Background colors - Warm paper-like tones */
--background: #fbf7ed; /* Main app background - warm off-white */
--background-secondary: #f7f2e9; /* Slightly darker background */
--background-card: #ffffff; /* Pure white for cards/notes */
--search-bar-background: #f0f0f0; /* Search bar background - light gray */
/* Text colors - Brown/black tones for readability */
--text-primary: #5c3c2a; /* Main text color - dark brown */
--text-secondary: #6e482f; /* Secondary text - medium brown */
--text-tertiary: #9e836c; /* Tertiary text - light brown/gray */
--text-inverted: #ffffff; /* White text for dark backgrounds */
/* Accent colors - Smartisan's signature colors */
--accent-blue: #5c89f2; /* Blue for links/actions */
--accent-green: #97cc4e; /* Green for success/positive actions */
--accent-red: #e65c53; /* Red for errors/dangerous actions */
--accent-orange: #f0880d; /* Orange for warnings/highlights */
--accent-yellow: #ffffdd33; /* Yellow for starred items/highlights (updated to match original) */
/* Note specific colors */
--note-title: #5c3c2a; /* Note title color */
--note-content: #6e482f; /* Note content color */
--note-date: #705c3c2a; /* Date/time color */
--note-star: #ffffdd33; /* Star/favorite color (updated to match original) */
/* Folder colors */
--folder-name: #9b9b9b; /* Folder name color (60% black) */
--folder-count: #b4b4b4; /* Folder item count color (30% black) */
--folder-item-selected: #f5f5f5; /* Folder item selected background color */
/* Button colors - Based on Smartisan's button styles */
--button-primary: #5c3c2a; /* Primary button - brown */
--button-secondary: #97cc4e; /* Secondary button - green */
--button-danger: #e65c53; /* Danger button - red */
--button-disabled: #d4d4d5; /* Disabled button - light gray */
/* Status colors */
--success: #79ad31; /* Success - green */
--warning: #f0880d; /* Warning - orange */
--error: #e64746; /* Error - red */
--info: #5c89f2; /* Info - blue */
/* UI elements - Borders, dividers, shadows */
--border: #e5ddca; /* Light brown border */
--divider: #e5e5e5; /* Light gray divider */
--shadow: #00000014; /* Subtle shadow */
/* Transparency variants */
--black-05: #0000000d; /* 5% black */
--black-10: #0000001a; /* 10% black */
--black-14: #00000024; /* 14% black */
--black-20: #00000033; /* 20% black */
--black-30: #0000004d; /* 30% black */
--black-40: #00000066; /* 40% black */
--black-50: #00000080; /* 50% black */
--black-60: #00000099; /* 60% black */
--black-80: #000000cc; /* 80% black */
--black-90: #000000e6; /* 90% black */
--white-10: #ffffff1a; /* 10% white */
--white-20: #ffffff33; /* 20% white */
--white-30: #ffffff4d; /* 30% white */
--white-40: #ffffff66; /* 40% white */
--white-50: #ffffff80; /* 50% white */
--white-60: #ffffff99; /* 60% white */
--white-80: #ffffffcc; /* 80% white */
--white-90: #ffffffe6; /* 90% white */
--confirmFontSize: 0.8rem;
--confirmBg: rgba(0, 0, 0, 0.15);
--confirmBtnColor: #000000cc;
}
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及更新机型的刘海屏 */
padding-top: env(safe-area-inset-top);
padding-right: env(safe-area-inset-right);
padding-bottom: env(safe-area-inset-bottom);
padding-left: env(safe-area-inset-left);
}
#app {
height: 100vh;
overflow: hidden;
/* 适配iPhone X及更新机型的刘海屏 */
padding-top: env(safe-area-inset-top);
padding-right: env(safe-area-inset-right);
padding-bottom: env(safe-area-inset-bottom);
padding-left: env(safe-area-inset-left);
}
</style>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
</body>
</html>
<!DOCTYPE html>
<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, 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" />
<!-- 透明 -->
<meta name="apple-mobile-web-app-orientation" content="portrait" />
<!-- 纵向 -->
<title>锤子便签</title>
<style>
/* Smartisan Notes Color Scheme - Based on Original Design */
:root {
/* Primary colors - Original Smartisan Notes brown/gold palette */
--primary: #5c3c2a; /* Main brown color for UI elements */
--primary-dark: #4a3224; /* Darker shade of primary */
--primary-light: #f5f0e6; /* Light background tone */
/* Editor typography - Consistent font size and line height */
--editor-font-size: 1.4375rem; /* Base font size for editor */
--editor-line-height: 1.1; /* Line height for editor */
/* Background colors - Warm paper-like tones */
--background: #fbf7ed; /* Main app background - warm off-white */
--background-secondary: #f7f2e9; /* Slightly darker background */
--background-card: #ffffff; /* Pure white for cards/notes */
--search-bar-background: #f0f0f0; /* Search bar background - light gray */
/* Text colors - Brown/black tones for readability */
--text-primary: #5c3c2a; /* Main text color - dark brown */
--text-secondary: #6e482f; /* Secondary text - medium brown */
--text-tertiary: #9e836c; /* Tertiary text - light brown/gray */
--text-inverted: #ffffff; /* White text for dark backgrounds */
/* Accent colors - Smartisan's signature colors */
--accent-blue: #5c89f2; /* Blue for links/actions */
--accent-green: #97cc4e; /* Green for success/positive actions */
--accent-red: #e65c53; /* Red for errors/dangerous actions */
--accent-orange: #f0880d; /* Orange for warnings/highlights */
--accent-yellow: #ffffdd33; /* Yellow for starred items/highlights (updated to match original) */
/* Note specific colors */
--note-title: #5c3c2a; /* Note title color */
--note-content: #6e482f; /* Note content color */
--note-date: #705c3c2a; /* Date/time color */
--note-star: #ffffdd33; /* Star/favorite color (updated to match original) */
/* Folder colors */
--folder-name: #9b9b9b; /* Folder name color (60% black) */
--folder-count: #b4b4b4; /* Folder item count color (30% black) */
--folder-item-selected: #f5f5f5; /* Folder item selected background color */
/* Button colors - Based on Smartisan's button styles */
--button-primary: #5c3c2a; /* Primary button - brown */
--button-secondary: #97cc4e; /* Secondary button - green */
--button-danger: #e65c53; /* Danger button - red */
--button-disabled: #d4d4d5; /* Disabled button - light gray */
/* Status colors */
--success: #79ad31; /* Success - green */
--warning: #f0880d; /* Warning - orange */
--error: #e64746; /* Error - red */
--info: #5c89f2; /* Info - blue */
/* UI elements - Borders, dividers, shadows */
--border: #e5ddca; /* Light brown border */
--divider: #e5e5e5; /* Light gray divider */
--shadow: #00000014; /* Subtle shadow */
/* Transparency variants */
--black-05: #0000000d; /* 5% black */
--black-10: #0000001a; /* 10% black */
--black-14: #00000024; /* 14% black */
--black-20: #00000033; /* 20% black */
--black-30: #0000004d; /* 30% black */
--black-40: #00000066; /* 40% black */
--black-50: #00000080; /* 50% black */
--black-60: #00000099; /* 60% black */
--black-80: #000000cc; /* 80% black */
--black-90: #000000e6; /* 90% black */
--white-10: #ffffff1a; /* 10% white */
--white-20: #ffffff33; /* 20% white */
--white-30: #ffffff4d; /* 30% white */
--white-40: #ffffff66; /* 40% white */
--white-50: #ffffff80; /* 50% white */
--white-60: #ffffff99; /* 60% white */
--white-80: #ffffffcc; /* 80% white */
--white-90: #ffffffe6; /* 90% white */
--confirmFontSize: 0.8rem;
--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: url('/assets/icons/drawable-xxhdpi/note_setting_bg.png');
color: var(--text-primary);
/* 适配iPhone X及更新机型的刘海屏 */
padding-top: env(safe-area-inset-top);
padding-right: env(safe-area-inset-right);
padding-bottom: env(safe-area-inset-bottom);
padding-left: env(safe-area-inset-left);
}
#app {
height: 100vh;
overflow: hidden;
/* 适配iPhone X及更新机型的刘海屏 */
padding-top: env(safe-area-inset-top);
padding-right: env(safe-area-inset-right);
padding-bottom: env(safe-area-inset-bottom);
padding-left: env(safe-area-inset-left);
}
</style>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
</body>
</html>

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;
}
// 网络状态指示器
@@ -128,20 +134,20 @@ onUnmounted(() => {
pointer-events: none;
}
.offline-indicator {
background-color: #ff6b6b;
color: white;
padding: 8px 16px;
border-radius: 0 0 4px 4px;
font-size: 14px;
display: flex;
align-items: center;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
pointer-events: auto;
}
.offline-icon {
margin-right: 8px;
.offline-indicator {
background-color: #ff6b6b;
color: white;
padding: 0.5rem 1rem;
border-radius: 0 0 0.25rem 0.25rem;
font-size: 0.875rem;
display: flex;
align-items: center;
box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.2);

File diff suppressed because it is too large Load Diff

View File

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

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

@@ -1,411 +1,378 @@
<template>
<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">
<span>删除</span>
</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-row code-fun-justify-between">
<!-- 便签编辑时间 -->
<span class="font_2 text_18">{{ formattedDate }}</span>
<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_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 class="code-fun-flex-row code-fun-justify-between mt-17-5">
<!-- 便签正文第一行 -->
<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" />
</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'" />
</div>
</template>
<script setup>
import { computed, ref } from 'vue'
const emit = defineEmits(['update:modelValue'])
const props = defineProps({
content: {
type: String,
required: true,
},
date: {
type: String,
required: true,
},
isStarred: {
type: Boolean,
default: false,
},
isTop: {
type: Boolean,
default: false,
},
hasImage: {
type: Boolean,
default: false,
},
onPress: {
type: Function,
default: () => {},
},
onStarToggle: {
type: Function,
default: () => {},
},
onTopToggle: {
type: Function,
default: () => {},
},
onDelete: {
type: Function,
default: () => {},
},
})
// 滑动相关状态
const slideOffset = ref(0)
const startX = ref(0)
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(() => {
// 过滤HTML标签只保留纯文本内容
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 {
opacity: isSlided.value ? 1 : 0,
pointerEvents: isSlided.value ? 'auto' : 'none',
}
})
// 滑动阈值(删除按钮宽度)
// 当滑动距离超过此值时,显示删除按钮
const SLIDE_THRESHOLD = 64 // 4rem 转换为 px
// 容器触摸事件处理函数
const handleContainerTouchStart = e => {
// 阻止事件冒泡到父组件
e.stopPropagation()
// 阻止父级滚动容器的滚动行为
e.stopImmediatePropagation()
}
const handleContainerTouchMove = e => {
// 阻止事件冒泡到父组件
e.stopPropagation()
// 阻止父级滚动容器的滚动行为
e.stopImmediatePropagation()
}
const handleContainerTouchEnd = e => {
// 阻止事件冒泡到父组件
e.stopPropagation()
// 阻止父级滚动容器的滚动行为
e.stopImmediatePropagation()
}
// 处理便签点击事件
// 只有在未滑动状态下才触发点击事件,避免与滑动操作冲突
const handlePress = () => {
// 只有在未滑动状态下才触发点击事件
if (slideOffset.value === 0 && props.onPress) {
props.onPress()
} else if (slideOffset.value !== 0) {
// 如果当前处于滑动状态,重置滑动状态(收回便签条)
resetSlideState()
}
}
// 处理星标切换事件
// 点击星标图标时调用父组件传递的回调函数
const handleStarToggle = () => {
if (props.onStarToggle) {
props.onStarToggle()
}
}
// 处理置顶切换事件
// 点击置顶图标时调用父组件传递的回调函数
const handleTopToggle = () => {
if (props.onTopToggle) {
props.onTopToggle()
}
}
// 处理删除事件
// 点击删除按钮时调用父组件传递的回调函数
const handleDelete = () => {
// 阻止事件冒泡,避免触发便签条的点击事件
props.onDelete()
// 重置滑动状态
slideOffset.value = 0
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 => {
// 阻止事件冒泡到父组件,防止页面滚动时触发便签滑动
e.stopPropagation()
// 阻止父级滚动容器的滚动行为
e.stopImmediatePropagation()
// 重置滑动状态
startX.value = e.touches[0].clientX
startY.value = e.touches[0].clientY // 记录起始Y坐标
isSliding.value = false
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)) {
isScrolling.value = true
// 阻止事件冒泡到父组件,防止页面滚动时触发便签滑动
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) {
// 线性滑动,在阈值内正常滑动
offset = diffX
} else {
// 超过阈值后应用阻尼效果,增加滑动阻力
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) {
// 左滑动,将便签条移回原位
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) {
// 保持滑出状态,显示删除按钮
slideOffset.value = SLIDE_THRESHOLD
isSlided.value = true
} else {
// 回弹到初始位置
slideOffset.value = 0
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;
}
.btn_delete {
background: url(/assets/icons/drawable-xxhdpi/btn_slide_delete_normal.png);
background-size: cover;
width: 4rem;
height: 2rem;
position: absolute;
top: 50%;
left: 1rem;
z-index: 1;
transform: translate(0, -50%);
color: white;
text-align: right;
border: none;
padding: 0;
transition: opacity 0.2s ease;
span {
margin-right: 0.7rem;
font-size: 0.6rem;
display: block;
}
}
.list-item_7 {
width: 100%;
height: 3.16rem;
touch-action: pan-y; /* 只允许垂直滚动,禁止水平滑动 */
.section_17 {
box-sizing: border-box;
width: 95%;
height: 100%;
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%);
transition: transform 0.2s ease-out;
border-radius: 3px;
&:before {
content: '';
width: 1.5rem;
height: 100%;
position: absolute;
left: 0;
top: 0;
background: linear-gradient(to bottom, #f9f5ee, #eee6dc);
}
.font_2 {
font-size: 0.71rem;
line-height: 0.71rem;
color: #c2bdb1;
}
.text_18 {
margin-top: 0.061rem;
color: #c3beb4;
}
.group_3 {
margin-right: 0.19rem;
margin-bottom: 0.063rem;
.image_11 {
width: 2.2rem;
height: 2.2rem;
object-fit: contain;
position: relative;
top: -0.15rem;
}
.image_29 {
margin-top: 0.063rem;
}
.image_26 {
width: 1.2rem;
height: 1.2rem;
}
}
.font_3 {
font-size: 0.88rem;
line-height: 0.88rem;
}
.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>
<template>
<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">
<span>删除</span>
</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-row code-fun-justify-between">
<!-- 便签编辑时间 -->
<span class="font_2 text_18">{{ formattedDate }}</span>
<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_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 class="code-fun-flex-row code-fun-justify-between mt-17-5">
<!-- 便签正文第一行 -->
<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" />
</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'" />
</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,
required: true,
},
date: {
type: String,
required: true,
},
isStarred: {
type: Boolean,
default: false,
},
isTop: {
type: Boolean,
default: false,
},
hasImage: {
type: Boolean,
default: false,
},
onPress: {
type: Function,
default: () => {},
},
onStarToggle: {
type: Function,
default: () => {},
},
onTopToggle: {
type: Function,
default: () => {},
},
onDelete: {
type: Function,
default: () => {},
},
})
// 滑动相关状态
const slideOffset = ref(0)
const startX = ref(0)
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(() => {
// 过滤HTML标签只保留纯文本内容
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 {
opacity: isSlided.value ? 1 : 0,
pointerEvents: isSlided.value ? 'auto' : 'none',
}
})
// 滑动阈值(删除按钮宽度)
// 当滑动距离超过此值时,显示删除按钮
const scaleNum = getRootFontSize() / 16
const SLIDE_THRESHOLD = 64 * scaleNum
// 容器触摸事件处理函数
const handleContainerTouchStart = e => {
// 阻止事件冒泡到父组件
e.stopPropagation()
// 阻止父级滚动容器的滚动行为
e.stopImmediatePropagation()
}
const handleContainerTouchMove = e => {
// 阻止事件冒泡到父组件
e.stopPropagation()
// 阻止父级滚动容器的滚动行为
e.stopImmediatePropagation()
}
const handleContainerTouchEnd = e => {
// 阻止事件冒泡到父组件
e.stopPropagation()
// 阻止父级滚动容器的滚动行为
e.stopImmediatePropagation()
}
// 处理便签点击事件
// 只有在未滑动状态下才触发点击事件,避免与滑动操作冲突
const handlePress = () => {
// 只有在未滑动状态下才触发点击事件
if (slideOffset.value === 0 && props.onPress) {
props.onPress()
} else if (slideOffset.value !== 0) {
// 如果当前处于滑动状态,重置滑动状态(收回便签条)
resetSlideState()
}
}
// 处理星标切换事件
// 点击星标图标时调用父组件传递的回调函数
const handleStarToggle = () => {
if (props.onStarToggle) {
props.onStarToggle()
}
}
// 处理置顶切换事件
// 点击置顶图标时调用父组件传递的回调函数
const handleTopToggle = () => {
if (props.onTopToggle) {
props.onTopToggle()
}
}
// 处理删除事件
// 点击删除按钮时调用父组件传递的回调函数
const handleDelete = () => {
// 阻止事件冒泡,避免触发便签条的点击事件
props.onDelete()
// 重置滑动状态
slideOffset.value = 0
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 => {
// 阻止事件冒泡到父组件,防止页面滚动时触发便签滑动
e.stopPropagation()
// 阻止父级滚动容器的滚动行为
e.stopImmediatePropagation()
// 重置滑动状态
startX.value = e.touches[0].clientX
startY.value = e.touches[0].clientY // 记录起始Y坐标
isSliding.value = false
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)) {
isScrolling.value = true
// 阻止事件冒泡到父组件,防止页面滚动时触发便签滑动
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) {
// 线性滑动,在阈值内正常滑
offset = diffX
} else {
// 超过阈值后应用阻尼效果,增加滑动阻力
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) {
// 左滑动,将便签条移回原位
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) {
// 保持滑出状态,显示删除按钮
slideOffset.value = SLIDE_THRESHOLD
isSlided.value = true
} else {
// 回弹到初始位置
slideOffset.value = 0
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;
}
.btn_delete {
background: url(/assets/icons/drawable-xxhdpi/btn_slide_delete_normal.png);
background-size: cover;
width: 4rem;
height: 2rem;
position: absolute;
top: 50%;
left: 1rem;
z-index: 1;
transform: translate(0, -50%);
color: white;
text-align: right;
border: none;
padding: 0;
transition: opacity 0.2s ease;
span {
margin-right: 0.7rem;
font-size: 0.6rem;
display: block;
}
}
.list-item_7 {
width: 100%;
height: 3.16rem;
touch-action: pan-y; /* 只允许垂直滚动,禁止水平滑动 */
.section_17 {
box-sizing: border-box;
width: 95%;
height: 100%;
background: linear-gradient(to bottom, #fffdf6, #f3eee4);
z-index: 2;
padding: 0.44rem 0.69rem 0.88rem 2.09rem;
box-shadow: 0 0.125rem 0.125rem 0.0625rem rgb(0 0 0 / 15%);
transition: transform 0.2s ease-out;
border-radius: 0.1875rem;
&:before {
content: '';
width: 1.5rem;
height: 100%;
position: absolute;
left: 0;
top: 0;
background: linear-gradient(to bottom, #f9f5ee, #eee6dc);
}
.font_2 {
font-size: 0.71rem;
line-height: 0.71rem;
color: #c2bdb1;
}
.text_18 {
margin-top: 0.061rem;
color: #c3beb4;
}
.group_3 {
margin-right: 0.19rem;
margin-bottom: 0.063rem;
.image_11 {
width: 2.2rem;
height: 2.2rem;
object-fit: contain;
position: relative;
top: -0.15rem;
}
.image_29 {
margin-top: 0.063rem;
}
.image_26 {
width: 1.2rem;
height: 1.2rem;
}
}
.font_3 {
font-size: 0.88rem;
line-height: 0.88rem;
}
.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>
<div class="code-fun-flex-col code-fun-justify-start section_3">
<div class="view">
<div class="image-wrapper">
<!-- 搜索图标 -->
<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" />
<!-- 清除按钮 -->
<img v-if="modelValue && modelValue.length > 0" class="clear-button" :src="`assets/icons/drawable-xxhdpi/search_clear_normal.png`" @click="handleClear" />
</div>
</div>
</div>
</template>
<script setup>
import { ref } from 'vue'
const props = defineProps({
modelValue: {
type: String,
default: '',
},
})
const emit = defineEmits(['update:modelValue', 'search', 'clear', 'focus', 'blur'])
const searchInput = ref(null)
const handleInput = event => {
emit('update:modelValue', event.target.value)
}
const handleSearch = event => {
emit('search', event.target.value)
}
const handleClear = () => {
emit('update:modelValue', '')
emit('clear')
if (searchInput.value) {
searchInput.value.focus()
}
}
const handleFocus = event => {
emit('focus', event)
}
const handleBlur = event => {
emit('blur', event)
}
// 暴露方法给父组件
defineExpose({
focus: () => {
if (searchInput.value) {
searchInput.value.focus()
}
},
blur: () => {
if (searchInput.value) {
searchInput.value.blur()
}
},
})
</script>
<style lang="less" scoped>
.section_3 {
.view {
.image-wrapper {
position: relative;
padding: 0.25rem 0.5rem;
border-radius: 2rem;
background: #f6f9fa;
border: 1px solid #ccb8a3;
display: flex;
flex-direction: row;
align-items: center;
.image_7,
.clear-button {
width: 1.2rem;
height: 1.2rem;
object-fit: contain;
margin-right: 0.1rem;
}
input {
flex: 1;
height: 1.2rem;
line-height: 1.2rem;
background: transparent;
border: none;
outline: none;
font-size: 0.75rem;
color: #333;
padding: 0;
}
}
}
}
</style>
<template>
<div class="code-fun-flex-col code-fun-justify-start section_3">
<div class="view">
<div class="image-wrapper">
<!-- 搜索图标 -->
<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" />
<!-- 清除按钮 -->
<img v-if="modelValue && modelValue.length > 0" class="clear-button" :src="`assets/icons/drawable-xxhdpi/search_clear_normal.png`" @click="handleClear" />
</div>
</div>
</div>
</template>
<script setup>
import { ref } from 'vue'
const props = defineProps({
modelValue: {
type: String,
default: '',
},
})
const emit = defineEmits(['update:modelValue', 'search', 'clear', 'focus', 'blur'])
const searchInput = ref(null)
const handleInput = event => {
emit('update:modelValue', event.target.value)
}
const handleSearch = event => {
emit('search', event.target.value)
}
const handleClear = () => {
emit('update:modelValue', '')
emit('clear')
if (searchInput.value) {
searchInput.value.focus()
}
}
const handleFocus = event => {
emit('focus', event)
}
const handleBlur = event => {
emit('blur', event)
}
// 暴露方法给父组件
defineExpose({
focus: () => {
if (searchInput.value) {
searchInput.value.focus()
}
},
blur: () => {
if (searchInput.value) {
searchInput.value.blur()
}
},
})
</script>
<style lang="less" scoped>
.section_3 {
.view {
.image-wrapper {
position: relative;
padding: 0.25rem 0.5rem;
border-radius: 2rem;
background: #f6f9fa;
border: 0.0625rem solid #ccb8a3;
display: flex;
flex-direction: row;
align-items: center;
.image_7,
.clear-button {
width: 1.2rem;
height: 1.2rem;
object-fit: contain;
margin-right: 0.1rem;
}
input {
flex: 1;
height: 1.2rem;
line-height: 1.2rem;
background: transparent;
border: none;
outline: none;
font-size: 0.75rem;
color: #333;
padding: 0;
}
}
}
}
</style>

View File

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

View File

@@ -1,152 +1,153 @@
<template>
<ion-page>
<Header title="文件夹" :onBack="() => window.history.back()" />
<div class="folder-page-container">
<div class="search-container">
<ion-icon :icon="search" class="search-icon"></ion-icon>
<ion-input placeholder="搜索文件夹..." :value="searchQuery" @ionChange="e => setSearchQuery(e.detail.value)" class="search-input"></ion-input>
<ion-button v-if="searchQuery.length > 0" fill="clear" @click="() => setSearchQuery('')">
<ion-icon :icon="closeCircle" class="clear-icon"></ion-icon>
</ion-button>
</div>
</div>
<ion-content>
<ion-list class="folder-list">
<FolderManage
:allCount="allNotesCount"
:starredCount="starredNotesCount"
:trashCount="trashNotesCount"
:archiveCount="archiveCount"
:selectedFolder="selectedFolder"
:onAllClick="() => handleFolderPress('all')"
:onStarredClick="() => handleFolderPress('starred')"
:onTrashClick="() => handleFolderPress('trash')"
:onArchiveClick="() => handleFolderPress('archive')" />
</ion-list>
</ion-content>
</ion-page>
</template>
<script setup>
import { ref, computed, onMounted } from 'vue'
import { useRouter } from 'vue-router'
import { useAppStore } from '../stores/useAppStore'
import { search, closeCircle } from 'ionicons/icons'
import FolderManage from '../components/FolderManage.vue'
import Header from '../components/Header.vue'
const store = useAppStore()
const router = useRouter()
// 加载初始数据
onMounted(() => {
store.loadData()
})
const searchQuery = ref('')
const selectedFolder = ref('all')
// 计算每个文件夹中的便签数量
// 遍历所有自定义文件夹,统计每个文件夹中的便签数量
const foldersWithCount = computed(() => {
return store.folders.map(folder => {
const noteCount = store.notes.filter(note => note.folderId === folder.id).length
return {
...folder,
noteCount,
}
})
})
// 添加默认文件夹(全部便签、加星便签、回收站)到列表开头
// 计算全部便签数量
const allNotesCount = computed(() => store.notes.length)
// 计算加星便签数量
const starredNotesCount = computed(() => store.notes.filter(note => note.isStarred).length)
// 回收站便签数量(暂未实现完整功能)
const trashNotesCount = 0
// 归档便签数量(暂未实现完整功能)
const archiveCount = 0
// 合并默认文件夹和自定义文件夹
const foldersWithAllNotes = computed(() => {
return [
{ id: 'all', name: '全部便签', noteCount: allNotesCount.value, createdAt: new Date() },
{ id: 'starred', name: '加星便签', noteCount: starredNotesCount.value, createdAt: new Date() },
{ id: 'trash', name: '回收站', noteCount: trashNotesCount, createdAt: new Date() },
...foldersWithCount.value,
]
})
const handleFolderPress = folderId => {
// 更新选中的文件夹状态
selectedFolder.value = folderId
// 使用vue-router导航回便签列表页面并传递文件夹参数
router.push(`/notes?folder=${folderId}`)
}
// 处理添加文件夹按钮点击事件
// 在完整实现中,这里会打开文件夹创建对话框
const handleAddFolder = () => {
console.log('Add folder pressed')
}
// 处理搜索功能
// 在完整实现中,这里会根据搜索关键词过滤文件夹
const handleSearch = () => {
console.log('Search for:', searchQuery.value)
}
const handleBackPress = () => {
router.back()
}
// 根据搜索关键词过滤文件夹
// 将文件夹名称转换为小写进行模糊匹配
const filteredFolders = computed(() => {
return foldersWithAllNotes.value.filter(folder => folder.name.toLowerCase().includes(searchQuery.value.toLowerCase()))
})
const setSearchQuery = value => {
searchQuery.value = value
}
</script>
<style scoped>
.folder-page-container {
padding: 0.625rem;
background-color: var(--background);
}
.search-container {
display: flex;
align-items: center;
background-color: var(--search-bar-background);
border-radius: 0.5rem;
padding: 0 0.625rem;
}
.search-icon {
font-size: 1.25rem;
color: var(--text-tertiary);
}
.search-input {
--padding-start: 0.625rem;
--padding-end: 0.625rem;
flex: 1;
font-size: 1rem;
color: var(--text-primary);
}
.clear-icon {
font-size: 1.25rem;
color: var(--text-tertiary);
}
.folder-list {
background-color: var(--background);
padding: 0 1rem;
--ion-item-background: var(--background);
}
</style>
<template>
<ion-page>
<Header title="文件夹" :onBack="() => window.history.back()" />
<div class="folder-page-container">
<div class="search-container">
<ion-icon :icon="search" class="search-icon"></ion-icon>
<ion-input placeholder="搜索文件夹..." :value="searchQuery" @ionChange="e => setSearchQuery(e.detail.value)" class="search-input"></ion-input>
<ion-button v-if="searchQuery.length > 0" fill="clear" @click="() => setSearchQuery('')">
<ion-icon :icon="closeCircle" class="clear-icon"></ion-icon>
</ion-button>
</div>
</div>
<ion-content>
<ion-list class="folder-list">
<FolderManage
:allCount="allNotesCount"
:starredCount="starredNotesCount"
:trashCount="trashNotesCount"
:archiveCount="archiveCount"
:selectedFolder="selectedFolder"
:onAllClick="() => handleFolderPress('all')"
:onStarredClick="() => handleFolderPress('starred')"
:onTrashClick="() => handleFolderPress('trash')"
:onArchiveClick="() => handleFolderPress('archive')" />
</ion-list>
</ion-content>
</ion-page>
</template>
<script setup>
import { ref, computed, onMounted } from 'vue'
import { useRouter } from 'vue-router'
import { useAppStore } from '../stores/useAppStore'
import { search, closeCircle } from 'ionicons/icons'
import FolderManage from '../components/FolderManage.vue'
import Header from '../components/Header.vue'
const store = useAppStore()
const router = useRouter()
// 加载初始数据
onMounted(() => {
store.loadData()
})
const searchQuery = ref('')
const selectedFolder = ref('all')
// 计算每个文件夹中的便签数量
// 遍历所有自定义文件夹,统计每个文件夹中的便签数量
const foldersWithCount = computed(() => {
return store.folders.map(folder => {
const noteCount = store.notes.filter(note => note.folderId === folder.id).length
return {
...folder,
noteCount,
}
})
})
// 添加默认文件夹(全部便签、加星便签、回收站)到列表开头
// 计算全部便签数量
const allNotesCount = computed(() => store.notes.length)
// 计算加星便签数量
const starredNotesCount = computed(() => store.notes.filter(note => note.isStarred).length)
// 回收站便签数量(暂未实现完整功能)
const trashNotesCount = 0
// 归档便签数量(暂未实现完整功能)
const archiveCount = 0
// 合并默认文件夹和自定义文件夹
const foldersWithAllNotes = computed(() => {
return [
{ id: 'all', name: '全部便签', noteCount: allNotesCount.value, createdAt: new Date() },
{ id: 'starred', name: '加星便签', noteCount: starredNotesCount.value, createdAt: new Date() },
{ id: 'trash', name: '回收站', noteCount: trashNotesCount, createdAt: new Date() },
...foldersWithCount.value,
]
})
const handleFolderPress = folderId => {
// 更新选中的文件夹状态
selectedFolder.value = folderId
// 使用vue-router导航回便签列表页面并传递文件夹参数
router.push(`/notes?folder=${folderId}`)
}
// 处理添加文件夹按钮点击事件
// 在完整实现中,这里会打开文件夹创建对话框
const handleAddFolder = () => {
console.log('Add folder pressed')
}
// 处理搜索功能
// 在完整实现中,这里会根据搜索关键词过滤文件夹
const handleSearch = () => {
console.log('Search for:', searchQuery.value)
}
const handleBackPress = () => {
router.back()
}
// 根据搜索关键词过滤文件夹
// 将文件夹名称转换为小写进行模糊匹配
const filteredFolders = computed(() => {
return foldersWithAllNotes.value.filter(folder => folder.name.toLowerCase().includes(searchQuery.value.toLowerCase()))
})
const setSearchQuery = value => {
searchQuery.value = value
}
</script>
<style scoped>
.folder-page-container {
padding: 0.625rem;
background-color: var(--background);
touch-action: pan-y;
}
.search-container {
display: flex;
align-items: center;
background-color: var(--search-bar-background);
border-radius: 0.5rem;
padding: 0 0.625rem;
}
.search-icon {
font-size: 1.25rem;
color: var(--text-tertiary);
}
.search-input {
--padding-start: 0.625rem;
--padding-end: 0.625rem;
flex: 1;
font-size: 1rem;
color: var(--text-primary);
}
.clear-icon {
font-size: 1.25rem;
color: var(--text-tertiary);
}
.folder-list {
background-color: var(--background);
padding: 0 1rem;
--ion-item-background: var(--background);
}
</style>

View File

@@ -438,37 +438,47 @@ 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 {
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 10000;
background-color: #ff6b6b;
color: white;
padding: 8px 16px;
text-align: center;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}
.offline-content {
display: flex;
align-items: center;
justify-content: center;
font-size: 14px;
font-weight: 500;
}
.offline-icon {
margin-right: 8px;
.offline-banner {
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 10000;
background-color: #ff6b6b;
color: white;
padding: 0.5rem 1rem;
text-align: center;
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

@@ -67,440 +67,442 @@
</ion-content>
</div>
</ion-page>
</template>
<script setup>
import { ref, computed, onMounted, watch } from 'vue'
import { useRouter } from 'vue-router'
import { useAppStore } from '../stores/useAppStore'
import NoteItem from '../components/NoteItem.vue'
import Header from '../components/Header.vue'
import FolderManage from '../components/FolderManage.vue'
import SearchBar from '../components/Search.vue'
import { formatNoteListDate } from '../utils/dateUtils'
import { IonContent, IonPage } from '@ionic/vue'
const store = useAppStore()
const router = useRouter()
const noteItemRefs = ref({})
// 页面挂载时加载初始数据
onMounted(() => {
// 检查URL参数是否包含mock数据加载指令用于开发和演示
const urlParams = new URLSearchParams(window.location.search)
if (urlParams.get('mock') === 'true') {
// 加载预设的模拟数据
store.loadMockData()
} else {
// 从Storage加载用户数据
store.loadData()
}
})
const searchQuery = ref('')
const sortBy = ref('date') // 排序方式:'date'(按日期)、'title'(按标题)、'starred'(按星标)
const isFolderExpanded = ref(false) // 文件夹列表是否展开
const currentFolder = ref('all') // 当前选中的文件夹,默认是"全部便签"
const noteToDelete = ref(null)
// 计算加星便签数量(未删除的)
const starredNotesCount = computed(() => {
return store.notes.filter(note => note.isStarred && !note.isDeleted).length
})
// 计算回收站便签数量
const trashNotesCount = computed(() => {
return store.notes.filter(note => note.isDeleted).length
})
// 根据当前文件夹过滤便签
const filteredNotes = computed(() => {
// 预处理搜索查询,提高性能
const lowerCaseQuery = searchQuery.value?.toLowerCase().trim() || ''
return store.notes.filter(note => {
// 先检查搜索条件
const matchesSearch =
!lowerCaseQuery || (note.title && typeof note.title === 'string' && note.title.toLowerCase().includes(lowerCaseQuery)) || (note.content && typeof note.content === 'string' && note.content.toLowerCase().includes(lowerCaseQuery))
if (!matchesSearch) return false
// 再检查文件夹条件
switch (currentFolder.value) {
case 'all':
// 全部便签中不显示已删除的便签
return !note.isDeleted
case 'starred':
// 加星便签中只显示未删除的加星便签
return note.isStarred && !note.isDeleted
case 'trash':
// 回收站中只显示已删除的便签
return note.isDeleted
default:
// 自定义文件夹中不显示已删除的便签
return note.folderId === currentFolder.value && !note.isDeleted
}
})
})
// 过滤并排序便签列表
// 首先按置顶状态排序,置顶的便签排在前面
// 然后根据sortBy的值进行二次排序
const filteredAndSortedNotes = computed(() => {
return [...filteredNotes.value].sort((a, b) => {
// 置顶的便签排在前面
if (a.isTop && !b.isTop) return -1
if (!a.isTop && b.isTop) return 1
// 根据排序方式排序
switch (sortBy.value) {
case 'title':
// 按标题字母顺序排序
return a.title.localeCompare(b.title)
case 'starred':
// 按星标状态排序,加星的便签排在前面
return (b.isStarred ? 1 : 0) - (a.isStarred ? 1 : 0)
case 'date':
default:
// 按更新时间倒序排列(最新的在前)
return new Date(b.updatedAt).getTime() - new Date(a.updatedAt).getTime()
}
})
})
// 计算头部标题
const headerTitle = computed(() => {
switch (currentFolder.value) {
case 'all':
return '全部便签'
case 'starred':
return '加星便签'
case 'trash':
return '回收站'
default:
// 查找自定义文件夹的名称
const folder = store.folders.find(f => f.id === currentFolder.value)
return folder ? folder.name : '全部便签'
}
})
// 计算全部便签数量(未删除的)
const allNotesCount = computed(() => {
return store.notes.filter(note => !note.isDeleted).length
})
const handleNotePress = noteId => {
// 检查是否有便签条处于展开状态
let hasSlidedNote = false
Object.values(noteItemRefs.value).forEach(noteItem => {
// 注意isSlided是ref值需要通过.value访问
if (noteItem && noteItem.getSlideState()) {
hasSlidedNote = true
noteItem.resetSlideState()
}
})
// 如果有便签条处于展开状态,不跳转到编辑页面
if (hasSlidedNote) {
return
}
// 使用vue-router导航到编辑页面
router.push(`/editor/${noteId}`)
}
const handleAddNote = () => {
// 使用vue-router导航到新建便签页面
router.push('/editor')
}
// 处理Header组件的操作按钮点击事件
const handleHeaderAction = actionType => {
if (actionType === 'create') {
handleAddNote()
}
}
const handleStarToggle = async noteId => {
const note = store.notes.find(n => n.id === noteId)
if (note) {
try {
await store.updateNote(noteId, { isStarred: !note.isStarred })
console.log(`便签 ${noteId} 星标状态已更新`)
} catch (error) {
console.error('更新便签星标状态失败:', error)
}
}
}
const handleTopToggle = async noteId => {
const note = store.notes.find(n => n.id === noteId)
if (note) {
try {
await store.updateNote(noteId, { isTop: !note.isTop })
console.log(`便签 ${noteId} 置顶状态已更新`)
} catch (error) {
console.error('更新便签置顶状态失败:', error)
}
}
}
const confirmDeleteNote = async noteId => {
noteToDelete.value = noteId
if (noteToDelete.value) {
try {
// 检查当前是否在回收站中
if (currentFolder.value === 'trash') {
// 在回收站中删除便签,彻底删除
await store.permanentlyDeleteNote(noteToDelete.value)
console.log(`便签 ${noteToDelete.value} 已彻底删除`)
} else {
// 不在回收站中,将便签移至回收站
await store.moveToTrash(noteToDelete.value)
console.log(`便签 ${noteToDelete.value} 已移至回收站`)
}
noteToDelete.value = null
} catch (error) {
console.error('删除便签失败:', error)
}
}
}
// 处理排序方式切换
// 循环切换排序选项:按日期 -> 按标题 -> 按星标 -> 按日期...
const handleSort = () => {
const sortOptions = ['date', 'title', 'starred']
const currentIndex = sortOptions.indexOf(sortBy.value)
const nextIndex = (currentIndex + 1) % sortOptions.length
sortBy.value = sortOptions[nextIndex]
console.log('当前排序方式:', sortOptions[nextIndex])
}
const handleAllNotesClick = () => {
setCurrentFolder('all')
setIsFolderExpanded(false)
}
const handleStarredNotesClick = () => {
setCurrentFolder('starred')
setIsFolderExpanded(false)
}
const handleTrashNotesClick = () => {
setCurrentFolder('trash')
setIsFolderExpanded(false)
}
const handleFolderClick = folderId => {
setCurrentFolder(folderId)
setIsFolderExpanded(false)
}
const handleAddFolder = () => {
// 文件夹添加功能已在FolderManage组件中实现
// 这里只需关闭文件夹列表
setIsFolderExpanded(false)
}
const handleFolderPress = () => {
// 使用vue-router导航到文件夹页面
router.push('/folders')
}
const handleSettingsPress = () => {
// 使用vue-router导航到设置页面
router.push('/settings')
}
const handleFolderToggle = () => {
// 在实际应用中,这里会触发文件夹列表的展开/收起
isFolderExpanded.value = !isFolderExpanded.value
}
const handleSearch = query => {
// 搜索功能已在computed属性filteredAndSortedNotes中实现
console.log('搜索:', query)
// 可以在这里添加搜索统计或其它功能
if (query && query.length > 0) {
console.log(`找到 ${filteredAndSortedNotes.value.length} 个匹配的便签`)
}
}
const handleClearSearch = () => {
// 清除搜索已在v-model中处理
console.log('搜索已清除')
// 清除搜索后可以重置一些状态
setSearchQuery('')
}
const handleSearchFocus = () => {
console.log('搜索栏获得焦点')
// 可以在这里添加获得焦点时的特殊处理
}
const handleSearchBlur = () => {
console.log('搜索栏失去焦点')
// 可以在这里添加失去焦点时的特殊处理
}
// 防抖函数,用于避免频繁触发搜索
// 通过延迟执行函数,只在最后一次调用后执行
const debounceSearch = (func, delay) => {
let timeoutId
return function (...args) {
clearTimeout(timeoutId)
timeoutId = setTimeout(() => func.apply(this, args), delay)
}
}
// 防抖搜索处理函数延迟300ms执行搜索
const debouncedHandleSearch = debounceSearch(query => {
handleSearch(query)
}, 300)
// 改进的日期格式化函数
const formatDate = dateString => {
return formatNoteListDate(dateString)
}
const setCurrentFolder = folder => {
currentFolder.value = folder
}
const setIsFolderExpanded = expanded => {
isFolderExpanded.value = expanded
}
const setSearchQuery = query => {
searchQuery.value = query
}
const notes = computed(() => store.notes)
</script>
<style lang="less" scoped>
.container {
width: 100vw;
height: 100vh;
background: url(/assets/icons/drawable-xxhdpi/note_background.png);
background-size: cover;
}
.offline-banner {
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 10000;
background-color: #ff6b6b;
color: white;
padding: 8px 16px;
text-align: center;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}
.offline-content {
display: flex;
align-items: center;
justify-content: center;
font-size: 14px;
font-weight: 500;
}
.offline-icon {
margin-right: 8px;
}
.folder-list {
position: absolute;
top: 3.125rem;
left: 10%;
right: 10%;
z-index: 1000;
background-color: var(--background-card);
border-radius: 0.5rem;
box-shadow: 0 0.125rem 0.25rem var(--shadow);
border: 1px solid #f0ece7;
overflow: hidden;
}
.folder-overlay {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: transparent;
z-index: 99;
}
.content {
--background: transparent;
--padding-top: 4.5rem;
--padding-bottom: 2rem;
}
.search-container {
padding: 0.8rem 0.5rem;
}
.notes-container {
flex: 1;
position: relative;
}
.notes-list {
position: relative;
}
.note-item {
margin: 0.6rem 0;
transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
/* 便签列表动画 */
.note-list-enter-active,
.note-list-leave-active {
transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.note-list-leave-to {
opacity: 0;
transform: translateX(-30px);
}
.note-list-move {
transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.note-list-leave-active {
position: absolute;
width: calc(100% - 1rem);
}
/* 文件夹列表动画 */
.folder-slide-enter-active,
.folder-slide-leave-active {
transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.folder-slide-enter-from {
opacity: 0;
transform: scale(0.8) translateY(-20px);
}
.folder-slide-enter-to {
opacity: 1;
transform: scale(1) translateY(0);
}
.folder-slide-leave-from {
opacity: 1;
transform: scale(1) translateY(0);
}
.folder-slide-leave-to {
opacity: 0;
transform: scale(0.8) translateY(-20px);
}
</style>
</template>
<script setup>
import { ref, computed, onMounted, watch } from 'vue'
import { useRouter } from 'vue-router'
import { useAppStore } from '../stores/useAppStore'
import NoteItem from '../components/NoteItem.vue'
import Header from '../components/Header.vue'
import FolderManage from '../components/FolderManage.vue'
import SearchBar from '../components/Search.vue'
import { formatNoteListDate } from '../utils/dateUtils'
import { IonContent, IonPage } from '@ionic/vue'
const store = useAppStore()
const router = useRouter()
const noteItemRefs = ref({})
// 页面挂载时加载初始数据
onMounted(() => {
// 检查URL参数是否包含mock数据加载指令用于开发和演示
const urlParams = new URLSearchParams(window.location.search)
if (urlParams.get('mock') === 'true') {
// 加载预设的模拟数据
store.loadMockData()
} else {
// 从Storage加载用户数据
store.loadData()
}
})
const searchQuery = ref('')
const sortBy = ref('date') // 排序方式:'date'(按日期)、'title'(按标题)、'starred'(按星标)
const isFolderExpanded = ref(false) // 文件夹列表是否展开
const currentFolder = ref('all') // 当前选中的文件夹,默认是"全部便签"
const noteToDelete = ref(null)
// 计算加星便签数量(未删除的)
const starredNotesCount = computed(() => {
return store.notes.filter(note => note.isStarred && !note.isDeleted).length
})
// 计算回收站便签数量
const trashNotesCount = computed(() => {
return store.notes.filter(note => note.isDeleted).length
})
// 根据当前文件夹过滤便签
const filteredNotes = computed(() => {
// 预处理搜索查询,提高性能
const lowerCaseQuery = searchQuery.value?.toLowerCase().trim() || ''
return store.notes.filter(note => {
// 先检查搜索条件
const matchesSearch =
!lowerCaseQuery || (note.title && typeof note.title === 'string' && note.title.toLowerCase().includes(lowerCaseQuery)) || (note.content && typeof note.content === 'string' && note.content.toLowerCase().includes(lowerCaseQuery))
if (!matchesSearch) return false
// 再检查文件夹条件
switch (currentFolder.value) {
case 'all':
// 全部便签中不显示已删除的便签
return !note.isDeleted
case 'starred':
// 加星便签中只显示未删除的加星便签
return note.isStarred && !note.isDeleted
case 'trash':
// 回收站中只显示已删除的便签
return note.isDeleted
default:
// 自定义文件夹中不显示已删除的便签
return note.folderId === currentFolder.value && !note.isDeleted
}
})
})
// 过滤并排序便签列表
// 首先按置顶状态排序,置顶的便签排在前面
// 然后根据sortBy的值进行二次排序
const filteredAndSortedNotes = computed(() => {
return [...filteredNotes.value].sort((a, b) => {
// 置顶的便签排在前面
if (a.isTop && !b.isTop) return -1
if (!a.isTop && b.isTop) return 1
// 根据排序方式排序
switch (sortBy.value) {
case 'title':
// 按标题字母顺序排序
return a.title.localeCompare(b.title)
case 'starred':
// 按星标状态排序,加星的便签排在前面
return (b.isStarred ? 1 : 0) - (a.isStarred ? 1 : 0)
case 'date':
default:
// 按更新时间倒序排列(最新的在前)
return new Date(b.updatedAt).getTime() - new Date(a.updatedAt).getTime()
}
})
})
// 计算头部标题
const headerTitle = computed(() => {
switch (currentFolder.value) {
case 'all':
return '全部便签'
case 'starred':
return '加星便签'
case 'trash':
return '回收站'
default:
// 查找自定义文件夹的名称
const folder = store.folders.find(f => f.id === currentFolder.value)
return folder ? folder.name : '全部便签'
}
})
// 计算全部便签数量(未删除的)
const allNotesCount = computed(() => {
return store.notes.filter(note => !note.isDeleted).length
})
const handleNotePress = noteId => {
// 检查是否有便签条处于展开状态
let hasSlidedNote = false
Object.values(noteItemRefs.value).forEach(noteItem => {
// 注意isSlided是ref值需要通过.value访问
if (noteItem && noteItem.getSlideState()) {
hasSlidedNote = true
noteItem.resetSlideState()
}
})
// 如果有便签条处于展开状态,不跳转到编辑页面
if (hasSlidedNote) {
return
}
// 使用vue-router导航到编辑页面
router.push(`/editor/${noteId}`)
}
const handleAddNote = () => {
// 使用vue-router导航到新建便签页面
router.push('/editor')
}
// 处理Header组件的操作按钮点击事件
const handleHeaderAction = actionType => {
if (actionType === 'create') {
handleAddNote()
}
}
const handleStarToggle = async noteId => {
const note = store.notes.find(n => n.id === noteId)
if (note) {
try {
await store.updateNote(noteId, { isStarred: !note.isStarred })
console.log(`便签 ${noteId} 星标状态已更新`)
} catch (error) {
console.error('更新便签星标状态失败:', error)
}
}
}
const handleTopToggle = async noteId => {
const note = store.notes.find(n => n.id === noteId)
if (note) {
try {
await store.updateNote(noteId, { isTop: !note.isTop })
console.log(`便签 ${noteId} 置顶状态已更新`)
} catch (error) {
console.error('更新便签置顶状态失败:', error)
}
}
}
const confirmDeleteNote = async noteId => {
noteToDelete.value = noteId
if (noteToDelete.value) {
try {
// 检查当前是否在回收站中
if (currentFolder.value === 'trash') {
// 在回收站中删除便签,彻底删除
await store.permanentlyDeleteNote(noteToDelete.value)
console.log(`便签 ${noteToDelete.value} 已彻底删除`)
} else {
// 不在回收站中,将便签移至回收站
await store.moveToTrash(noteToDelete.value)
console.log(`便签 ${noteToDelete.value} 已移至回收站`)
}
noteToDelete.value = null
} catch (error) {
console.error('删除便签失败:', error)
}
}
}
// 处理排序方式切换
// 循环切换排序选项:按日期 -> 按标题 -> 按星标 -> 按日期...
const handleSort = () => {
const sortOptions = ['date', 'title', 'starred']
const currentIndex = sortOptions.indexOf(sortBy.value)
const nextIndex = (currentIndex + 1) % sortOptions.length
sortBy.value = sortOptions[nextIndex]
console.log('当前排序方式:', sortOptions[nextIndex])
}
const handleAllNotesClick = () => {
setCurrentFolder('all')
setIsFolderExpanded(false)
}
const handleStarredNotesClick = () => {
setCurrentFolder('starred')
setIsFolderExpanded(false)
}
const handleTrashNotesClick = () => {
setCurrentFolder('trash')
setIsFolderExpanded(false)
}
const handleFolderClick = folderId => {
setCurrentFolder(folderId)
setIsFolderExpanded(false)
}
const handleAddFolder = () => {
// 文件夹添加功能已在FolderManage组件中实现
// 这里只需关闭文件夹列表
setIsFolderExpanded(false)
}
const handleFolderPress = () => {
// 使用vue-router导航到文件夹页面
router.push('/folders')
}
const handleSettingsPress = () => {
// 使用vue-router导航到设置页面
router.push('/settings')
}
const handleFolderToggle = () => {
// 在实际应用中,这里会触发文件夹列表的展开/收起
isFolderExpanded.value = !isFolderExpanded.value
}
const handleSearch = query => {
// 搜索功能已在computed属性filteredAndSortedNotes中实现
console.log('搜索:', query)
// 可以在这里添加搜索统计或其它功能
if (query && query.length > 0) {
console.log(`找到 ${filteredAndSortedNotes.value.length} 个匹配的便签`)
}
}
const handleClearSearch = () => {
// 清除搜索已在v-model中处理
console.log('搜索已清除')
// 清除搜索后可以重置一些状态
setSearchQuery('')
}
const handleSearchFocus = () => {
console.log('搜索栏获得焦点')
// 可以在这里添加获得焦点时的特殊处理
}
const handleSearchBlur = () => {
console.log('搜索栏失去焦点')
// 可以在这里添加失去焦点时的特殊处理
}
// 防抖函数,用于避免频繁触发搜索
// 通过延迟执行函数,只在最后一次调用后执行
const debounceSearch = (func, delay) => {
let timeoutId
return function (...args) {
clearTimeout(timeoutId)
timeoutId = setTimeout(() => func.apply(this, args), delay)
}
}
// 防抖搜索处理函数延迟300ms执行搜索
const debouncedHandleSearch = debounceSearch(query => {
handleSearch(query)
}, 300)
// 改进的日期格式化函数
const formatDate = dateString => {
return formatNoteListDate(dateString)
}
const setCurrentFolder = folder => {
currentFolder.value = folder
}
const setIsFolderExpanded = expanded => {
isFolderExpanded.value = expanded
}
const setSearchQuery = query => {
searchQuery.value = query
}
const notes = computed(() => store.notes)
</script>
<style lang="less" scoped>
.container {
width: 100vw;
height: 100vh;
background: url(/assets/icons/drawable-xxhdpi/note_background.png);
background-size: cover;
}
.offline-banner {
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 10000;
background-color: #ff6b6b;
color: white;
padding: 0.5rem 1rem;
text-align: center;
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: 0.875rem;
font-weight: 500;
}
.offline-icon {
margin-right: 0.5rem;
}
.folder-list {
position: absolute;
top: 3.125rem;
left: 10%;
right: 10%;
z-index: 1000;
background-color: var(--background-card);
border-radius: 0.5rem;
box-shadow: 0 0.125rem 0.25rem var(--shadow);
border: 0.0625rem solid #f0ece7;
overflow: hidden;
}
.folder-overlay {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: transparent;
z-index: 99;
}
.content {
--background: transparent;
--padding-top: 4.5rem;
--padding-bottom: 2rem;
}
.search-container {
padding: 0.8rem 0.5rem;
}
.notes-container {
flex: 1;
position: relative;
overflow: hidden;
touch-action: pan-y;
}
.notes-list {
position: relative;
}
.note-item {
margin: 0.6rem 0;
transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
/* 便签列表动画 */
.note-list-enter-active,
.note-list-leave-active {
transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.note-list-leave-to {
opacity: 0;
transform: translateX(-1.875rem);
}
.note-list-move {
transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.note-list-leave-active {
position: absolute;
width: calc(100% - 1rem);
}
/* 文件夹列表动画 */
.folder-slide-enter-active,
.folder-slide-leave-active {
transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.folder-slide-enter-from {
opacity: 0;
transform: scale(0.8) translateY(-1.25rem);
}
.folder-slide-enter-to {
opacity: 1;
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`;
}