动态和命名空间模块未注册(vuex-module-decorators,vuex-class)

Dynamic & Namespaced modules not registered (vuex-module-decorators, vuex-class)

模块未注册:

$nuxt.$store._modulesNamespaceMap // No properties

此外,我收到此警告:

Classic mode for store/ is deprecated and will be removed in Nuxt 3.

我尝试过的:

  1. 正在手动加载模块以查看命名空间是否正常工作(失败)。
  2. 尝试在没有命名空间的情况下动态加载模块(失败)。

代码:

// @/store/modules/User.ts
import { Module, VuexModule, Mutation, Action } from "vuex-module-decorators";
import { firebase, auth, GoogleProvider, StoreDB } from "@/services/fireinit";
import { IUser } from "~/types/user";
import { store } from "..";

// It seems like the "store" is messed somehow
@Module({ dynamic: true, namespaced: true, store: store, name: "user" })
export default class User extends VuexModule {
  user: IUser = null;

  @Action
  async autoSignIn(user: IUser) {
    this.context.commit("setUser", user);
  }

  @Action
  async signInWithGoogle() {
    return new Promise(resolve => {
      console.log("signInWithGoogle:", this);
      auth.signInWithRedirect(GoogleProvider);
      resolve();
    });
  }

  // trunked ...
}
// @/store/index.ts
import Vuex, { Store } from "vuex";
import User from "./modules/User";

// trunked ...

// Declare empty store first
export const store = new Vuex.Store<IStoreType>({});

const createStore = () => store;

export default createStore;
// @/pages/login.vue

// trunked ...

const User = namespace('user'); // [vuex] module namespace not found in mapActions(): user/

@Component({})
export default class LoginComponent extends Vue {
  @User.State("activeUser") stateUser;
  @User.Action("signInWithGoogle") actionSignInWithGoogle;
}

树:

├── pages
│   └── login.vue
├── store
│   ├── index.ts
│   └── modules
│       └── User.ts

我希望能够加载动态和命名空间模块...

我尝试了我在万维网上能找到的一切,但我无法让它工作。

我做错了什么?

好的,我找到了一个可行的方法...

代码:

// @/store/index.ts
import Vuex, { Store } from "vuex";
import User from "./modules/User";

// trunked ...

// Declare empty store first
export const store = new Vuex.Store<IStoreType>({});
// No more "createStore" shit.
// @/pages/login.vue

// trunked ...

const User = namespace('modules/User/'); // "modules/" is important to make it work.

@Component({})
export default class LoginComponent extends Vue {
  @User.State("activeUser") stateUser;
  @User.Action("signInWithGoogle") actionSignInWithGoogle;
}