1 Star 0 Fork 23

ookk / php_desktop

forked from lobtao / php_desktop 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
unChromeMessage.pas 1.57 KB
一键复制 编辑 原始数据 按行查看 历史
lobtao 提交于 2018-08-30 20:31 . add feature
unit unChromeMessage;
interface
uses
Contnrs, uCEFChromium, Classes, utils_strings, SysUtils, Generics.Collections,
Windows, utils_dvalue, unConfig, Dialogs;
type
TWatchSubject = class(TObject)
public
listChome: TList<TChromium>;
// 注册消息监听
procedure attach(observer: TChromium);
procedure unAttach(observer: TChromium);
// 通知所有监听
procedure notifyAll(aMsg, aFrameName: string);
constructor Create; overload;
destructor Destroy; override;
end;
var
subject: TWatchSubject;
implementation
{ TSubject }
procedure TWatchSubject.attach(observer: TChromium);
var
iIndex: Integer;
begin
iIndex := listChome.IndexOf(observer);
if iIndex = -1 then
listChome.Add(observer);
end;
constructor TWatchSubject.Create;
begin
inherited;
listChome := TList<TChromium>.Create;
end;
destructor TWatchSubject.Destroy;
begin
listChome.Free;
inherited;
end;
procedure TWatchSubject.notifyAll(aMsg, aFrameName: string);
var
i: Integer;
observer: TChromium;
strFunc: string;
begin
aMsg := StringReplace(aMsg, '"', '\"', [rfReplaceAll]);
strFunc := 'if(window.onMsg) window.onMsg("' + aMsg + '")';
for i := 0 to listChome.Count - 1 do
begin
observer := listChome.Items[i];
observer.ExecuteJavaScript(strFunc,
observer.DocumentURL, aFrameName);
end;
end;
procedure TWatchSubject.unAttach(observer: TChromium);
var
iIndex: Integer;
begin
iIndex := listChome.IndexOf(observer);
if iIndex > -1 then
listChome.Delete(iIndex);
end;
initialization
subject := TWatchSubject.Create;
finalization
subject.Free;
end.
PHP
1
https://gitee.com/gay_hub/php_desktop.git
git@gitee.com:gay_hub/php_desktop.git
gay_hub
php_desktop
php_desktop
master

搜索帮助

53164aa7 5694891 3bd8fe86 5694891