Skip to content

Commit

Permalink
UI 已经可以实现菜单的编辑使用了
Browse files Browse the repository at this point in the history
  • Loading branch information
linxinhong committed Dec 23, 2019
1 parent 4c41c21 commit 99fd44e
Show file tree
Hide file tree
Showing 14 changed files with 207 additions and 174 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/ui/ico
/ui/js/*.map
/docs/_build
/.vscode
Expand All @@ -8,3 +7,4 @@
/user/run.log
/ges/*.png
/user/include.ahk
/user/icons/*.*
169 changes: 139 additions & 30 deletions editor.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@ quickz.LoadPlugins()
quickz.GenerateInclude()

QZM.Listen(A_ScriptDir "\ui", 5210)
; The final parameter is the name of the ActiveX component.
;Gui Add, ActiveX, x0 y0 w980 h640 vWB, Shell.Explorer
;Gui Show, w980 h640, QuickZ 配置
; This is specific to the web browser control.
;WB.Navigate("http://127.0.0.1:5210/")
!z::reload
run http://127.0.0.1:5210

return

Expand Down Expand Up @@ -77,6 +75,12 @@ Class QZM {
else if (req.path == "/api/generateicon") {
QZM.GenerateIcon(req, res, server)
}
else if (req.path == "/api/generateiconlist") {
QZM.GenerateIconList(req, res, server)
}
else if (req.path == "/api/savefavicon") {
QZM.SaveFavIcon(req, res, server)
}
else {
res.NotFound()
}
Expand All @@ -96,53 +100,158 @@ Class QZM {
res.status := 200
}

GenerateIconList_search_file(iconpath, iconnumber) {
iconList := {}
SplitPath, iconpath, , , ext
if (InStr(",exe,ico,dll,icl,", "," ext ",")) {
if (not StrLen(iconNumber)) {
Loop 9999 {
iconindex := A_Index - 1
DllCall("PrivateExtractIcons", "Str", iconpath, "Int", iconindex, "Int", 16, "Int", 16, "PTR*", Icon, "PTR*", 0, "UInt", 1, "UInt", 0, "Int")
if (ErrorLevel) {
break
}
if (icon) {
iconList.push(iconpath ":" iconindex)
}
else {
break
}
}
}
else {
DllCall("PrivateExtractIcons", "Str", iconpath, "Int", iconNumber, "Int", 16, "Int", 16, "PTR*", Icon, "PTR*", 0, "UInt", 1, "UInt", 0, "Int")
if (icon) {
iconList.push(iconpath ":" iconNumber)
}
}
}
else {
iconList.push(iconpath ":" (iconNumber is integer ? iconNumber : "0" ))
}
return iconList
}

GenerateIconList(byRef req, byRef res, byRef server) {
if (req.method == "GET") {
query := req.queries["query"]
pos := RegExMatch(query , ":(\d+)$")
if (pos) {
filepath := Substr(query, 1, pos-1)
iconNumber := Substr(query, pos+1)
}
else {
filepath := query
}
if (FileExist(filepath)) {
if InStr(filepath, "*") {
iconList := {}
Loop, Files, %filepath%, RF
{
iconlist_once := QZM.GenerateIconList_search_file(A_LoopFileFullPath, "")
Loop, % iconlist_once.MaxIndex()
{
iconList.push(iconlist_once[A_Index])
}
}
}
else {
iconList := QZM.GenerateIconList_search_file(filepath, iconNumber)
}
res.SetBodyText(json.dump(iconList))
res.headers["Content-Type"] := "application/json"
res.status := 200
}
else {
res.SetBodyText("[]")
res.status := 200
}
}
}

GenerateIcon(byRef req, byRef res, byRef server) {
res.SetBodyText("")
if (req.method == "GET") {
filepath := req.queries["filepath"]
IconNumber := req.queries["number"] is integer ? req.queries["number"] : 0
if (FileExist(filepath)) {
SplitPath, filePath, filename, , ext
SplitPath, filePath, , , ext
gdip_tokent := Gdip_StartUp()
if (InStr(",exe,ico,dll,icl,", "," ext ",")) {
if (not FileExist(iconByResources)) {
pbitmap := Gdip_createBitmapFromFile(filePath, iconNumber, 16)
}
if (InStr(",exe,ico,dll,icl,png,", "," ext ",")) {
pbitmap := Gdip_createBitmapFromFile(filePath, iconNumber, 16)
}
else {
if (not FileExist(iconByFileType)) {
gdip_tokent := Gdip_StartUp()
SHGFI_TYPENAME = 0x000000400
SHGFI_DISPLAYNAME = 0x000000200
SHGFI_ICON = 0x000000100
SHGFI_ATTRIBUTES = 0x000000800
MAX_PATH := 260
SHFILEINFO := "
(
INT_PTR hIcon;
DWORD iIcon;
DWORD dwAttributes;
WCHAR szDisplayName[" MAX_PATH "];
WCHAR szTypeName[80];
)"
SHFO := Struct(SHFILEINFO)
DllCall("Shell32\SHGetFileInfo" . (A_IsUnicode ? "W":"A"), "str", FilePath, "uint", 0, "ptr", SHFO[""], "uint", sizeof(SHFILEINFO), "uint", SHGFI_TYPENAME|SHGFI_DISPLAYNAME|SHGFI_ICON|SHGFI_ATTRIBUTES)
pBitmap := Gdip_createBitmapFromHICON(SHFO.hIcon)
; Gdip_SaveBitmapToFile(pBitmap, iconFile, 100)
}
SHGFI_TYPENAME = 0x000000400
SHGFI_DISPLAYNAME = 0x000000200
SHGFI_ICON = 0x000000100
SHGFI_ATTRIBUTES = 0x000000800
MAX_PATH := 260
SHFILEINFO := "
(
INT_PTR hIcon;
DWORD iIcon;
DWORD dwAttributes;
WCHAR szDisplayName[" MAX_PATH "];
WCHAR szTypeName[80];
)"
SHFO := Struct(SHFILEINFO)
DllCall("Shell32\SHGetFileInfo" . (A_IsUnicode ? "W":"A"), "str", FilePath, "uint", 0, "ptr", SHFO[""], "uint", sizeof(SHFILEINFO), "uint", SHGFI_TYPENAME|SHGFI_DISPLAYNAME|SHGFI_ICON|SHGFI_ATTRIBUTES)
pBitmap := Gdip_createBitmapFromHICON(SHFO.hIcon)
; Gdip_SaveBitmapToFile(pBitmap, iconFile, 100)
}
length := Gdip_SaveBitmapToStream(pbitmap, data)
res.SetBody(data, length)
res.headers["Content-Type"] := "image/png"
Gdip_ShutDown(gdip_tokent)
res.status := 200
}
else {
res.SetBodyText("")
res.status := 404
}
}
res.status := 200
}

SaveFavIcon(byRef req, byRef res, byRef server) {
if (req.method == "GET") {
filepath := req.queries["filepath"]
IconNumber := req.queries["number"] is integer ? req.queries["number"] : 0
savefilepath := A_ScriptDir "\User\icons\" md5(filepath "|" iconNumber) ".png"
if (FileExist(filepath)) {
SplitPath, filePath, , , ext
gdip_tokent := Gdip_StartUp()
if (InStr(",exe,ico,dll,icl,png,", "," ext ",")) {
pbitmap := Gdip_createBitmapFromFile(filePath, iconNumber, 16)
}
else {
SHGFI_TYPENAME = 0x000000400
SHGFI_DISPLAYNAME = 0x000000200
SHGFI_ICON = 0x000000100
SHGFI_ATTRIBUTES = 0x000000800
MAX_PATH := 260
SHFILEINFO := "
(
INT_PTR hIcon;
DWORD iIcon;
DWORD dwAttributes;
WCHAR szDisplayName[" MAX_PATH "];
WCHAR szTypeName[80];
)"
SHFO := Struct(SHFILEINFO)
DllCall("Shell32\SHGetFileInfo" . (A_IsUnicode ? "W":"A"), "str", FilePath, "uint", 0, "ptr", SHFO[""], "uint", sizeof(SHFILEINFO), "uint", SHGFI_TYPENAME|SHGFI_DISPLAYNAME|SHGFI_ICON|SHGFI_ATTRIBUTES)
pBitmap := Gdip_createBitmapFromHICON(SHFO.hIcon)
}
Gdip_SaveBitmapToFile(pBitmap, savefilepath, 100)
Gdip_ShutDown(gdip_tokent)
res.SetBodyText(savefilepath)
res.status := 200
}
else {
res.status := 200
}
}
}


Config(byRef req, byRef res, byRef server) {
if (req.method == "GET") {
if (not FileExist(QZM.self.config)) {
Expand Down
2 changes: 1 addition & 1 deletion lib/GDIP.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -1775,7 +1775,7 @@ Gdip_CreateBitmapFromFile(sFile, IconNumber=1, IconSize="")
, PtrA := A_PtrSize ? "UPtr*" : "UInt*"

SplitPath, sFile,,, ext
if ext in exe,dll
if ext in exe,dll,icl
{
Sizes := IconSize ? IconSize : 256 "|" 128 "|" 64 "|" 48 "|" 32 "|" 16
BufSize := 16 + (2*(A_PtrSize ? A_PtrSize : 4))
Expand Down
1 change: 1 addition & 0 deletions ui/css/app.7a5dc9dc.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion ui/css/app.ce4f8b39.css

This file was deleted.

1 change: 1 addition & 0 deletions ui/css/chunk-0a718db4.abf2a4ef.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ui/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!DOCTYPE html><html lang=en><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><link rel=icon href=/favicon.ico><title>QuickZ 配置</title><link href=/css/app.ce4f8b39.css rel=preload as=style><link href=/css/chunk-vendors.5ff96fee.css rel=preload as=style><link href=/js/app.694289b5.js rel=preload as=script><link href=/js/chunk-vendors.109730cd.js rel=preload as=script><link href=/css/chunk-vendors.5ff96fee.css rel=stylesheet><link href=/css/app.ce4f8b39.css rel=stylesheet></head><body><noscript><strong>We're sorry but quickz-ui doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script src=/js/chunk-vendors.109730cd.js></script><script src=/js/app.694289b5.js></script></body></html>
<!DOCTYPE html><html lang=en><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><link rel=icon href=/favicon.ico><title>QuickZ 配置</title><link href=/css/chunk-0a718db4.abf2a4ef.css rel=prefetch><link href=/js/chunk-0a718db4.f76a129e.js rel=prefetch><link href=/css/app.7a5dc9dc.css rel=preload as=style><link href=/css/chunk-vendors.64b736a1.css rel=preload as=style><link href=/js/app.1172fe11.js rel=preload as=script><link href=/js/chunk-vendors.a6d946cb.js rel=preload as=script><link href=/css/chunk-vendors.64b736a1.css rel=stylesheet><link href=/css/app.7a5dc9dc.css rel=stylesheet></head><body><noscript><strong>We're sorry but quickz-ui doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script src=/js/chunk-vendors.a6d946cb.js></script><script src=/js/app.1172fe11.js></script></body></html>
2 changes: 2 additions & 0 deletions ui/js/app.1172fe11.js

Large diffs are not rendered by default.

0 comments on commit 99fd44e

Please sign in to comment.