c语言微信备份文件,文件保存后自动刷新微信小程序
微信開發者工具支持刷新和重建的快捷鍵,所以我們可以發送一段 apple script 腳本來達到刷新/重建項目的效果,
從而免去手工切換再使用快捷鍵的麻煩。例如:
tell application "wechatwebdevtools"
activate
delay 0.2
tell application "System Events"
key code {55, 15}
end tell
end tell
這段代碼可以使用命令 osascript 執行,效果就是聚焦微信開發者工具,然后發送 Command + R 刷新界面。
這里的問題是我們還是需要每次刷新都要切換到微信開發者工具界面,這對于開發的流暢度還是有影響的。
一個簡單的解決辦法就是修改開發者工具源碼,讓它支持全局快捷鍵,經過一番查找,找到了文件:
/Applications/wechatwebdevtools.app/Contents/Resources/app.nw/app/dist/common/menu/menu.js,
添加代碼:
function registShortcut(key, onactive) {
var option = {
key : key,
active : onactive,
failed : function(msg) {
// :(, fail to register the |key| or couldn't parse the |key|.
console.log(msg);
}
};
// Create a shortcut with |option|.
var shortcut = new nw.Shortcut(option);
// Register global desktop shortcut, which can work without focus.
nw.App.registerGlobalHotKey(shortcut);
}
以及
registShortcut("Command+Shift+R", function () {
e.reload()
})
registShortcut("Command+Shift+B", function () {
e.reBuild()
})
到 init 函數下面就可以讓開發者工具支持全局刷新的熱鍵了(Command+Shift+R 和 Command+Shift+B),
完整文件下載
然后只需要讓 vim 保存 wxss 和 wxml 文件后發送快捷鍵就可以了。使用一鍵安裝命令:
curl https://raw.githubusercontent.com/chemzqm/vim-macos/master/autoload/macos.vim > ~/.vim/autoload/macos.vim
安裝 vim-macos 插件, 然后在 ~/.vimrc 中配置:
autocmd BufWritePost *.wxml call macos#keycodes('command', 'shift', 'r')
autocmd BufWritePost *.wxss call macos#keycodes('command', 'shift', 'r')
大功告成。
(完)
總結
以上是生活随笔為你收集整理的c语言微信备份文件,文件保存后自动刷新微信小程序的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: php点链接直接现在文件吗,PHP实现点
- 下一篇: mysql部署策略_MySQL延迟问题和