feat(system):优化后端

1.新增后端测试
2.增加了后端的加密
3.增加了i18n(国际化)
This commit is contained in:
2026-05-31 15:39:34 +00:00
parent affe460180
commit 99520c69d7
118 changed files with 8174 additions and 1491 deletions
@@ -1,8 +1,10 @@
import { useState, useEffect } from 'react';
import { Download, Trash2, Plus, Box, Sparkles } from 'lucide-react';
import { useTranslation } from 'react-i18next';
import { Download, Trash2, Plus, Box, Sparkles, Loader2, Wand2 } from 'lucide-react';
import apiClient from '../../api/client';
export function SkillSettings() {
const { t } = useTranslation();
const [skills, setSkills] = useState<string[]>([]);
const [loading, setLoading] = useState(true);
const [repoUrl, setRepoUrl] = useState('');
@@ -34,24 +36,24 @@ export function SkillSettings() {
setError('');
try {
await apiClient.post('/api/v1/resource/skill', { repo_url: repoUrl, path: path || null });
setMessage('Skill installed successfully');
setMessage(t('plugin.skillInstallSuccess'));
setRepoUrl('');
setPath('');
fetchSkills();
} catch (err: any) {
setError(err.response?.data?.message || 'Failed to install skill');
setError(err.response?.data?.message || t('plugin.skillInstallFailed'));
} finally {
setInstalling(false);
}
};
const handleDelete = async (skillName: string) => {
if (!confirm(`Delete ${skillName}?`)) return;
if (!confirm(t('plugin.deleteSkillConfirm', { name: skillName }))) return;
try {
await apiClient.delete(`/api/v1/resource/skill/${skillName}`);
fetchSkills();
} catch {
alert('Failed to delete skill');
alert(t('plugin.skillDeleteFailed'));
}
};
@@ -60,9 +62,9 @@ export function SkillSettings() {
<div>
<div className="flex items-center gap-2 mb-1">
<Sparkles size={16} className="text-accent" />
<h1 className="text-lg font-bold text-text-primary">Skill Management</h1>
<h1 className="text-lg font-bold text-text-primary">{t('plugin.skillManagement')}</h1>
</div>
<p className="text-sm text-text-muted">Manage agent skills and functions</p>
<p className="text-sm text-text-muted">{t('plugin.skillDesc')}</p>
</div>
<div className="bg-bg-card rounded-2xl border border-border-primary shadow-sm overflow-hidden">
@@ -71,21 +73,21 @@ export function SkillSettings() {
<Download size={16} className="text-accent" />
</div>
<div>
<h2 className="text-sm font-bold text-text-primary">Install Skill</h2>
<p className="text-[11px] text-text-muted">Install from a repository</p>
<h2 className="text-sm font-bold text-text-primary">{t('plugin.installSkill')}</h2>
<p className="text-[11px] text-text-muted">{t('plugin.installSkillDesc')}</p>
</div>
</div>
<div className="p-6">
<form onSubmit={handleInstall} className="space-y-4">
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<label className="block text-xs font-semibold text-text-secondary mb-1.5 uppercase tracking-wider">Repository URL</label>
<input type="text" required value={repoUrl} onChange={(e) => setRepoUrl(e.target.value)} placeholder="https://github.com/user/repo"
<label className="block text-xs font-semibold text-text-secondary mb-1.5 uppercase tracking-wider">{t('plugin.repoUrl')}</label>
<input type="text" required value={repoUrl} onChange={(e) => setRepoUrl(e.target.value)} placeholder={t('plugin.repoUrlPlaceholder')}
className="w-full px-3.5 py-2.5 bg-bg-input border border-border-primary rounded-xl text-sm text-text-primary focus:outline-none focus:ring-2 focus:ring-accent/20 focus:border-accent placeholder:text-text-muted/50" />
</div>
<div>
<label className="block text-xs font-semibold text-text-secondary mb-1.5 uppercase tracking-wider">Path (Optional)</label>
<input type="text" value={path} onChange={(e) => setPath(e.target.value)} placeholder="subfolder/path"
<label className="block text-xs font-semibold text-text-secondary mb-1.5 uppercase tracking-wider">{t('plugin.pathOptional')}</label>
<input type="text" value={path} onChange={(e) => setPath(e.target.value)} placeholder={t('plugin.pathPlaceholder')}
className="w-full px-3.5 py-2.5 bg-bg-input border border-border-primary rounded-xl text-sm text-text-primary focus:outline-none focus:ring-2 focus:ring-accent/20 focus:border-accent placeholder:text-text-muted/50" />
</div>
</div>
@@ -95,7 +97,7 @@ export function SkillSettings() {
<button type="submit" disabled={installing}
className="flex items-center gap-2 px-5 py-2.5 bg-accent text-white rounded-xl hover:bg-accent-hover transition-all shadow-lg shadow-accent/15 text-sm font-medium disabled:opacity-50">
<Plus size={14} />
{installing ? 'Installing...' : 'Install'}
{installing ? t('common.installing') : t('plugin.install')}
</button>
</div>
</form>
@@ -104,13 +106,19 @@ export function SkillSettings() {
<div className="bg-bg-card rounded-2xl border border-border-primary shadow-sm overflow-hidden">
<div className="px-6 py-4 border-b border-border-primary">
<h2 className="text-sm font-bold text-text-primary">Installed Skills ({skills.length})</h2>
<h2 className="text-sm font-bold text-text-primary">{t('plugin.installedSkills', { count: skills.length })}</h2>
</div>
<div className="p-6">
{loading ? (
<div className="text-text-muted text-sm">Loading skills...</div>
<div className="flex flex-col items-center justify-center py-12 text-text-muted">
<Loader2 size={24} className="animate-spin mb-3" />
<span className="text-sm">{t('common.loading')}</span>
</div>
) : skills.length === 0 ? (
<div className="text-text-muted text-sm">No skills installed yet.</div>
<div className="flex flex-col items-center justify-center py-12 text-text-muted">
<Wand2 size={32} className="mb-3 opacity-40" />
<span className="text-sm">{t('plugin.noSkills')}</span>
</div>
) : (
<div className="grid grid-cols-1 md:grid-cols-2 gap-3">
{skills.map((skill) => (