初始化提交

This commit is contained in:
2025-10-10 08:13:38 +08:00
commit 0d4c7353f4
1361 changed files with 13945 additions and 0 deletions

View File

@@ -0,0 +1,229 @@
<template>
<div
@click="onPress"
class="folder-item-container"
:class="{ 'folder-item-selected': isSelected, 'folder-item-pressed': isPressed }"
@mousedown="handleMouseDown"
@mouseup="handleMouseUp"
@mouseleave="handleMouseLeave"
>
<div class="folder-item-content">
<!-- Hidden folder icon (matches native implementation) -->
<img
v-if="folderIconSrc"
:src="folderIconSrc"
class="folder-item-icon"
alt="folder icon"
style="visibility: hidden;"
/>
<ion-icon
v-else
:icon="folderIcon"
class="folder-item-icon"
style="visibility: hidden;"
></ion-icon>
<!-- Checkbox for selection (visible when isSelected is true) -->
<img
v-if="isSelected"
src="/assets/icons/drawable-xxhdpi/icon_folder_checked.png"
class="folder-item-checkbox"
alt="selected"
/>
<img
v-else
src="/assets/icons/drawable-xxhdpi/icon_folder_unchecked.png"
class="folder-item-checkbox"
alt="not selected"
/>
<div class="folder-item-text-container">
<div class="folder-item-name">
{{ name }}
</div>
<div class="folder-item-count">
{{ noteCount }} 条便签
</div>
</div>
<!-- Selected indicator (visible when isSelected is true) -->
<img
v-if="isSelected"
src="/assets/icons/drawable-xxhdpi/folder_selected.png"
class="folder-item-selected-icon"
alt="selected"
/>
</div>
</div>
</template>
<script>
import { folder, star, trash, document } from 'ionicons/icons';
export default {
name: 'FolderItem',
props: {
id: {
type: String,
required: true
},
name: {
type: String,
required: true
},
noteCount: {
type: Number,
required: true
},
onPress: {
type: Function,
required: true
},
isSelected: {
type: Boolean,
default: false
}
},
data() {
return {
folder,
star,
trash,
document,
isPressed: false
}
},
computed: {
folderIcon() {
switch (this.id) {
case 'all':
return this.folder;
case 'starred':
return this.star;
case 'trash':
return this.trash;
default:
return this.document;
}
},
folderIconSrc() {
switch (this.id) {
case 'all':
return '/assets/icons/drawable-xxhdpi/sidebar_folder_icon_all.png';
case 'starred':
return '/assets/icons/drawable-xxhdpi/sidebar_folder_icon_favorite.png';
case 'trash':
return '/assets/icons/drawable-xxhdpi/sidebar_folder_icon_trash.png';
default:
return '/assets/icons/drawable-xxhdpi/sidebar_folder_icon_document.png';
}
}
},
methods: {
handleMouseDown() {
this.isPressed = true;
},
handleMouseUp() {
this.isPressed = false;
},
handleMouseLeave() {
this.isPressed = false;
}
}
}
</script>
<style scoped>
.folder-item-container {
position: relative;
min-height: 44px;
background-color: var(--background-card);
cursor: pointer;
overflow: hidden;
}
.folder-item-container.folder-item-selected {
background-color: var(--folder-item-selected);
}
.folder-item-container.folder-item-pressed {
background-color: var(--black-05);
transform: scale(0.99);
}
.folder-item-container.folder-item-pressed::after {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: url('/assets/icons/drawable-xxhdpi/folder_item_pressed_bg.png') repeat;
background-size: 100% 100%;
opacity: 0.5;
pointer-events: none;
transition: opacity 0.2s ease;
}
.folder-item-content {
display: flex;
align-items: center;
width: 100%;
height: 44px;
padding: 0 16px;
position: relative;
}
.folder-item-icon {
width: 30px;
height: 30px;
color: var(--folder-name);
flex-shrink: 0;
margin-left: 1px;
padding-left: 11px;
}
.folder-item-icon[src] {
width: 30px;
height: 30px;
object-fit: contain;
}
.folder-item-checkbox {
width: 30px;
height: 30px;
flex-shrink: 0;
margin-left: 10px;
}
.folder-item-selected-icon {
width: 30px;
height: 30px;
margin-left: auto;
flex-shrink: 0;
margin-right: 0;
}
.folder-item-text-container {
flex: 1;
margin-left: 10px;
margin-right: 6px;
}
.folder-item-name {
font-size: 15px;
font-weight: normal;
color: var(--folder-name);
line-height: 1.2;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.folder-item-count {
font-size: 12px;
color: var(--folder-count);
line-height: 1.2;
margin-top: 2px;
}
</style>

313
src/components/Header.vue Normal file
View File

@@ -0,0 +1,313 @@
<template>
<div class="header-container">
<!-- 左侧区域 -->
<div class="header-left-area">
<!-- 左侧图标 -->
<div
v-if="onBack"
@click="onBack"
class="header-icon-button"
>
<img
src="/assets/icons/drawable-xxhdpi/btn_back.png"
class="header-icon"
alt="back"
/>
</div>
<div
v-else-if="leftIcon === 'back' && leftIconSource && onLeftAction"
@click="onLeftAction"
class="header-icon-button"
>
<img
:src="leftIconSource"
class="header-icon"
alt="left icon"
/>
</div>
<div
v-else-if="leftIcon === 'settings'"
@click="onLeftAction"
class="header-icon-button"
>
<img
:src="leftIconSource"
class="header-icon"
alt="settings"
/>
</div>
</div>
<!-- 中间标题区域 -->
<div
@click="onTitlePress"
class="header-title-container"
>
<span class="header-title">
{{ title }}
</span>
<!-- 文件夹切换按钮 (在标题区域内) -->
<div
v-if="leftIcon === 'settings'"
@click.stop="handleFolderToggle"
class="folder-toggle-button"
>
<img
:src="folderExpanded ? '/assets/icons/drawable-xxhdpi/folder_title_arrow_pressed.png' : '/assets/icons/drawable-xxhdpi/folder_title_arrow_normal.png'"
class="folder-toggle-icon"
alt="folder toggle"
/>
</div>
</div>
<!-- 右侧区域 -->
<div class="header-right-area">
<div
v-if="onAction"
@click="onAction"
class="header-icon-button"
>
<img
v-if="actionIconSource"
:src="actionIconSource"
class="header-icon"
alt="action"
/>
<span
v-else
class="header-action-text"
>
{{ actionText }}
</span>
</div>
</div>
</div>
</template>
<script>
export default {
name: 'Header',
props: {
title: {
type: String,
required: true
},
onBack: {
type: Function,
default: null
},
onAction: {
type: Function,
default: null
},
actionText: {
type: String,
default: ''
},
actionIcon: {
type: String,
default: ''
},
leftIcon: {
type: String,
default: ''
},
onLeftAction: {
type: Function,
default: null
},
onFolderToggle: {
type: Function,
default: null
},
isFolderExpanded: {
type: Boolean,
default: undefined
},
onTitlePress: {
type: Function,
default: null
}
},
data() {
return {
localFolderExpanded: false
}
},
computed: {
folderExpanded() {
// 优先使用父组件传递的isFolderExpanded状态否则使用本地状态
return this.isFolderExpanded !== undefined ? this.isFolderExpanded : this.localFolderExpanded;
},
actionIconSource() {
// 根据actionIcon属性返回对应的图标路径
switch (this.actionIcon) {
case 'settings':
return '/assets/icons/drawable-xxhdpi/btn_settings.png';
case 'create':
return '/assets/icons/drawable-xxhdpi/btn_create.png';
default:
return null;
}
},
leftIconSource() {
// 根据leftIcon属性返回对应的图标路径
switch (this.leftIcon) {
case 'folder':
// 文件夹图标根据展开状态切换
return this.folderExpanded
? '/assets/icons/drawable-xxhdpi/folder_title_arrow_pressed.png'
: '/assets/icons/drawable-xxhdpi/folder_title_arrow_normal.png';
case 'back':
// 返回图标
return '/assets/icons/drawable-xxhdpi/btn_back.png';
case 'settings':
// 设置图标
return '/assets/icons/drawable-xxhdpi/btn_settings.png';
default:
return null;
}
}
},
methods: {
handleFolderToggle() {
// 切换文件夹展开状态
if (this.isFolderExpanded === undefined) {
// 如果父组件没有传递isFolderExpanded则使用本地状态
this.localFolderExpanded = !this.localFolderExpanded;
}
// 调用父组件传递的回调函数
if (this.onFolderToggle) {
this.onFolderToggle();
}
}
}
}
</script>
<style scoped>
.header-container {
position: relative;
width: 100%;
height: 48px;
background-color: var(--background-card);
box-shadow: 0 1px 0 0 var(--border);
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
padding: 0 4px;
}
.header-left-area {
display: flex;
flex-direction: row;
align-items: center;
height: 100%;
flex-shrink: 0;
}
.header-right-area {
display: flex;
flex-direction: row;
align-items: center;
height: 100%;
flex-shrink: 0;
}
.header-icon-button {
width: 44px;
height: 44px;
display: flex;
justify-content: center;
align-items: center;
cursor: pointer;
border-radius: 4px;
transition: background-color 0.2s ease;
flex-shrink: 0;
}
.header-icon-button:hover {
background-color: var(--black-05);
}
.header-icon-button:active {
background-color: var(--black-10);
transform: scale(0.95);
}
.header-icon {
width: 24px;
height: 24px;
object-fit: contain;
}
.header-title-container {
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
cursor: pointer;
transition: background-color 0.2s ease;
border-radius: 4px;
padding: 4px 8px;
flex: 1;
margin: 0 8px;
}
.header-title-container:hover {
background-color: var(--black-05);
}
.header-title-container:active {
background-color: var(--black-10);
transform: scale(0.98);
}
.header-title {
font-size: 18px;
font-weight: 600;
color: var(--text-primary);
text-align: center;
max-width: 100%;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
flex-shrink: 1;
}
.folder-toggle-button {
width: 20px;
height: 20px;
display: flex;
justify-content: center;
align-items: center;
cursor: pointer;
transition: background-color 0.2s ease;
border-radius: 4px;
flex-shrink: 0;
margin-left: 8px;
}
.folder-toggle-button:hover {
background-color: var(--black-05);
}
.folder-toggle-button:active {
background-color: var(--black-10);
transform: scale(0.95);
}
.folder-toggle-icon {
width: 20px;
height: 20px;
object-fit: contain;
}
.header-action-text {
font-size: 16px;
color: var(--primary);
font-weight: 500;
}
</style>

223
src/components/NoteItem.vue Normal file
View File

@@ -0,0 +1,223 @@
<template>
<div class="note-item-container">
<!-- 左滑删除操作区域 -->
<div
v-if="onDelete"
class="delete-area"
:class="{ 'delete-area-visible': isSwiped }"
>
<span class="delete-text">删除</span>
</div>
<!-- 便签内容区域 -->
<div
class="note-content"
:class="{
'note-content-swiped': isSwiped,
'note-content-pressed': isPressed
}"
@click="onPress"
@touchstart="handleTouchStart"
@touchmove="handleTouchMove"
@touchend="handleTouchEnd"
@mousedown="handleMouseDown"
@mouseup="handleMouseUp"
@mouseleave="handleMouseLeave"
>
<div class="note-header">
<span class="note-date">
{{ date }}
</span>
<ion-icon
v-if="isStarred"
:icon="star"
class="star-icon"
></ion-icon>
</div>
<div class="note-title-container">
<span class="note-title">
{{ firstLine || '无内容' }}
</span>
</div>
</div>
</div>
</template>
<script>
import { star } from 'ionicons/icons';
export default {
name: 'NoteItem',
props: {
title: {
type: String,
required: true
},
content: {
type: String,
required: true
},
date: {
type: String,
required: true
},
isStarred: {
type: Boolean,
default: false
},
onPress: {
type: Function,
required: true
},
onDelete: {
type: Function,
default: null
}
},
data() {
return {
star,
isSwiped: false,
isPressed: false,
touchStartX: 0,
touchEndX: 0
}
},
computed: {
firstLine() {
if (!this.content) return '';
return this.content.split('\n')[0];
}
},
methods: {
handleTouchStart(event) {
this.touchStartX = event.touches[0].clientX;
this.isPressed = true;
},
handleTouchMove(event) {
this.touchEndX = event.touches[0].clientX;
// 如果有滑动,取消按下状态
if (Math.abs(this.touchStartX - this.touchEndX) > 5) {
this.isPressed = false;
}
},
handleTouchEnd() {
// 重置按下状态
this.isPressed = false;
// 计算滑动距离
const swipeDistance = this.touchStartX - this.touchEndX;
// 如果滑动距离超过阈值,则显示删除按钮
if (swipeDistance > 50) {
this.isSwiped = true;
} else if (swipeDistance < -50) {
this.isSwiped = false;
}
},
handleMouseDown() {
this.isPressed = true;
},
handleMouseUp() {
this.isPressed = false;
},
handleMouseLeave() {
this.isPressed = false;
}
}
}
</script>
<style scoped>
.note-item-container {
height: 78.33px;
width: 100%;
overflow: hidden;
margin-bottom: 1px;
position: relative;
background: var(--background-card);
}
.delete-area {
position: absolute;
right: -80px;
top: 0;
bottom: 0;
width: 80px;
height: 100%;
background: #ffe65c53;
display: flex;
justify-content: center;
align-items: center;
transition: right 0.3s ease;
}
.delete-area-visible {
right: 0px;
}
.delete-text {
font-size: 12px;
font-weight: bold;
color: white;
}
.note-content {
width: 100%;
cursor: pointer;
height: 100%;
background: var(--background-card);
box-sizing: border-box;
transition: transform 0.3s ease, background-color 0.2s ease;
position: relative;
border-bottom: 1px solid var(--border);
position: relative;
transition: background-color 0.2s ease;
}
.note-content-swiped {
transform: translateX(-80px);
}
.note-content-pressed {
background: var(--background-secondary);
transform: scale(0.99);
}
.note-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 5px 12px 0 52px;
position: relative;
height: 24px;
}
.note-date {
font-size: 10px;
color: var(--note-date);
line-height: 1.2;
}
.star-icon {
font-size: 16px;
color: var(--note-star);
}
.note-title-container {
position: absolute;
top: 38.5px;
left: 52px;
right: 12px;
height: 30px;
}
.note-title {
font-size: 16.5px;
color: var(--note-title);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
line-height: 30px;
}
</style>