create-packer 1.11.2 → 1.11.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-packer",
3
- "version": "1.11.2",
3
+ "version": "1.11.4",
4
4
  "main": "index.js",
5
5
  "repository": "https://github.com/kevily/create-packer",
6
6
  "author": "1k <bug_zero@163.com>",
@@ -1,8 +1,8 @@
1
- import create from 'zustand'
2
- import { combine } from 'zustand/middleware'
1
+ import { defineStore } from '@/providers'
3
2
 
4
- export const useApp = create(
5
- combine({}, setState => {
3
+ export const useApp = defineStore({
4
+ state: () => ({}),
5
+ actions: () => {
6
6
  return {}
7
- })
8
- )
7
+ }
8
+ })
@@ -0,0 +1,22 @@
1
+ import { StateCreator } from 'zustand/vanilla'
2
+ import create from 'zustand'
3
+ import { combine } from 'zustand/middleware'
4
+
5
+ export interface defineStoreOptionsType<S extends object, A extends object> {
6
+ state: () => S
7
+ actions?: StateCreator<{ state: S }, [], [], A>
8
+ }
9
+ export function defineStore<S extends object, U extends object>(
10
+ options: defineStoreOptionsType<S, U>
11
+ ) {
12
+ return create(
13
+ combine({ state: options.state() }, (setState, getState, store, $$storeMutations) => {
14
+ return {
15
+ reset() {
16
+ setState(() => options.state(), true)
17
+ },
18
+ ...(options.actions?.(setState, getState, store, $$storeMutations) || {})
19
+ }
20
+ })
21
+ )
22
+ }
@@ -0,0 +1 @@
1
+ export * from './defineStore'
@@ -1,2 +1,2 @@
1
1
  export { default } from './router.container'
2
- export { default as routePaths } from './paths'
2
+ export { default as routePaths } from '././router.paths'
@@ -1,12 +1,12 @@
1
1
  import { lazy } from 'react'
2
2
  import { RouteObject } from 'react-router-dom'
3
- import paths from './paths'
3
+ import paths from './router.paths'
4
4
  import Layout from '@/layout'
5
5
  import Home from '@/pages/home'
6
6
 
7
7
  const NotFound = lazy(() => import('@/pages/notFound'))
8
8
 
9
- const routes: RouteObject[] = [
9
+ const routerConfig: RouteObject[] = [
10
10
  {
11
11
  path: paths.root,
12
12
  element: <Layout />,
@@ -23,4 +23,4 @@ const routes: RouteObject[] = [
23
23
  }
24
24
  ]
25
25
 
26
- export default routes
26
+ export default routerConfig
@@ -1,6 +1,6 @@
1
1
  import { useRoutes } from 'react-router-dom'
2
- import routes from './routes'
2
+ import routerConfig from './router.config'
3
3
 
4
4
  export default function Route() {
5
- return useRoutes(routes)
5
+ return useRoutes(routerConfig)
6
6
  }
@@ -1,6 +1,6 @@
1
1
  import app from './app'
2
2
  import { createPinia } from 'pinia'
3
- import router from '@/routes'
3
+ import router from '@/router'
4
4
  import './style.css'
5
5
 
6
6
  app.use(createPinia()).use(router).mount('#app')
@@ -1,9 +1,8 @@
1
1
  import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'
2
- import names from './names'
3
- import Home from '@/pages/Home'
2
+ import names from './router.names'
4
3
 
5
4
  const routes: (RouteRecordRaw & { name: string })[] = [
6
- { path: '/', name: names.home, component: Home },
5
+ { path: '/', name: names.home, component: () => import('@/pages/home') },
7
6
  { path: '/404', name: names.notFound, component: () => import('@/pages/notFound') }
8
7
  ]
9
8
  const router = createRouter({