{"id":20881580,"url":"https://github.com/boenfu/vuex-along","last_synced_at":"2025-05-15T20:03:27.221Z","repository":{"id":30680950,"uuid":"125712475","full_name":"boenfu/vuex-along","owner":"boenfu","description":":memo:  auto save and restore state for vuex","archived":false,"fork":false,"pushed_at":"2025-05-06T01:15:35.000Z","size":1834,"stargazers_count":260,"open_issues_count":0,"forks_count":36,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-05-15T20:03:24.681Z","etag":null,"topics":["localstorage","vue","vuex"],"latest_commit_sha":null,"homepage":"https://boenfu.github.io/vuex-along/","language":"TypeScript","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/boenfu.png","metadata":{"files":{"readme":"README.EN.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":["boenfu"],"patreon":"boen","open_collective":null,"ko_fi":null,"tidelift":null,"custom":null}},"created_at":"2018-03-18T10:09:06.000Z","updated_at":"2024-12-24T06:01:18.000Z","dependencies_parsed_at":"2024-06-18T16:48:23.988Z","dependency_job_id":"cf62f91c-d3af-4103-92f2-6d18c63e6950","html_url":"https://github.com/boenfu/vuex-along","commit_stats":{"total_commits":60,"total_committers":4,"mean_commits":15.0,"dds":"0.30000000000000004","last_synced_commit":"d95d8d685dc761fbf567887726637546fca531e1"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boenfu%2Fvuex-along","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boenfu%2Fvuex-along/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boenfu%2Fvuex-along/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boenfu%2Fvuex-along/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/boenfu","download_url":"https://codeload.github.com/boenfu/vuex-along/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254414493,"owners_count":22067271,"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":["localstorage","vue","vuex"],"created_at":"2024-11-18T07:25:24.189Z","updated_at":"2025-05-15T20:03:25.341Z","avatar_url":"https://github.com/boenfu.png","language":"TypeScript","funding_links":["https://github.com/sponsors/boenfu","https://patreon.com/boen"],"categories":[],"sub_categories":[],"readme":"English | [简体中文](./README.md)\n\n\u003cp align=\"center\"\u003e\u003cimg width=\"140\" src=\"./logo.png\"\u003e\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"#\"\u003e\u003cimg alt=\"Travis (.org) branch\" src=\"https://img.shields.io/travis/boenfu/vuex-along/master?style=flat-square\"\u003e\u003c/a\u003e\n  \u003ca href=\"#\"\u003e\u003cimg alt=\"npm\" src=\"https://img.shields.io/npm/v/vuex-along?style=flat-square\"\u003e\u003c/a\u003e\n    \u003ca href=\"#\"\u003e\u003cimg alt=\"npm\" src=\"https://img.shields.io/npm/dt/vuex-along?style=flat-square\"\u003e\u003c/a\u003e\n  \u003ca href=\"#\"\u003e\u003cimg alt=\"NPM\" src=\"https://img.shields.io/npm/l/vuex-along?style=flat-square\"\u003e\u003c/a\u003e\n  \u003ca href=\"#\"\u003e\u003cimg alt=\"GitHub last commit\" src=\"https://img.shields.io/github/last-commit/boenfu/vuex-along?style=flat-square\"\u003e\u003c/a\u003e\n  \u003ca href=\"http://makeapullrequest.com\"\u003e\u003cimg alt=\"PRS\" src=\"https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003ch2 align=\"center\"\u003evuex-along - A plugins for vuex\u003c/h2\u003e\n\u003cp align=\"center\"\u003e\u003cb\u003eAutomatically restore vuex state after refreshing the page\u003c/b\u003e\u003c/p\u003e\n\n# Directory\n\n- [Install](#Install)\n- [Usage](#Usage)\n- [Example](#Example)\n- [Options](#Options)\n- [Cleanup](#Cleanup)\n- [RunDemo](#RunDemo)\n- [Tips](#Tips)\n- [Contribution](#Contribution)\n- [Maintainers](#Maintainers)\n- [License](#license)\n\n## Install\n\n```shell\nnpm install vuex-along --save\n# or\nyarn add vuex-along\n```\n\n## Usage\n\n```javascript\nimport createVuexAlong from 'vuex-along'\n\nexport default new Vuex.Store({\n  state:{...},\n  modules:{...},\n  plugins: [createVuexAlong()]\n});\n```\n\n\u003e Now, the plugin has been in effect, and all state is stored to localStorage by default.\n\u003e\n\u003e Set [Options](#Options) to meet the usage requirements\n\u003e\n\u003e- [secure-adapter](https://github.com/boenfu/vuex-along-secure-adapter)\n\n## Example\n\n[→ Online Example](https://boenfu.github.io/vuex-along/)\n\n```javascript\nimport createVuexAlong from \"vuex-along\";\n\nconst moduleA = {\n  state: {\n    a1: \"hello\",\n    a2: \"world\",\n  },\n};\n\nconst store = new Vuex.Store({\n  state: {\n    count: 0,\n  },\n  modules: {\n    ma: moduleA,\n  },\n  plugins: [\n    createVuexAlong({\n      //Set the collection name to avoid multi-project data conflicts with the same site\n      name: \"hello-vuex-along\",\n      local: {\n        list: [\"ma\"],\n        // Filter the module ma data, save the other to localStorage\n        isFilter: true,\n      },\n      session: {\n        // Save a1 in module ma to sessionStorage\n        list: [\"ma.a1\"],\n      },\n    }),\n  ],\n});\n```\n\n## Options\n\n#### VuexAlongOptions\n\n| **Field**   | **Required** | **Type** | **Description**                                                          |\n| ----------- | ------------ | -------- | ------------------------------------------------------------------------ |\n| name        | no           | String   | Set the name of the local data collection, the default is **vuex-along** |\n| local       | no           | Object   | LocalStorage configuration, see #WatchOptions                            |\n| session     | no           | Object   | SessionStorage configuration, see #WatchOptions                          |\n| justSession | no           | Boolean  | Use only sessionStorage                                                  |\n\n#### WatchOptions\n\n| **Field** | **Required** | **Type**  | **Description**                                                                |\n| --------- | ------------ | --------- | ------------------------------------------------------------------------------ |\n| list      | yes          | String [] | List of strings of attribute names or module names that need to be listened to |\n| isFilter  | no           | Boolean   | Filter fields in list instead of saving                                        |\n\n## Cleanup\n\n```typescript\nwindow.clearVuexAlong(local = true, session = true):void;\nclearVuexAlong() // localStorage and sessionStorage will be cleaned up\nclearVuexAlong(true,false) // Just localStorage\nclearVuexAlong(false,true) // Just sessionStorage\n```\n\n## RunDemo\n\n```shell\ngit clone https://github.com/boenfu/vuex-along.git\ncd ./vuex-along\nyarn run:demo\n```\n\n## Tips\n\n- Support `typescript`\n- Support `IE11`\n- `sessionStorage` data recovery takes precedence over `localStorage`\n- The `key` of the top-level object that stores the content is fixed to `root`\n\n## Contribution\n\n\u003ctable\u003e\n    \u003ctbody\u003e\n        \u003ctr\u003e\n            \u003ctd\u003e\n                \u003ca target=\"_blank\" href=\"https://github.com/boenfu\"\u003e\u003cimg width=\"60px\" src=\"https://avatars0.githubusercontent.com/u/33797740?s=460\u0026v=4\"\u003e\u003c/a\u003e\n              \u003ca target=\"_blank\" href=\"https://github.com/han-feng\"\u003e\u003cimg width=\"60px\" src=\"https://avatars3.githubusercontent.com/u/1127566?s=460\u0026v=4\"\u003e\u003c/a\u003e\n            \u003c/td\u003e\n        \u003c/tr\u003e\n    \u003c/tbody\u003e\n\u003c/table\u003e\n\n## Maintainers\n\n- [boen](https://github.com/boenfu)\n\n## License\n\n- [MIT](https://opensource.org/licenses/MIT)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fboenfu%2Fvuex-along","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fboenfu%2Fvuex-along","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fboenfu%2Fvuex-along/lists"}