first commit
This commit is contained in:
100
pages/WorkSpace/TemplateSpace/TemplateSpace.css
Normal file
100
pages/WorkSpace/TemplateSpace/TemplateSpace.css
Normal file
@@ -0,0 +1,100 @@
|
||||
/* 编辑模板弹窗 */
|
||||
.edit-template-wrapper {
|
||||
|
||||
}
|
||||
|
||||
.template-grid {
|
||||
width: 100%;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
padding: 20rpx;
|
||||
box-sizing: border-box;
|
||||
gap: 20rpx;
|
||||
align-items: start;
|
||||
}
|
||||
|
||||
.template-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
box-sizing: border-box;
|
||||
border-radius: 20rpx;
|
||||
border: 1rpx solid #ddd;
|
||||
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.05);
|
||||
overflow: hidden;
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.template-name {
|
||||
width: 100%;
|
||||
background: linear-gradient(to right, rgba(0, 122, 255, 0.8), rgba(170, 170, 255, 0.8));
|
||||
color: #fff;
|
||||
font-weight: bold;
|
||||
font-size: 18px;
|
||||
padding: 10rpx 20rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.template-content {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
min-height: 200rpx;
|
||||
padding: 18rpx;
|
||||
margin: 6rpx 6rpx 0 6rpx;
|
||||
box-sizing: border-box;
|
||||
border: 1px solid #eee;
|
||||
border-radius: 20rpx;
|
||||
box-shadow: 2rpx 5rpx 8rpx rgba(170, 170, 255, 0.3);
|
||||
overflow: hidden;
|
||||
|
||||
}
|
||||
|
||||
.template-content-text {
|
||||
width: 100%;
|
||||
color: #666;
|
||||
overflow: hidden;
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 4;
|
||||
/* 限制显示行数 */
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: normal;
|
||||
word-break: break-all;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.template-info-wrapper {
|
||||
padding: 0 16rpx;
|
||||
}
|
||||
|
||||
.template-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
color: #007aff;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.template-item .background-style {
|
||||
display: flex;
|
||||
box-sizing: border-box;
|
||||
border-radius: 10rpx;
|
||||
align-self: flex-start;
|
||||
margin-top: 6rpx;
|
||||
}
|
||||
|
||||
.template-option {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin: 10rpx;
|
||||
}
|
||||
|
||||
.template-option .iconfont {
|
||||
color: #007aff;
|
||||
}
|
||||
|
||||
.iconfont.icon-favorite-fill {
|
||||
color: #ffaa00;
|
||||
}
|
||||
482
pages/WorkSpace/TemplateSpace/TemplateSpace.vue
Normal file
482
pages/WorkSpace/TemplateSpace/TemplateSpace.vue
Normal file
@@ -0,0 +1,482 @@
|
||||
<template>
|
||||
<view class="status-bar"></view>
|
||||
<!-- 编辑模板弹窗 -->
|
||||
<view class="popup-overlay">
|
||||
<view class="popup-card">
|
||||
<view class="close-popup-card"><view class="iconfont icon-quxiao"></view></view>
|
||||
<view class="popup-title">编辑模板</view>
|
||||
<view class="edit-template-wrapper">
|
||||
<view class="edit-template-name">
|
||||
<view>模板名称</view>
|
||||
<input placeholder-style="请输入模板名称" v-model="templateName"/>
|
||||
</view>
|
||||
<view class="edit-template-name">
|
||||
<view>模板内容</view>
|
||||
<view class="markdown-editor-pane">
|
||||
<view class="markdown-pane-header">
|
||||
编辑
|
||||
</view>
|
||||
<textarea>
|
||||
|
||||
</textarea>
|
||||
</view>
|
||||
<view class="markdown-preview-pane">
|
||||
<view class="markdown-pane-header">
|
||||
预览
|
||||
</view>
|
||||
<view></view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="workspace-container page-container">
|
||||
|
||||
<view class="workspace-header">
|
||||
<view class="custom-navbar">
|
||||
<view class="navbar-left" @click="handleBackOrCheck ">
|
||||
<view class="iconfont icon-fanhui custom-navbar-icon"></view>
|
||||
<view class="navbar-before-title workspace-text">{{isSelectFolder?'全选':navbarBeforeTitle}}</view>
|
||||
</view>
|
||||
|
||||
<view class="navbar-title workspace-text">{{navbarTitle}}</view>
|
||||
<view class="navbar-right" v-if="checkTemplate">
|
||||
<view v-if="isSelectFolder" class="navbar-right-text workspace-text" @click="handleSelectFolder()">
|
||||
完成</view>
|
||||
<view v-else class="iconfont icon-gengduo" :class="isMenuOpen ?'menu-open':'custom-navbar-icon'"
|
||||
@click="handleMenu"></view>
|
||||
</view>
|
||||
<view v-if="isMenuOpen" class="menu-card">
|
||||
<view class="menu-card-item" @click="handleSelectFolder();handleMenu()">选择</view>
|
||||
<view class="solid-line"></view>
|
||||
<view class="menu-card-item">新建模板</view>
|
||||
<view class="solid-line"></view>
|
||||
<view class="menu-card-item">上传模板</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="search-file-warpper">
|
||||
<view class="search-file">
|
||||
<view class="iconfont icon-sousuo"></view>
|
||||
<input class="search-file-input" placeholder="搜索" @focus="handleSearchFocus"
|
||||
v-model="searchKeyword" />
|
||||
</view>
|
||||
<view v-if="isSearchFocus" class="cancel-search" @click="handleSearchFocus">取消</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
<view class="folder-grid" v-if="!checkTemplate">
|
||||
<view class="folder-item" @click="checkShowTemplate('all')">
|
||||
<view class="iconfont icon-a-wenjianjiawenjian folder-item-style"></view>
|
||||
<view class="folder-name">全部模板</view>
|
||||
</view>
|
||||
<view class="folder-item" @click="checkShowTemplate('like')">
|
||||
<view class="iconfont icon-a-wenjianjiawenjian folder-item-style"></view>
|
||||
<view class="folder-name">收藏模板</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="workspace-content" v-if="checkTemplate">
|
||||
|
||||
<view class="folder-null" v-if="currentTemplateList.length===0">
|
||||
<view class="iconfont icon-wenjianjia"></view>
|
||||
暂无模板
|
||||
</view>
|
||||
<view class="template-grid" v-if="currentTemplateList.length>0">
|
||||
<view class="template-card" v-for="(item,index) in currentTemplateList" :key="index">
|
||||
|
||||
<view class="template-name">{{item.name}}</view>
|
||||
<view class="template-content">
|
||||
<view class="template-content-text">
|
||||
{{item.content}}
|
||||
</view>
|
||||
</view>
|
||||
<view class="template-info-wrapper">
|
||||
|
||||
<view class="template-item">
|
||||
<view class="template-time background-style">{{formatTime(item.modified_time)}}</view>
|
||||
<view class="template-cache background-style">{{formatSize(item.size)}}</view>
|
||||
</view>
|
||||
<view class="template-option">
|
||||
<view class="iconfont" :class="item.is_favorite ? 'icon-favorite-fill':'icon-favorite'"
|
||||
@click="handleLikeTemplate(index)"></view>
|
||||
<view class="iconfont icon-edit-fill" @click="editTemplate"></view>
|
||||
<view class="iconfont icon-choose-fill"></view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="isSelectFolder" class="workspace-footer" :class="{'folder-actions':selectFileList.length>0}">
|
||||
<view class="iconfont icon-shangchuan"></view>
|
||||
<view class="iconfont icon-fuzhi"></view>
|
||||
<view class="iconfont icon-wenjian"></view>
|
||||
<view class="iconfont icon-del"></view>
|
||||
<view class="iconfont icon-gengduo"></view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
onMounted,
|
||||
ref
|
||||
} from 'vue';
|
||||
|
||||
// 格式化时间函数
|
||||
const formatTime = (timestamp) => {
|
||||
if (!timestamp) return ''
|
||||
|
||||
// 处理包含毫秒的时间戳
|
||||
const seconds = Math.floor(timestamp)
|
||||
const date = new Date(seconds * 1000)
|
||||
|
||||
const year = date.getFullYear()
|
||||
const month = (date.getMonth() + 1).toString().padStart(2, '0')
|
||||
const day = date.getDate().toString().padStart(2, '0')
|
||||
const hours = date.getHours().toString().padStart(2, '0')
|
||||
const minutes = date.getMinutes().toString().padStart(2, '0')
|
||||
const seconds_part = date.getSeconds().toString().padStart(2, '0')
|
||||
|
||||
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds_part}`
|
||||
}
|
||||
|
||||
// 转换字节大小
|
||||
const formatSize = (bytes) => {
|
||||
if (!bytes || bytes === 0) return '0 B'
|
||||
|
||||
const units = ['B', 'KB', 'MB', 'GB', 'TB']
|
||||
let size = bytes
|
||||
let unitIndex = 0
|
||||
|
||||
while (size >= 1024 && unitIndex < units.length - 1) {
|
||||
size /= 1024
|
||||
unitIndex++
|
||||
}
|
||||
|
||||
// 保留一位或两位小数
|
||||
return `${size.toFixed(1)} ${units[unitIndex]}`
|
||||
}
|
||||
|
||||
// 核心:点赞/取消点赞
|
||||
const handleLikeTemplate = (index) => {
|
||||
let targetItem
|
||||
|
||||
// 1. 根据当前展示类型,找到真实被点击的项
|
||||
if (checkTemplate.value === 'all') {
|
||||
// 全部列表:直接用 index
|
||||
targetItem = allTemplate.value[index]
|
||||
} else if (checkTemplate.value === 'like') {
|
||||
// 收藏列表:先过滤出收藏项,再用 index 找到
|
||||
const favoriteList = allTemplate.value.filter(item => item.is_favorite)
|
||||
targetItem = favoriteList[index]
|
||||
}
|
||||
|
||||
// 2. 切换收藏状态
|
||||
if (targetItem) {
|
||||
targetItem.is_favorite = !targetItem.is_favorite
|
||||
}
|
||||
|
||||
// 3. 关键:切换后重新刷新当前列表(否则页面不更新)
|
||||
if (checkTemplate.value === 'all') {
|
||||
currentTemplateList.value = [...allTemplate.value]
|
||||
} else {
|
||||
currentTemplateList.value = allTemplate.value.filter(item => item.is_favorite)
|
||||
}
|
||||
}
|
||||
// 编辑模板
|
||||
const templateName = ref('aaa')
|
||||
const editTemplate = () => {
|
||||
console.log('点击了编辑模板');
|
||||
}
|
||||
|
||||
// 选择的模板区(全部or收藏)
|
||||
const checkTemplate = ref('')
|
||||
const currentTemplateList = ref([])
|
||||
const checkShowTemplate = (type) => {
|
||||
checkTemplate.value = type;
|
||||
if (type === 'all') {
|
||||
navbarTitle.value = '全部模板'
|
||||
currentTemplateList.value = allTemplate.value
|
||||
}
|
||||
if (type === 'like') {
|
||||
navbarTitle.value = '收藏模板'
|
||||
currentTemplateList.value = allTemplate.value.filter(item => item.is_favorite === true)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const navbarBeforeTitle = ref('');
|
||||
const navbarTitle = ref('模板区');
|
||||
|
||||
// 选择文件模式
|
||||
const isSelectFolder = ref(false);
|
||||
const selectFileList = ref([]);
|
||||
const handleSelectFolder = () => {
|
||||
if (isSelectFolder.value) {
|
||||
selectFileList.value = []
|
||||
}
|
||||
isSelectFolder.value = !isSelectFolder.value;
|
||||
}
|
||||
const selectFolder = (id) => {
|
||||
const index = selectFileList.value.indexOf(id);
|
||||
if (index !== -1) {
|
||||
selectFileList.value.splice(index, 1);
|
||||
} else {
|
||||
selectFileList.value.push(id);
|
||||
}
|
||||
}
|
||||
const handleLongPress = (folder) => {
|
||||
if (isSelectFolder.value) return;
|
||||
uni.showActionSheet({
|
||||
itemList: ['重命名', '删除', '下载', '压缩'],
|
||||
success: (res) => {
|
||||
switch (res.tapIndex) {
|
||||
case 0:
|
||||
handleRename(folder);
|
||||
break;
|
||||
case 1:
|
||||
handleDelete(folder);
|
||||
break;
|
||||
case 2:
|
||||
handleDownload(folder);
|
||||
break;
|
||||
case 3:
|
||||
handleDownload(folder);
|
||||
break;
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 重命名
|
||||
const handleRename = (folder) => {
|
||||
uni.showModal({
|
||||
title: '重命名',
|
||||
content: '请输入新名称',
|
||||
editable: true,
|
||||
placeholderText: folder.name,
|
||||
success: (res) => {
|
||||
if (res.confirm && res.content) {
|
||||
// 更新文件夹名称
|
||||
updateFolderName(folder.id, res.content);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 移动
|
||||
const handleDownload = (folder) => {
|
||||
// 可以选择跳转到移动页面或显示选择器
|
||||
uni.showToast({
|
||||
title: '移动功能开发中',
|
||||
icon: 'none'
|
||||
});
|
||||
};
|
||||
|
||||
// 删除
|
||||
const handleDelete = (folder) => {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: `确定要删除文件夹"${folder.name}"吗?`,
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
// deleteFolder(folder.id);
|
||||
console.log('确认删除文件夹');
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// const handleFolderClick = (id) => {
|
||||
// console.log(id);
|
||||
// }
|
||||
|
||||
// 菜单
|
||||
const isMenuOpen = ref(false)
|
||||
const handleMenu = () => {
|
||||
isMenuOpen.value = !isMenuOpen.value;
|
||||
}
|
||||
|
||||
// 搜索框
|
||||
const searchKeyword = ref('')
|
||||
const isSearchFocus = ref(false)
|
||||
const handleSearchFocus = () => {
|
||||
isSearchFocus.value = !isSearchFocus.value
|
||||
}
|
||||
|
||||
const allTemplate = ref([{
|
||||
"name": "SKILL.md",
|
||||
"type": "file",
|
||||
"path": "SKILL.md",
|
||||
"children": [],
|
||||
"file_count": 0,
|
||||
"directory_count": 0,
|
||||
"size": 4768,
|
||||
"modified_time": 1776827361.9123552,
|
||||
"extension": ".md",
|
||||
"is_favorite": false,
|
||||
"usage_count": 0,
|
||||
"sort": 0,
|
||||
"content": 'khgvshbbthvgbihepiubjhrviifdhiuhrviuehrviuawhiuvrhy'
|
||||
},
|
||||
{
|
||||
"name": "222.md",
|
||||
"type": "file",
|
||||
"path": "222.md",
|
||||
"children": [],
|
||||
"file_count": 0,
|
||||
"directory_count": 0,
|
||||
"size": 5558,
|
||||
"modified_time": 1776827666.9123552,
|
||||
"extension": ".md",
|
||||
"is_favorite": false,
|
||||
"usage_count": 0,
|
||||
"sort": 0,
|
||||
"content": 'khgvshbbthvgbihepiubjhiuvrhy'
|
||||
},
|
||||
{
|
||||
"name": "222.md",
|
||||
"type": "file",
|
||||
"path": "222.md",
|
||||
"children": [],
|
||||
"file_count": 0,
|
||||
"directory_count": 0,
|
||||
"size": 5558,
|
||||
"modified_time": 1776827666.9123552,
|
||||
"extension": ".md",
|
||||
"is_favorite": false,
|
||||
"usage_count": 0,
|
||||
"sort": 0,
|
||||
"content": '该回家看了的法国红酒看来法帝国海军快来尝尝v吧给v复仇计划曝光vi计划日方提供与i哦的风格和健康'
|
||||
},
|
||||
{
|
||||
"name": "222.md",
|
||||
"type": "file",
|
||||
"path": "222.md",
|
||||
"children": [],
|
||||
"file_count": 0,
|
||||
"directory_count": 0,
|
||||
"size": 5558,
|
||||
"modified_time": 1776827666.9123552,
|
||||
"extension": ".md",
|
||||
"is_favorite": false,
|
||||
"usage_count": 0,
|
||||
"sort": 0,
|
||||
"content": '的法国红酒看来法帝国海军快来尝尝v吧给'
|
||||
},
|
||||
{
|
||||
"name": "222.md",
|
||||
"type": "file",
|
||||
"path": "222.md",
|
||||
"children": [],
|
||||
"file_count": 0,
|
||||
"directory_count": 0,
|
||||
"size": 5558,
|
||||
"modified_time": 1776827666.9123552,
|
||||
"extension": ".md",
|
||||
"is_favorite": false,
|
||||
"usage_count": 0,
|
||||
"sort": 0,
|
||||
"content": ''
|
||||
},
|
||||
{
|
||||
"name": "222.md",
|
||||
"type": "file",
|
||||
"path": "222.md",
|
||||
"children": [],
|
||||
"file_count": 0,
|
||||
"directory_count": 0,
|
||||
"size": 5558,
|
||||
"modified_time": 1776827666.9123552,
|
||||
"extension": ".md",
|
||||
"is_favorite": false,
|
||||
"usage_count": 0,
|
||||
"sort": 0,
|
||||
"content": 'khgvshbbthvgbihepiubjhrviifdhiuhrviuehrviuawhiuvrhy'
|
||||
},
|
||||
{
|
||||
"name": "222.md",
|
||||
"type": "file",
|
||||
"path": "222.md",
|
||||
"children": [],
|
||||
"file_count": 0,
|
||||
"directory_count": 0,
|
||||
"size": 5558,
|
||||
"modified_time": 1776827666.9123552,
|
||||
"extension": ".md",
|
||||
"is_favorite": false,
|
||||
"usage_count": 0,
|
||||
"sort": 0,
|
||||
"content": 'khgvshbbthvgbihepiubjhrviifdhiuhrviuehrviuawhiuvrhy'
|
||||
},
|
||||
{
|
||||
"name": "222.md",
|
||||
"type": "file",
|
||||
"path": "222.md",
|
||||
"children": [],
|
||||
"file_count": 0,
|
||||
"directory_count": 0,
|
||||
"size": 5558,
|
||||
"modified_time": 1776827666.9123552,
|
||||
"extension": ".md",
|
||||
"is_favorite": false,
|
||||
"usage_count": 0,
|
||||
"sort": 0,
|
||||
"content": 'khgvshbbthvgbihepiubjhrviifdhiuhrviuehrviuawhiuvrhy'
|
||||
},
|
||||
{
|
||||
"name": "222.md",
|
||||
"type": "file",
|
||||
"path": "222.md",
|
||||
"children": [],
|
||||
"file_count": 0,
|
||||
"directory_count": 0,
|
||||
"size": 5558,
|
||||
"modified_time": 1776827666.9123552,
|
||||
"extension": ".md",
|
||||
"is_favorite": false,
|
||||
"usage_count": 0,
|
||||
"sort": 0,
|
||||
"content": 'khgvshbbthvgbihepiubjhrviifdhiuhrviuehrviuawhiuvrhy'
|
||||
}
|
||||
])
|
||||
|
||||
// 全选/取消全选
|
||||
const handleSelectAll = () => {
|
||||
if (selectFileList.value.length === currentTemplateList.value.length) {
|
||||
selectFileList.value = [];
|
||||
} else {
|
||||
selectFileList.value = currentTemplateList.value.map(f => f.id);
|
||||
}
|
||||
};
|
||||
|
||||
// 返回上一级
|
||||
const handleBackOrCheck = () => {
|
||||
if (isSelectFolder.value) {
|
||||
// 选择模式下点击全选/取消全选
|
||||
handleSelectAll();
|
||||
return;
|
||||
}
|
||||
if (!isSelectFolder.value && currentTemplateList.value) {
|
||||
currentTemplateList.value = []
|
||||
checkTemplate.value = ''
|
||||
navbarTitle.value = '模板区'
|
||||
}
|
||||
if (!isSelectFolder.value && !currentTemplateList.value) {
|
||||
uni.navigateBack({
|
||||
delta: 1,
|
||||
fail() {
|
||||
console.log("返回失败,进入兜底跳转")
|
||||
uni.reLaunch({
|
||||
url: '/pages/Chat/Chat'
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
@import url('../WorkSpace.css');
|
||||
@import url('TemplateSpace.css');
|
||||
</style>
|
||||
219
pages/WorkSpace/WorkSpace.css
Normal file
219
pages/WorkSpace/WorkSpace.css
Normal file
@@ -0,0 +1,219 @@
|
||||
.workspace-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background: rgba(140, 140, 140, 0.1);
|
||||
}
|
||||
|
||||
.workspace-text {
|
||||
color: #0073ff;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.workspace-header {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-shrink: 0;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
padding: 16rpx 0;
|
||||
box-sizing: border-box;
|
||||
border-bottom: 1rpx solid #ddd;
|
||||
}
|
||||
|
||||
.custom-navbar {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 20rpx 10rpx;
|
||||
box-sizing: border-box;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.navbar-left {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.navbar-before-title {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.navbar-title {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
}
|
||||
|
||||
.navbar-right {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
margin-right: 20rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.navbar-right .menu-open {
|
||||
color: #3ab0ff !important;
|
||||
font-size: 40rpx !important;
|
||||
}
|
||||
|
||||
.custom-navbar-icon {
|
||||
color: #0073ff !important;
|
||||
font-size: 40rpx !important;
|
||||
}
|
||||
|
||||
.search-file-warpper {
|
||||
display: flex;
|
||||
width: 90%;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.search-file {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
align-items: center;
|
||||
background: rgba(255, 255, 255, 1);
|
||||
padding: 16rpx;
|
||||
box-sizing: border-box;
|
||||
border-radius: 30rpx;
|
||||
}
|
||||
|
||||
.icon-sousuo {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.search-file-input {
|
||||
margin-left: 20rpx;
|
||||
}
|
||||
|
||||
.cancel-search {
|
||||
display: flex;
|
||||
flex-shrink: 0;
|
||||
padding: 0 0 0 20rpx;
|
||||
box-sizing: border-box;
|
||||
color: #0073ff;
|
||||
}
|
||||
|
||||
.workspace-content {
|
||||
width: 100%;
|
||||
display: block;
|
||||
flex: 1;
|
||||
overflow: auto;
|
||||
box-sizing: border-box;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
/* 菜单卡片 */
|
||||
.menu-card {
|
||||
position: absolute;
|
||||
top: 100%;
|
||||
right: 20rpx;
|
||||
width: 300rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
background: #fff;
|
||||
border-radius: 30rpx;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.menu-card-item {
|
||||
width: 100%;
|
||||
padding: 20rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.folder-null {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
top: 30%;
|
||||
transform: translateX(-50%);
|
||||
font-size: 32rpx;
|
||||
}
|
||||
.folder-null .iconfont {
|
||||
font-size: 180rpx;
|
||||
}
|
||||
|
||||
.folder-grid {
|
||||
width: 100%;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3,1fr);
|
||||
padding: 20rpx;
|
||||
box-sizing: border-box;
|
||||
gap: 20rpx;
|
||||
align-items: start;
|
||||
}
|
||||
|
||||
.folder-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.folder-item.select-folder {
|
||||
border-radius: 30rpx;
|
||||
background: rgba(9, 9, 9, 0.1);
|
||||
}
|
||||
|
||||
.folder-item-style {
|
||||
font-size: 160rpx !important;
|
||||
font-weight: 10rpx !important;
|
||||
color: #3ab0ff !important;
|
||||
}
|
||||
|
||||
.folder-checkbox {
|
||||
width: 50rpx;
|
||||
height: 50rpx;
|
||||
border: 6rpx solid #fff;
|
||||
border-radius: 50%;
|
||||
box-shadow: 0 2rpx 3rpx #333;
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
box-sizing: border-box;
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
top: 30%;
|
||||
transform: translate(-50%);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.folder-checkbox.select-folder {
|
||||
background-color: #0073ff;
|
||||
}
|
||||
|
||||
.workspace-footer {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-shrink: 0;
|
||||
justify-content: space-between;
|
||||
padding: 30rpx;
|
||||
box-sizing: border-box;
|
||||
color: #999999;
|
||||
background: #eeeeee;
|
||||
}
|
||||
|
||||
.workspace-footer.folder-actions {
|
||||
color: #0073ff;
|
||||
}
|
||||
|
||||
.workspace-footer .iconfont {
|
||||
font-size: 40rpx !important;
|
||||
}
|
||||
384
pages/WorkSpace/WorkSpace.vue
Normal file
384
pages/WorkSpace/WorkSpace.vue
Normal file
@@ -0,0 +1,384 @@
|
||||
<template>
|
||||
<view class="status-bar"></view>
|
||||
<view class="workspace-container page-container">
|
||||
|
||||
<view class="workspace-header">
|
||||
<view class="custom-navbar">
|
||||
<view class="navbar-left" @click="handleBackOrCheck ">
|
||||
<view class="iconfont icon-fanhui custom-navbar-icon"></view>
|
||||
<view class="navbar-before-title workspace-text">{{isSelectFolder?'全选':navbarBeforeTitle}}</view>
|
||||
</view>
|
||||
|
||||
<view class="navbar-title workspace-text">{{navbarTitle}}</view>
|
||||
<view class="navbar-right">
|
||||
<view v-if="isSelectFolder" class="navbar-right-text workspace-text" @click="handleSelectFolder()">
|
||||
完成</view>
|
||||
<view v-else class="iconfont icon-gengduo" :class="isMenuOpen ?'menu-open':'custom-navbar-icon'"
|
||||
@click="handleMenu"></view>
|
||||
</view>
|
||||
<view v-if="isMenuOpen" class="menu-card">
|
||||
<view class="menu-card-item" @click="handleSelectFolder();handleMenu()">选择</view>
|
||||
<view class="solid-line"></view>
|
||||
<view class="menu-card-item">新建文件夹</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="search-file-warpper">
|
||||
<view class="search-file">
|
||||
<view class="iconfont icon-sousuo"></view>
|
||||
<input class="search-file-input" placeholder="搜索" @focus="handleSearchFocus"
|
||||
v-model="searchKeyword" />
|
||||
</view>
|
||||
<view v-if="isSearchFocus" class="cancel-search" @click="handleSearchFocus">取消</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
<view class="workspace-content">
|
||||
<view class="folder-null" v-if="currentFolderList.length===0">
|
||||
<view class="iconfont icon-wenjianjia"></view>
|
||||
文件夹为空
|
||||
</view>
|
||||
<view class="folder-grid" v-if="currentFolderList.length>0">
|
||||
<view class="folder-item" :class="{'select-folder':selectFileList.includes(folder.id)}"
|
||||
v-for="folder in currentFolderList" :key="folder.id"
|
||||
@click="isSelectFolder?selectFolder(folder.id):handleFolderClick(folder)"
|
||||
@longpress="handleLongPress(folder)">
|
||||
<view class="iconfont icon-a-wenjianjiawenjian folder-item-style"></view>
|
||||
<view class="folder-name">{{folder.name}}</view>
|
||||
<view v-if="isSelectFolder" class="folder-checkbox"
|
||||
:class="{'select-folder':selectFileList.includes(folder.id)}">
|
||||
<uni-icons v-if="selectFileList.includes(folder.id)" type="checkmarkempty"
|
||||
color="#fff"></uni-icons>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="isSelectFolder" class="workspace-footer" :class="{'folder-actions':selectFileList.length>0}">
|
||||
<view class="iconfont icon-shangchuan"></view>
|
||||
<view class="iconfont icon-fuzhi"></view>
|
||||
<view class="iconfont icon-wenjian"></view>
|
||||
<view class="iconfont icon-del"></view>
|
||||
<view class="iconfont icon-gengduo"></view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
onMounted,
|
||||
ref
|
||||
} from 'vue';
|
||||
import {getWorkspaceId} from '@/utils/user-info.js'
|
||||
import {getWorkspaceList} from '@/utils/cloud-api.js'
|
||||
|
||||
const workspaceId = ref('')
|
||||
const navbarBeforeTitle = ref('');
|
||||
const navbarTitle = ref('工作区');
|
||||
|
||||
// 选择文件模式
|
||||
const isSelectFolder = ref(false);
|
||||
const selectFileList = ref([]);
|
||||
const handleSelectFolder = () => {
|
||||
if (isSelectFolder.value) {
|
||||
selectFileList.value = []
|
||||
}
|
||||
isSelectFolder.value = !isSelectFolder.value;
|
||||
}
|
||||
const selectFolder = (id) => {
|
||||
const index = selectFileList.value.indexOf(id);
|
||||
if (index !== -1) {
|
||||
selectFileList.value.splice(index, 1);
|
||||
} else {
|
||||
selectFileList.value.push(id);
|
||||
}
|
||||
}
|
||||
const handleLongPress = (folder) => {
|
||||
if (isSelectFolder.value) return;
|
||||
uni.showActionSheet({
|
||||
itemList:['重命名','删除','下载','压缩'],
|
||||
success: (res) => {
|
||||
switch(res.tapIndex) {
|
||||
case 0:
|
||||
handleRename(folder);
|
||||
break;
|
||||
case 1:
|
||||
handleDelete(folder);
|
||||
break;
|
||||
case 2:
|
||||
handleDownload(folder);
|
||||
break;
|
||||
case 3:
|
||||
handleDownload(folder);
|
||||
break;
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 重命名
|
||||
const handleRename = (folder) => {
|
||||
uni.showModal({
|
||||
title: '重命名',
|
||||
content: '请输入新名称',
|
||||
editable: true,
|
||||
placeholderText: folder.name,
|
||||
success: (res) => {
|
||||
if (res.confirm && res.content) {
|
||||
// 更新文件夹名称
|
||||
updateFolderName(folder.id, res.content);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 移动
|
||||
const handleDownload = (folder) => {
|
||||
// 可以选择跳转到移动页面或显示选择器
|
||||
uni.showToast({
|
||||
title: '移动功能开发中',
|
||||
icon: 'none'
|
||||
});
|
||||
};
|
||||
|
||||
// 删除
|
||||
const handleDelete = (folder) => {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: `确定要删除文件夹"${folder.name}"吗?`,
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
// deleteFolder(folder.id);
|
||||
console.log('确认删除文件夹');
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// const handleFolderClick = (id) => {
|
||||
// console.log(id);
|
||||
// }
|
||||
|
||||
// 菜单
|
||||
const isMenuOpen = ref(false)
|
||||
const handleMenu = () => {
|
||||
isMenuOpen.value = !isMenuOpen.value;
|
||||
}
|
||||
|
||||
// 搜索框
|
||||
const searchKeyword = ref('')
|
||||
const isSearchFocus = ref(false)
|
||||
const handleSearchFocus = () => {
|
||||
isSearchFocus.value = !isSearchFocus.value
|
||||
}
|
||||
|
||||
const allFoldersData = ref({
|
||||
// 根目录下的文件夹
|
||||
'root': [{
|
||||
id: 1,
|
||||
name: '文档资料',
|
||||
parentId: 'root',
|
||||
children: [{
|
||||
id: 11,
|
||||
name: '工作文档',
|
||||
parentId: 1,
|
||||
children: []
|
||||
},
|
||||
{
|
||||
id: 12,
|
||||
name: '学习笔记',
|
||||
parentId: 1,
|
||||
children: []
|
||||
},
|
||||
{
|
||||
id: 13,
|
||||
name: '合同模板',
|
||||
parentId: 1,
|
||||
children: []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: '图片素材',
|
||||
parentId: 'root',
|
||||
children: [{
|
||||
id: 21,
|
||||
name: '风景图片',
|
||||
parentId: 2,
|
||||
children: []
|
||||
},
|
||||
{
|
||||
id: 22,
|
||||
name: '人物照片',
|
||||
parentId: 2,
|
||||
children: []
|
||||
},
|
||||
{
|
||||
id: 23,
|
||||
name: 'UI图标',
|
||||
parentId: 2,
|
||||
children: []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: '视频文件',
|
||||
parentId: 'root',
|
||||
children: [{
|
||||
id: 31,
|
||||
name: '教程视频',
|
||||
parentId: 3,
|
||||
children: []
|
||||
},
|
||||
{
|
||||
id: 32,
|
||||
name: '会议录像',
|
||||
parentId: 3,
|
||||
children: []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: '项目代码',
|
||||
parentId: 'root',
|
||||
children: [{
|
||||
id: 41,
|
||||
name: '前端项目',
|
||||
parentId: 4,
|
||||
children: []
|
||||
},
|
||||
{
|
||||
id: 42,
|
||||
name: '后端服务',
|
||||
parentId: 4,
|
||||
children: []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
name: '安装包',
|
||||
parentId: 'root',
|
||||
children: []
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
name: '备份文件',
|
||||
parentId: 'root',
|
||||
children: []
|
||||
},
|
||||
{
|
||||
id: 7,
|
||||
name: '临时文件',
|
||||
parentId: 'root',
|
||||
children: []
|
||||
},
|
||||
{
|
||||
id: 8,
|
||||
name: '个人收藏',
|
||||
parentId: 'root',
|
||||
children: []
|
||||
}
|
||||
]
|
||||
});
|
||||
// 文件夹路径栈
|
||||
const folderStack = ref([]);
|
||||
// 当前显示的文件夹列表
|
||||
const currentFolderList = ref([]);
|
||||
|
||||
const getCurrentFolderList = () => {
|
||||
const currentPath = folderStack.value.length > 0 ? folderStack.value[folderStack.value.length - 1].id : 'root';
|
||||
if (currentPath === "root") {
|
||||
return allFoldersData.value['root'] || [];
|
||||
}
|
||||
const findFolderById = (folders, id) => {
|
||||
for (const folder of folders) {
|
||||
if (folder.id === id) return folder;
|
||||
if (folder.children && folder.children.length > 0) {
|
||||
const found = findFolderById(folder.children, id);
|
||||
if (found) return found;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
};
|
||||
const currentFolder = findFolderById(allFoldersData.value['root'], currentPath);
|
||||
return currentFolder ? currentFolder.children : [];
|
||||
}
|
||||
|
||||
// 初始化当前文件夹列表
|
||||
const initCurrentFolderList = () => {
|
||||
workspaceId.value = getWorkspaceId();
|
||||
console.log("getWorkspaceId:",workspaceId.value);
|
||||
currentFolderList.value = getCurrentFolderList();
|
||||
};
|
||||
|
||||
// 处理文件夹点击(非选择模式下进入文件夹)
|
||||
const handleFolderClick = (folder) => {
|
||||
folderStack.value.push({
|
||||
id: folder.id,
|
||||
name: folder.name
|
||||
});
|
||||
navbarTitle.value = folder.name;
|
||||
navbarBeforeTitle.value = folderStack.value.length > 1 ? folderStack.value[folderStack.value.length - 2].name :
|
||||
'工作区';
|
||||
initCurrentFolderList();
|
||||
searchKeyword.value = '';
|
||||
isSearchFocus.value = false;
|
||||
};
|
||||
|
||||
// 全选/取消全选
|
||||
const handleSelectAll = () => {
|
||||
if (selectFileList.value.length === currentFolderList.value.length) {
|
||||
selectFileList.value = [];
|
||||
} else {
|
||||
selectFileList.value = currentFolderList.value.map(f => f.id);
|
||||
}
|
||||
};
|
||||
|
||||
// 返回上一级
|
||||
const handleBackOrCheck = () => {
|
||||
if (isSelectFolder.value) {
|
||||
// 选择模式下点击全选/取消全选
|
||||
handleSelectAll();
|
||||
return;
|
||||
}
|
||||
|
||||
if (folderStack.value.length > 0) {
|
||||
folderStack.value.pop();
|
||||
if (folderStack.value.length === 0) {
|
||||
navbarTitle.value = '工作区';
|
||||
navbarBeforeTitle.value = null;
|
||||
} else {
|
||||
navbarTitle.value = folderStack.value[folderStack.value.length - 1].name;
|
||||
navbarBeforeTitle.value = folderStack.value.length > 1 ?
|
||||
folderStack.value[folderStack.value.length - 2].name :
|
||||
'工作区';
|
||||
}
|
||||
initCurrentFolderList();
|
||||
// 返回后清空搜索
|
||||
searchKeyword.value = '';
|
||||
isSearchFocus.value = false;
|
||||
} else {
|
||||
// 已在根目录,返回到聊天界面
|
||||
uni.navigateBack({
|
||||
delta: 1,
|
||||
fail() {
|
||||
console.log("返回失败,进入兜底跳转")
|
||||
uni.reLaunch({
|
||||
url: '/pages/Chat/Chat'
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
initCurrentFolderList();
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
@import url("WorkSpace.css");
|
||||
</style>
|
||||
Reference in New Issue
Block a user