{"id":15019570,"url":"https://github.com/dwqs/lue","last_synced_at":"2025-10-24T12:31:32.677Z","repository":{"id":57146310,"uuid":"101546587","full_name":"dwqs/lue","owner":"dwqs","description":":seedling: Vue and vuex based library, writing less verbose code.","archived":false,"fork":false,"pushed_at":"2018-03-09T14:02:57.000Z","size":242,"stargazers_count":12,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-31T01:23:32.910Z","etag":null,"topics":["vue-router","vue-router-sync","vue2","vuejs2","vuex","vuex2"],"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/dwqs.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":"2017-08-27T11:00:51.000Z","updated_at":"2020-07-30T17:00:49.000Z","dependencies_parsed_at":"2022-09-06T05:51:38.852Z","dependency_job_id":null,"html_url":"https://github.com/dwqs/lue","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dwqs%2Flue","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dwqs%2Flue/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dwqs%2Flue/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dwqs%2Flue/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dwqs","download_url":"https://codeload.github.com/dwqs/lue/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237964687,"owners_count":19394446,"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":["vue-router","vue-router-sync","vue2","vuejs2","vuex","vuex2"],"created_at":"2024-09-24T19:53:42.591Z","updated_at":"2025-10-24T12:31:27.289Z","avatar_url":"https://github.com/dwqs.png","language":"JavaScript","funding_links":[],"categories":["公用事业","Components \u0026 Libraries","Utilities","Utilities [🔝](#readme)"],"sub_categories":["国家管理","Utilities","State Management"],"readme":"[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com) [![build pass](https://api.travis-ci.org/dwqs/lue.svg?branch=master)](https://travis-ci.org/dwqs/lue) ![npm-version](https://img.shields.io/npm/v/lue.svg) ![license](https://img.shields.io/npm/l/lue.svg)\n\n# lue\n:seedling: Vue and vuex based library, writing less verbose code.\n\n## Installation\nInstall the pkg with npm:\n```\nnpm install lue --save\n```\nor yarn\n```\nyarn add lue\n```\n\n## Basic Uasage\n#### 1. create a module\n```js\n// counter.js\nexport default {\n    namespace: 'counter',\n    state: {\n        count: 0,\n        title: 'Counter'\n    },\n    actions: {\n        increase ({dispatch, state}, payload) {\n            const val = state.count + 1;\n            // should be return a object to update state\n            // if return undefined or not a object, state won't be updated \n            return {\n                count: val\n            };\n        },\n        decrease ({dispatch, state}, payload) {\n            const val = state.count - 1;         \n            return {\n                count: val\n            };\n        }\n    }  \n};\n```\n\n#### 2. export all modules as a object\n```js\n// modules/index.js\nimport counter from 'path/to/counter';\nimport other from 'path/to/other';\n\nexport default {\n    counter,\n    other\n};\n```\n\n#### 3. create vue router options\n```js\n// options/index.js\nconst App = () =\u003e import(/* webpackChunkName: \"app\" */ 'path/to/app/index.vue');\nconst Counter = () =\u003e import(/* webpackChunkName: \"counter\" */ 'path/to/counter/index');\n\nconst Outer = { template: '\u003crouter-view\u003e\u003c/router-view\u003e' };\n\nexport default {\n    mode: 'history',\n    routes: [\n        {\n            path: '/',\n            component: Outer,\n            children: [\n                { path: '', component: App },\n                { path: 'counter', component: Counter },\n                // other config\n            ]\n        }\n    ]\n}\n```\n\n#### 4. create your app\n```js\nimport Vue from 'vue';\n// path/to/index.js\nimport Lue from 'lue';\n\nimport modules from 'path/to/modules/index';\nimport routerOptions from 'path/to/options/index';\nimport filters from 'path/to/filter/index';\n\n// 1. install plugin\nVue.use(Lue);\n\n// 2. new a lue instance\nconst app = new Lue();\n\n// 3. create store\napp.createStore(modules);\n\n// 4. init router\napp.initRouter(routerOptions);\n\n// 5. start your application\napp.start('#app', {\n    // optional options object\n    filters,\n    // env/vue-i18n.etc\n});\n```\n\n#### 5. combine lue with vue components\n```js\n\u003ctemplate\u003e\n    \u003cdiv class=\"counter\"\u003e\n        \u003ch3\u003e{{title}}:\u003c/h3\u003e\n        \u003cdiv\u003e\n            \u003cspan class=\"decrease\" @click=\"sub\"\u003e-\u003c/span\u003e\n            \u003cspan\u003e{{count}}\u003c/span\u003e\n            \u003cspan class=\"increase\" @click=\"add\"\u003e+\u003c/span\u003e\n        \u003c/div\u003e\n    \u003c/div\u003e\n\u003c/template\u003e\n\n\u003cscript\u003e\n    import { mergeActions, mergeProps } from 'lue';\n\n    export default {\n        computed: {\n            ...mergeProps(['counter.count', 'counter.title'])\n            // or\n            // ...mergeProps({\n            //    test: 'counter.title',\n            // })\n        },\n\n        methods: {\n            ...mergeActions(['counter.increase', 'counter.decrease']),\n            add () {\n                this.increase();\n            },\n\n            sub () {\n                this.decrease();\n            }\n        }\n    }\n\u003c/script\u003e\n```\n\n## Lue Instance Properties\n#### .store: Object\nVuex store instance.\n\n#### .router: Object\nVue router instance.\n\n#### .options: Object\nLue constructor options.\n\n## Lue Instance Methods\n#### .createStore(modules: Object, opts?: Object)\nCreate vuex store. See [opts](https://vuex.vuejs.org/en/api.html).\n\n#### .initRouter(routerOptions: Object)\nInit vue-router instance. See [routerOptions](https://router.vuejs.org/en/api/options.html)\n\n#### .start(el: String, opts?: Object)\nStart the app. See [opts](https://vuejs.org/v2/guide/instance.html#Creating-a-Vue-Instance) of creating a vue instance. `el` is a css selector for [`document.querySelector`](https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector)\n\n## Examples\nRunning the examples:\n\n```\nnpm install\nnpm run dev # serve examples at localhost:8000\n```\n\n## LICENSE\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdwqs%2Flue","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdwqs%2Flue","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdwqs%2Flue/lists"}