41 lines
918 B
Swift
41 lines
918 B
Swift
//
|
|
// FollowListModel.swift
|
|
// dimensionhub
|
|
//
|
|
// Created by 安礼成 on 2025/4/8.
|
|
//
|
|
|
|
import Foundation
|
|
import Observation
|
|
|
|
@Observable
|
|
final class FollowDramaModel {
|
|
|
|
@ObservationIgnored
|
|
var drama: FollowListModel.DramaItem
|
|
|
|
// 选中的频道信息
|
|
var checkedChannelId: Int = 0
|
|
var episodes: [FollowListModel.DramaItem.Channel.Episode]
|
|
|
|
init(drama: FollowListModel.DramaItem) {
|
|
self.drama = drama
|
|
self.checkedChannelId = 0
|
|
if let channel = drama.channels.first {
|
|
self.episodes = channel.episodes
|
|
} else {
|
|
self.episodes = []
|
|
}
|
|
}
|
|
|
|
func changeChannel(channelId: Int) {
|
|
self.checkedChannelId = channelId
|
|
if drama.channels.indices.contains(channelId) {
|
|
self.episodes = drama.channels[channelId].episodes
|
|
} else {
|
|
self.episodes = []
|
|
}
|
|
}
|
|
|
|
}
|