refactor(services): 重构服务模块导入和文件重命名功能
- 移除 services/__init__.py 中的所有服务导入导出 - 将各个蓝图中的通配符导入改为具体服务模块导入 - 将 files_rename 函数重命名为 file_rename 并更新相关引用 - 更新前端 API 调用中的函数名映射 - 修复视频蓝图中的多余空行问题 - 移除种子蓝图中的未使用路由代码
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
from flask import Blueprint, current_app, Response
|
from flask import Blueprint, current_app, Response
|
||||||
|
|
||||||
from app.services import BookService
|
from app.services.book_service import BookService
|
||||||
|
|
||||||
bp = Blueprint("book", __name__)
|
bp = Blueprint("book", __name__)
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
from typing import List
|
from typing import List
|
||||||
from flask import Blueprint, jsonify
|
from flask import Blueprint, jsonify
|
||||||
|
|
||||||
from app.services import FileService
|
from app.services.file_service import FileService
|
||||||
|
|
||||||
bp = Blueprint("file", __name__)
|
bp = Blueprint("file", __name__)
|
||||||
|
|
||||||
|
|
||||||
@bp.route('/rename')
|
@bp.route('/rename')
|
||||||
def files_rename():
|
def file_rename():
|
||||||
paths: List[str] = [
|
paths: List[str] = [
|
||||||
"C:\\迅雷下载\\0_done",
|
"C:\\迅雷下载\\0_done",
|
||||||
"C:\\Users\\Localhost\\Desktop\\BT",
|
"C:\\Users\\Localhost\\Desktop\\BT",
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
from flask import Blueprint, Response, jsonify
|
from flask import Blueprint, Response, jsonify
|
||||||
|
|
||||||
from app.services import ImageService, TorrentService
|
from app.services.image_service import ImageService
|
||||||
|
from app.services.torrent_service import TorrentService
|
||||||
|
|
||||||
bp = Blueprint("image", __name__)
|
bp = Blueprint("image", __name__)
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
from flask import Blueprint, jsonify
|
from flask import Blueprint, jsonify
|
||||||
|
|
||||||
from app.services import MusicService
|
from app.services.music_service import MusicService
|
||||||
|
|
||||||
bp = Blueprint("music", __name__)
|
bp = Blueprint("music", __name__)
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
from flask import Blueprint, jsonify
|
from flask import Blueprint, jsonify
|
||||||
|
|
||||||
from app.services import TorrentService
|
from app.services.torrent_service import TorrentService
|
||||||
|
|
||||||
bp = Blueprint("torrent", __name__)
|
bp = Blueprint("torrent", __name__)
|
||||||
|
|
||||||
@@ -17,7 +17,12 @@ def torrent_statistics():
|
|||||||
return jsonify({"code": 200, "message": torrent_object.statistics()})
|
return jsonify({"code": 200, "message": torrent_object.statistics()})
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/s/<name>")
|
@bp.route("/<name>")
|
||||||
def torrent_by_name(name):
|
def torrent_by_name(name):
|
||||||
torrent_object = TorrentService(["C:\\Users\\Localhost\\Desktop\\BT"])
|
torrent_object = TorrentService(["C:\\Users\\Localhost\\Desktop\\BT"])
|
||||||
return jsonify({"code": 200, "message": torrent_object.get_by_name(name)})
|
return jsonify({"code": 200, "message": torrent_object.get_by_name(name)})
|
||||||
|
|
||||||
|
# @bp.route("/extract/name")
|
||||||
|
# def torrent_extract_name():
|
||||||
|
# torrent_object = TorrentService([])
|
||||||
|
# return jsonify({"code": 200, "message": torrent_object.extract_name("AVSA-429.torrent")})
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
from flask import Blueprint, jsonify
|
from flask import Blueprint, jsonify
|
||||||
|
|
||||||
from app.services import VideoService, TorrentService
|
from app.services.video_service import VideoService
|
||||||
|
from app.services.torrent_service import TorrentService
|
||||||
|
|
||||||
bp = Blueprint("video", __name__)
|
bp = Blueprint("video", __name__)
|
||||||
|
|
||||||
@@ -24,7 +25,6 @@ def video_deduplication():
|
|||||||
"E:\\",
|
"E:\\",
|
||||||
"F:\\"
|
"F:\\"
|
||||||
])
|
])
|
||||||
|
|
||||||
return jsonify({"code": 200, "message": video_object.deduplication()})
|
return jsonify({"code": 200, "message": video_object.deduplication()})
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
from .folder_service import FolderService
|
|
||||||
from .file_service import FileService
|
|
||||||
from .torrent_service import TorrentService
|
|
||||||
from .book_service import BookService
|
|
||||||
from .image_service import ImageService
|
|
||||||
from .music_service import MusicService
|
|
||||||
from .video_service import VideoService
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import os
|
import os
|
||||||
from typing import List, Optional
|
from typing import List, Optional
|
||||||
|
|
||||||
from app.services import FolderService
|
from app.services.folder_service import FolderService
|
||||||
from app.utils import windows_sort_unicode
|
from app.utils import windows_sort_unicode
|
||||||
from app.constants import IGNORE_DIRS, SEPARATORS, SPECIAL_PREFIXES, SPECIAL_DIRS
|
from app.constants import IGNORE_DIRS, SEPARATORS, SPECIAL_PREFIXES, SPECIAL_DIRS
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import os
|
|||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
from app.services import FolderService
|
from app.services.folder_service import FolderService
|
||||||
from app.constants import IMAGE_EXTENSIONS, IGNORE_DIRS
|
from app.constants import IMAGE_EXTENSIONS, IGNORE_DIRS
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import os
|
import os
|
||||||
from typing import List
|
from typing import List
|
||||||
from app.services import FolderService
|
from app.services.folder_service import FolderService
|
||||||
from app.utils import windows_sort_unicode
|
from app.utils import windows_sort_unicode
|
||||||
|
|
||||||
class MusicService:
|
class MusicService:
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ from collections import defaultdict
|
|||||||
from typing import List, Optional
|
from typing import List, Optional
|
||||||
|
|
||||||
from app.constants import IGNORE_DIRS, SEPARATORS, SPECIAL_PREFIXES, SPECIAL_DIRS
|
from app.constants import IGNORE_DIRS, SEPARATORS, SPECIAL_PREFIXES, SPECIAL_DIRS
|
||||||
from app.services import FolderService
|
from app.services.folder_service import FolderService
|
||||||
from app.utils import to_json_serializable
|
from app.utils import to_json_serializable
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import shutil
|
|||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
|
||||||
from app.constants import IGNORE_DIRS, TORRENT_ROOT_FOLDER
|
from app.constants import IGNORE_DIRS, TORRENT_ROOT_FOLDER
|
||||||
from app.services import FolderService
|
from app.services.folder_service import FolderService
|
||||||
|
|
||||||
|
|
||||||
class VideoService:
|
class VideoService:
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ export function video_hasTorrent() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function files_rename() {
|
export function file_rename() {
|
||||||
return request({
|
return request({
|
||||||
url: "/file/rename",
|
url: "/file/rename",
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {ref, onUnmounted} from "vue";
|
import {ref, onUnmounted} from "vue";
|
||||||
import {
|
import {
|
||||||
files_rename,
|
file_rename,
|
||||||
music_rename,
|
music_rename,
|
||||||
image_hasTorrent,
|
image_hasTorrent,
|
||||||
video_hasTorrent,
|
video_hasTorrent,
|
||||||
@@ -30,7 +30,7 @@ const messages = ref<messageItem[]>([{id: Date.now(), text: '输出结果'}])
|
|||||||
|
|
||||||
const buttons = [
|
const buttons = [
|
||||||
{id: 0, title: "小说下载"},
|
{id: 0, title: "小说下载"},
|
||||||
{id: 1, title: "文件重命名", handle: files_rename},
|
{id: 1, title: "文件重命名", handle: file_rename},
|
||||||
{id: 2, title: "视频查找重复", handle: video_findDeduplication},
|
{id: 2, title: "视频查找重复", handle: video_findDeduplication},
|
||||||
{id: 3, title: "视频去重", handle: video_deduplication},
|
{id: 3, title: "视频去重", handle: video_deduplication},
|
||||||
{id: 4, title: "种子去重", handle: torrent_deduplication},
|
{id: 4, title: "种子去重", handle: torrent_deduplication},
|
||||||
|
|||||||
Reference in New Issue
Block a user