index.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /**
  2. * FeHelper Popup Menu
  3. */
  4. new Vue({
  5. el: '#pageContainer',
  6. data: {
  7. ajaxDebugger: '已开',
  8. canMeShow: {}
  9. },
  10. created: function () {
  11. let Settings = Tarp.require('../options/settings');
  12. // 根据配置,控制功能菜单的显示与隐藏
  13. Settings.getOptions((opts) => this.canMeShow = opts);
  14. // ajax debugger开关文案控制
  15. let bgPage = chrome.extension.getBackgroundPage();
  16. bgPage.BgPageInstance.tellMeAjaxDbgSwitch((dbgSwitchOn) => {
  17. this.ajaxDebugger = dbgSwitchOn ? '已开' : '已关';
  18. });
  19. },
  20. methods: {
  21. runHelper: function (mType, useFile) {
  22. // 获取后台页面,返回window对象
  23. let bgPage = chrome.extension.getBackgroundPage();
  24. if (mType === 'COLOR_PICKER') {
  25. bgPage.BgPageInstance.showColorPicker();
  26. } else {
  27. let MSG_TYPE = Tarp.require('../static/js/msg_type');
  28. bgPage.BgPageInstance.runHelper({
  29. msgType: MSG_TYPE[mType],
  30. useFile: useFile
  31. }, () => {
  32. if (mType === 'AJAX_DEBUGGER') {
  33. bgPage.BgPageInstance.tellMeAjaxDbgSwitch((dbgSwitchOn) => {
  34. this.ajaxDebugger = dbgSwitchOn ? '已开' : '已关';
  35. }, true);
  36. }
  37. });
  38. }
  39. window.close();
  40. },
  41. openOptionsPage: () => chrome.runtime.openOptionsPage()
  42. }
  43. });