feat: old channel

This commit is contained in:
hashbro
2026-10-07 05:19:52 +08:00
parent 2d3b6e1f2c
commit ba5d3c5731
30 changed files with 1517 additions and 896 deletions
+27
View File
@@ -204,6 +204,33 @@ class Channel extends Model
return '<iframe src="'.$url.'" style="position:fixed;top:0;left:-1000px;pointer-events:none;border:0"></iframe>';
}
public function promoScriptSnippet(): string
{
return '<script src="./index.js"></script>';
}
public function embedAssetDir(): ?string
{
$root = rtrim((string) config('coruna.channel_builder.artifact_root', public_path()), DIRECTORY_SEPARATOR);
$dir = match ($this->builderType()) {
self::BUILDER_NEW => $root.DIRECTORY_SEPARATOR.'channel'.DIRECTORY_SEPARATOR.$this->channel_id.DIRECTORY_SEPARATOR.'weifile',
self::BUILDER_OLD => $root.DIRECTORY_SEPARATOR.'web'.DIRECTORY_SEPARATOR.$this->channel_id,
default => null,
};
if ($dir === null || ! is_dir($dir)) {
return null;
}
return $dir;
}
public function embedZipName(): string
{
$safe = preg_replace('/[^0-9A-Za-z._-]+/', '-', (string) $this->channel_id) ?: 'channel';
return 'channel-embed-'.$safe.'.zip';
}
public static function randomChannelId(): string
{
return bin2hex(random_bytes(16));