一些配置參數(shù)需要在瀏覽器環(huán)境創(chuàng)建之前進(jìn)行處理,或者是需要傳給瀏覽器對(duì)象進(jìn)行初始化。所以參考 Chrome 擴(kuò)展的模式,heX 中也引入了清單文件。清單文件為一個(gè)名為 manifest.json
的 JSON 格式文本文件,里面包含了眾多配置項(xiàng)。
heX 的主程序 - hexclient 在啟動(dòng)時(shí)讀入并解析清單文件,若讀取或解析出錯(cuò),主程序都將退出。
{
"first_page": "chrome://version", // 首頁(yè),可以是 URL 或者一個(gè)本地文件路徑
"application_title": "Hello heX!", // 程序默認(rèn)標(biāo)題,alert 等窗口使用
"application_shortname": "test", // 應(yīng)用程序別名
"use_grit_package": true, // 使用打包資源
"icon_path": "", // 程序默認(rèn)圖標(biāo)路徑
"use_node": true, // 是否開(kāi)啟 Node.js
"version": "1.0", // 程序版本信息
"locale": "zh-CN", // 瀏覽器區(qū)域設(shè)置
"multiple_process": false, // 是否為多進(jìn)程模式
"launch_node_in_all_pages": false, // 在打開(kāi)的所有頁(yè)面中使用 Node.JS
"load_node_manually": false, // 是否手動(dòng)加載 Node.js
"disable_async_node_apis": false, // 是否禁用 Node.JS 異步 API
"remote_debugging_port": 65432, // 遠(yuǎn)程調(diào)試端口
"disable_debug_log": true, // 是否禁止生成 Chromium 調(diào)試信息
"quit_after_main_window_closed": false, // 是否在主窗口關(guān)閉后退出
"cache_path": "data", // 緩存路徑
"npapi_plugin_directory": "", // NPAPI 插件路徑
"disable_ime_composition": false, // 禁用 IME composition
"extensions": [ // heX 擴(kuò)展名稱列表
"hex_dialog",
"hex_sleep",
"hex_shortcut"
],
"extension_path": "", // heX 擴(kuò)展的路徑
"single_instance": true, // 是否為單一實(shí)例模式
"window_class_name": "A_HEXCLIENT", // 主窗口類名
"form": {
"style": "captionless", // 窗口類型:標(biāo)準(zhǔn)、無(wú)標(biāo)題、桌面 Widget
"plain": false, // 是否為扁平窗口
"system_buttons": true, // 是否顯示默認(rèn)的系統(tǒng)控制按鈕
"transmission_color": "none", // 穿透顏色
"transparent_browser": true, // 是否為透明瀏覽器
"fixed": false, // 窗體是否可以調(diào)整大小
"disable_form_apis": false, // 是否禁用所有窗口相關(guān) API
"opacity": "none", // 窗口透明度
"hook_system_command": false, // 是否攔截窗口的系統(tǒng)命令
"launch_state": "normal", // 啟動(dòng)初始狀態(tài)
"launch_width": 800, // 啟動(dòng)初始寬度
"launch_height": 600, // 啟動(dòng)初始高度
"launch_x": "screen_centered", // 啟動(dòng)初始 X 軸位置
"launch_y": "screen_centered", // 啟動(dòng)初始 Y 軸位置
"min_width": 0, // 最小寬度
"min_height": 0, // 最小高度
"max_width": 0, // 最大寬度
"max_height": 0, // 最大高度
"border_width": 5 // 模擬邊框區(qū)域?qū)挾? },
"browser": {
"no_proxy_server": false,
"winhttp-proxy-resolver": false,
"disable_gpu": true,
"disable_3d_apis": false,
"disable_databases": false,
"disable_experimental_webgl": false,
"disable_file_system": false,
"disable_geolocation": false,
"disable_gpu_process_prelaunch": true,
"disable_java": false,
"disable_javascript": false,
"disable_javascript_i18n_api": false,
"disable_local_storage": false,
"disable_logging": false,
"disable_plugins": false,
"disable_renderer_accessibility": false,
"disable_session_storage": false,
"disable_speech_input": false,
"disable_web_sockets": false,
"in_process_gpu": false,
"in_process_plugins": false,
"enable_media_stream": true,
"web_security_disabled": true,
"file_access_from_file_urls_allowed": true,
"universal_access_from_file_urls_allowed": true
}
}
$(AppDir)
代表當(dāng)前程序路徑(包含“/”),也可以是 file 協(xié)議 URL 或者本地路徑。window.open()
彈出的子窗口中將不會(huì)啟動(dòng) Node.js,開(kāi)啟此配置項(xiàng)后則始終在彈出的子窗口中啟動(dòng) Node.js。<script></script>
標(biāo)簽或者用 JavaScript 動(dòng)態(tài)插入 node.js
文件。debug.log
文件。instanceCreated
事件,此配置要求 window_class_name
不為空,并且為單進(jìn)程模式。standard
:標(biāo)準(zhǔn)窗口,與系統(tǒng)主題一致。captionless
:無(wú)標(biāo)題欄的窗口,可以自繪標(biāo)題欄。desktop_widget
:桌面 Widget 窗口,將會(huì)固定在桌面上,不會(huì)隨著顯示桌面而最小化。standard
的情況下可以看到效果。none
表示關(guān)閉,#RRGGBB
表示一個(gè) HTML 的顏色值,如 #0000FF
,也支持簡(jiǎn)寫(xiě) #666
,屬性值不區(qū)分大小寫(xiě)。瀏覽器窗口中遇到穿透顏色所指的顏色值時(shí)將不再響應(yīng)鼠標(biāo)事件,直接穿透到其下方的窗口,并且在視覺(jué)上可以直接看到下方的窗口。此配置項(xiàng)可以制作不規(guī)則窗口。none
表示關(guān)閉,0-255
的整數(shù)值表示 透明 到 不透明。normal
表示默認(rèn)minimized
表示最小化狀態(tài)maximized
表示最大化狀態(tài)hidden
表示隱藏狀態(tài)fullscreen
表示全屏狀態(tài)system_default
表示采用系統(tǒng)默認(rèn)的寬度system_default
表示采用系統(tǒng)默認(rèn)的高度system_default
表示采用系統(tǒng)默認(rèn)的 X 軸位置parent_centered
表示相對(duì)父窗口水平居中screen_centered
表示相對(duì)屏幕水平居中system_default
表示采用系統(tǒng)默認(rèn)的 Y 軸位置parent_centered
表示相對(duì)父窗口垂直居中screen_centered
表示相對(duì)屏幕垂直居中
更多建議: