there is a requirement that the store of vuex should be initialized to obtain the secondary domain address of the web page, which I write down as the variable host. The setting of cookie is relative to the second-level domain name, that is, a.xx.com and b.xx.com share a set of cookie, so setCookie and getCookie functions need to use host, in store. However, some action or mutation functions such as login and app status in store need to operate cookie, that is to say, setCookie and getCookie functions are also referenced in store. This forms circular dependency. How to solve this problem?
I have thought about solving the problem from two directions: either store does not use host, to write in global variables, but it is too dirty, and the test environment is not easy to deal with; or login (recording state settings such as token), app (some Boolean values) setCookie and getCookie functions are written in specific pages instead of store, but I also feel that it is not elegant and the management is not centralized (currently login and other operations are all written in mutation)
in addition, host must be obtained dynamically, because the host is not fixed. It may be a system similar to sass that uses
for many domain names.ask for advice