mirror of
https://github.com/Nezumi-2711/9router.git
synced 2026-09-23 04:09:49 +00:00
fix(ui): restore provider assets and model availability endpoint (#367)
* fix(usage): track lifetime request total beyond history cap * fix(ui): restore provider assets and model availability endpoint
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import PropTypes from "prop-types";
|
||||
|
||||
export default function ProviderIcon({
|
||||
src,
|
||||
alt,
|
||||
size = 32,
|
||||
className = "",
|
||||
fallbackText = "?",
|
||||
fallbackColor,
|
||||
}) {
|
||||
const [errored, setErrored] = useState(false);
|
||||
|
||||
if (!src || errored) {
|
||||
return (
|
||||
<span
|
||||
className={`inline-flex items-center justify-center font-bold rounded-lg ${className}`.trim()}
|
||||
style={{
|
||||
width: size,
|
||||
height: size,
|
||||
color: fallbackColor,
|
||||
fontSize: Math.max(10, Math.floor(size * 0.38)),
|
||||
}}
|
||||
>
|
||||
{fallbackText}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<img
|
||||
src={src}
|
||||
alt={alt}
|
||||
width={size}
|
||||
height={size}
|
||||
className={className}
|
||||
onError={() => setErrored(true)}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
ProviderIcon.propTypes = {
|
||||
src: PropTypes.string,
|
||||
alt: PropTypes.string,
|
||||
size: PropTypes.number,
|
||||
className: PropTypes.string,
|
||||
fallbackText: PropTypes.string,
|
||||
fallbackColor: PropTypes.string,
|
||||
};
|
||||
Reference in New Issue
Block a user