增加测速
This commit is contained in:
@@ -786,6 +786,26 @@ const CreateStationDialog: React.FC<{
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
onClick={async () => {
|
||||
setFormToast({ message: "正在测速,请稍候...", type: "success" });
|
||||
try {
|
||||
const best = await api.autoSelectBestNode();
|
||||
setPackycodeNode(best.url);
|
||||
setFormData(prev => ({ ...prev, api_url: best.url }));
|
||||
setFormToast({
|
||||
message: `已选择最快节点: ${best.name} (延迟: ${best.response_time}ms)`,
|
||||
type: "success"
|
||||
});
|
||||
} catch (error) {
|
||||
setFormToast({ message: "节点测速失败", type: "error" });
|
||||
}
|
||||
}}
|
||||
>
|
||||
自动选择
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<p className="text-xs text-muted-foreground">
|
||||
@@ -1163,6 +1183,26 @@ const EditStationDialog: React.FC<{
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
onClick={async () => {
|
||||
setFormToast({ message: "正在测速,请稍候...", type: "success" });
|
||||
try {
|
||||
const best = await api.autoSelectBestNode();
|
||||
setPackycodeNode(best.url);
|
||||
setFormData(prev => ({ ...prev, api_url: best.url }));
|
||||
setFormToast({
|
||||
message: `已选择最快节点: ${best.name} (延迟: ${best.response_time}ms)`,
|
||||
type: "success"
|
||||
});
|
||||
} catch (error) {
|
||||
setFormToast({ message: "节点测速失败", type: "error" });
|
||||
}
|
||||
}}
|
||||
>
|
||||
自动选择
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<p className="text-xs text-muted-foreground">
|
||||
|
@@ -2349,12 +2349,11 @@ export const api = {
|
||||
|
||||
/**
|
||||
* Tests all PackyCode nodes and returns speed test results
|
||||
* @param token - API token for authentication
|
||||
* @returns Promise resolving to array of node speed test results
|
||||
*/
|
||||
async testAllPackycodeNodes(token: string): Promise<NodeSpeedTestResult[]> {
|
||||
async testAllPackycodeNodes(): Promise<NodeSpeedTestResult[]> {
|
||||
try {
|
||||
return await invoke<NodeSpeedTestResult[]>("test_all_packycode_nodes", { token });
|
||||
return await invoke<NodeSpeedTestResult[]>("test_all_packycode_nodes");
|
||||
} catch (error) {
|
||||
console.error("Failed to test PackyCode nodes:", error);
|
||||
throw error;
|
||||
@@ -2363,12 +2362,11 @@ export const api = {
|
||||
|
||||
/**
|
||||
* Automatically selects the best PackyCode node based on speed
|
||||
* @param token - API token for authentication
|
||||
* @returns Promise resolving to the best node
|
||||
*/
|
||||
async autoSelectBestNode(token: string): Promise<PackycodeNode> {
|
||||
async autoSelectBestNode(): Promise<PackycodeNode> {
|
||||
try {
|
||||
return await invoke<PackycodeNode>("auto_select_best_node", { token });
|
||||
return await invoke<PackycodeNode>("auto_select_best_node");
|
||||
} catch (error) {
|
||||
console.error("Failed to auto-select best node:", error);
|
||||
throw error;
|
||||
|
Reference in New Issue
Block a user