第一次打包失败
This commit is contained in:
@@ -850,4 +850,91 @@
|
||||
color: #999;
|
||||
margin-bottom: 20rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* ===== 加载动画 ===== */
|
||||
.loading-area {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 60rpx 0;
|
||||
gap: 16rpx;
|
||||
}
|
||||
|
||||
.loading-spinner {
|
||||
width: 56rpx;
|
||||
height: 56rpx;
|
||||
border: 4rpx solid #e8e8e8;
|
||||
border-top-color: #3b86ff;
|
||||
border-radius: 50%;
|
||||
animation: spin 0.8s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
.loading-text {
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
/* ===== 数据库标签 ===== */
|
||||
.db-tag {
|
||||
display: inline-block;
|
||||
font-size: 20rpx;
|
||||
font-weight: 500;
|
||||
padding: 2rpx 12rpx;
|
||||
border-radius: 8rpx;
|
||||
margin-left: 10rpx;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.db-tag.tag-personal {
|
||||
color: #3b86ff;
|
||||
background: rgba(59, 134, 255, 0.08);
|
||||
border: 1rpx solid rgba(59, 134, 255, 0.2);
|
||||
}
|
||||
|
||||
.db-tag.tag-team {
|
||||
color: #67c23a;
|
||||
background: rgba(103, 194, 58, 0.08);
|
||||
border: 1rpx solid rgba(103, 194, 58, 0.2);
|
||||
}
|
||||
|
||||
/* ===== 上传数据库弹窗 ===== */
|
||||
.upload-db-hint {
|
||||
font-size: 22rpx;
|
||||
color: #999;
|
||||
margin-bottom: 20rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.upload-file-area {
|
||||
padding: 40rpx;
|
||||
border: 2rpx dashed #d0d0d0;
|
||||
border-radius: 16rpx;
|
||||
background: #f9fafb;
|
||||
text-align: center;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.upload-file-area:active {
|
||||
border-color: #3b86ff;
|
||||
background: rgba(59, 134, 255, 0.03);
|
||||
}
|
||||
|
||||
.selected-file {
|
||||
font-size: 26rpx;
|
||||
color: #3b86ff;
|
||||
font-weight: 500;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.upload-hint {
|
||||
font-size: 24rpx;
|
||||
color: #bbb;
|
||||
}
|
||||
@@ -150,24 +150,39 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- ===== 新建文件夹弹窗 ===== -->
|
||||
<view v-if="showNewTable" class="popup-overlay" @click="closeNewTableModal">
|
||||
<!-- ===== 新建数据库弹窗 ===== -->
|
||||
<view v-if="showNewDb" class="popup-overlay" @click="closeNewDbModal">
|
||||
<view class="popup-card" @click.stop>
|
||||
<view class="close-popup-card" @click="closeNewTableModal">
|
||||
<view class="close-popup-card" @click="closeNewDbModal">
|
||||
<view class="iconfont icon-quxiao"></view>
|
||||
</view>
|
||||
<view class="popup-title">新建{{ currentCategory === 'user' ? '个人' : '团队' }}数据表</view>
|
||||
<view class="new-folder-name">表名称</view>
|
||||
<view class="popup-title">新建个人数据库</view>
|
||||
<view class="new-folder-name">数据库名称</view>
|
||||
<view class="create-folder-name">
|
||||
<input v-model="newTableName" type="text" placeholder="输入表名称,如:users" />
|
||||
</view>
|
||||
<view class="new-folder-name">描述</view>
|
||||
<view class="create-folder-name">
|
||||
<input v-model="newTableDesc" type="text" placeholder="输入表描述(可选)" />
|
||||
<input v-model="newDbName" type="text" placeholder="输入数据库名称" />
|
||||
</view>
|
||||
<view class="option-wrapper">
|
||||
<view class="opt-btn opt-cancel" @click="closeNewTableModal">取消</view>
|
||||
<view class="opt-btn opt-confirm" @click="confirmCreateTable">确认</view>
|
||||
<view class="opt-btn opt-cancel" @click="closeNewDbModal">取消</view>
|
||||
<view class="opt-btn opt-confirm" @click="confirmCreateDb">确认</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- ===== 上传数据库文件弹窗 ===== -->
|
||||
<view v-if="showUploadDb" class="popup-overlay" @click="closeUploadDbModal">
|
||||
<view class="popup-card" @click.stop>
|
||||
<view class="close-popup-card" @click="closeUploadDbModal">
|
||||
<view class="iconfont icon-quxiao"></view>
|
||||
</view>
|
||||
<view class="popup-title">上传数据库文件</view>
|
||||
<view class="upload-db-hint">支持 .db / .sqlite / .sqlite3 格式的 SQLite 数据库文件</view>
|
||||
<view class="upload-file-area" @click="handlePickDbFile">
|
||||
<view v-if="uploadDbFileName" class="selected-file">{{ uploadDbFileName }}</view>
|
||||
<view v-else class="upload-hint">点击选择数据库文件</view>
|
||||
</view>
|
||||
<view class="option-wrapper">
|
||||
<view class="opt-btn opt-cancel" @click="closeUploadDbModal">取消</view>
|
||||
<view class="opt-btn opt-confirm" @click="confirmUploadDb">确认上传</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -182,15 +197,15 @@
|
||||
</view>
|
||||
<view class="navbar-title">{{ navbarTitle }}</view>
|
||||
<view class="navbar-right">
|
||||
<view v-if="isSelectFolder" class="navbar-right-text" @click="handleSelectFolder">完成</view>
|
||||
<!-- <view v-if="isSelectFolder" class="navbar-right-text" @click="handleSelectFolder">完成</view>
|
||||
<view v-else class="iconfont icon-gengduo" :class="isMenuOpen ? 'menu-open' : 'custom-navbar-icon'"
|
||||
@click="handleMenu"></view>
|
||||
@click="handleMenu"></view> -->
|
||||
</view>
|
||||
<!-- <view v-if="isMenuOpen" class="menu-card">
|
||||
<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" @click="openNewFolderModal(); handleMenu()">新建文件夹</view>
|
||||
</view> -->
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 个人/团队 分类切换 -->
|
||||
@@ -258,31 +273,46 @@
|
||||
<view class="section-title">
|
||||
<view class="iconfont icon-shujuku"></view>
|
||||
<text>云端数据库</text>
|
||||
<text class="file-count">{{ !isDbLoading && personalDatabases.length > 0 ? '(' + personalDatabases.length + ')' : '' }}</text>
|
||||
</view>
|
||||
<view class="section-actions">
|
||||
<view class="action-btn" @click="openNewTableModal">
|
||||
<view class="action-btn" @click="openUploadDbModal">
|
||||
<uni-icons type="upload" size="16"></uni-icons>
|
||||
<text>上传数据库</text>
|
||||
</view>
|
||||
<view class="action-btn" @click="openNewDbModal">
|
||||
<uni-icons type="plus" size="16"></uni-icons>
|
||||
<text>新建表</text>
|
||||
<text>新建数据库</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="section-body">
|
||||
<view v-if="personalTables.length === 0" class="empty-tip">
|
||||
<!-- 加载中 -->
|
||||
<view v-if="isDbLoading" class="loading-area">
|
||||
<view class="loading-spinner"></view>
|
||||
<text class="loading-text">加载中...</text>
|
||||
</view>
|
||||
<view v-else-if="personalDatabases.length === 0" class="empty-tip">
|
||||
<view class="iconfont icon-shujuku"></view>
|
||||
<text>暂无数据表</text>
|
||||
<text>暂无数据库</text>
|
||||
</view>
|
||||
<view v-else class="table-list">
|
||||
<view class="table-item" v-for="table in personalTables" :key="table.id"
|
||||
@click="handleTableClick(table)">
|
||||
<view class="table-item" v-for="db in personalDatabases" :key="db.database_id"
|
||||
@click="handleDbClick(db)" @longpress="handleDeleteDb(db)">
|
||||
<view class="table-icon">
|
||||
<uni-icons type="compose" size="22" color="#3b86ff"></uni-icons>
|
||||
</view>
|
||||
<view class="table-info">
|
||||
<view class="table-name">{{ table.name }}</view>
|
||||
<view class="table-desc">{{ table.desc || '无描述' }}</view>
|
||||
<view class="table-name">
|
||||
{{ db.database_name }}
|
||||
<text class="db-tag" :class="db.team_id ? 'tag-team' : 'tag-personal'">
|
||||
{{ db.team_id ? '团队共享' : '个人私有' }}
|
||||
</text>
|
||||
</view>
|
||||
<view class="table-desc">{{ db.table_count || 0 }} 张表 · {{ getAccessLevelLabel(db.access_level) }}</view>
|
||||
</view>
|
||||
<view class="table-meta">
|
||||
<text class="table-rows">{{ table.rowCount || 0 }} 条记录</text>
|
||||
<text class="table-rows">{{ formatDbTime(db.modified_time) }}</text>
|
||||
<uni-icons type="right" size="14" color="#999"></uni-icons>
|
||||
</view>
|
||||
</view>
|
||||
@@ -376,30 +406,32 @@
|
||||
<view class="iconfont icon-shujuku"></view>
|
||||
<text>团队云端数据库</text>
|
||||
</view>
|
||||
<view class="section-actions">
|
||||
<view class="action-btn" @click="openNewTableModal">
|
||||
<uni-icons type="plus" size="16"></uni-icons>
|
||||
<text>新建表</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="section-body">
|
||||
<view v-if="teamTables.length === 0" class="empty-tip">
|
||||
<!-- 加载中 -->
|
||||
<view v-if="isDbLoading" class="loading-area">
|
||||
<view class="loading-spinner"></view>
|
||||
<text class="loading-text">加载中...</text>
|
||||
</view>
|
||||
<view v-else-if="teamDatabases.length === 0" class="empty-tip">
|
||||
<view class="iconfont icon-shujuku"></view>
|
||||
<text>暂无团队数据表</text>
|
||||
<text>暂无团队数据库</text>
|
||||
</view>
|
||||
<view v-else class="table-list">
|
||||
<view class="table-item" v-for="table in teamTables" :key="table.id"
|
||||
@click="handleTableClick(table)">
|
||||
<view class="table-item" v-for="db in teamDatabases" :key="db.database_id"
|
||||
@click="handleDbClick(db)">
|
||||
<view class="table-icon">
|
||||
<uni-icons type="compose" size="22" color="#3b86ff"></uni-icons>
|
||||
</view>
|
||||
<view class="table-info">
|
||||
<view class="table-name">{{ table.name }}</view>
|
||||
<view class="table-desc">{{ table.desc || '无描述' }}</view>
|
||||
<view class="table-name">
|
||||
{{ db.database_name }}
|
||||
<text class="db-tag tag-team">团队共享</text>
|
||||
</view>
|
||||
<view class="table-desc">{{ db.table_count || 0 }} 张表 · {{ getAccessLevelLabel(db.access_level) }}</view>
|
||||
</view>
|
||||
<view class="table-meta">
|
||||
<text class="table-rows">{{ table.rowCount || 0 }} 条记录</text>
|
||||
<text class="table-rows">{{ formatDbTime(db.modified_time) }}</text>
|
||||
<uni-icons type="right" size="14" color="#999"></uni-icons>
|
||||
</view>
|
||||
</view>
|
||||
@@ -420,6 +452,7 @@
|
||||
import {
|
||||
getToken
|
||||
} from '@/utils/user-info.js';
|
||||
import { chooseFile } from '@/uni_modules/lime-choose-file';
|
||||
import {
|
||||
getUserInfo,
|
||||
getCloudFileList,
|
||||
@@ -436,7 +469,11 @@
|
||||
removeTeamMember,
|
||||
uploadCloudFile,
|
||||
deleteCloudFile,
|
||||
deleteTeam
|
||||
deleteTeam,
|
||||
getCloudDbList,
|
||||
createCloudDb,
|
||||
uploadCloudDbFile,
|
||||
deleteCloudDb
|
||||
} from '@/utils/cloud-api.js';
|
||||
|
||||
const userToken = ref('');
|
||||
@@ -1075,31 +1112,7 @@
|
||||
|
||||
// 选择文件并上传
|
||||
const chooseAndUploadFile = () => {
|
||||
// #ifdef APP-PLUS
|
||||
// App 端使用系统文件选择器
|
||||
plus.io.chooseFile(
|
||||
(res) => {
|
||||
// plus.io.chooseFile 返回格式可能是 { files: [...] } 或直接是数组
|
||||
const files = Array.isArray(res) ? res : (res.files || []);
|
||||
if (files.length === 0) {
|
||||
uni.showToast({
|
||||
title: '未选择文件',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
doUploadFiles(files);
|
||||
},
|
||||
(err) => {
|
||||
if (err.code !== 11) { // 11 是用户取消
|
||||
console.error('选择文件失败:', err);
|
||||
}
|
||||
}
|
||||
);
|
||||
// #endif
|
||||
// #ifndef APP-PLUS
|
||||
// 小程序/H5 端使用 uni.chooseFile(H5 可能不支持)
|
||||
uni.chooseFile({
|
||||
chooseFile({
|
||||
count: 10,
|
||||
type: 'all',
|
||||
success: (res) => {
|
||||
@@ -1120,7 +1133,6 @@
|
||||
console.error('选择文件失败:', err);
|
||||
}
|
||||
});
|
||||
// #endif
|
||||
};
|
||||
|
||||
// 执行上传
|
||||
@@ -1152,88 +1164,160 @@
|
||||
}
|
||||
};
|
||||
|
||||
// ========== 数据库表 ==========
|
||||
const personalTables = ref([{
|
||||
id: '1',
|
||||
name: 'users',
|
||||
desc: '用户信息表',
|
||||
rowCount: 128
|
||||
},
|
||||
{
|
||||
id: '2',
|
||||
name: 'messages',
|
||||
desc: '聊天记录表',
|
||||
rowCount: 2048
|
||||
},
|
||||
{
|
||||
id: '3',
|
||||
name: 'settings',
|
||||
desc: '用户配置表',
|
||||
rowCount: 56
|
||||
}
|
||||
]);
|
||||
const teamTables = ref([{
|
||||
id: 't1',
|
||||
name: 'team_tasks',
|
||||
desc: '团队任务表',
|
||||
rowCount: 32
|
||||
},
|
||||
{
|
||||
id: 't2',
|
||||
name: 'team_docs',
|
||||
desc: '团队文档表',
|
||||
rowCount: 15
|
||||
}
|
||||
]);
|
||||
// ========== 云端数据库 ==========
|
||||
const allDatabases = ref([]); // API 返回的全部数据库列表
|
||||
const isDbLoading = ref(false); // 数据库加载中
|
||||
// 个人展示全部数据库(个人私有 + 归属团队的),团队只展示属于当前选中团队的
|
||||
const personalDatabases = computed(() => allDatabases.value);
|
||||
const teamDatabases = computed(() => allDatabases.value.filter(db => db.team_id && String(db.team_id) === String(currentTeamId.value)));
|
||||
|
||||
const showNewTable = ref(false);
|
||||
const newTableName = ref('');
|
||||
const newTableDesc = ref('');
|
||||
const showNewDb = ref(false);
|
||||
const newDbName = ref('');
|
||||
|
||||
const openNewTableModal = () => {
|
||||
showNewTable.value = true;
|
||||
newTableName.value = '';
|
||||
newTableDesc.value = '';
|
||||
// 获取数据库列表
|
||||
const fetchDbList = async () => {
|
||||
isDbLoading.value = true;
|
||||
try {
|
||||
const token = getToken();
|
||||
const list = await getCloudDbList(token);
|
||||
allDatabases.value = list || [];
|
||||
} catch (error) {
|
||||
console.error('获取数据库列表失败:', error);
|
||||
allDatabases.value = [];
|
||||
} finally {
|
||||
isDbLoading.value = false;
|
||||
}
|
||||
};
|
||||
const closeNewTableModal = () => {
|
||||
showNewTable.value = false;
|
||||
newTableName.value = '';
|
||||
newTableDesc.value = '';
|
||||
|
||||
const openNewDbModal = () => {
|
||||
showNewDb.value = true;
|
||||
newDbName.value = '';
|
||||
};
|
||||
const confirmCreateTable = () => {
|
||||
const name = newTableName.value.trim();
|
||||
const closeNewDbModal = () => {
|
||||
showNewDb.value = false;
|
||||
newDbName.value = '';
|
||||
};
|
||||
const confirmCreateDb = async () => {
|
||||
const name = newDbName.value.trim();
|
||||
if (!name) {
|
||||
uni.showToast({
|
||||
title: '请输入表名称',
|
||||
icon: 'none'
|
||||
});
|
||||
uni.showToast({ title: '请输入数据库名称', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
const newTable = {
|
||||
id: Date.now().toString(),
|
||||
name: name,
|
||||
desc: newTableDesc.value.trim() || '无描述',
|
||||
rowCount: 0
|
||||
};
|
||||
if (currentCategory.value === 'user') {
|
||||
personalTables.value.push(newTable);
|
||||
} else {
|
||||
teamTables.value.push(newTable);
|
||||
uni.showLoading({ title: '创建中...' });
|
||||
try {
|
||||
const token = getToken();
|
||||
await createCloudDb(token, name);
|
||||
uni.hideLoading();
|
||||
uni.showToast({ title: '创建成功', icon: 'success' });
|
||||
closeNewDbModal();
|
||||
await fetchDbList();
|
||||
} catch (error) {
|
||||
uni.hideLoading();
|
||||
console.error('创建数据库失败:', error);
|
||||
uni.showToast({ title: '创建失败,请重试', icon: 'error' });
|
||||
}
|
||||
uni.showToast({
|
||||
title: '创建成功',
|
||||
icon: 'success'
|
||||
});
|
||||
closeNewTableModal();
|
||||
};
|
||||
|
||||
const handleTableClick = (table) => {
|
||||
uni.showToast({
|
||||
title: `进入数据表:${table.name}`,
|
||||
icon: 'none'
|
||||
// ========== 上传数据库文件 ==========
|
||||
const showUploadDb = ref(false);
|
||||
const uploadDbFileName = ref('');
|
||||
const uploadDbFilePath = ref('');
|
||||
|
||||
const openUploadDbModal = () => {
|
||||
showUploadDb.value = true;
|
||||
uploadDbFileName.value = '';
|
||||
uploadDbFilePath.value = '';
|
||||
};
|
||||
const closeUploadDbModal = () => {
|
||||
showUploadDb.value = false;
|
||||
};
|
||||
|
||||
const handlePickDbFile = () => {
|
||||
chooseFile({
|
||||
count: 1,
|
||||
type: 'all',
|
||||
success: (res) => {
|
||||
const file = res.tempFiles[0];
|
||||
uploadDbFileName.value = file.name || 'unknown';
|
||||
uploadDbFilePath.value = file.path;
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error('选择文件失败:', err);
|
||||
uni.showToast({ title: '选择文件失败', icon: 'none' });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const confirmUploadDb = async () => {
|
||||
if (!uploadDbFilePath.value) {
|
||||
uni.showToast({ title: '请选择数据库文件', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
// 校验文件后缀
|
||||
const ext = uploadDbFileName.value.split('.').pop()?.toLowerCase();
|
||||
const allowedExts = ['db', 'sqlite', 'sqlite3'];
|
||||
if (!allowedExts.includes(ext)) {
|
||||
uni.showToast({ title: '仅支持 .db / .sqlite / .sqlite3 文件', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
uni.showLoading({ title: '上传中...' });
|
||||
try {
|
||||
const token = getToken();
|
||||
await uploadCloudDbFile(token, uploadDbFilePath.value);
|
||||
uni.hideLoading();
|
||||
uni.showToast({ title: '上传成功', icon: 'success' });
|
||||
closeUploadDbModal();
|
||||
await fetchDbList();
|
||||
} catch (error) {
|
||||
uni.hideLoading();
|
||||
console.error('上传数据库失败:', error);
|
||||
uni.showToast({ title: '上传失败,请重试', icon: 'error' });
|
||||
}
|
||||
};
|
||||
|
||||
const handleDeleteDb = (db) => {
|
||||
uni.showModal({
|
||||
title: '删除数据库',
|
||||
content: `确定要删除数据库"${db.database_name}"吗?此操作不可恢复。`,
|
||||
success: async (res) => {
|
||||
if (res.confirm) {
|
||||
uni.showLoading({ title: '删除中...' });
|
||||
try {
|
||||
const token = getToken();
|
||||
await deleteCloudDb(token, db.database_id);
|
||||
uni.hideLoading();
|
||||
uni.showToast({ title: '删除成功', icon: 'success' });
|
||||
await fetchDbList();
|
||||
} catch (error) {
|
||||
uni.hideLoading();
|
||||
console.error('删除数据库失败:', error);
|
||||
uni.showToast({ title: '删除失败,请重试', icon: 'error' });
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const handleDbClick = (db) => {
|
||||
uni.navigateTo({
|
||||
url: `/pages/CloudDbDetail/CloudDbDetail?databaseId=${db.database_id}&databaseName=${encodeURIComponent(db.database_name)}&teamId=${db.team_id || ''}`
|
||||
});
|
||||
};
|
||||
|
||||
const formatDbTime = (timestamp) => {
|
||||
if (!timestamp) return '';
|
||||
const date = new Date(timestamp * 1000);
|
||||
const y = date.getFullYear();
|
||||
const m = String(date.getMonth() + 1).padStart(2, '0');
|
||||
const d = String(date.getDate()).padStart(2, '0');
|
||||
return `${y}-${m}-${d}`;
|
||||
};
|
||||
|
||||
const getAccessLevelLabel = (level) => {
|
||||
const labels = { 0: '无权限', 1: '只读', 2: '读写', 3: '管理' };
|
||||
return labels[level] || '未知';
|
||||
};
|
||||
|
||||
// ========== 团队管理 ==========
|
||||
const showTeamManage = ref(false);
|
||||
const teamGroups = ref([]);
|
||||
@@ -1568,6 +1652,7 @@
|
||||
onMounted(async () => {
|
||||
await fetchFileList();
|
||||
await fetchTeamList();
|
||||
await fetchDbList();
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
546
pages/CloudDbDetail/CloudDbDetail.css
Normal file
546
pages/CloudDbDetail/CloudDbDetail.css
Normal file
@@ -0,0 +1,546 @@
|
||||
/* ========== 通用 ========== */
|
||||
.status-bar {
|
||||
height: var(--status-bar-height);
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
.page-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100vh;
|
||||
background-color: #f5f6fa;
|
||||
}
|
||||
|
||||
/* ========== 导航栏 ========== */
|
||||
.cloud-db-header {
|
||||
background-color: #ffffff;
|
||||
flex-shrink: 0;
|
||||
position: relative;
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
.custom-navbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
height: 88rpx;
|
||||
padding: 0 30rpx;
|
||||
}
|
||||
|
||||
.navbar-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
min-width: 120rpx;
|
||||
}
|
||||
|
||||
.custom-navbar-icon {
|
||||
font-size: 40rpx;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.navbar-title {
|
||||
font-size: 34rpx;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
flex: 1;
|
||||
text-align: center;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.navbar-right {
|
||||
min-width: 120rpx;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
/* 下拉菜单 */
|
||||
.menu-card {
|
||||
position: absolute;
|
||||
top: 88rpx;
|
||||
right: 20rpx;
|
||||
background: #fff;
|
||||
border-radius: 16rpx;
|
||||
box-shadow: 0 8rpx 32rpx rgba(0,0,0,0.12);
|
||||
z-index: 500;
|
||||
overflow: hidden;
|
||||
min-width: 200rpx;
|
||||
}
|
||||
|
||||
.menu-card-item {
|
||||
padding: 24rpx 36rpx;
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.menu-card-item:active {
|
||||
background-color: #f5f6fa;
|
||||
}
|
||||
|
||||
.solid-line {
|
||||
height: 1rpx;
|
||||
background-color: #eee;
|
||||
margin: 0 20rpx;
|
||||
}
|
||||
|
||||
/* ========== 数据库信息栏 ========== */
|
||||
.db-info-bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 24rpx;
|
||||
padding: 20rpx 30rpx;
|
||||
background: #fff;
|
||||
border-bottom: 1rpx solid #f0f0f0;
|
||||
}
|
||||
|
||||
.db-info-text {
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
/* ========== 内容区域 ========== */
|
||||
.cloud-db-content {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.section-block {
|
||||
margin: 20rpx;
|
||||
background: #fff;
|
||||
border-radius: 20rpx;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.section-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 24rpx 30rpx;
|
||||
border-bottom: 1rpx solid #f5f6fa;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12rpx;
|
||||
font-size: 30rpx;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.section-title .iconfont {
|
||||
font-size: 36rpx;
|
||||
color: #3b86ff;
|
||||
}
|
||||
|
||||
.section-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16rpx;
|
||||
}
|
||||
|
||||
.row-count {
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.section-divider {
|
||||
height: 1rpx;
|
||||
background-color: #f0f0f0;
|
||||
margin: 0 20rpx;
|
||||
}
|
||||
|
||||
.section-body {
|
||||
padding: 16rpx 0;
|
||||
}
|
||||
|
||||
/* ========== 空状态 ========== */
|
||||
.empty-tip {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 60rpx 0;
|
||||
color: #ccc;
|
||||
font-size: 26rpx;
|
||||
}
|
||||
|
||||
.empty-tip .iconfont {
|
||||
font-size: 80rpx;
|
||||
margin-bottom: 16rpx;
|
||||
}
|
||||
|
||||
/* ========== 表列表 ========== */
|
||||
.table-list {
|
||||
padding: 0 30rpx;
|
||||
}
|
||||
|
||||
.table-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 24rpx 0;
|
||||
border-bottom: 1rpx solid #f5f6fa;
|
||||
}
|
||||
|
||||
.table-item:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.table-item:active {
|
||||
background-color: #fafbfc;
|
||||
margin: 0 -30rpx;
|
||||
padding-left: 30rpx;
|
||||
padding-right: 30rpx;
|
||||
}
|
||||
|
||||
.table-icon {
|
||||
width: 72rpx;
|
||||
height: 72rpx;
|
||||
border-radius: 16rpx;
|
||||
background: rgba(59, 134, 255, 0.08);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-right: 20rpx;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.table-info {
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.table-name {
|
||||
font-size: 30rpx;
|
||||
font-weight: 500;
|
||||
color: #333;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.table-desc {
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
margin-top: 4rpx;
|
||||
}
|
||||
|
||||
.table-meta {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8rpx;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
/* ========== 数据表格 ========== */
|
||||
.data-table-wrapper {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.data-table-scroll {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.data-table {
|
||||
min-width: 100%;
|
||||
}
|
||||
|
||||
.data-row {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
border-bottom: 1rpx solid #f0f0f0;
|
||||
}
|
||||
|
||||
.data-row:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.data-header {
|
||||
background-color: #f8f9fb;
|
||||
}
|
||||
|
||||
.data-cell {
|
||||
padding: 16rpx 20rpx;
|
||||
font-size: 26rpx;
|
||||
color: #333;
|
||||
min-width: 160rpx;
|
||||
max-width: 300rpx;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
border-right: 1rpx solid #f0f0f0;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.data-cell:last-child {
|
||||
border-right: none;
|
||||
}
|
||||
|
||||
.data-header .data-cell {
|
||||
font-weight: 600;
|
||||
color: #666;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.index-cell {
|
||||
min-width: 80rpx !important;
|
||||
max-width: 80rpx !important;
|
||||
text-align: center;
|
||||
color: #999;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.data-row:active {
|
||||
background-color: #f5f7fa;
|
||||
}
|
||||
|
||||
/* ========== 弹窗通用 ========== */
|
||||
.popup-overlay {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 900;
|
||||
}
|
||||
|
||||
.popup-card {
|
||||
width: 640rpx;
|
||||
background: #fff;
|
||||
border-radius: 24rpx;
|
||||
padding: 40rpx 36rpx 30rpx;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.close-popup-card {
|
||||
position: absolute;
|
||||
top: 20rpx;
|
||||
right: 20rpx;
|
||||
width: 48rpx;
|
||||
height: 48rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.close-popup-card .iconfont {
|
||||
font-size: 36rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.popup-title {
|
||||
font-size: 34rpx;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
text-align: center;
|
||||
margin-bottom: 30rpx;
|
||||
}
|
||||
|
||||
.new-folder-name {
|
||||
font-size: 26rpx;
|
||||
color: #666;
|
||||
margin-bottom: 12rpx;
|
||||
}
|
||||
|
||||
.create-folder-name {
|
||||
margin-bottom: 24rpx;
|
||||
}
|
||||
|
||||
.create-folder-name input {
|
||||
width: 100%;
|
||||
height: 80rpx;
|
||||
border: 2rpx solid #e0e0e0;
|
||||
border-radius: 12rpx;
|
||||
padding: 0 20rpx;
|
||||
font-size: 28rpx;
|
||||
box-sizing: border-box;
|
||||
background: #f8f9fb;
|
||||
}
|
||||
|
||||
.upload-file-area {
|
||||
width: 100%;
|
||||
height: 120rpx;
|
||||
border: 2rpx dashed #d0d0d0;
|
||||
border-radius: 12rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-bottom: 24rpx;
|
||||
background: #fafbfc;
|
||||
}
|
||||
|
||||
.selected-file {
|
||||
font-size: 26rpx;
|
||||
color: #3b86ff;
|
||||
}
|
||||
|
||||
.upload-hint {
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.option-wrapper {
|
||||
display: flex;
|
||||
gap: 20rpx;
|
||||
margin-top: 10rpx;
|
||||
}
|
||||
|
||||
.opt-btn {
|
||||
flex: 1;
|
||||
height: 80rpx;
|
||||
border-radius: 12rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 30rpx;
|
||||
}
|
||||
|
||||
.opt-cancel {
|
||||
background: #f5f6fa;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.opt-confirm {
|
||||
background: #3b86ff;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
/* ========== 权限管理 ========== */
|
||||
.permission-body {
|
||||
max-height: 600rpx;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.permission-list {
|
||||
padding: 0 10rpx;
|
||||
}
|
||||
|
||||
.permission-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 20rpx 10rpx;
|
||||
border-bottom: 1rpx solid #f0f0f0;
|
||||
}
|
||||
|
||||
.perm-info {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4rpx;
|
||||
}
|
||||
|
||||
.perm-name {
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.perm-type {
|
||||
font-size: 22rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.perm-level {
|
||||
font-size: 24rpx;
|
||||
color: #3b86ff;
|
||||
background: rgba(59, 134, 255, 0.08);
|
||||
padding: 6rpx 16rpx;
|
||||
border-radius: 8rpx;
|
||||
margin: 0 16rpx;
|
||||
}
|
||||
|
||||
.perm-actions {
|
||||
display: flex;
|
||||
gap: 12rpx;
|
||||
}
|
||||
|
||||
.perm-action-btn {
|
||||
font-size: 24rpx;
|
||||
color: #3b86ff;
|
||||
padding: 8rpx 16rpx;
|
||||
border: 1rpx solid #3b86ff;
|
||||
border-radius: 8rpx;
|
||||
}
|
||||
|
||||
.perm-action-btn.delete {
|
||||
color: #f56c6c;
|
||||
border-color: #f56c6c;
|
||||
}
|
||||
|
||||
.close-permission-btn {
|
||||
text-align: center;
|
||||
font-size: 28rpx;
|
||||
color: #999;
|
||||
padding: 16rpx 0;
|
||||
}
|
||||
|
||||
.folder-null {
|
||||
text-align: center;
|
||||
padding: 40rpx 0;
|
||||
font-size: 26rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
/* ========== 移交团队 ========== */
|
||||
.transfer-body {
|
||||
max-height: 500rpx;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.transfer-list {
|
||||
padding: 0 10rpx;
|
||||
}
|
||||
|
||||
.transfer-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 24rpx 16rpx;
|
||||
border-bottom: 1rpx solid #f0f0f0;
|
||||
border-radius: 12rpx;
|
||||
margin-bottom: 8rpx;
|
||||
}
|
||||
|
||||
.transfer-item.active {
|
||||
background: rgba(59, 134, 255, 0.06);
|
||||
}
|
||||
|
||||
.transfer-name {
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
/* ===== 加载动画 ===== */
|
||||
.loading-area {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 60rpx 0;
|
||||
gap: 16rpx;
|
||||
}
|
||||
|
||||
.loading-spinner {
|
||||
width: 56rpx;
|
||||
height: 56rpx;
|
||||
border: 4rpx solid #e8e8e8;
|
||||
border-top-color: #3b86ff;
|
||||
border-radius: 50%;
|
||||
animation: spin 0.8s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
.loading-text {
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
}
|
||||
715
pages/CloudDbDetail/CloudDbDetail.vue
Normal file
715
pages/CloudDbDetail/CloudDbDetail.vue
Normal file
@@ -0,0 +1,715 @@
|
||||
<template>
|
||||
<view class="cloud-db-detail-wrapper">
|
||||
<view class="status-bar"></view>
|
||||
|
||||
<!-- ===== 新建表弹窗 ===== -->
|
||||
<view v-if="showNewTable" class="popup-overlay" @click="closeNewTableModal">
|
||||
<view class="popup-card" @click.stop>
|
||||
<view class="close-popup-card" @click="closeNewTableModal">
|
||||
<view class="iconfont icon-quxiao"></view>
|
||||
</view>
|
||||
<view class="popup-title">导入文件到数据库</view>
|
||||
<view class="new-folder-name">表名称</view>
|
||||
<view class="create-folder-name">
|
||||
<input v-model="importTableName" type="text" placeholder="输入表名称" />
|
||||
</view>
|
||||
<view class="new-folder-name">文件</view>
|
||||
<view class="upload-file-area" @click="handlePickFile">
|
||||
<view v-if="importFileName" class="selected-file">{{ importFileName }}</view>
|
||||
<view v-else class="upload-hint">点击选择文件(支持 CSV/Excel/SQLite)</view>
|
||||
</view>
|
||||
<view class="option-wrapper">
|
||||
<view class="opt-btn opt-cancel" @click="closeNewTableModal">取消</view>
|
||||
<view class="opt-btn opt-confirm" @click="confirmImportFile">确认导入</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- ===== 权限管理弹窗 ===== -->
|
||||
<view v-if="showPermission" class="popup-overlay" @click="closePermissionModal">
|
||||
<view class="popup-card" @click.stop>
|
||||
<view class="close-popup-card" @click="closePermissionModal">
|
||||
<view class="iconfont icon-quxiao"></view>
|
||||
</view>
|
||||
<view class="popup-title">权限管理</view>
|
||||
|
||||
<scroll-view class="permission-body" scroll-y>
|
||||
<view v-if="permissionList.length === 0" class="folder-null">暂无权限记录</view>
|
||||
<view v-else class="permission-list">
|
||||
<view class="permission-item" v-for="perm in permissionList" :key="perm._id || perm.id">
|
||||
<view class="perm-info">
|
||||
<!-- <text class="perm-name">{{ perm.name }}</text> -->
|
||||
<text class="perm-type">{{ perm.permType === 'team_id' ? '团队' : '个人' }}</text>
|
||||
</view>
|
||||
<view class="perm-level">{{ getAccessLevelLabel(perm.access_level) }}</view>
|
||||
<view class="perm-actions">
|
||||
<view class="perm-action-btn" @click="changePermission(perm, 'change')">修改</view>
|
||||
<view class="perm-action-btn delete" @click="changePermission(perm, 'delete')">移除</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
|
||||
<view class="close-permission-btn" @click="closePermissionModal">关闭</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- ===== 移交团队弹窗 ===== -->
|
||||
<view v-if="showTransfer" class="popup-overlay" @click="closeTransferModal">
|
||||
<view class="popup-card" @click.stop>
|
||||
<view class="close-popup-card" @click="closeTransferModal">
|
||||
<view class="iconfont icon-quxiao"></view>
|
||||
</view>
|
||||
<view class="popup-title">移交数据库到团队</view>
|
||||
<scroll-view class="transfer-body" scroll-y>
|
||||
<view v-if="teamList.length === 0" class="folder-null">暂无可用团队</view>
|
||||
<view v-else class="transfer-list">
|
||||
<view class="transfer-item" v-for="team in teamList" :key="team.id"
|
||||
:class="{ active: selectedTeamId === team.id }" @click="selectedTeamId = team.id">
|
||||
<text class="transfer-name">{{ team.name }}</text>
|
||||
<uni-icons v-if="selectedTeamId === team.id" type="checkmarkempty" size="20"
|
||||
color="#3b86ff"></uni-icons>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
<view class="option-wrapper">
|
||||
<view class="opt-btn opt-cancel" @click="closeTransferModal">取消</view>
|
||||
<view class="opt-btn opt-confirm" @click="confirmTransfer">确认移交</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- ===== 主页面 ===== -->
|
||||
<view class="cloud-db-detail page-container">
|
||||
<view class="cloud-db-header">
|
||||
<view class="custom-navbar">
|
||||
<view class="navbar-left" @click="handleBack">
|
||||
<view class="iconfont icon-fanhui custom-navbar-icon"></view>
|
||||
</view>
|
||||
<view class="navbar-title">{{ databaseName }}</view>
|
||||
<view class="navbar-right">
|
||||
<view class="iconfont icon-gengduo custom-navbar-icon" @click="handleMenu"></view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 下拉菜单 -->
|
||||
<view v-if="isMenuOpen" class="menu-card">
|
||||
<view class="menu-card-item" @click="openImportModal(); handleMenu()">导入文件</view>
|
||||
<view class="solid-line"></view>
|
||||
<view class="menu-card-item" @click="openPermissionModal(); handleMenu()">权限管理</view>
|
||||
<view v-if="!teamId" class="solid-line"></view>
|
||||
<view v-if="!teamId" class="menu-card-item" @click="openTransferModal(); handleMenu()">移交团队</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<scroll-view class="cloud-db-content" scroll-y>
|
||||
<!-- 数据库基本信息 -->
|
||||
<view class="db-info-bar">
|
||||
<text class="db-info-text">{{ dbTableCount }} 张表</text>
|
||||
<text class="db-info-text">权限:{{ getAccessLevelLabel(dbAccessLevel) }}</text>
|
||||
</view>
|
||||
|
||||
<!-- 表列表 -->
|
||||
<view class="section-block">
|
||||
<view class="section-header">
|
||||
<view class="section-title">
|
||||
<view class="iconfont icon-biaoge"></view>
|
||||
<text>数据表</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="section-body">
|
||||
<!-- 加载中 -->
|
||||
<view v-if="isTableLoading" class="loading-area">
|
||||
<view class="loading-spinner"></view>
|
||||
<text class="loading-text">加载中...</text>
|
||||
</view>
|
||||
<view v-else-if="tableList.length === 0" class="empty-tip">
|
||||
<view class="iconfont icon-shujuku"></view>
|
||||
<text>暂无数据表</text>
|
||||
</view>
|
||||
<view v-else class="table-list">
|
||||
<view class="table-item" v-for="table in tableList" :key="table.table_name"
|
||||
@click="selectTable(table)" @longpress="handleDeleteTable(table)">
|
||||
<view class="table-icon">
|
||||
<uni-icons type="compose" size="22" color="#3b86ff"></uni-icons>
|
||||
</view>
|
||||
<view class="table-info">
|
||||
<view class="table-name">{{ table.table_name }}</view>
|
||||
<view class="table-desc">{{ table.row_count || 0 }} 条记录</view>
|
||||
</view>
|
||||
<view class="table-meta">
|
||||
<uni-icons type="right" size="14" color="#999"></uni-icons>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 表数据查看 -->
|
||||
<view v-if="currentTable" class="section-block">
|
||||
<view class="section-divider"></view>
|
||||
<view class="section-header">
|
||||
<view class="section-title">
|
||||
<view class="iconfont icon-biaoge"></view>
|
||||
<text>{{ currentTable.table_name }}</text>
|
||||
</view>
|
||||
<view class="section-actions">
|
||||
<text class="row-count">{{ tableData.length }} / {{ currentTable.row_count || 0 }} 条</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="section-body">
|
||||
<view v-if="tableData.length === 0" class="empty-tip">
|
||||
<text>暂无数据</text>
|
||||
</view>
|
||||
<view v-else class="data-table-wrapper">
|
||||
<scroll-view scroll-x class="data-table-scroll">
|
||||
<view class="data-table">
|
||||
<!-- 表头 -->
|
||||
<view class="data-row data-header">
|
||||
<view class="data-cell index-cell">#</view>
|
||||
<view v-for="col in tableColumns" :key="col" class="data-cell">
|
||||
{{ col }}
|
||||
</view>
|
||||
</view>
|
||||
<!-- 数据行 -->
|
||||
<view class="data-row" v-for="(row, rowIdx) in tableData"
|
||||
:key="row._row_id || rowIdx" @click="openEditRow(row)">
|
||||
<view class="data-cell index-cell">{{ rowIdx + 1 }}</view>
|
||||
<view v-for="col in tableColumns" :key="col" class="data-cell">
|
||||
{{ formatCellValue(row[col]) }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
onMounted,
|
||||
ref,
|
||||
computed
|
||||
} from 'vue';
|
||||
import {
|
||||
getToken,
|
||||
getUserId
|
||||
} from '@/utils/user-info.js';
|
||||
import {
|
||||
chooseFile
|
||||
} from '@/uni_modules/lime-choose-file';
|
||||
import {
|
||||
getCloudDbTables,
|
||||
deleteCloudDbTable,
|
||||
getCloudDbTableData,
|
||||
updateCloudDbTableData,
|
||||
importFileToCloudDb,
|
||||
getCloudDbPermission,
|
||||
deleteCloudDbPermission,
|
||||
updateCloudDbPermission,
|
||||
dbTransferToTeam,
|
||||
getTeamList
|
||||
} from '@/utils/cloud-api.js';
|
||||
|
||||
// 声明 props 以避免 "Extraneous non-props attributes" 警告
|
||||
const props = defineProps({
|
||||
databaseId: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
databaseName: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
teamId: {
|
||||
type: String,
|
||||
default: ''
|
||||
}
|
||||
});
|
||||
|
||||
const databaseId = ref(props.databaseId || '');
|
||||
const databaseName = ref(props.databaseName || '');
|
||||
const teamId = ref(props.teamId || '');
|
||||
const dbAccessLevel = ref(2);
|
||||
const dbTableCount = ref(0);
|
||||
|
||||
const tableList = ref([]);
|
||||
const isTableLoading = ref(false);
|
||||
const currentTable = ref(null);
|
||||
const tableData = ref([]);
|
||||
const tableColumns = computed(() => {
|
||||
// 如果有表数据,从数据中提取列名
|
||||
if (tableData.value.length > 0) {
|
||||
const keys = new Set();
|
||||
tableData.value.forEach(row => Object.keys(row).forEach(k => keys.add(k)));
|
||||
return Array.from(keys).filter(k => k !== '_row_id' && k !== '_id');
|
||||
}
|
||||
// 否则使用表结构中的 columns
|
||||
if (currentTable.value?.columns) {
|
||||
return currentTable.value.columns.map(c => c.name).filter(n => n !== '_row_id');
|
||||
}
|
||||
return [];
|
||||
});
|
||||
|
||||
// 菜单
|
||||
const isMenuOpen = ref(false);
|
||||
const handleMenu = () => {
|
||||
isMenuOpen.value = !isMenuOpen.value;
|
||||
};
|
||||
|
||||
const handleBack = () => {
|
||||
uni.navigateBack();
|
||||
};
|
||||
|
||||
// ========== 数据加载 ==========
|
||||
const fetchTables = async () => {
|
||||
isTableLoading.value = true;
|
||||
try {
|
||||
const token = getToken();
|
||||
const tables = await getCloudDbTables(token, databaseId.value, true);
|
||||
// API 返回 { tables: [...] } 格式,字段名为 name / columns / row_count
|
||||
// const tables = result?.tables || result || [];
|
||||
tableList.value = (tables || []).map(t => ({
|
||||
table_name: t.name,
|
||||
row_count: t.row_count || 0,
|
||||
columns: t.columns || []
|
||||
}));
|
||||
dbTableCount.value = tableList.value.length;
|
||||
} catch (error) {
|
||||
console.error('获取表列表失败:', error);
|
||||
tableList.value = [];
|
||||
} finally {
|
||||
isTableLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const selectTable = async (table) => {
|
||||
currentTable.value = table;
|
||||
tableData.value = [];
|
||||
|
||||
uni.showLoading({
|
||||
title: '加载中...'
|
||||
});
|
||||
try {
|
||||
const token = getToken();
|
||||
const data = await getCloudDbTableData(token, databaseId.value, table.table_name);
|
||||
tableData.value = data || [];
|
||||
uni.hideLoading();
|
||||
} catch (err) {
|
||||
uni.hideLoading();
|
||||
uni.showToast({
|
||||
title: typeof err === 'string' ? err : '加载表数据失败',
|
||||
icon: 'none'
|
||||
});
|
||||
tableData.value = [];
|
||||
}
|
||||
};
|
||||
|
||||
const handleDeleteTable = (table) => {
|
||||
uni.showModal({
|
||||
title: '删除表',
|
||||
content: `确定要删除表"${table.table_name}"吗?此操作不可恢复。`,
|
||||
success: async (res) => {
|
||||
if (res.confirm) {
|
||||
uni.showLoading({
|
||||
title: '删除中...'
|
||||
});
|
||||
try {
|
||||
const token = getToken();
|
||||
await deleteCloudDbTable(token, databaseId.value, table.table_name);
|
||||
uni.hideLoading();
|
||||
uni.showToast({
|
||||
title: '删除成功',
|
||||
icon: 'success'
|
||||
});
|
||||
if (currentTable.value?.table_name === table.table_name) {
|
||||
currentTable.value = null;
|
||||
tableData.value = [];
|
||||
}
|
||||
await fetchTables();
|
||||
} catch (error) {
|
||||
uni.hideLoading();
|
||||
console.error('删除表失败:', error);
|
||||
uni.showToast({
|
||||
title: '删除失败,请重试',
|
||||
icon: 'error'
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// ========== 数据编辑 ==========
|
||||
const openEditRow = (row) => {
|
||||
const rowId = row._row_id || row._id;
|
||||
if (!rowId) {
|
||||
uni.showToast({
|
||||
title: '无法识别该行',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
// 收集可编辑字段
|
||||
const columns = tableColumns.value;
|
||||
if (columns.length === 0) {
|
||||
uni.showToast({
|
||||
title: '无可用列',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
// 简化:弹出编辑第一个字段
|
||||
const firstCol = columns[0];
|
||||
uni.showModal({
|
||||
title: `编辑 ${firstCol}`,
|
||||
editable: true,
|
||||
placeholderText: row[firstCol] || '',
|
||||
content: '',
|
||||
success: async (res) => {
|
||||
if (res.confirm && res.content !== undefined) {
|
||||
uni.showLoading({
|
||||
title: '更新中...'
|
||||
});
|
||||
try {
|
||||
const token = getToken();
|
||||
await updateCloudDbTableData(
|
||||
token,
|
||||
databaseId.value,
|
||||
currentTable.value.table_name, {
|
||||
_row_id: rowId
|
||||
}, {
|
||||
[firstCol]: res.content
|
||||
}
|
||||
);
|
||||
uni.hideLoading();
|
||||
uni.showToast({
|
||||
title: '更新成功',
|
||||
icon: 'success'
|
||||
});
|
||||
// 更新本地数据
|
||||
row[firstCol] = res.content;
|
||||
} catch (error) {
|
||||
uni.hideLoading();
|
||||
console.error('更新失败:', error);
|
||||
uni.showToast({
|
||||
title: error,
|
||||
icon: 'error'
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// ========== 导入文件 ==========
|
||||
const showNewTable = ref(false);
|
||||
const importTableName = ref('');
|
||||
const importFileName = ref('');
|
||||
const importFilePath = ref('');
|
||||
|
||||
const openImportModal = () => {
|
||||
showNewTable.value = true;
|
||||
importTableName.value = '';
|
||||
importFileName.value = '';
|
||||
importFilePath.value = '';
|
||||
};
|
||||
const closeNewTableModal = () => {
|
||||
showNewTable.value = false;
|
||||
};
|
||||
|
||||
const handlePickFile = () => {
|
||||
chooseFile({
|
||||
count: 1,
|
||||
type: 'all',
|
||||
success: (res) => {
|
||||
const file = res.tempFiles[0];
|
||||
importFileName.value = file.name || 'unknown';
|
||||
importFilePath.value = file.path;
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error('选择文件失败:', err);
|
||||
uni.showToast({
|
||||
title: '选择文件失败',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const confirmImportFile = async () => {
|
||||
const tableName = importTableName.value.trim() || "";
|
||||
// if (!tableName) {
|
||||
// uni.showToast({
|
||||
// title: '请输入表名称',
|
||||
// icon: 'none'
|
||||
// });
|
||||
// return;
|
||||
// }
|
||||
if (!importFilePath.value) {
|
||||
uni.showToast({
|
||||
title: '请选择文件',
|
||||
icon: 'none'
|
||||
});
|
||||
return
|
||||
}
|
||||
uni.showLoading({
|
||||
title: '导入中...'
|
||||
});
|
||||
try {
|
||||
const token = getToken();
|
||||
await importFileToCloudDb(token, false, databaseId.value, importFilePath.value, tableName);
|
||||
uni.hideLoading();
|
||||
uni.showToast({
|
||||
title: '导入成功',
|
||||
icon: 'success'
|
||||
});
|
||||
closeNewTableModal();
|
||||
await fetchTables();
|
||||
} catch (error) {
|
||||
uni.hideLoading();
|
||||
console.error('导入失败:', error);
|
||||
if (error === "table_exists"){
|
||||
uni.showToast({
|
||||
title: '文件已存在',
|
||||
icon: 'error'
|
||||
});
|
||||
}
|
||||
|
||||
else{
|
||||
uni.showToast({
|
||||
title: '导入失败,请重试',
|
||||
icon: 'error'
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
// ========== 权限管理 ==========
|
||||
const showPermission = ref(false);
|
||||
const permissionList = ref([]);
|
||||
|
||||
const openPermissionModal = async () => {
|
||||
showPermission.value = true;
|
||||
uni.showLoading({
|
||||
title: '加载中...'
|
||||
});
|
||||
try {
|
||||
const token = getToken();
|
||||
// 如果有 teamId 则查团队权限,否则查用户权限(传空字符串后端自动识别当前用户)
|
||||
let result;
|
||||
if (teamId.value) {
|
||||
result = await getCloudDbPermission(token, databaseId.value, 'team_id', teamId.value);
|
||||
} else {
|
||||
result = await getCloudDbPermission(token, databaseId.value, 'user_id', getUserId());
|
||||
}
|
||||
const rawList = Array.isArray(result) ? result : [];
|
||||
// 归一化:根据数据中是否存在 team 对象或 team_id 字段来判断类型
|
||||
permissionList.value = rawList.map(item => {
|
||||
if (item.team) {
|
||||
// team_id 返回格式:团队权限
|
||||
return {
|
||||
_id: item._id,
|
||||
database_id: item.database_id,
|
||||
access_level: item.access_level,
|
||||
permType: 'team_id',
|
||||
id: item.team._id || item.team.id,
|
||||
name: item.team.name
|
||||
};
|
||||
} else if (item.team_id) {
|
||||
// user_id 返回格式但有 team_id:说明数据库归属团队,显示为团队
|
||||
return {
|
||||
database_id: item.database_id,
|
||||
access_level: item.access_level,
|
||||
permType: 'team_id',
|
||||
id: item.team_id,
|
||||
name: item.database?.database_name || ''
|
||||
};
|
||||
} else {
|
||||
// user_id 返回格式且无 team_id:真正的个人数据库
|
||||
return {
|
||||
database_id: item.database_id,
|
||||
access_level: item.access_level,
|
||||
permType: 'user_id',
|
||||
id: item.user_id || item.database?.user_id || getUserId(),
|
||||
name: item.database?.database_name || ''
|
||||
};
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('获取权限失败:', error);
|
||||
permissionList.value = [];
|
||||
}
|
||||
uni.hideLoading();
|
||||
};
|
||||
const closePermissionModal = () => {
|
||||
showPermission.value = false;
|
||||
};
|
||||
|
||||
const changePermission = (perm, action) => {
|
||||
if (action === 'delete') {
|
||||
uni.showModal({
|
||||
title: '移除权限',
|
||||
content: `确定要移除"${perm.name}"的权限吗?`,
|
||||
success: async (res) => {
|
||||
if (res.confirm) {
|
||||
uni.showLoading({
|
||||
title: '移除中...'
|
||||
});
|
||||
try {
|
||||
const token = getToken();
|
||||
await deleteCloudDbPermission(token, databaseId.value, perm.permType, perm.id);
|
||||
uni.hideLoading();
|
||||
uni.showToast({
|
||||
title: '已移除',
|
||||
icon: 'success'
|
||||
});
|
||||
await openPermissionModal();
|
||||
} catch (error) {
|
||||
uni.hideLoading();
|
||||
console.error('移除权限失败:', error);
|
||||
uni.showToast({
|
||||
title: '操作失败,请重试',
|
||||
icon: 'error'
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// 修改权限级别
|
||||
const levels = ['无权限访问', '仅访问', '管理员完全控制', '团队完全控制'];
|
||||
const currentLevel = perm.access_level || 0;
|
||||
uni.showActionSheet({
|
||||
title: '选择权限级别',
|
||||
itemList: levels.map((label, idx) => `${idx}. ${label}`),
|
||||
success: async (res) => {
|
||||
const newLevel = res.tapIndex;
|
||||
if (newLevel === currentLevel) return;
|
||||
uni.showLoading({
|
||||
title: '更新中...'
|
||||
});
|
||||
try {
|
||||
const token = getToken();
|
||||
await updateCloudDbPermission(token, databaseId.value, perm.permType, perm.id,
|
||||
newLevel);
|
||||
uni.hideLoading();
|
||||
uni.showToast({
|
||||
title: '已更新',
|
||||
icon: 'success'
|
||||
});
|
||||
await openPermissionModal();
|
||||
} catch (error) {
|
||||
uni.hideLoading();
|
||||
console.error('更新权限失败:', error);
|
||||
uni.showToast({
|
||||
title: '操作失败,请重试',
|
||||
icon: 'error'
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// ========== 移交团队 ==========
|
||||
const showTransfer = ref(false);
|
||||
const teamList = ref([]);
|
||||
const selectedTeamId = ref('');
|
||||
|
||||
const openTransferModal = async () => {
|
||||
showTransfer.value = true;
|
||||
selectedTeamId.value = '';
|
||||
try {
|
||||
const token = getToken();
|
||||
const teams = await getTeamList(token);
|
||||
teamList.value = teams || [];
|
||||
} catch (error) {
|
||||
console.error('获取团队列表失败:', error);
|
||||
teamList.value = [];
|
||||
}
|
||||
};
|
||||
const closeTransferModal = () => {
|
||||
showTransfer.value = false;
|
||||
};
|
||||
|
||||
const confirmTransfer = async () => {
|
||||
if (!selectedTeamId.value) {
|
||||
uni.showToast({
|
||||
title: '请选择目标团队',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
uni.showModal({
|
||||
title: '确认移交',
|
||||
content: '移交后数据库将归属于该团队,确定继续吗?',
|
||||
success: async (res) => {
|
||||
if (res.confirm) {
|
||||
uni.showLoading({
|
||||
title: '移交中...'
|
||||
});
|
||||
try {
|
||||
const token = getToken();
|
||||
await dbTransferToTeam(token, databaseId.value, selectedTeamId.value);
|
||||
uni.hideLoading();
|
||||
uni.showToast({
|
||||
title: '移交成功',
|
||||
icon: 'success'
|
||||
});
|
||||
closeTransferModal();
|
||||
setTimeout(() => {
|
||||
uni.navigateBack();
|
||||
}, 1000);
|
||||
} catch (error) {
|
||||
uni.hideLoading();
|
||||
console.error('移交失败:', error);
|
||||
uni.showToast({
|
||||
title: '移交失败,请重试',
|
||||
icon: 'error'
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// ========== 工具函数 ==========
|
||||
const getAccessLevelLabel = (level) => {
|
||||
const labels = {
|
||||
0: '无权限访问',
|
||||
1: '仅访问',
|
||||
2: '管理员完全控制',
|
||||
3: '团队完全控制'
|
||||
};
|
||||
return labels[level] || '未知';
|
||||
};
|
||||
|
||||
const formatCellValue = (val) => {
|
||||
if (val === null || val === undefined) return '';
|
||||
if (typeof val === 'object') return JSON.stringify(val);
|
||||
return String(val);
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
// 从路由参数获取数据
|
||||
const pages = getCurrentPages();
|
||||
const currentPage = pages[pages.length - 1];
|
||||
const options = currentPage.$page?.options || currentPage.options || {};
|
||||
databaseId.value = options.databaseId || '';
|
||||
databaseName.value = decodeURIComponent(options.databaseName || '数据库详情');
|
||||
teamId.value = options.teamId || '';
|
||||
|
||||
if (databaseId.value) {
|
||||
fetchTables();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
@import url("CloudDbDetail.css");
|
||||
</style>
|
||||
@@ -194,7 +194,7 @@
|
||||
</view>
|
||||
</swiper-item>
|
||||
|
||||
<swiper-item class="content-swiper-item">
|
||||
<!-- <swiper-item class="content-swiper-item">
|
||||
<view class="tabpage-containner">
|
||||
<view class="tabpage-header">
|
||||
<view class="iconfont icon-fanhui" @click="handleBack"></view>
|
||||
@@ -258,7 +258,7 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</swiper-item>
|
||||
</swiper-item> -->
|
||||
|
||||
<swiper-item class="content-swiper-item">
|
||||
<view class="tabpage-containner">
|
||||
@@ -389,11 +389,11 @@
|
||||
label: '添加好友',
|
||||
icon: '➕'
|
||||
},
|
||||
{
|
||||
name: 'videoCall',
|
||||
label: '视频会议',
|
||||
icon: '📹'
|
||||
},
|
||||
// {
|
||||
// name: 'videoCall',
|
||||
// label: '视频会议',
|
||||
// icon: '📹'
|
||||
// },
|
||||
{
|
||||
name: 'friendRequest',
|
||||
label: '好友申请',
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
<!-- 目录名称输入 -->
|
||||
<view class="new-folder-name">目录名称</view>
|
||||
<view class="create-folder-name" :class="{'has-value': isNFNFocused || newFolderName}">
|
||||
<input v-model="newFolderName" @focus="isNFNFocused=true"
|
||||
@blur="isNFNFocused=false" type="text" placeholder="输入目录名称,如:项目资料/设计图" />
|
||||
<input v-model="newFolderName" @focus="isNFNFocused=true" @blur="isNFNFocused=false" type="text"
|
||||
placeholder="输入目录名称,如:项目资料/设计图" />
|
||||
</view>
|
||||
|
||||
<!-- 当前路径 -->
|
||||
@@ -50,7 +50,9 @@
|
||||
@click="handleMenu"></view>
|
||||
</view>
|
||||
<view v-if="isMenuOpen" class="menu-card">
|
||||
<view class="menu-card-item" @click="handleSelectFolder();handleMenu()">选择</view>
|
||||
<!-- <view class="menu-card-item" @click="handleSelectFolder();handleMenu()">选择</view>
|
||||
<view class="solid-line"></view> -->
|
||||
<view class="menu-card-item" @click="handleUploadFile();handleMenu()">上传文件</view>
|
||||
<view class="solid-line"></view>
|
||||
<view class="menu-card-item" @click="newWorkspaceFolder();handleMenu()">新建文件夹</view>
|
||||
</view>
|
||||
@@ -88,11 +90,11 @@
|
||||
</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-shangchuan" @click="handleUploadFile"></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 class="iconfont icon-gengduo"></view> -->
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
@@ -107,11 +109,17 @@
|
||||
getWorkspaceId,
|
||||
getToken
|
||||
} from '@/utils/user-info.js'
|
||||
import {
|
||||
chooseFile
|
||||
} from '@/uni_modules/lime-choose-file';
|
||||
import {
|
||||
getWorkspaceList,
|
||||
createWorkspaceFolder,
|
||||
daleteWorkspace,
|
||||
getWorkspaceFileURL
|
||||
getWorkspaceFileURL,
|
||||
uploadFileToShortStorage,
|
||||
workspaceUploadFileByURL,
|
||||
updateWorkspaceFileName
|
||||
} from '@/utils/cloud-api.js'
|
||||
|
||||
const UserToken = ref('')
|
||||
@@ -148,6 +156,84 @@
|
||||
showNewFolder.value = true
|
||||
}
|
||||
|
||||
// ========== 上传文件 ==========
|
||||
const handleUploadFile = () => {
|
||||
chooseFile({
|
||||
count: 10,
|
||||
type: 'all',
|
||||
success: async (res) => {
|
||||
const files = res.tempFiles || [];
|
||||
if (files.length === 0) {
|
||||
uni.showToast({
|
||||
title: '未选择文件',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
await doUploadWorkspaceFiles(files);
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error('选择文件失败:', err);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const doUploadWorkspaceFiles = async (files) => {
|
||||
uni.showLoading({
|
||||
title: '上传中...'
|
||||
});
|
||||
try {
|
||||
const dirPath = folderStack.value.length > 0 ?
|
||||
'./' + folderStack.value.map(f => f.name).join('/') + '/' :
|
||||
'/';
|
||||
|
||||
// 1. 一次性上传所有文件到短存云端,获取 URL 数组
|
||||
const results = await uploadFileToShortStorage(
|
||||
workspaceId.value,
|
||||
files,
|
||||
dirPath
|
||||
);
|
||||
// results: [{ url, success }, ...]
|
||||
|
||||
// 2. 收集成功的 URL,批量上传到工作区
|
||||
const successUrls = results
|
||||
.filter(r => r.success)
|
||||
.map(r => r.url);
|
||||
|
||||
if (successUrls.length === 0) {
|
||||
const errors = results.filter(r => !r.success).map(r => r.error).join('; ');
|
||||
throw new Error(errors || '所有文件上传失败');
|
||||
}
|
||||
|
||||
await workspaceUploadFileByURL(
|
||||
UserToken.value,
|
||||
workspaceId.value,
|
||||
successUrls,
|
||||
dirPath
|
||||
);
|
||||
|
||||
uni.hideLoading();
|
||||
const total = files.length;
|
||||
const failed = total - successUrls.length;
|
||||
const msg = failed > 0 ?
|
||||
`上传完成:成功 ${successUrls.length},失败 ${failed}` :
|
||||
`成功上传 ${total} 个文件`;
|
||||
uni.showToast({
|
||||
title: msg,
|
||||
icon: successUrls.length > 0 ? 'success' : 'error'
|
||||
});
|
||||
// 刷新文件列表
|
||||
initCurrentFolderList();
|
||||
} catch (error) {
|
||||
uni.hideLoading();
|
||||
console.error('上传文件失败:', error);
|
||||
uni.showToast({
|
||||
title: typeof error === 'string' ? error : '上传失败,请重试',
|
||||
icon: 'error'
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// 当前文件夹路径
|
||||
const currentFolderPath = computed(() => {
|
||||
if (folderStack.value.length === 0) return '根目录'
|
||||
@@ -168,7 +254,10 @@
|
||||
const confirmCreateFolder = async () => {
|
||||
const name = newFolderName.value.trim()
|
||||
if (!name) {
|
||||
uni.showToast({ title: '请输入目录名称', icon: 'none' })
|
||||
uni.showToast({
|
||||
title: '请输入目录名称',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
try {
|
||||
@@ -176,12 +265,18 @@
|
||||
const folderPath = folderStack.value.map(f => f.name).join('/')
|
||||
const dirPath = folderPath ? `./${folderPath}/${name}` : `./${name}`
|
||||
await createWorkspaceFolder(UserToken.value, workspaceId.value, dirPath)
|
||||
uni.showToast({ title: '创建成功', icon: 'success' })
|
||||
uni.showToast({
|
||||
title: '创建成功',
|
||||
icon: 'success'
|
||||
})
|
||||
closeNewFolderModal()
|
||||
initCurrentFolderList()
|
||||
} catch (error) {
|
||||
console.error('创建文件夹失败:', error)
|
||||
uni.showToast({ title: '创建失败,请重试', icon: 'error' })
|
||||
uni.showToast({
|
||||
title: '创建失败,请重试',
|
||||
icon: 'error'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,132 +284,107 @@
|
||||
const handleLongPress = (folder) => {
|
||||
if (isSelectFolder.value) return;
|
||||
uni.showActionSheet({
|
||||
itemList: ['重命名', '删除', '下载', '压缩'],
|
||||
itemList: ['下载', '删除'], // ['删除', '下载', '压缩', '重命名']
|
||||
success: (res) => {
|
||||
switch (res.tapIndex) {
|
||||
case 0:
|
||||
handleRename(folder);
|
||||
handleDownload(folder);
|
||||
break;
|
||||
case 1:
|
||||
handleDelete(folder);
|
||||
break;
|
||||
case 2:
|
||||
handleDownload(folder);
|
||||
break;
|
||||
case 3:
|
||||
handleDownload(folder);
|
||||
break;
|
||||
// case 2:
|
||||
// handleDownload(folder);
|
||||
// break;
|
||||
// case 3:
|
||||
// handleRename(folder);
|
||||
// break;
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 重命名
|
||||
const handleRename = (folder) => {
|
||||
const handleRename = async (folder) => {
|
||||
uni.showModal({
|
||||
title: '重命名',
|
||||
content: '请输入新名称',
|
||||
editable: true,
|
||||
placeholderText: folder.name,
|
||||
success: (res) => {
|
||||
success: async (res) => {
|
||||
if (res.confirm && res.content) {
|
||||
// 更新文件夹名称
|
||||
updateFolderName(folder.id, res.content);
|
||||
try {
|
||||
uni.showLoading({
|
||||
title: '重命名中...'
|
||||
});
|
||||
// 构建文件路径:当前目录 + 文件名
|
||||
const dirPath = folderStack.value.length > 0 ?
|
||||
'./' + folderStack.value.map(f => f.name).join('/') + '/' :
|
||||
'/';
|
||||
const filePath = dirPath + folder.name;
|
||||
await updateWorkspaceFileName(
|
||||
workspaceId.value,
|
||||
filePath,
|
||||
res.content
|
||||
);
|
||||
uni.hideLoading();
|
||||
uni.showToast({
|
||||
title: '重命名成功',
|
||||
icon: 'success'
|
||||
});
|
||||
// 刷新文件列表
|
||||
initCurrentFolderList();
|
||||
} catch (error) {
|
||||
uni.hideLoading();
|
||||
console.error('重命名失败:', error);
|
||||
uni.showToast({
|
||||
title: typeof error === 'string' ? error : '重命名失败,请重试',
|
||||
icon: 'error'
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// // 下载文件
|
||||
// const handleDownload = async (folder) => {
|
||||
// // 目录不能下载
|
||||
// if (folder.type === 'directory') {
|
||||
// uni.showToast({ title: '暂不支持下载目录', icon: 'none' });
|
||||
// return;
|
||||
// }
|
||||
|
||||
// try {
|
||||
// uni.showLoading({ title: '获取下载链接...' });
|
||||
|
||||
// // 构建文件路径,去掉开头的 ./
|
||||
// const filePath = folder.path.startsWith('./') ? folder.path.slice(2) : folder.path;
|
||||
// const result = await getWorkspaceFileURL(UserToken.value, workspaceId.value, filePath);
|
||||
|
||||
// uni.hideLoading();
|
||||
|
||||
// // 接口返回数组,取第一个文件的 url
|
||||
// const fileInfo = Array.isArray(result) ? result[0] : result;
|
||||
// if (!fileInfo || !fileInfo.url) {
|
||||
// uni.showToast({ title: '获取下载链接失败', icon: 'error' });
|
||||
// return;
|
||||
// }
|
||||
|
||||
// const downloadUrl = fileInfo.url;
|
||||
// const fileName = folder.name;
|
||||
|
||||
// uni.showLoading({ title: '下载中...' });
|
||||
|
||||
// uni.downloadFile({
|
||||
// url: downloadUrl,
|
||||
// success: (downloadRes) => {
|
||||
// uni.hideLoading();
|
||||
// if (downloadRes.statusCode === 200) {
|
||||
// // 保存到手机相册/文件
|
||||
// uni.saveFile({
|
||||
// tempFilePath: downloadRes.tempFilePath,
|
||||
// success: (saveRes) => {
|
||||
// uni.showToast({ title: '下载成功', icon: 'success' });
|
||||
// console.log('文件已保存到:', saveRes.savedFilePath);
|
||||
// },
|
||||
// fail: (err) => {
|
||||
// console.error('保存文件失败:', err);
|
||||
// uni.showToast({ title: '保存文件失败', icon: 'error' });
|
||||
// }
|
||||
// });
|
||||
// } else {
|
||||
// uni.showToast({ title: '下载失败', icon: 'error' });
|
||||
// }
|
||||
// },
|
||||
// fail: (err) => {
|
||||
// uni.hideLoading();
|
||||
// console.error('下载文件失败:', err);
|
||||
// uni.showToast({ title: '下载失败,请重试', icon: 'error' });
|
||||
// }
|
||||
// });
|
||||
// } catch (error) {
|
||||
// uni.hideLoading();
|
||||
// console.error('获取下载链接失败:', error);
|
||||
// uni.showToast({ title: '获取下载链接失败,请重试', icon: 'error' });
|
||||
// }
|
||||
// };
|
||||
const handleDownload = async (folder) => {
|
||||
// 目录不能下载
|
||||
if (folder.type === 'directory') {
|
||||
uni.showToast({ title: '暂不支持下载目录', icon: 'none' });
|
||||
uni.showToast({
|
||||
title: '暂不支持下载目录',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
uni.showLoading({ title: '获取下载链接...' });
|
||||
|
||||
uni.showLoading({
|
||||
title: '获取下载链接...'
|
||||
});
|
||||
|
||||
// 构建文件路径,去掉开头的 ./
|
||||
const filePath = folder.path.startsWith('./') ? folder.path.slice(2) : folder.path;
|
||||
const result = await getWorkspaceFileURL(UserToken.value, workspaceId.value, filePath);
|
||||
|
||||
|
||||
uni.hideLoading();
|
||||
|
||||
|
||||
// 接口返回数组,取第一个文件的 url
|
||||
const fileInfo = Array.isArray(result) ? result[0] : result;
|
||||
if (!fileInfo || !fileInfo.url) {
|
||||
uni.showToast({ title: '获取下载链接失败', icon: 'error' });
|
||||
uni.showToast({
|
||||
title: '获取下载链接失败',
|
||||
icon: 'error'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
const downloadUrl = fileInfo.url;
|
||||
const fileName = folder.name;
|
||||
|
||||
uni.showLoading({ title: '下载中...' });
|
||||
|
||||
|
||||
uni.showLoading({
|
||||
title: '下载中...'
|
||||
});
|
||||
|
||||
uni.downloadFile({
|
||||
url: downloadUrl,
|
||||
name: fileName,
|
||||
@@ -325,19 +395,28 @@
|
||||
// 下载成功,保存到 yxd 目录
|
||||
saveFileToYxd(fileName, tempPath);
|
||||
} else {
|
||||
uni.showToast({ title: '下载失败', icon: 'error' });
|
||||
uni.showToast({
|
||||
title: '下载失败',
|
||||
icon: 'error'
|
||||
});
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
uni.hideLoading();
|
||||
console.error('下载文件失败:', err);
|
||||
uni.showToast({ title: '下载失败,请重试', icon: 'error' });
|
||||
uni.showToast({
|
||||
title: '下载失败,请重试',
|
||||
icon: 'error'
|
||||
});
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
uni.hideLoading();
|
||||
console.error('获取下载链接失败:', error);
|
||||
uni.showToast({ title: '获取下载链接失败,请重试', icon: 'error' });
|
||||
uni.showToast({
|
||||
title: '获取下载链接失败,请重试',
|
||||
icon: 'error'
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -352,16 +431,24 @@
|
||||
callback(dirEntry);
|
||||
}, () => {
|
||||
plus.io.resolveLocalFileSystemURL('/storage/emulated/0/', (rootEntry) => {
|
||||
rootEntry.getDirectory('yxd', { create: true }, (dirEntry) => {
|
||||
rootEntry.getDirectory('yxd', {
|
||||
create: true
|
||||
}, (dirEntry) => {
|
||||
callback(dirEntry);
|
||||
}, (err) => {
|
||||
console.error('创建 yxd 目录失败:', JSON.stringify(err));
|
||||
uni.showToast({ title: '创建目录失败', icon: 'error' });
|
||||
uni.showToast({
|
||||
title: '创建目录失败',
|
||||
icon: 'error'
|
||||
});
|
||||
openFileConfirm(fileName, tempPath);
|
||||
});
|
||||
}, (err) => {
|
||||
console.error('访问外部存储根目录失败:', JSON.stringify(err));
|
||||
uni.showToast({ title: '无法访问存储目录', icon: 'error' });
|
||||
uni.showToast({
|
||||
title: '无法访问存储目录',
|
||||
icon: 'error'
|
||||
});
|
||||
openFileConfirm(fileName, tempPath);
|
||||
});
|
||||
});
|
||||
@@ -478,13 +565,19 @@
|
||||
try {
|
||||
// 路径加 ./ 前缀
|
||||
const filePath = `./${folder.path}`
|
||||
console.log("删除的是:",filePath);
|
||||
console.log("删除的是:", filePath);
|
||||
await daleteWorkspace(UserToken.value, workspaceId.value, filePath)
|
||||
uni.showToast({ title: '删除成功', icon: 'success' })
|
||||
uni.showToast({
|
||||
title: '删除成功',
|
||||
icon: 'success'
|
||||
})
|
||||
initCurrentFolderList()
|
||||
} catch (error) {
|
||||
console.error('删除失败:', error)
|
||||
uni.showToast({ title: '删除失败,请重试', icon: 'error' })
|
||||
uni.showToast({
|
||||
title: '删除失败,请重试',
|
||||
icon: 'error'
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user