Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ repos:
- id: check-added-large-files

- repo: https://github.com/psf/black
rev: 25.12.0
rev: 26.1.0
hooks:
- id: black
files: ^api/
Expand All @@ -21,9 +21,18 @@ repos:

- repo: local
hooks:
- id: web-format
name: web-format
- id: prettier-format
name: prettier-format
entry: npm run format --prefix web
language: system
files: ^web/
pass_filenames: false

- repo: local
hooks:
- id: eslint
name: eslint
entry: npm run lint --prefix web
language: system
files: ^web/
pass_filenames: false
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,16 @@ docker compose -f docker-compose.dev.yml up --build

API 文档:http://localhost:8000/docs

## 代码提交

使用 [pre-commit](https://pre-commit.com/) 格式化

```shell
pip install pre-commit

pre-commit run --all-files
```

## 📚 数据库迁移

```bash
Expand All @@ -92,23 +102,13 @@ alembic upgrade head
alembic downgrade -1
```

## 🤝 贡献

欢迎贡献!请遵循以下步骤:

1. Fork 本仓库
2. 创建特性分支 (`git checkout -b feature/AmazingFeature`)
3. 提交更改 (`git commit -m 'Add some AmazingFeature'`)
4. 推送到分支 (`git push origin feature/AmazingFeature`)
5. 开启 Pull Request

## 📄 许可证

本项目采用 MIT 许可证 - 查看 [LICENSE](LICENSE) 文件了解详情

## 📧 联系方式

如有问题或建议,请提交 Issue 或 Pull Request
如有问题或建议,请提交 Issue 。

---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,22 +82,18 @@ def downgrade() -> None:
batch_op.add_column(sa.Column("role", sa.String(), nullable=True))

# 将 system_admins 表中的用户恢复到 users.role
op.execute(
"""
op.execute("""
UPDATE users
SET role = 'admin'
WHERE id IN (SELECT user_id FROM system_admins)
"""
)
""")

# 设置其他用户为 'user'
op.execute(
"""
op.execute("""
UPDATE users
SET role = 'user'
WHERE role IS NULL
"""
)
""")

# 删除 system_admins 表
op.drop_index(op.f("ix_system_admins_id"), table_name="system_admins")
Expand Down
1 change: 1 addition & 0 deletions api/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ dependencies = [
"boto3>=1.35.0",
"alembic>=1.17.2",
"shortuuid>=1.0.13",
"pre-commit>=4.5.1",
]

[tool.black]
Expand Down
124 changes: 124 additions & 0 deletions api/uv.lock

Large diffs are not rendered by default.

12 changes: 11 additions & 1 deletion web/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ export default defineConfig([
},

js.configs.recommended,
...pluginVue.configs['flat/essential'],
...pluginVue.configs['flat/recommended'],
{
rules: {
'vue/block-order': [
'error',
{
order: ['script', 'template', 'style'],
},
],
},
},
skipFormatting,
])
6 changes: 3 additions & 3 deletions web/src/components/DragUploadZone.vue
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ defineExpose({
/>

<!-- 默认插槽:包裹需要拖拽上传功能的内容 -->
<slot :triggerFileInput="triggerFileInput" :triggerFolderInput="triggerFolderInput"></slot>
<slot :trigger-file-input="triggerFileInput" :trigger-folder-input="triggerFolderInput"></slot>

<!-- 拖拽覆盖层 -->
<div
Expand Down Expand Up @@ -290,9 +290,9 @@ defineExpose({
class="absolute top-4 right-4 z-40 flex gap-2"
>
<button
@click.stop="triggerFileInput"
class="btn btn-sm btn-primary gap-2 shadow-lg"
title="选择文件上传"
@click.stop="triggerFileInput"
>
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path
Expand All @@ -305,9 +305,9 @@ defineExpose({
上传文件
</button>
<button
@click.stop="triggerFolderInput"
class="btn btn-sm btn-primary gap-2 shadow-lg"
title="选择文件夹上传"
@click.stop="triggerFolderInput"
>
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path
Expand Down
18 changes: 9 additions & 9 deletions web/src/components/FileDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const props = defineProps({
// 当模态框打开才有 fileId
fileId: {
type: String,
// required: true,
default: '',
},
isOpen: {
type: Boolean,
Expand Down Expand Up @@ -103,15 +103,15 @@ watch(
</h2>
<p class="flex gap-3 text-sm text-gray-500 dark:text-gray-400 mt-1">
<span class="badge badge-outline">{{ getFileExtension(file.filename) }} 文件</span>
<span class="badge badge-outline badge-warning" v-if="file.is_deleted === 1"
<span v-if="file.is_deleted === 1" class="badge badge-outline badge-warning"
>在回收站</span
>
</p>
</div>
</div>
<button
@click="close"
class="btn btn-sm btn-circle btn-ghost text-gray-500 hover:text-gray-700 dark:hover:text-gray-300"
@click="close"
>
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path
Expand Down Expand Up @@ -217,9 +217,9 @@ watch(
{{ file.filename }}
</span>
<button
@click="copyToClipboard(file.filename)"
class="btn btn-xs btn-ghost text-gray-400 hover:text-blue-500"
title="复制文件名"
@click="copyToClipboard(file.filename)"
>
<svg class="w-3 h-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path
Expand Down Expand Up @@ -260,9 +260,9 @@ watch(
</span>
<button
v-if="file.hash"
@click="copyToClipboard(file.hash)"
class="btn btn-xs btn-ghost text-gray-400 hover:text-blue-500"
title="复制哈希值"
@click="copyToClipboard(file.hash)"
>
<svg class="w-3 h-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path
Expand Down Expand Up @@ -340,9 +340,9 @@ watch(
{{ file.id }}
</span>
<button
@click="copyToClipboard(file.id)"
class="btn btn-xs btn-ghost text-gray-400 hover:text-blue-500"
title="复制 ID"
@click="copyToClipboard(file.id)"
>
<svg class="w-3 h-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path
Expand Down Expand Up @@ -384,8 +384,8 @@ watch(
<div class="flex gap-2">
<button
v-if="showRename"
@click="$emit('rename', file)"
class="btn btn-sm btn-outline gap-2"
@click="$emit('rename', file)"
>
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path
Expand All @@ -399,8 +399,8 @@ watch(
</button>
<button
v-if="showDelete"
@click="$emit('delete', file.id)"
class="btn btn-sm btn-outline btn-error gap-2"
@click="$emit('delete', file.id)"
>
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path
Expand All @@ -416,8 +416,8 @@ watch(
<div class="flex gap-2">
<button
v-if="showManageNotes"
@click="$emit('manage-notes', file, 'file')"
class="btn btn-sm btn-primary gap-2"
@click="$emit('manage-notes', file, 'file')"
>
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path
Expand Down
6 changes: 3 additions & 3 deletions web/src/components/FileFolderSelector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,10 @@ onMounted(() => {
</svg>
<input
v-model="searchQuery"
@input="handleSearch"
type="text"
placeholder="搜索文件..."
class="w-full pl-10 pr-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-primary focus:border-primary bg-white dark:bg-gray-800"
@input="handleSearch"
/>
</div>

Expand All @@ -218,11 +218,11 @@ onMounted(() => {

<!-- 内容区域 -->
<DragUploadZone
:showSelected="true"
:show-selected="true"
:folder-id="currentFolderId"
:upload-mode="uploadMode"
@upload-complete="handleDragUploadComplete"
class="flex-1 overflow-y-auto"
@upload-complete="handleDragUploadComplete"
>
<div v-if="loading" class="flex justify-center items-center py-12">
<span class="loading loading-spinner loading-lg"></span>
Expand Down
22 changes: 11 additions & 11 deletions web/src/components/FileGrid.vue
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,12 @@ const hoveredFolder = ref(null)
@mouseenter="hoveredFolder = folder.id"
@mouseleave="hoveredFolder = null"
>
<div class="absolute top-2 left-2 z-10" v-if="selectionMode">
<div v-if="selectionMode" class="absolute top-2 left-2 z-10">
<input
type="checkbox"
:checked="localSelectedFolders.includes(folder.id)"
@click.stop="toggleFolderSelection(folder.id)"
class="checkbox checkbox-sm checkbox-primary"
@click.stop="toggleFolderSelection(folder.id)"
/>
</div>
<div
Expand All @@ -137,10 +137,10 @@ const hoveredFolder = ref(null)
{{ folder.name }}
</h3>
<button
@click.stop="$emit('manage-notes', folder, 'folder')"
class="btn btn-xs btn-outline text-gray-400 hover:text-blue-500"
:class="{ 'text-blue-500': folder.notes_count > 0 }"
:title="`管理笔记 (${folder.notes_count || 0})`"
@click.stop="$emit('manage-notes', folder, 'folder')"
>
📝
<span v-if="folder.notes_count > 0" class="text-xs">{{ folder.notes_count }}</span>
Expand All @@ -153,8 +153,8 @@ const hoveredFolder = ref(null)
<div class="flex-1">
<button
class="btn btn-xs btn-ghost text-gray-500 hover:text-blue-600"
@click.stop="$emit('edit-folder', folder)"
title="重命名"
@click.stop="$emit('edit-folder', folder)"
>
<svg class="w-3 h-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path
Expand Down Expand Up @@ -199,12 +199,12 @@ const hoveredFolder = ref(null)
@mouseenter="hoveredFile = file.id"
@mouseleave="hoveredFile = null"
>
<div class="absolute top-2 left-2 z-10" v-if="selectionMode">
<div v-if="selectionMode" class="absolute top-2 left-2 z-10">
<input
type="checkbox"
:checked="localSelectedFiles.includes(file.id)"
@click.stop="toggleFileSelection(file.id)"
class="checkbox checkbox-sm checkbox-primary"
@click.stop="toggleFileSelection(file.id)"
/>
</div>
<!-- 文件预览区域 -->
Expand Down Expand Up @@ -238,9 +238,9 @@ const hoveredFolder = ref(null)
>
<div class="flex gap-2">
<button
@click.stop="$emit('view-details', file)"
class="btn btn-sm btn-circle bg-white/90 hover:bg-white text-gray-700 border-0 shadow-lg"
title="查看文件"
@click.stop="$emit('view-details', file)"
>
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path
Expand Down Expand Up @@ -271,10 +271,10 @@ const hoveredFolder = ref(null)
{{ file.filename }}
</h3>
<button
@click="$emit('manage-notes', file, 'file')"
class="btn btn-xs btn-outline text-gray-400 hover:text-blue-500"
:class="{ 'text-blue-500': file.notes_count > 0 }"
:title="`管理笔记 (${file.notes_count || 0})`"
@click="$emit('manage-notes', file, 'file')"
>
📝
<span v-if="file.notes_count > 0" class="text-xs">{{ file.notes_count }}</span>
Expand All @@ -288,13 +288,13 @@ const hoveredFolder = ref(null)

<!-- 操作按钮 -->
<div
class="flex gap-2 pt-2 border-t border-gray-100 dark:border-gray-700"
v-if="isShowOperationBtn"
class="flex gap-2 pt-2 border-t border-gray-100 dark:border-gray-700"
>
<button
class="btn btn-xs btn-ghost text-gray-500 hover:text-blue-600"
@click="$emit('view-details', file)"
title="查看详情"
@click="$emit('view-details', file)"
>
<svg class="w-3 h-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path
Expand All @@ -307,8 +307,8 @@ const hoveredFolder = ref(null)
</button>
<button
class="btn btn-xs btn-ghost text-gray-500 hover:text-blue-600"
@click="$emit('rename-file', file)"
title="重命名"
@click="$emit('rename-file', file)"
>
<svg class="w-3 h-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path
Expand Down
Loading