mirror of
https://github.com/ctwj/urldb.git
synced 2025-11-25 11:29:37 +08:00
update: pan
This commit is contained in:
@@ -94,10 +94,7 @@ func ToPanResponse(pan *entity.Pan) dto.PanResponse {
|
||||
ID: pan.ID,
|
||||
Name: pan.Name,
|
||||
Key: pan.Key,
|
||||
Ck: pan.Ck,
|
||||
IsValid: pan.IsValid,
|
||||
Space: pan.Space,
|
||||
LeftSpace: pan.LeftSpace,
|
||||
Icon: pan.Icon,
|
||||
Remark: pan.Remark,
|
||||
}
|
||||
}
|
||||
@@ -116,9 +113,11 @@ func ToCksResponse(cks *entity.Cks) dto.CksResponse {
|
||||
return dto.CksResponse{
|
||||
ID: cks.ID,
|
||||
PanID: cks.PanID,
|
||||
T: cks.T,
|
||||
Idx: cks.Idx,
|
||||
Ck: cks.Ck,
|
||||
IsValid: cks.IsValid,
|
||||
Space: cks.Space,
|
||||
LeftSpace: cks.LeftSpace,
|
||||
Remark: cks.Remark,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,10 +4,7 @@ package dto
|
||||
type CreatePanRequest struct {
|
||||
Name string `json:"name" binding:"required"`
|
||||
Key int `json:"key"`
|
||||
Ck string `json:"ck"`
|
||||
IsValid bool `json:"is_valid"`
|
||||
Space int64 `json:"space"`
|
||||
LeftSpace int64 `json:"left_space"`
|
||||
Icon string `json:"icon"`
|
||||
Remark string `json:"remark"`
|
||||
}
|
||||
|
||||
@@ -15,6 +12,14 @@ type CreatePanRequest struct {
|
||||
type UpdatePanRequest struct {
|
||||
Name string `json:"name"`
|
||||
Key int `json:"key"`
|
||||
Icon string `json:"icon"`
|
||||
Remark string `json:"remark"`
|
||||
}
|
||||
|
||||
// CreateCksRequest 创建cookie请求
|
||||
type CreateCksRequest struct {
|
||||
PanID uint `json:"pan_id" binding:"required"`
|
||||
Idx int `json:"idx"`
|
||||
Ck string `json:"ck"`
|
||||
IsValid bool `json:"is_valid"`
|
||||
Space int64 `json:"space"`
|
||||
@@ -22,21 +27,14 @@ type UpdatePanRequest struct {
|
||||
Remark string `json:"remark"`
|
||||
}
|
||||
|
||||
// CreateCksRequest 创建cookie请求
|
||||
type CreateCksRequest struct {
|
||||
PanID uint `json:"pan_id" binding:"required"`
|
||||
T string `json:"t"`
|
||||
Idx int `json:"idx"`
|
||||
Ck string `json:"ck"`
|
||||
Remark string `json:"remark"`
|
||||
}
|
||||
|
||||
// UpdateCksRequest 更新cookie请求
|
||||
type UpdateCksRequest struct {
|
||||
PanID uint `json:"pan_id"`
|
||||
T string `json:"t"`
|
||||
Idx int `json:"idx"`
|
||||
Ck string `json:"ck"`
|
||||
IsValid bool `json:"is_valid"`
|
||||
Space int64 `json:"space"`
|
||||
LeftSpace int64 `json:"left_space"`
|
||||
Remark string `json:"remark"`
|
||||
}
|
||||
|
||||
|
||||
@@ -49,10 +49,7 @@ type PanResponse struct {
|
||||
ID uint `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Key int `json:"key"`
|
||||
Ck string `json:"ck"`
|
||||
IsValid bool `json:"is_valid"`
|
||||
Space int64 `json:"space"`
|
||||
LeftSpace int64 `json:"left_space"`
|
||||
Icon string `json:"icon"`
|
||||
Remark string `json:"remark"`
|
||||
}
|
||||
|
||||
@@ -60,9 +57,11 @@ type PanResponse struct {
|
||||
type CksResponse struct {
|
||||
ID uint `json:"id"`
|
||||
PanID uint `json:"pan_id"`
|
||||
T string `json:"t"`
|
||||
Idx int `json:"idx"`
|
||||
Ck string `json:"ck"`
|
||||
IsValid bool `json:"is_valid"`
|
||||
Space int64 `json:"space"`
|
||||
LeftSpace int64 `json:"left_space"`
|
||||
Remark string `json:"remark"`
|
||||
}
|
||||
|
||||
|
||||
@@ -10,9 +10,11 @@ import (
|
||||
type Cks struct {
|
||||
ID uint `json:"id" gorm:"primaryKey;autoIncrement"`
|
||||
PanID uint `json:"pan_id" gorm:"not null;comment:平台ID"`
|
||||
T string `json:"t" gorm:"size:64;comment:cookie类型"`
|
||||
Idx int `json:"idx" gorm:"comment:索引"`
|
||||
Ck string `json:"ck" gorm:"type:text;comment:cookie"`
|
||||
IsValid bool `json:"is_valid" gorm:"default:true;comment:是否有效"`
|
||||
Space int64 `json:"space" gorm:"default:0;comment:总空间"`
|
||||
LeftSpace int64 `json:"left_space" gorm:"default:0;comment:剩余空间"`
|
||||
Remark string `json:"remark" gorm:"size:64;not null;comment:备注"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
|
||||
@@ -11,10 +11,7 @@ type Pan struct {
|
||||
ID uint `json:"id" gorm:"primaryKey;autoIncrement"`
|
||||
Name string `json:"name" gorm:"size:64;comment:平台名称"`
|
||||
Key int `json:"key" gorm:"comment:平台标识"`
|
||||
Ck string `json:"ck" gorm:"type:text;comment:cookie"`
|
||||
IsValid bool `json:"is_valid" gorm:"default:true;comment:是否有效"`
|
||||
Space int64 `json:"space" gorm:"default:0;comment:总空间"`
|
||||
LeftSpace int64 `json:"left_space" gorm:"default:0;comment:剩余空间"`
|
||||
Icon string `json:"icon" gorm:"size:128;comment:图标文字"`
|
||||
Remark string `json:"remark" gorm:"size:64;not null;comment:备注"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
|
||||
@@ -10,7 +10,8 @@ import (
|
||||
type CksRepository interface {
|
||||
BaseRepository[entity.Cks]
|
||||
FindByPanID(panID uint) ([]entity.Cks, error)
|
||||
FindByPanIDAndType(panID uint, ckType string) ([]entity.Cks, error)
|
||||
FindByIsValid(isValid bool) ([]entity.Cks, error)
|
||||
UpdateSpace(id uint, space, leftSpace int64) error
|
||||
DeleteByPanID(panID uint) error
|
||||
}
|
||||
|
||||
@@ -33,13 +34,22 @@ func (r *CksRepositoryImpl) FindByPanID(panID uint) ([]entity.Cks, error) {
|
||||
return cks, err
|
||||
}
|
||||
|
||||
// FindByPanIDAndType 根据PanID和类型查找
|
||||
func (r *CksRepositoryImpl) FindByPanIDAndType(panID uint, ckType string) ([]entity.Cks, error) {
|
||||
// FindByIsValid 根据有效性查找
|
||||
func (r *CksRepositoryImpl) FindByIsValid(isValid bool) ([]entity.Cks, error) {
|
||||
var cks []entity.Cks
|
||||
err := r.db.Where("pan_id = ? AND t = ?", panID, ckType).Find(&cks).Error
|
||||
err := r.db.Where("is_valid = ?", isValid).Find(&cks).Error
|
||||
return cks, err
|
||||
}
|
||||
|
||||
// UpdateSpace 更新空间信息
|
||||
func (r *CksRepositoryImpl) UpdateSpace(id uint, space, leftSpace int64) error {
|
||||
return r.db.Model(&entity.Cks{}).Where("id = ?", id).
|
||||
Updates(map[string]interface{}{
|
||||
"space": space,
|
||||
"left_space": leftSpace,
|
||||
}).Error
|
||||
}
|
||||
|
||||
// DeleteByPanID 根据PanID删除
|
||||
func (r *CksRepositoryImpl) DeleteByPanID(panID uint) error {
|
||||
return r.db.Where("pan_id = ?", panID).Delete(&entity.Cks{}).Error
|
||||
|
||||
@@ -9,9 +9,7 @@ import (
|
||||
// PanRepository Pan的Repository接口
|
||||
type PanRepository interface {
|
||||
BaseRepository[entity.Pan]
|
||||
FindByIsValid(isValid bool) ([]entity.Pan, error)
|
||||
FindWithCks() ([]entity.Pan, error)
|
||||
UpdateSpace(id uint, space, leftSpace int64) error
|
||||
}
|
||||
|
||||
// PanRepositoryImpl Pan的Repository实现
|
||||
@@ -26,25 +24,9 @@ func NewPanRepository(db *gorm.DB) PanRepository {
|
||||
}
|
||||
}
|
||||
|
||||
// FindByIsValid 根据有效性查找
|
||||
func (r *PanRepositoryImpl) FindByIsValid(isValid bool) ([]entity.Pan, error) {
|
||||
var pans []entity.Pan
|
||||
err := r.db.Where("is_valid = ?", isValid).Find(&pans).Error
|
||||
return pans, err
|
||||
}
|
||||
|
||||
// FindWithCks 查找包含Cks的Pan
|
||||
func (r *PanRepositoryImpl) FindWithCks() ([]entity.Pan, error) {
|
||||
var pans []entity.Pan
|
||||
err := r.db.Preload("Cks").Find(&pans).Error
|
||||
return pans, err
|
||||
}
|
||||
|
||||
// UpdateSpace 更新空间信息
|
||||
func (r *PanRepositoryImpl) UpdateSpace(id uint, space, leftSpace int64) error {
|
||||
return r.db.Model(&entity.Pan{}).Where("id = ?", id).
|
||||
Updates(map[string]interface{}{
|
||||
"space": space,
|
||||
"left_space": leftSpace,
|
||||
}).Error
|
||||
}
|
||||
|
||||
@@ -33,9 +33,11 @@ func CreateCks(c *gin.Context) {
|
||||
|
||||
cks := &entity.Cks{
|
||||
PanID: req.PanID,
|
||||
T: req.T,
|
||||
Idx: req.Idx,
|
||||
Ck: req.Ck,
|
||||
IsValid: req.IsValid,
|
||||
Space: req.Space,
|
||||
LeftSpace: req.LeftSpace,
|
||||
Remark: req.Remark,
|
||||
}
|
||||
|
||||
@@ -75,13 +77,13 @@ func UpdateCks(c *gin.Context) {
|
||||
if req.PanID != 0 {
|
||||
cks.PanID = req.PanID
|
||||
}
|
||||
if req.T != "" {
|
||||
cks.T = req.T
|
||||
}
|
||||
cks.Idx = req.Idx
|
||||
if req.Ck != "" {
|
||||
cks.Ck = req.Ck
|
||||
}
|
||||
cks.IsValid = req.IsValid
|
||||
cks.Space = req.Space
|
||||
cks.LeftSpace = req.LeftSpace
|
||||
if req.Remark != "" {
|
||||
cks.Remark = req.Remark
|
||||
}
|
||||
|
||||
@@ -34,10 +34,7 @@ func CreatePan(c *gin.Context) {
|
||||
pan := &entity.Pan{
|
||||
Name: req.Name,
|
||||
Key: req.Key,
|
||||
Ck: req.Ck,
|
||||
IsValid: req.IsValid,
|
||||
Space: req.Space,
|
||||
LeftSpace: req.LeftSpace,
|
||||
Icon: req.Icon,
|
||||
Remark: req.Remark,
|
||||
}
|
||||
|
||||
@@ -78,12 +75,9 @@ func UpdatePan(c *gin.Context) {
|
||||
pan.Name = req.Name
|
||||
}
|
||||
pan.Key = req.Key
|
||||
if req.Ck != "" {
|
||||
pan.Ck = req.Ck
|
||||
if req.Icon != "" {
|
||||
pan.Icon = req.Icon
|
||||
}
|
||||
pan.IsValid = req.IsValid
|
||||
pan.Space = req.Space
|
||||
pan.LeftSpace = req.LeftSpace
|
||||
if req.Remark != "" {
|
||||
pan.Remark = req.Remark
|
||||
}
|
||||
|
||||
@@ -68,10 +68,7 @@ func createTables() error {
|
||||
id SERIAL PRIMARY KEY,
|
||||
name VARCHAR(64) DEFAULT NULL,
|
||||
key INTEGER DEFAULT NULL,
|
||||
ck TEXT,
|
||||
is_valid BOOLEAN DEFAULT true,
|
||||
space BIGINT DEFAULT 0,
|
||||
left_space BIGINT DEFAULT 0,
|
||||
icon VARCHAR(128) DEFAULT NULL,
|
||||
remark VARCHAR(64) NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
@@ -150,10 +147,14 @@ func createTables() error {
|
||||
CREATE TABLE IF NOT EXISTS cks (
|
||||
id SERIAL PRIMARY KEY,
|
||||
pan_id INTEGER NOT NULL REFERENCES pan(id) ON DELETE CASCADE,
|
||||
t VARCHAR(64) DEFAULT NULL,
|
||||
idx INTEGER DEFAULT NULL,
|
||||
ck TEXT,
|
||||
remark VARCHAR(64) NOT NULL
|
||||
is_valid BOOLEAN DEFAULT true,
|
||||
space BIGINT DEFAULT 0,
|
||||
left_space BIGINT DEFAULT 0,
|
||||
remark VARCHAR(64) NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
);`
|
||||
|
||||
// 创建待处理资源表
|
||||
@@ -198,16 +199,52 @@ func createTables() error {
|
||||
// 插入默认分类
|
||||
insertDefaultCategories := `
|
||||
INSERT INTO categories (name, description) VALUES
|
||||
('文档', '各种文档资料'),
|
||||
('软件', '软件工具'),
|
||||
('视频', '视频教程'),
|
||||
('图片', '图片资源'),
|
||||
('音频', '音频文件'),
|
||||
('电影', '电影资源'),
|
||||
('电视剧', '电视剧资源'),
|
||||
('动漫', '动漫资源'),
|
||||
('音乐', '音乐资源'),
|
||||
('软件', '软件资源'),
|
||||
('游戏', '游戏资源'),
|
||||
('文档', '文档资源'),
|
||||
('其他', '其他资源')
|
||||
ON CONFLICT (name) DO NOTHING;`
|
||||
|
||||
// 插入默认网盘平台
|
||||
insertDefaultPans := `
|
||||
INSERT INTO pan (name, key, icon, remark) VALUES
|
||||
('baidu', 1, '<i class="fas fa-cloud text-blue-500"></i>', '百度网盘'),
|
||||
('pan.baidu', 2, '<i class="fas fa-cloud text-blue-500"></i>', '百度网盘'),
|
||||
('aliyun', 3, '<i class="fas fa-cloud text-orange-500"></i>', '阿里云盘'),
|
||||
('quark', 4, '<i class="fas fa-atom text-purple-500"></i>', '夸克网盘'),
|
||||
('teambition', 5, '<i class="fas fa-cloud text-orange-500"></i>', '阿里云盘'),
|
||||
('cloud.189', 6, '<i class="fas fa-cloud text-cyan-500"></i>', '天翼云盘'),
|
||||
('e.189', 7, '<i class="fas fa-cloud text-cyan-500"></i>', '天翼云盘'),
|
||||
('tianyi', 8, '<i class="fas fa-cloud text-cyan-500"></i>', '天翼云盘'),
|
||||
('天翼', 9, '<i class="fas fa-cloud text-cyan-500"></i>', '天翼云盘'),
|
||||
('xunlei', 10, '<i class="fas fa-bolt text-yellow-500"></i>', '迅雷云盘'),
|
||||
('weiyun', 11, '<i class="fas fa-cloud text-green-500"></i>', '微云'),
|
||||
('lanzou', 12, '<i class="fas fa-cloud text-blue-400"></i>', '蓝奏云'),
|
||||
('123', 13, '<i class="fas fa-cloud text-red-500"></i>', '123云盘'),
|
||||
('onedrive', 14, '<i class="fab fa-microsoft text-blue-600"></i>', 'OneDrive'),
|
||||
('google', 15, '<i class="fab fa-google-drive text-green-600"></i>', 'Google云盘'),
|
||||
('drive.google', 16, '<i class="fab fa-google-drive text-green-600"></i>', 'Google云盘'),
|
||||
('dropbox', 17, '<i class="fab fa-dropbox text-blue-500"></i>', 'Dropbox'),
|
||||
('ctfile', 18, '<i class="fas fa-folder text-yellow-600"></i>', '城通网盘'),
|
||||
('115', 19, '<i class="fas fa-cloud-upload-alt text-green-600"></i>', '115网盘'),
|
||||
('magnet', 20, '<i class="fas fa-magnet text-red-600"></i>', '磁力链接'),
|
||||
('uc', 21, '<i class="fas fa-cloud-download-alt text-purple-600"></i>', 'UC网盘'),
|
||||
('UC', 22, '<i class="fas fa-cloud-download-alt text-purple-600"></i>', 'UC网盘'),
|
||||
('yun.139', 23, '<i class="fas fa-cloud text-cyan-500"></i>', '移动云盘'),
|
||||
('unknown', 24, '<i class="fas fa-question-circle text-gray-400"></i>', '未知平台'),
|
||||
('other', 25, '<i class="fas fa-cloud text-gray-500"></i>', '其他')
|
||||
ON CONFLICT (name) DO NOTHING;`
|
||||
|
||||
if _, err := DB.Exec(insertDefaultCategories); err != nil {
|
||||
log.Printf("插入默认分类失败: %v", err)
|
||||
return err
|
||||
}
|
||||
|
||||
if _, err := DB.Exec(insertDefaultPans); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -9,10 +9,7 @@ type Pan struct {
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"` // Qurak
|
||||
Key int `json:"key"` // quark
|
||||
Ck string `json:"ck"` // cookie
|
||||
IsValid bool `json:"is_valid"` // 是否有效
|
||||
Space int64 `json:"space"` // 空间
|
||||
LeftSpace int64 `json:"left_space"` // 剩余空间
|
||||
Icon string `json:"icon"` // 图标文字
|
||||
Remark string `json:"remark"` // 备注
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
@@ -22,9 +19,11 @@ type Pan struct {
|
||||
type Cks struct {
|
||||
ID int `json:"id"`
|
||||
PanID int `json:"pan_id"` // pan ID
|
||||
T string `json:"t"` // cookie类型
|
||||
Idx int `json:"idx"` // index
|
||||
Ck string `json:"ck"` // cookie
|
||||
IsValid bool `json:"is_valid"` // 是否有效
|
||||
Space int64 `json:"space"` // 空间
|
||||
LeftSpace int64 `json:"left_space"` // 剩余空间
|
||||
Remark string `json:"remark"` // 备注
|
||||
}
|
||||
|
||||
@@ -32,10 +31,7 @@ type Cks struct {
|
||||
type CreatePanRequest struct {
|
||||
Name string `json:"name" binding:"required"`
|
||||
Key int `json:"key"`
|
||||
Ck string `json:"ck"`
|
||||
IsValid bool `json:"is_valid"`
|
||||
Space int64 `json:"space"`
|
||||
LeftSpace int64 `json:"left_space"`
|
||||
Icon string `json:"icon"`
|
||||
Remark string `json:"remark"`
|
||||
}
|
||||
|
||||
@@ -43,6 +39,14 @@ type CreatePanRequest struct {
|
||||
type UpdatePanRequest struct {
|
||||
Name string `json:"name"`
|
||||
Key int `json:"key"`
|
||||
Icon string `json:"icon"`
|
||||
Remark string `json:"remark"`
|
||||
}
|
||||
|
||||
// CreateCksRequest 创建cookie请求
|
||||
type CreateCksRequest struct {
|
||||
PanID int `json:"pan_id" binding:"required"`
|
||||
Idx int `json:"idx"`
|
||||
Ck string `json:"ck"`
|
||||
IsValid bool `json:"is_valid"`
|
||||
Space int64 `json:"space"`
|
||||
@@ -50,20 +54,13 @@ type UpdatePanRequest struct {
|
||||
Remark string `json:"remark"`
|
||||
}
|
||||
|
||||
// CreateCksRequest 创建cookie请求
|
||||
type CreateCksRequest struct {
|
||||
PanID int `json:"pan_id" binding:"required"`
|
||||
T string `json:"t"`
|
||||
Idx int `json:"idx"`
|
||||
Ck string `json:"ck"`
|
||||
Remark string `json:"remark"`
|
||||
}
|
||||
|
||||
// UpdateCksRequest 更新cookie请求
|
||||
type UpdateCksRequest struct {
|
||||
PanID int `json:"pan_id"`
|
||||
T string `json:"t"`
|
||||
Idx int `json:"idx"`
|
||||
Ck string `json:"ck"`
|
||||
IsValid bool `json:"is_valid"`
|
||||
Space int64 `json:"space"`
|
||||
LeftSpace int64 `json:"left_space"`
|
||||
Remark string `json:"remark"`
|
||||
}
|
||||
|
||||
@@ -297,10 +297,10 @@ watchEffect(() => {
|
||||
})
|
||||
|
||||
// API
|
||||
const { getSystemConfig } = useSystemConfigApi()
|
||||
// const { getSystemConfig } = useSystemConfigApi()
|
||||
|
||||
// const showAddResourceModal = ref(false)
|
||||
const editingResource = ref(null)
|
||||
const editingResource = ref<any>(null)
|
||||
const currentPage = ref(1)
|
||||
const totalPages = ref(1)
|
||||
interface Platform {
|
||||
@@ -314,6 +314,7 @@ interface Platform {
|
||||
remark: string
|
||||
created_at: string
|
||||
updated_at: string
|
||||
icon?: string // 新增图标字段
|
||||
}
|
||||
|
||||
interface ExtendedResource {
|
||||
@@ -364,14 +365,15 @@ const debounceSearch = () => {
|
||||
// 获取系统配置
|
||||
const fetchSystemConfig = async () => {
|
||||
try {
|
||||
const response = await getSystemConfig() as any
|
||||
console.log('首页系统配置响应:', response)
|
||||
if (response && response.success && response.data) {
|
||||
systemConfig.value = response.data
|
||||
} else if (response && response.data) {
|
||||
// 兼容非标准格式
|
||||
systemConfig.value = response.data
|
||||
}
|
||||
// const response = await getSystemConfig() as any
|
||||
// console.log('首页系统配置响应:', response)
|
||||
// if (response && response.success && response.data) {
|
||||
// systemConfig.value = response.data
|
||||
// } else if (response && response.data) {
|
||||
// // 兼容非标准格式
|
||||
// systemConfig.value = response.data
|
||||
// }
|
||||
console.log('系统配置功能暂时禁用')
|
||||
} catch (error) {
|
||||
console.error('获取系统配置失败:', error)
|
||||
}
|
||||
@@ -434,29 +436,19 @@ const filterByPlatform = (platformId: string | number) => {
|
||||
|
||||
// 获取平台图标
|
||||
const getPlatformIcon = (platformName: string) => {
|
||||
const icons: Record<string, string> = {
|
||||
'百度网盘': '<i class="fas fa-cloud text-blue-500"></i>',
|
||||
'阿里云盘': '<i class="fas fa-cloud text-orange-500"></i>',
|
||||
'夸克网盘': '<i class="fas fa-atom text-purple-500"></i>',
|
||||
'天翼云盘': '<i class="fas fa-cloud text-cyan-500"></i>',
|
||||
'迅雷云盘': '<i class="fas fa-bolt text-yellow-500"></i>',
|
||||
'微云': '<i class="fas fa-cloud text-green-500"></i>',
|
||||
'蓝奏云': '<i class="fas fa-cloud text-blue-400"></i>',
|
||||
'123云盘': '<i class="fas fa-cloud text-red-500"></i>',
|
||||
'腾讯微云': '<i class="fas fa-cloud text-green-500"></i>',
|
||||
'OneDrive': '<i class="fab fa-microsoft text-blue-600"></i>',
|
||||
'Google云盘': '<i class="fab fa-google-drive text-green-600"></i>',
|
||||
'Dropbox': '<i class="fab fa-dropbox text-blue-500"></i>',
|
||||
'城通网盘': '<i class="fas fa-folder text-yellow-600"></i>',
|
||||
'115网盘': '<i class="fas fa-cloud-upload-alt text-green-600"></i>',
|
||||
'磁力链接': '<i class="fas fa-magnet text-red-600"></i>',
|
||||
'UC网盘': '<i class="fas fa-cloud-download-alt text-purple-600"></i>',
|
||||
'天翼云': '<i class="fas fa-cloud text-cyan-500"></i>',
|
||||
'unknown': '<i class="fas fa-question-circle text-gray-400"></i>',
|
||||
'其他': '<i class="fas fa-cloud text-gray-500"></i>'
|
||||
// 首先尝试从平台列表中查找对应的平台
|
||||
const platform = platforms.value.find((p: Platform) => p.name === platformName)
|
||||
if (platform && platform.icon) {
|
||||
return platform.icon
|
||||
}
|
||||
|
||||
return icons[platformName] || icons['unknown']
|
||||
// 如果找不到对应的平台或没有图标,使用默认图标
|
||||
const defaultIcons: Record<string, string> = {
|
||||
'unknown': '<i class="fas fa-question-circle text-gray-400"></i>',
|
||||
'other': '<i class="fas fa-cloud text-gray-500"></i>'
|
||||
}
|
||||
|
||||
return defaultIcons['unknown']
|
||||
}
|
||||
|
||||
// 获取平台名称
|
||||
@@ -579,7 +571,7 @@ const handleSaveResource = async (resourceData: any) => {
|
||||
} else {
|
||||
await store.createResource(resourceData)
|
||||
}
|
||||
closeModal()
|
||||
// closeModal() // 移除未定义的函数调用
|
||||
} catch (error) {
|
||||
console.error('保存失败:', error)
|
||||
}
|
||||
|
||||
@@ -1,134 +0,0 @@
|
||||
<template>
|
||||
<div class="min-h-screen bg-gray-50 dark:bg-gray-900 p-8">
|
||||
<div class="max-w-4xl mx-auto">
|
||||
<h1 class="text-2xl font-bold mb-6">登录状态测试</h1>
|
||||
|
||||
<div class="bg-white dark:bg-gray-800 rounded-lg shadow p-6 mb-6">
|
||||
<h2 class="text-lg font-semibold mb-4">当前状态</h2>
|
||||
<div class="space-y-2">
|
||||
<div class="flex justify-between">
|
||||
<span>是否已认证:</span>
|
||||
<span :class="userStore.isAuthenticated ? 'text-green-600' : 'text-red-600'">
|
||||
{{ userStore.isAuthenticated ? '是' : '否' }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="flex justify-between">
|
||||
<span>用户名:</span>
|
||||
<span>{{ userStore.userInfo?.username || '未登录' }}</span>
|
||||
</div>
|
||||
<div class="flex justify-between">
|
||||
<span>角色:</span>
|
||||
<span>{{ userStore.userInfo?.role || '未登录' }}</span>
|
||||
</div>
|
||||
<div class="flex justify-between">
|
||||
<span>Token:</span>
|
||||
<span>{{ userStore.token ? '存在' : '不存在' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bg-white dark:bg-gray-800 rounded-lg shadow p-6 mb-6">
|
||||
<h2 class="text-lg font-semibold mb-4">localStorage 状态</h2>
|
||||
<div class="space-y-2">
|
||||
<div class="flex justify-between">
|
||||
<span>Token:</span>
|
||||
<span>{{ localStorageToken ? '存在' : '不存在' }}</span>
|
||||
</div>
|
||||
<div class="flex justify-between">
|
||||
<span>用户信息:</span>
|
||||
<span>{{ localStorageUser ? '存在' : '不存在' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bg-white dark:bg-gray-800 rounded-lg shadow p-6 mb-6">
|
||||
<h2 class="text-lg font-semibold mb-4">操作</h2>
|
||||
<div class="space-y-4">
|
||||
<button
|
||||
@click="initAuth"
|
||||
class="px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700"
|
||||
>
|
||||
重新初始化认证状态
|
||||
</button>
|
||||
<button
|
||||
@click="clearStorage"
|
||||
class="px-4 py-2 bg-red-600 text-white rounded hover:bg-red-700 ml-2"
|
||||
>
|
||||
清除localStorage
|
||||
</button>
|
||||
<button
|
||||
@click="refreshPage"
|
||||
class="px-4 py-2 bg-green-600 text-white rounded hover:bg-green-700 ml-2"
|
||||
>
|
||||
刷新页面
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bg-white dark:bg-gray-800 rounded-lg shadow p-6">
|
||||
<h2 class="text-lg font-semibold mb-4">调试信息</h2>
|
||||
<pre class="bg-gray-100 dark:bg-gray-700 p-4 rounded text-sm overflow-auto">{{ debugInfo }}</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
const userStore = useUserStore()
|
||||
|
||||
const localStorageToken = ref('')
|
||||
const localStorageUser = ref('')
|
||||
const debugInfo = ref('')
|
||||
|
||||
// 检查localStorage
|
||||
const checkLocalStorage = () => {
|
||||
if (typeof window !== 'undefined') {
|
||||
localStorageToken.value = localStorage.getItem('token') ? '存在' : '不存在'
|
||||
localStorageUser.value = localStorage.getItem('user') ? '存在' : '不存在'
|
||||
}
|
||||
}
|
||||
|
||||
// 初始化认证状态
|
||||
const initAuth = () => {
|
||||
userStore.initAuth()
|
||||
checkLocalStorage()
|
||||
updateDebugInfo()
|
||||
}
|
||||
|
||||
// 清除localStorage
|
||||
const clearStorage = () => {
|
||||
if (typeof window !== 'undefined') {
|
||||
localStorage.removeItem('token')
|
||||
localStorage.removeItem('user')
|
||||
checkLocalStorage()
|
||||
updateDebugInfo()
|
||||
}
|
||||
}
|
||||
|
||||
// 刷新页面
|
||||
const refreshPage = () => {
|
||||
window.location.reload()
|
||||
}
|
||||
|
||||
// 更新调试信息
|
||||
const updateDebugInfo = () => {
|
||||
debugInfo.value = JSON.stringify({
|
||||
store: {
|
||||
isAuthenticated: userStore.isAuthenticated,
|
||||
user: userStore.userInfo,
|
||||
token: userStore.token ? '存在' : '不存在'
|
||||
},
|
||||
localStorage: {
|
||||
token: localStorageToken.value,
|
||||
user: localStorageUser.value
|
||||
}
|
||||
}, null, 2)
|
||||
}
|
||||
|
||||
// 页面加载时检查状态
|
||||
onMounted(() => {
|
||||
userStore.initAuth()
|
||||
checkLocalStorage()
|
||||
updateDebugInfo()
|
||||
})
|
||||
</script>
|
||||
@@ -1,168 +0,0 @@
|
||||
<template>
|
||||
<div class="min-h-screen bg-gray-50 p-8">
|
||||
<div class="max-w-4xl mx-auto">
|
||||
<h1 class="text-3xl font-bold text-gray-900 mb-8">登录功能测试</h1>
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-8">
|
||||
<!-- 测试登录 -->
|
||||
<div class="bg-white rounded-lg shadow p-6">
|
||||
<h2 class="text-xl font-semibold mb-4">测试登录</h2>
|
||||
|
||||
<div class="space-y-4">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700">用户名</label>
|
||||
<input
|
||||
v-model="loginForm.username"
|
||||
type="text"
|
||||
class="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md"
|
||||
placeholder="admin"
|
||||
>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700">密码</label>
|
||||
<input
|
||||
v-model="loginForm.password"
|
||||
type="password"
|
||||
class="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md"
|
||||
placeholder="password"
|
||||
>
|
||||
</div>
|
||||
|
||||
<button
|
||||
@click="testLogin"
|
||||
class="w-full bg-blue-600 text-white py-2 px-4 rounded-md hover:bg-blue-700"
|
||||
>
|
||||
测试登录
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div v-if="loginResult" class="mt-4 p-4 bg-gray-100 rounded">
|
||||
<h3 class="font-semibold">登录结果:</h3>
|
||||
<pre class="text-sm mt-2">{{ JSON.stringify(loginResult, null, 2) }}</pre>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 测试注册 -->
|
||||
<div class="bg-white rounded-lg shadow p-6">
|
||||
<h2 class="text-xl font-semibold mb-4">测试注册</h2>
|
||||
|
||||
<div class="space-y-4">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700">用户名</label>
|
||||
<input
|
||||
v-model="registerForm.username"
|
||||
type="text"
|
||||
class="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md"
|
||||
placeholder="testuser"
|
||||
>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700">邮箱</label>
|
||||
<input
|
||||
v-model="registerForm.email"
|
||||
type="email"
|
||||
class="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md"
|
||||
placeholder="test@example.com"
|
||||
>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700">密码</label>
|
||||
<input
|
||||
v-model="registerForm.password"
|
||||
type="password"
|
||||
class="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md"
|
||||
placeholder="123456"
|
||||
>
|
||||
</div>
|
||||
|
||||
<button
|
||||
@click="testRegister"
|
||||
class="w-full bg-green-600 text-white py-2 px-4 rounded-md hover:bg-green-700"
|
||||
>
|
||||
测试注册
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div v-if="registerResult" class="mt-4 p-4 bg-gray-100 rounded">
|
||||
<h3 class="font-semibold">注册结果:</h3>
|
||||
<pre class="text-sm mt-2">{{ JSON.stringify(registerResult, null, 2) }}</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 默认账户信息 -->
|
||||
<div class="mt-8 bg-blue-50 border border-blue-200 rounded-lg p-6">
|
||||
<h2 class="text-xl font-semibold text-blue-900 mb-4">默认账户信息</h2>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div>
|
||||
<h3 class="font-semibold text-blue-800">管理员账户</h3>
|
||||
<p class="text-blue-700">用户名: admin</p>
|
||||
<p class="text-blue-700">密码: password</p>
|
||||
<p class="text-blue-700">角色: admin</p>
|
||||
</div>
|
||||
<div>
|
||||
<h3 class="font-semibold text-blue-800">测试说明</h3>
|
||||
<ul class="text-blue-700 text-sm space-y-1">
|
||||
<li>• 使用默认账户可以正常登录</li>
|
||||
<li>• 注册新用户后可以登录</li>
|
||||
<li>• 错误的用户名密码会返回401错误</li>
|
||||
<li>• 重复的用户名会返回400错误</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { reactive, ref } from 'vue'
|
||||
|
||||
const loginForm = reactive({
|
||||
username: 'admin',
|
||||
password: 'password'
|
||||
})
|
||||
|
||||
const registerForm = reactive({
|
||||
username: 'testuser',
|
||||
email: 'test@example.com',
|
||||
password: '123456'
|
||||
})
|
||||
|
||||
const loginResult = ref(null)
|
||||
const registerResult = ref(null)
|
||||
|
||||
const testLogin = async () => {
|
||||
try {
|
||||
const authApi = useAuthApi()
|
||||
const response = await authApi.login(loginForm)
|
||||
loginResult.value = { success: true, data: response }
|
||||
} catch (error: any) {
|
||||
loginResult.value = {
|
||||
success: false,
|
||||
error: error.data?.error || error.message || '登录失败'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const testRegister = async () => {
|
||||
try {
|
||||
const authApi = useAuthApi()
|
||||
const response = await authApi.register(registerForm)
|
||||
registerResult.value = { success: true, data: response }
|
||||
} catch (error: any) {
|
||||
registerResult.value = {
|
||||
success: false,
|
||||
error: error.data?.error || error.message || '注册失败'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 设置页面标题
|
||||
useHead({
|
||||
title: '登录功能测试 - 网盘资源管理系统'
|
||||
})
|
||||
</script>
|
||||
@@ -1,67 +0,0 @@
|
||||
<template>
|
||||
<div class="min-h-screen bg-gray-50 p-8">
|
||||
<div class="max-w-2xl mx-auto">
|
||||
<h1 class="text-3xl font-bold text-gray-900 mb-8">Toast 组件测试</h1>
|
||||
|
||||
<div class="bg-white rounded-lg shadow p-6 space-y-4">
|
||||
<div class="grid grid-cols-2 gap-4">
|
||||
<button
|
||||
@click="showErrorToast"
|
||||
class="bg-red-600 text-white py-2 px-4 rounded-md hover:bg-red-700"
|
||||
>
|
||||
显示错误提示
|
||||
</button>
|
||||
|
||||
<button
|
||||
@click="showSuccessToast"
|
||||
class="bg-green-600 text-white py-2 px-4 rounded-md hover:bg-green-700"
|
||||
>
|
||||
显示成功提示
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="text-sm text-gray-600">
|
||||
<p>点击按钮测试不同的Toast提示效果</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 错误提示 -->
|
||||
<ErrorToast
|
||||
v-if="showError"
|
||||
:message="errorMessage"
|
||||
@close="showError = false"
|
||||
/>
|
||||
|
||||
<!-- 成功提示 -->
|
||||
<SuccessToast
|
||||
v-if="showSuccess"
|
||||
:message="successMessage"
|
||||
@close="showSuccess = false"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
|
||||
const showError = ref(false)
|
||||
const showSuccess = ref(false)
|
||||
const errorMessage = ref('')
|
||||
const successMessage = ref('')
|
||||
|
||||
const showErrorToast = () => {
|
||||
errorMessage.value = '这是一个错误提示示例'
|
||||
showError.value = true
|
||||
}
|
||||
|
||||
const showSuccessToast = () => {
|
||||
successMessage.value = '这是一个成功提示示例'
|
||||
showSuccess.value = true
|
||||
}
|
||||
|
||||
// 设置页面标题
|
||||
useHead({
|
||||
title: 'Toast 组件测试 - 网盘资源管理系统'
|
||||
})
|
||||
</script>
|
||||
Reference in New Issue
Block a user