@hlw-uni/mp-cli 1.0.18 → 1.0.20

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/bin/cli.js CHANGED
File without changes
package/package.json CHANGED
@@ -1,38 +1,38 @@
1
1
  {
2
- "name": "@hlw-uni/mp-cli",
3
- "version": "1.0.18",
4
- "description": "uniapp 小程序脚手架生成器",
5
- "main": "bin/cli.js",
6
- "bin": {
7
- "hlw-uni-mp": "./bin/cli.js"
8
- },
9
- "keywords": [
10
- "uniapp",
11
- "scaffold",
12
- "weixin",
13
- "toutiao",
14
- "miniprogram"
15
- ],
16
- "author": "hlw2326",
17
- "license": "MIT",
18
- "dependencies": {
19
- "chalk": "^4.1.2",
20
- "commander": "^11.1.0",
21
- "fs-extra": "^11.2.0",
22
- "inquirer": "^8.2.7",
23
- "ora": "^5.4.1"
24
- },
25
- "devDependencies": {
26
- "@types/fs-extra": "^11.0.4",
27
- "@types/node": "^20.11.0",
28
- "esbuild": "^0.28.0",
29
- "tsx": "^4.19.0"
30
- },
31
- "scripts": {
32
- "dev": "tsx bin/cli.ts",
33
- "create": "tsx bin/cli.ts create",
34
- "build": "esbuild bin/cli.ts --bundle --platform=node --outfile=bin/cli.js --format=cjs --external:fs-extra --external:inquirer --external:chalk --external:commander --external:ora --external:path --external:fs",
35
- "prepublish": "pnpm build",
36
- "postbuild": "node scripts/fix-templates-path.js"
37
- }
38
- }
2
+ "name": "@hlw-uni/mp-cli",
3
+ "version": "1.0.20",
4
+ "description": "uniapp 小程序脚手架生成器",
5
+ "main": "bin/cli.js",
6
+ "bin": {
7
+ "hlw-uni-mp": "./bin/cli.js"
8
+ },
9
+ "scripts": {
10
+ "dev": "tsx bin/cli.ts",
11
+ "create": "tsx bin/cli.ts create",
12
+ "build": "esbuild bin/cli.ts --bundle --platform=node --outfile=bin/cli.js --format=cjs --external:fs-extra --external:inquirer --external:chalk --external:commander --external:ora --external:path --external:fs",
13
+ "prepublish": "pnpm build",
14
+ "postbuild": "node scripts/fix-templates-path.js"
15
+ },
16
+ "keywords": [
17
+ "uniapp",
18
+ "scaffold",
19
+ "weixin",
20
+ "toutiao",
21
+ "miniprogram"
22
+ ],
23
+ "author": "hlw2326",
24
+ "license": "MIT",
25
+ "dependencies": {
26
+ "chalk": "^4.1.2",
27
+ "commander": "^11.1.0",
28
+ "fs-extra": "^11.2.0",
29
+ "inquirer": "^8.2.7",
30
+ "ora": "^5.4.1"
31
+ },
32
+ "devDependencies": {
33
+ "@types/fs-extra": "^11.0.4",
34
+ "@types/node": "^20.11.0",
35
+ "esbuild": "^0.28.0",
36
+ "tsx": "^4.19.0"
37
+ }
38
+ }
@@ -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.7",
14
+ "@hlw-uni/mp-core": "^1.0.9",
15
15
  "@hlw-uni/mp-vue": "^1.0.2",
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.8",
25
+ "@hlw-uni/mp-vite-plugin": "^1.0.9",
26
26
  "@unocss/transformer-directives": "^66.1.1",
27
27
  "@vue/tsconfig": "^0.1.3",
28
28
  "sass": "^1.70.0",
@@ -1,18 +1,13 @@
1
- import App from './App.vue';
1
+ import { createSSRApp } from "vue";
2
2
  import { createPinia } from "pinia";
3
3
  import { createUnistorage } from "pinia-plugin-unistorage";
4
- import { useApp, setupDefaultInterceptors, http } from '@hlw-uni/mp-core';
5
- import { useUserStore } from './stores/user';
6
-
7
- const app = useApp();
8
-
9
- // 初始化 Pinia(必须在 setupDefaultInterceptors 之前)
10
- const pinia = createPinia();
11
- pinia.use(createUnistorage());
12
- app.use(pinia);
4
+ import App from "./App.vue";
5
+ import { setupDefaultInterceptors, hlw, http } from "@hlw-uni/mp-core";
6
+ import { useUserStore } from "./stores/user";
13
7
 
14
8
  // 注册默认拦截器(Token + 业务错误 + 401)
15
9
  setupDefaultInterceptors({
10
+ baseURL: (import.meta.env as Record<string, string>).VITE_API_BASE_URL ?? "",
16
11
  getToken: () => useUserStore().token,
17
12
  onUnauthorized: () => {
18
13
  useUserStore().$patch({ token: "", userInfo: null });
@@ -21,12 +16,17 @@ setupDefaultInterceptors({
21
16
  sigSecret: (import.meta.env as Record<string, string>).VITE_SIG_SECRET ?? "",
22
17
  });
23
18
 
24
- // --- 可选:添加全局请求拦截器 ---
25
- // http.onRequest((config) => {
26
- // config.headers = { ...config.headers, 'X-Custom-Header': 'value' };
27
- // return config;
28
- // });
19
+ export function createApp() {
20
+ const app = createSSRApp(App);
21
+
22
+ // 初始化 Pinia
23
+ const pinia = createPinia();
24
+ pinia.use(createUnistorage());
25
+ app.use(pinia);
26
+
27
+ // 挂载全局工具
28
+ app.config.globalProperties["hlw"] = hlw;
29
29
 
30
- // uni-app 要求导出 createApp 函数
31
- export const createApp = app.install(App);
30
+ return { app };
31
+ }
32
32
 
@@ -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.8",
15
+ "@hlw-uni/mp-core": "^1.0.9",
16
16
  "@hlw-uni/mp-vue": "^1.0.2",
17
17
  "@vueuse/core": "^10.9.0",
18
18
  "pinia": "^2.1.7",
@@ -23,7 +23,7 @@
23
23
  "@dcloudio/types": "^3.4.8",
24
24
  "@dcloudio/uni-cli-shared": "3.0.0-4080420251103001",
25
25
  "@dcloudio/vite-plugin-uni": "3.0.0-4080420251103001",
26
- "@hlw-uni/mp-vite-plugin": "^1.0.8",
26
+ "@hlw-uni/mp-vite-plugin": "^1.0.9",
27
27
  "@unocss/transformer-directives": "^66.1.1",
28
28
  "@vue/tsconfig": "^0.1.3",
29
29
  "sass": "^1.70.0",
@@ -1,18 +1,13 @@
1
- import App from "./App.vue";
1
+ import { createSSRApp } from "vue";
2
2
  import { createPinia } from "pinia";
3
3
  import { createUnistorage } from "pinia-plugin-unistorage";
4
- import { useApp, setupDefaultInterceptors, http } from "@hlw-uni/mp-core";
4
+ import App from "./App.vue";
5
+ import { setupDefaultInterceptors, hlw, http } from "@hlw-uni/mp-core";
5
6
  import { useUserStore } from "./stores/user";
6
7
 
7
- const app = useApp();
8
-
9
- // 初始化 Pinia(必须在 setupDefaultInterceptors 之前)
10
- const pinia = createPinia();
11
- pinia.use(createUnistorage());
12
- app.use(pinia);
13
-
14
8
  // 注册默认拦截器(Token + 业务错误 + 401)
15
9
  setupDefaultInterceptors({
10
+ baseURL: (import.meta.env as Record<string, string>).VITE_API_BASE_URL ?? "",
16
11
  getToken: () => useUserStore().token,
17
12
  onUnauthorized: () => {
18
13
  useUserStore().$patch({ token: "", userInfo: null });
@@ -21,12 +16,17 @@ setupDefaultInterceptors({
21
16
  sigSecret: (import.meta.env as Record<string, string>).VITE_SIG_SECRET ?? "",
22
17
  });
23
18
 
24
- // --- 可选:添加全局请求拦截器 ---
25
- // http.onRequest((config) => {
26
- // config.headers = { ...config.headers, 'X-Custom-Header': 'value' };
27
- // return config;
28
- // });
19
+ export function createApp() {
20
+ const app = createSSRApp(App);
21
+
22
+ // 初始化 Pinia
23
+ const pinia = createPinia();
24
+ pinia.use(createUnistorage());
25
+ app.use(pinia);
26
+
27
+ // 挂载全局工具
28
+ app.config.globalProperties["hlw"] = hlw;
29
29
 
30
- // uni-app 要求导出 createApp 函数
31
- export const createApp = app.install(App);
30
+ return { app };
31
+ }
32
32
 
@@ -1,5 +1,5 @@
1
1
  {
2
- "name": "",
2
+ "name": "hlw-uni",
3
3
  "appid": "",
4
4
  "description": "",
5
5
  "versionName": "1.0.0",
@@ -7,7 +7,11 @@
7
7
  "transformPx": false,
8
8
  "mp-weixin": {
9
9
  "appid": "",
10
- "setting": { "urlCheck": false },
10
+ "setting": {
11
+ "urlCheck": false,
12
+ "postcss": true,
13
+ "minified": true
14
+ },
11
15
  "usingComponents": true
12
16
  }
13
17
  }