75 lines
2.8 KiB
C++
75 lines
2.8 KiB
C++
//---------------------------------------------------------------------------
|
|
|
|
#ifndef AIFormUnitH
|
|
#define AIFormUnitH
|
|
//---------------------------------------------------------------------------
|
|
#include <System.Classes.hpp>
|
|
#include <Vcl.Controls.hpp>
|
|
#include <Vcl.StdCtrls.hpp>
|
|
#include <Vcl.Forms.hpp>
|
|
|
|
#include "CEF4DelphiVCLRTL.hpp"
|
|
#include "GlobalUnit.h"
|
|
//---------------------------------------------------------------------------
|
|
class TAIForm : public TForm
|
|
{
|
|
__published: // IDE-managed Components
|
|
void __fastcall FormClose(TObject *Sender, TCloseAction &Action);
|
|
void __fastcall FormCreate(TObject *Sender);
|
|
void __fastcall FormCloseQuery(TObject *Sender, bool &CanClose);
|
|
private: // User declarations
|
|
TChromiumWindow *m_chrm; //AI视窗浏览器
|
|
TStringList* m_v8Values;
|
|
HANDLE m_hV8Sema;
|
|
HANDLE m_hV8ValueSema;
|
|
bool m_bClosing;
|
|
|
|
String m_baseUrl, m_apiKey;
|
|
|
|
static const int SKILL_COUNT = 10;
|
|
static const String skills[SKILL_COUNT];
|
|
String m_skillCache[SKILL_COUNT];
|
|
void __fastcall LoadSkillCache();
|
|
void __fastcall UnloadSkillCache();
|
|
|
|
//applyStrategy 结果结构
|
|
struct ApplyResult {
|
|
bool ok;
|
|
int code; //失败:1=解析失败 3=校验失败 4=用户取消
|
|
String message;
|
|
int id;
|
|
String name;
|
|
};
|
|
ApplyResult SaveAIPolicy(const String& json);
|
|
|
|
void __fastcall InitBrowser();
|
|
|
|
void __fastcall WebAfterCreated(TObject *Sender, const _di_ICefBrowser browser);
|
|
void __fastcall WebBeforeClose(TObject* Sender, const _di_ICefBrowser browse);
|
|
void __fastcall WebBeforeContextMenu(TObject* Sender, const _di_ICefBrowser browser,
|
|
const _di_ICefFrame frame, const _di_ICefContextMenuParams params,
|
|
const _di_ICefMenuModel model);
|
|
void __fastcall WebLoadEnd(TObject* Sender, const _di_ICefBrowser browser,
|
|
const _di_ICefFrame frame, int httpStatusCode);
|
|
void __fastcall WebProcessMessageReceived(TObject* Sender, const _di_ICefBrowser browser,
|
|
const _di_ICefFrame frame, TCefProcessId sourceProcess, const _di_ICefProcessMessage message,
|
|
/* out */ bool &Result);
|
|
void __fastcall WebLoadError(TObject* Sender, const _di_ICefBrowser browser, const _di_ICefFrame frame,
|
|
TCefErrorCode errorCode, const ustring errorText, const ustring failedUrl);
|
|
void __fastcall WebPreKeyEvent(TObject* Sender, const _di_ICefBrowser browser, const PCefKeyEvent event,
|
|
TCefEventHandle osEvent, /* out */ bool &isKeyboardShortcut, /* out */ bool &Result);
|
|
|
|
|
|
TStringList* __fastcall GetJQValue( String& str, _di_ICefFrame frame );
|
|
void __fastcall ReleaseV8ValueSema();
|
|
public: // User declarations
|
|
__fastcall TAIForm(TComponent* Owner, String apiKey);
|
|
|
|
void __fastcall OnLogin(String apiKey);
|
|
void __fastcall OnLogout();
|
|
};
|
|
//---------------------------------------------------------------------------
|
|
extern PACKAGE TAIForm *AIForm;
|
|
//---------------------------------------------------------------------------
|
|
#endif
|