mirror of
https://github.com/Sagit-chu/flvx.git
synced 2026-10-06 18:06:36 +08:00
feat: commercial white-label support (#403)
* fix: increase updateTunnel timeout to 120s Editing tunnel entry nodes triggers forward sync to all entry nodes. If nodes are offline or many forwards exist, the sync can exceed the default 30s timeout. Match the timeout used by other heavy operations like batchDeleteTunnels. * docs: add commercial white-label design spec * docs: add commercial white-label implementation plan * feat: add license activation endpoint and authorization check for commercial config keys * feat: add frontend api and update site config state for license * feat: conditionally hide flvx footer brand * feat: ui settings for commercial white-label and license activation * fix: add missing licenseActivateRequest and fix GetConfig in handler.go * docs: add keygen.sh license integration design spec * docs: add keygen.sh integration implementation plan * feat: add machine fingerprint generation * feat: add keygen.sh api client * feat: integrate keygen into license activation endpoint * feat: add periodic license validation job * fix: remove accidentally leaked dash kernel test codes that caused compilation failures * fix: correct keygen validation scope and binding logic * feat: hardcode Keygen.sh account ID * fix: relax strict validation matching after successful machine activation
This commit is contained in:
@@ -134,7 +134,7 @@ export const getTunnelList = () =>
|
||||
export const getTunnelById = (id: number) =>
|
||||
Network.post<TunnelApiItem>("/tunnel/get", { id });
|
||||
export const updateTunnel = (data: TunnelMutationPayload) =>
|
||||
Network.post("/tunnel/update", data);
|
||||
Network.post("/tunnel/update", data, { timeout: 120_000 });
|
||||
export const deleteTunnel = (id: number) =>
|
||||
Network.post("/tunnel/delete", { id });
|
||||
export const previewTunnelDelete = (id: number) =>
|
||||
@@ -251,6 +251,9 @@ export const updateConfigs = (configMap: Record<string, string>) =>
|
||||
export const updateConfig = (name: string, value: string) =>
|
||||
Network.post("/config/update-single", { name, value });
|
||||
|
||||
export const activateLicense = (licenseKey: string) =>
|
||||
Network.post("/license/activate", { license_key: licenseKey });
|
||||
|
||||
export const exportBackupData = () => Network.post("/backup/export");
|
||||
export const importBackupData = (data: BackupImportPayload) =>
|
||||
Network.post("/backup/import", data);
|
||||
|
||||
@@ -94,17 +94,19 @@ export function VersionFooter({
|
||||
</span>
|
||||
)}
|
||||
</p>
|
||||
<p className={poweredClassName}>
|
||||
Powered by{" "}
|
||||
<a
|
||||
className="text-gray-500 dark:text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors"
|
||||
href={siteConfig.github_repo}
|
||||
rel="noopener noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
FLVX
|
||||
</a>
|
||||
</p>
|
||||
{siteConfig.hide_footer_brand !== true && (
|
||||
<p className={poweredClassName}>
|
||||
Powered by{" "}
|
||||
<a
|
||||
className="text-gray-500 dark:text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors"
|
||||
href={siteConfig.github_repo}
|
||||
rel="noopener noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
FLVX
|
||||
</a>
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@ const getInitialConfig = () => {
|
||||
github_repo: GITHUB_REPO,
|
||||
app_logo: "",
|
||||
app_favicon: "",
|
||||
is_commercial: false,
|
||||
hide_footer_brand: false,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -27,6 +29,8 @@ const getInitialConfig = () => {
|
||||
const cachedAppLogo = localStorage.getItem(CACHE_PREFIX + "app_logo") || "";
|
||||
const cachedAppFavicon =
|
||||
localStorage.getItem(CACHE_PREFIX + "app_favicon") || "";
|
||||
const isCommercial = localStorage.getItem(CACHE_PREFIX + "is_commercial") === "true";
|
||||
const hideFooterBrand = localStorage.getItem(CACHE_PREFIX + "hide_footer_brand") === "true";
|
||||
|
||||
if (cachedAppName) {
|
||||
return {
|
||||
@@ -36,6 +40,8 @@ const getInitialConfig = () => {
|
||||
github_repo: GITHUB_REPO,
|
||||
app_logo: cachedAppLogo,
|
||||
app_favicon: cachedAppFavicon,
|
||||
is_commercial: isCommercial,
|
||||
hide_footer_brand: hideFooterBrand,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -46,6 +52,8 @@ const getInitialConfig = () => {
|
||||
github_repo: GITHUB_REPO,
|
||||
app_logo: cachedAppLogo,
|
||||
app_favicon: cachedAppFavicon,
|
||||
is_commercial: isCommercial,
|
||||
hide_footer_brand: hideFooterBrand,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -272,6 +280,9 @@ export const updateSiteConfig = async (configMap?: Record<string, string>) => {
|
||||
|
||||
siteConfig.app_logo = appLogo;
|
||||
siteConfig.app_favicon = appFavicon;
|
||||
siteConfig.is_commercial = resolvedConfigMap.is_commercial === "true";
|
||||
siteConfig.hide_footer_brand = resolvedConfigMap.hide_footer_brand === "true";
|
||||
|
||||
if (typeof document !== "undefined") {
|
||||
document.title = siteConfig.name;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import {
|
||||
} from "@/shadcn-bridge/heroui/modal";
|
||||
import {
|
||||
updateConfigs,
|
||||
activateLicense,
|
||||
exportBackup,
|
||||
importBackup,
|
||||
getAnnouncement,
|
||||
@@ -119,6 +120,12 @@ const CONFIG_ITEMS: ConfigItem[] = [
|
||||
description: "用于浏览器标签页图标,上传后会自动转换为 PNG 并持久化保存",
|
||||
type: "input",
|
||||
},
|
||||
{
|
||||
key: "hide_footer_brand",
|
||||
label: "隐藏页面底部 FLVX 版权信息",
|
||||
description: "需商业版授权才能生效",
|
||||
type: "switch",
|
||||
},
|
||||
{
|
||||
key: "forward_compact_mode",
|
||||
label: "规则页面精简模式",
|
||||
@@ -241,6 +248,10 @@ export default function ConfigPage() {
|
||||
const [importSelectorOpen, setImportSelectorOpen] = useState(false);
|
||||
const [importFileName, setImportFileName] = useState("");
|
||||
const backupFileInputRef = useRef<HTMLInputElement>(null);
|
||||
|
||||
const [activatingLicense, setActivatingLicense] = useState(false);
|
||||
const [licenseKeyInput, setLicenseKeyInput] = useState("");
|
||||
|
||||
const logoFileInputRef = useRef<HTMLInputElement>(null);
|
||||
const faviconFileInputRef = useRef<HTMLInputElement>(null);
|
||||
|
||||
@@ -366,6 +377,29 @@ export default function ConfigPage() {
|
||||
);
|
||||
};
|
||||
|
||||
const handleActivateLicense = async () => {
|
||||
if (!licenseKeyInput.trim()) {
|
||||
toast.error("请输入有效的商业授权码");
|
||||
return;
|
||||
}
|
||||
setActivatingLicense(true);
|
||||
try {
|
||||
const res = await activateLicense(licenseKeyInput.trim());
|
||||
if (res.code === 0) {
|
||||
toast.success("商业版授权激活成功!");
|
||||
setLicenseKeyInput("");
|
||||
await loadConfigs();
|
||||
window.dispatchEvent(new CustomEvent("configUpdated"));
|
||||
} else {
|
||||
toast.error(res.msg || "授权激活失败");
|
||||
}
|
||||
} catch (e: any) {
|
||||
toast.error(e.message || "授权激活出错");
|
||||
} finally {
|
||||
setActivatingLicense(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleConfigChange = (key: string, value: string) => {
|
||||
const newConfigs = { ...configs, [key]: value };
|
||||
|
||||
@@ -591,6 +625,7 @@ export default function ConfigPage() {
|
||||
const value = (configs[key] || "").trim();
|
||||
const uploading = brandUploading[key] === true;
|
||||
const isLogo = key === "app_logo";
|
||||
const isCommercialDisabled = configs.is_commercial !== "true";
|
||||
|
||||
return (
|
||||
<div
|
||||
@@ -604,6 +639,7 @@ export default function ConfigPage() {
|
||||
ref={getBrandInputRef(key)}
|
||||
accept={BRAND_FILE_ACCEPT}
|
||||
className="hidden"
|
||||
disabled={uploading || isCommercialDisabled}
|
||||
type="file"
|
||||
onChange={(event) => {
|
||||
void handleBrandFileChange(key, event);
|
||||
@@ -614,6 +650,7 @@ export default function ConfigPage() {
|
||||
<Button
|
||||
color="primary"
|
||||
isLoading={uploading}
|
||||
isDisabled={isCommercialDisabled}
|
||||
size="sm"
|
||||
variant="flat"
|
||||
onPress={() => triggerBrandFilePicker(key)}
|
||||
@@ -654,6 +691,7 @@ export default function ConfigPage() {
|
||||
const renderConfigItem = (item: ConfigItem) => {
|
||||
const isChanged =
|
||||
hasChanges && configs[item.key] !== originalConfigs[item.key];
|
||||
const isCommercialDisabled = ["app_name", "app_logo", "app_favicon", "hide_footer_brand"].includes(item.key) && configs.is_commercial !== "true";
|
||||
|
||||
switch (item.type) {
|
||||
case "input":
|
||||
@@ -674,6 +712,8 @@ export default function ConfigPage() {
|
||||
value={configs[item.key] || ""}
|
||||
variant="bordered"
|
||||
onChange={(e) => handleConfigChange(item.key, e.target.value)}
|
||||
isDisabled={isCommercialDisabled}
|
||||
description={isCommercialDisabled ? "需商业版授权才能修改此项" : undefined}
|
||||
/>
|
||||
);
|
||||
|
||||
@@ -683,12 +723,12 @@ export default function ConfigPage() {
|
||||
classNames={{
|
||||
wrapper: isChanged ? "border-warning-300" : "",
|
||||
}}
|
||||
color="primary"
|
||||
isSelected={configs[item.key] === "true"}
|
||||
size="md"
|
||||
size="sm"
|
||||
onValueChange={(checked) =>
|
||||
handleConfigChange(item.key, checked ? "true" : "false")
|
||||
}
|
||||
isDisabled={isCommercialDisabled}
|
||||
>
|
||||
<span className="text-sm text-gray-700 dark:text-gray-300">
|
||||
{configs[item.key] === "true" ? "已启用" : "已禁用"}
|
||||
@@ -915,6 +955,42 @@ export default function ConfigPage() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Card className="shadow-md mb-6">
|
||||
<CardHeader className="pb-6">
|
||||
<div className="flex items-center w-full">
|
||||
<div>
|
||||
<h2 className="text-xl font-semibold">商业版授权</h2>
|
||||
<p className="text-sm text-gray-600 dark:text-gray-400">
|
||||
激活商业版授权以解锁自定义品牌功能(替换 Logo、应用名称,移除底部版权信息等)
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</CardHeader>
|
||||
<Divider />
|
||||
<CardBody className="pt-8">
|
||||
<div className="flex items-end gap-3 max-w-lg">
|
||||
<Input
|
||||
label="授权激活码"
|
||||
placeholder="请输入 FLVX- 开头的商业授权码"
|
||||
value={licenseKeyInput}
|
||||
variant="bordered"
|
||||
onChange={(e) => setLicenseKeyInput(e.target.value)}
|
||||
isDisabled={configs.is_commercial === "true"}
|
||||
description={configs.is_commercial === "true" ? "已激活商业版授权" : "需商业授权才能修改站名、图标并隐藏页脚品牌"}
|
||||
/>
|
||||
<Button
|
||||
color="primary"
|
||||
className="mb-6"
|
||||
isDisabled={configs.is_commercial === "true" || !licenseKeyInput.trim()}
|
||||
isLoading={activatingLicense}
|
||||
onPress={handleActivateLicense}
|
||||
>
|
||||
{configs.is_commercial === "true" ? "已授权" : "激活授权"}
|
||||
</Button>
|
||||
</div>
|
||||
</CardBody>
|
||||
</Card>
|
||||
|
||||
<Card className="shadow-md">
|
||||
<CardHeader className="pb-6">
|
||||
<div className="flex items-center w-full">
|
||||
|
||||
Reference in New Issue
Block a user