@hlw-uni/mp-cli 1.0.29 → 1.0.31

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": "@hlw-uni/mp-cli",
3
- "version": "1.0.29",
3
+ "version": "1.0.31",
4
4
  "description": "uniapp 小程序脚手架生成器",
5
5
  "main": "bin/cli.js",
6
6
  "bin": {
@@ -1,3 +1,4 @@
1
- VITE_API_BASE_URL=http://localhost:3000/api
1
+ # 开发环境接口地址(小程序不支持 localhost,请改为本机局域网 IP,如 http://192.168.1.100:3000/api
2
+ VITE_API_BASE_URL=
2
3
  VITE_SIG_SECRET=your-secret-key-here
3
4
  VITE_PLUGIN_NAME=plugin-qz
@@ -11,7 +11,7 @@
11
11
  "@dcloudio/uni-app-plus": "3.0.0-4080420251103001",
12
12
  "@dcloudio/uni-components": "3.0.0-4080420251103001",
13
13
  "@dcloudio/uni-mp-toutiao": "3.0.0-4080420251103001",
14
- "@hlw-uni/mp-core": "^1.0.10",
14
+ "@hlw-uni/mp-core": "^1.0.11",
15
15
  "@hlw-uni/mp-vue": "^1.0.3",
16
16
  "@vueuse/core": "^10.9.0",
17
17
  "pinia": "^2.1.7",
@@ -22,7 +22,7 @@
22
22
  "@dcloudio/types": "^3.4.8",
23
23
  "@dcloudio/uni-cli-shared": "3.0.0-4080420251103001",
24
24
  "@dcloudio/vite-plugin-uni": "3.0.0-4080420251103001",
25
- "@hlw-uni/mp-vite-plugin": "^1.0.10",
25
+ "@hlw-uni/mp-vite-plugin": "^1.0.11",
26
26
  "@unocss/transformer-directives": "^66.1.1",
27
27
  "sass": "^1.70.0",
28
28
  "typescript": "^4.9.4",
@@ -2,19 +2,9 @@ import { createSSRApp } from "vue";
2
2
  import { createPinia } from "pinia";
3
3
  import { createUnistorage } from "pinia-plugin-unistorage";
4
4
  import App from "./App.vue";
5
- import { setupDefaultInterceptors, hlw, http } from "@hlw-uni/mp-core";
5
+ import { setupDefaultInterceptors, hlw } from "@hlw-uni/mp-core";
6
6
  import { useUserStore } from "./store";
7
7
 
8
- // 注册默认拦截器(Token + 业务错误 + 401)
9
- setupDefaultInterceptors({
10
- baseURL: import.meta.env.VITE_API_BASE_URL,
11
- getToken: () => useUserStore().token,
12
- onUnauthorized: () => {
13
- useUserStore().$patch({ token: "", userInfo: null });
14
- },
15
- sigSecret: import.meta.env.VITE_SIG_SECRET,
16
- });
17
-
18
8
  export function createApp() {
19
9
  const app = createSSRApp(App);
20
10
 
@@ -23,9 +13,19 @@ export function createApp() {
23
13
  pinia.use(createUnistorage());
24
14
  app.use(pinia);
25
15
 
16
+ // 注册默认拦截器(Token + 业务错误 + 401)— 放在 pinia 初始化之后
17
+ setupDefaultInterceptors({
18
+ baseURL: import.meta.env.VITE_API_BASE_URL ?? "",
19
+ getToken: () => useUserStore().token,
20
+ onUnauthorized: () => {
21
+ useUserStore().$patch({ token: "", userInfo: null });
22
+ },
23
+ // @ts-ignore
24
+ sigSecret: import.meta.env.VITE_SIG_SECRET ?? "",
25
+ });
26
+
26
27
  // 挂载全局工具
27
28
  app.config.globalProperties["hlw"] = hlw;
28
29
 
29
30
  return { app };
30
31
  }
31
-
@@ -1,3 +1,4 @@
1
- VITE_API_BASE_URL=http://localhost:3000/api
1
+ # 开发环境接口地址(小程序不支持 localhost,请改为本机局域网 IP,如 http://192.168.1.100:3000/api
2
+ VITE_API_BASE_URL=
2
3
  VITE_SIG_SECRET=your-secret-key-here
3
4
  VITE_PLUGIN_NAME=plugin-qz
@@ -12,7 +12,7 @@
12
12
  "@dcloudio/uni-app-plus": "3.0.0-4080420251103001",
13
13
  "@dcloudio/uni-components": "3.0.0-4080420251103001",
14
14
  "@dcloudio/uni-mp-weixin": "3.0.0-4080420251103001",
15
- "@hlw-uni/mp-core": "^1.0.10",
15
+ "@hlw-uni/mp-core": "^1.0.11",
16
16
  "@hlw-uni/mp-vue": "^1.0.3",
17
17
  "@vueuse/core": "^10.9.0",
18
18
  "pinia": "^2.1.7",
@@ -2,19 +2,9 @@ import { createSSRApp } from "vue";
2
2
  import { createPinia } from "pinia";
3
3
  import { createUnistorage } from "pinia-plugin-unistorage";
4
4
  import App from "./App.vue";
5
- import { setupDefaultInterceptors, hlw, http } from "@hlw-uni/mp-core";
5
+ import { setupDefaultInterceptors, hlw } from "@hlw-uni/mp-core";
6
6
  import { useUserStore } from "./store";
7
7
 
8
- // 注册默认拦截器(Token + 业务错误 + 401)
9
- setupDefaultInterceptors({
10
- baseURL: import.meta.env.VITE_API_BASE_URL,
11
- getToken: () => useUserStore().token,
12
- onUnauthorized: () => {
13
- useUserStore().$patch({ token: "", userInfo: null });
14
- },
15
- sigSecret: import.meta.env.VITE_SIG_SECRET,
16
- });
17
-
18
8
  export function createApp() {
19
9
  const app = createSSRApp(App);
20
10
 
@@ -23,9 +13,19 @@ export function createApp() {
23
13
  pinia.use(createUnistorage());
24
14
  app.use(pinia);
25
15
 
16
+ // 注册默认拦截器(Token + 业务错误 + 401)— 放在 pinia 初始化之后
17
+ setupDefaultInterceptors({
18
+ baseURL: import.meta.env.VITE_API_BASE_URL ?? "",
19
+ getToken: () => useUserStore().token,
20
+ onUnauthorized: () => {
21
+ useUserStore().$patch({ token: "", userInfo: null });
22
+ },
23
+ // @ts-ignore
24
+ sigSecret: import.meta.env.VITE_SIG_SECRET ?? "",
25
+ });
26
+
26
27
  // 挂载全局工具
27
28
  app.config.globalProperties["hlw"] = hlw;
28
29
 
29
30
  return { app };
30
31
  }
31
-