{"id":20073534,"url":"https://github.com/ragingwind/electron-menu-loader","last_synced_at":"2025-05-05T21:30:53.392Z","repository":{"id":57221762,"uuid":"43719404","full_name":"ragingwind/electron-menu-loader","owner":"ragingwind","description":"Loading menu items with custom events","archived":false,"fork":false,"pushed_at":"2016-12-29T00:47:52.000Z","size":38,"stargazers_count":11,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-25T02:03:41.821Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ragingwind.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-10-05T23:20:09.000Z","updated_at":"2018-04-11T03:03:55.000Z","dependencies_parsed_at":"2022-08-29T04:10:07.271Z","dependency_job_id":null,"html_url":"https://github.com/ragingwind/electron-menu-loader","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ragingwind%2Felectron-menu-loader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ragingwind%2Felectron-menu-loader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ragingwind%2Felectron-menu-loader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ragingwind%2Felectron-menu-loader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ragingwind","download_url":"https://codeload.github.com/ragingwind/electron-menu-loader/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252579993,"owners_count":21771248,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-13T14:46:40.030Z","updated_at":"2025-05-05T21:30:53.101Z","avatar_url":"https://github.com/ragingwind.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# electron-menu-loader\n\n\u003e Loading menu manifest from seperated menu files, Supporting a delegate custom event for Menu click event\n\n\n## Install\n\n```\n$ npm install --save electron-menu-loader\n```\n\n## Usage\n\n```js\n// load manifest from a file\nrequire('electron-menu-loader')('./menu');\nrequire('electron-menu-loader')(require('./menu'));\n\n// load manifest with params\nconst {app} = require('electron');\n\n// load shared meny and specific menu of target platform\nlet menu = require('./menu');\nmenu[process.platform] = require(process.platform);\nrequire('electron-menu-loader')(menu);\n\n// manange menu click event in the single place\napp.on('menuitem-click', event =\u003e {\n\tconsole.log(event.event,\n\tevent.menuItem.label,\n\tevent.browserWindow.getTitle());\n});\n```\n\n## API\n\n### electronMenuLoader(manifest, [options])\n\n#### manifest\n\nType: `string`\n\npath of the file content with the sets of the menu items\n\n#### options\n\n##### appMenu\n\nIf it set with true? this will register a menu to application menu. default is true.\n\n## Events\n\n`menu loader` will convert `event` property to custom event if the property is set in manifest like below. The custom event function translated is beging converted when the manifest has been loading.\n\n```json\nmodule.exports = {\n\tlabel: appName,\n\tsubmenu: [{\n\t\tlabel: 'Preferences',\n\t\tevent: 'prefer',\n\t\tparams: 'optional params'\n\t}]\n};\n```\n\nWhen user click the `Preferences`, the custom event will be fired to `app` with the event named [meuitem-click](https://github.com/ragingwind/electron-menu-loader/blob/master/index.js#L9). See refer to below sample.\n\n```js\napp.on('menuitem-click', event =\u003e {\n\tconsole.log(event.event,\n\tevent.menuItem.label,\n\tevent.browserWindow.getTitle());\n});\n```\n## License\n\nMIT © [Jimmy Moon](http://ragingwind.me)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fragingwind%2Felectron-menu-loader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fragingwind%2Felectron-menu-loader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fragingwind%2Felectron-menu-loader/lists"}