@hlw-uni/mp-cli 1.0.14 → 1.0.15
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 +0 -0
- package/package.json +37 -37
- package/templates/mp-toutiao/base/package.json +1 -0
- package/templates/mp-toutiao/base/src/api/ad.ts +2 -2
- package/templates/mp-toutiao/base/src/api/config.ts +15 -1
- package/templates/mp-toutiao/base/src/api/feedback.ts +7 -7
- package/templates/mp-toutiao/base/src/api/help.ts +4 -4
- package/templates/mp-toutiao/base/src/api/index.ts +1 -0
- package/templates/mp-toutiao/base/src/api/login.ts +3 -3
- package/templates/mp-toutiao/base/src/api/notice.ts +2 -2
- package/templates/mp-toutiao/base/src/api/tools.ts +5 -5
- package/templates/mp-toutiao/base/src/api/user.ts +27 -0
- package/templates/mp-toutiao/base/src/pages.json +1 -1
- package/templates/mp-toutiao/base/src/stores/user.ts +1 -9
- package/templates/mp-weixin/base/package.json +1 -0
- package/templates/mp-weixin/base/src/api/ad.ts +2 -2
- package/templates/mp-weixin/base/src/api/config.ts +15 -1
- package/templates/mp-weixin/base/src/api/feedback.ts +7 -7
- package/templates/mp-weixin/base/src/api/help.ts +4 -4
- package/templates/mp-weixin/base/src/api/index.ts +1 -0
- package/templates/mp-weixin/base/src/api/login.ts +3 -3
- package/templates/mp-weixin/base/src/api/notice.ts +2 -2
- package/templates/mp-weixin/base/src/api/tools.ts +5 -5
- package/templates/mp-weixin/base/src/api/user.ts +27 -0
- package/templates/mp-weixin/base/src/pages.json +1 -1
- package/templates/mp-weixin/base/src/stores/user.ts +3 -11
package/bin/cli.js
CHANGED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
2
|
+
"name": "@hlw-uni/mp-cli",
|
|
3
|
+
"version": "1.0.15",
|
|
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
|
+
}
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"@dcloudio/uni-components": "3.0.0-4080420251103001",
|
|
13
13
|
"@dcloudio/uni-mp-toutiao": "3.0.0-4080420251103001",
|
|
14
14
|
"@hlw-uni/mp-core": "workspace:*",
|
|
15
|
+
"@hlw-uni/mp-vue": "^1.0.0",
|
|
15
16
|
"@vueuse/core": "^10.9.0",
|
|
16
17
|
"pinia": "^2.1.7",
|
|
17
18
|
"pinia-plugin-unistorage": "^1.2.3",
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* 控制器:Ad (extends Base,无需登录)
|
|
4
4
|
*/
|
|
5
5
|
import { http } from "@hlw-uni/mp-core";
|
|
6
|
-
import {
|
|
6
|
+
import { v1 } from "./config";
|
|
7
7
|
|
|
8
8
|
/** 广告单元 */
|
|
9
9
|
export interface AdUnit {
|
|
@@ -25,7 +25,7 @@ export interface AdConfigResult {
|
|
|
25
25
|
*/
|
|
26
26
|
export function getAdConfig() {
|
|
27
27
|
return http.request<AdConfigResult>({
|
|
28
|
-
url:
|
|
28
|
+
url: v1("ad/config"),
|
|
29
29
|
method: "GET",
|
|
30
30
|
});
|
|
31
31
|
}
|
|
@@ -7,10 +7,13 @@
|
|
|
7
7
|
* 使用方式:
|
|
8
8
|
* api("ad/config") // => "/plugin-qz/api.v1.ad/config" (默认版本)
|
|
9
9
|
* api("ad/config", "v2") // => "/plugin-qz/api.v2.ad/config" (指定版本)
|
|
10
|
+
* v1("ad/config") // => "/plugin-qz/api.v1.ad/config" (语法糖)
|
|
11
|
+
* v2("ad/config") // => "/plugin-qz/api.v2.ad/config" (语法糖)
|
|
10
12
|
*/
|
|
11
13
|
|
|
12
14
|
/** 插件名称(从 .env 读取) */
|
|
13
15
|
export const PLUGIN_NAME = import.meta.env.VITE_PLUGIN_NAME;
|
|
16
|
+
if (!PLUGIN_NAME) throw new Error("[api] 请在 .env 中配置 VITE_PLUGIN_NAME");
|
|
14
17
|
|
|
15
18
|
/** 默认 API 版本 */
|
|
16
19
|
export const API_VERSION = "v1";
|
|
@@ -28,5 +31,16 @@ export const API_VERSION = "v1";
|
|
|
28
31
|
*/
|
|
29
32
|
export function api(path: string, version: string = API_VERSION): string {
|
|
30
33
|
const i = path.indexOf("/");
|
|
31
|
-
|
|
34
|
+
if (i === -1) throw new Error(`[api] path 格式错误,需含 "/": "${path}"`);
|
|
35
|
+
return `/${PLUGIN_NAME}/api.${version}.${path.slice(0, i)}/${path.slice(i + 1)}`;
|
|
32
36
|
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* 语法糖:固定版本的路径构建器
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* v1("ad/config") // => "/plugin-qz/api.v1.ad/config"
|
|
43
|
+
* v2("help/list") // => "/plugin-qz/api.v2.help/list"
|
|
44
|
+
*/
|
|
45
|
+
export const v1 = (path: string) => api(path, "v1");
|
|
46
|
+
export const v2 = (path: string) => api(path, "v2");
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* 控制器:Feedback (extends Auth,需要登录)
|
|
4
4
|
*/
|
|
5
5
|
import { http } from "@hlw-uni/mp-core";
|
|
6
|
-
import {
|
|
6
|
+
import { v1 } from "./config";
|
|
7
7
|
|
|
8
8
|
/** 反馈类型 */
|
|
9
9
|
export interface FeedbackType {
|
|
@@ -55,7 +55,7 @@ export interface FeedbackStats {
|
|
|
55
55
|
*/
|
|
56
56
|
export function getFeedbackTypes() {
|
|
57
57
|
return http.request<{ list: FeedbackType[] }>({
|
|
58
|
-
url:
|
|
58
|
+
url: v1("feedback/types"),
|
|
59
59
|
method: "GET",
|
|
60
60
|
});
|
|
61
61
|
}
|
|
@@ -70,7 +70,7 @@ export function submitFeedback(data: {
|
|
|
70
70
|
images?: string[] | string;
|
|
71
71
|
}) {
|
|
72
72
|
return http.request<{ id: number }>({
|
|
73
|
-
url:
|
|
73
|
+
url: v1("feedback/submit"),
|
|
74
74
|
method: "POST",
|
|
75
75
|
data,
|
|
76
76
|
});
|
|
@@ -81,7 +81,7 @@ export function submitFeedback(data: {
|
|
|
81
81
|
*/
|
|
82
82
|
export function getMyFeedback(page = 1, limit = 20) {
|
|
83
83
|
return http.request<{ list: FeedbackItem[]; total: number; page: number; limit: number }>({
|
|
84
|
-
url:
|
|
84
|
+
url: v1("feedback/my"),
|
|
85
85
|
method: "GET",
|
|
86
86
|
data: { page, limit },
|
|
87
87
|
});
|
|
@@ -92,7 +92,7 @@ export function getMyFeedback(page = 1, limit = 20) {
|
|
|
92
92
|
*/
|
|
93
93
|
export function getFeedbackDetail(id: number) {
|
|
94
94
|
return http.request<{ data: FeedbackDetail }>({
|
|
95
|
-
url:
|
|
95
|
+
url: v1("feedback/detail"),
|
|
96
96
|
method: "GET",
|
|
97
97
|
data: { id },
|
|
98
98
|
});
|
|
@@ -103,7 +103,7 @@ export function getFeedbackDetail(id: number) {
|
|
|
103
103
|
*/
|
|
104
104
|
export function appendFeedback(feedback_id: number, content: string) {
|
|
105
105
|
return http.request<{ time: string }>({
|
|
106
|
-
url:
|
|
106
|
+
url: v1("feedback/append"),
|
|
107
107
|
method: "POST",
|
|
108
108
|
data: { feedback_id, content },
|
|
109
109
|
});
|
|
@@ -114,7 +114,7 @@ export function appendFeedback(feedback_id: number, content: string) {
|
|
|
114
114
|
*/
|
|
115
115
|
export function getFeedbackStats() {
|
|
116
116
|
return http.request<FeedbackStats>({
|
|
117
|
-
url:
|
|
117
|
+
url: v1("feedback/stats"),
|
|
118
118
|
method: "GET",
|
|
119
119
|
});
|
|
120
120
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* 控制器:Help (extends Base,无需登录)
|
|
4
4
|
*/
|
|
5
5
|
import { http } from "@hlw-uni/mp-core";
|
|
6
|
-
import {
|
|
6
|
+
import { v1 } from "./config";
|
|
7
7
|
|
|
8
8
|
/** 帮助分类 */
|
|
9
9
|
export interface HelpCategory {
|
|
@@ -30,7 +30,7 @@ export interface HelpArticle {
|
|
|
30
30
|
*/
|
|
31
31
|
export function getHelpCates() {
|
|
32
32
|
return http.request<{ list: HelpCategory[] }>({
|
|
33
|
-
url:
|
|
33
|
+
url: v1("help/cates"),
|
|
34
34
|
method: "GET",
|
|
35
35
|
});
|
|
36
36
|
}
|
|
@@ -41,7 +41,7 @@ export function getHelpCates() {
|
|
|
41
41
|
*/
|
|
42
42
|
export function getHelpList(cate_id?: number) {
|
|
43
43
|
return http.request<{ list: HelpArticle[] }>({
|
|
44
|
-
url:
|
|
44
|
+
url: v1("help/list"),
|
|
45
45
|
method: "GET",
|
|
46
46
|
data: cate_id ? { cate_id } : undefined,
|
|
47
47
|
});
|
|
@@ -53,7 +53,7 @@ export function getHelpList(cate_id?: number) {
|
|
|
53
53
|
*/
|
|
54
54
|
export function getHelpDetail(id: number) {
|
|
55
55
|
return http.request<{ data: HelpArticle }>({
|
|
56
|
-
url:
|
|
56
|
+
url: v1("help/detail"),
|
|
57
57
|
method: "GET",
|
|
58
58
|
data: { id },
|
|
59
59
|
});
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* 控制器:Login (extends Base,无需登录)
|
|
4
4
|
*/
|
|
5
5
|
import { http } from "@hlw-uni/mp-core";
|
|
6
|
-
import type { UserInfo } from "
|
|
7
|
-
import {
|
|
6
|
+
import type { UserInfo } from "./user";
|
|
7
|
+
import { v1 } from "./config";
|
|
8
8
|
|
|
9
9
|
/** 登录响应数据 */
|
|
10
10
|
export interface LoginResult {
|
|
@@ -18,7 +18,7 @@ export interface LoginResult {
|
|
|
18
18
|
*/
|
|
19
19
|
export function login(code: string, nickname?: string, avatar_url?: string) {
|
|
20
20
|
return http.request<LoginResult>({
|
|
21
|
-
url:
|
|
21
|
+
url: v1("login/in"),
|
|
22
22
|
method: "POST",
|
|
23
23
|
data: { code, nickname, avatar_url },
|
|
24
24
|
});
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* 控制器:Notice (extends Base,无需登录)
|
|
4
4
|
*/
|
|
5
5
|
import { http } from "@hlw-uni/mp-core";
|
|
6
|
-
import {
|
|
6
|
+
import { v1 } from "./config";
|
|
7
7
|
|
|
8
8
|
/** 通知公告 */
|
|
9
9
|
export interface NoticeItem {
|
|
@@ -23,7 +23,7 @@ export interface NoticeItem {
|
|
|
23
23
|
*/
|
|
24
24
|
export function getNoticeList(type?: string) {
|
|
25
25
|
return http.request<{ list: NoticeItem[] }>({
|
|
26
|
-
url:
|
|
26
|
+
url: v1("notice/list"),
|
|
27
27
|
method: "GET",
|
|
28
28
|
data: type ? { type } : undefined,
|
|
29
29
|
});
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* 控制器:Tools (extends Base,无需登录)
|
|
4
4
|
*/
|
|
5
5
|
import { http } from "@hlw-uni/mp-core";
|
|
6
|
-
import {
|
|
6
|
+
import { v1 } from "./config";
|
|
7
7
|
|
|
8
8
|
/** 工具分类 */
|
|
9
9
|
export interface ToolsCategory {
|
|
@@ -31,7 +31,7 @@ export interface ToolItem {
|
|
|
31
31
|
*/
|
|
32
32
|
export function getToolsCates() {
|
|
33
33
|
return http.request<{ list: ToolsCategory[] }>({
|
|
34
|
-
url:
|
|
34
|
+
url: v1("tools/cates"),
|
|
35
35
|
method: "GET",
|
|
36
36
|
});
|
|
37
37
|
}
|
|
@@ -42,7 +42,7 @@ export function getToolsCates() {
|
|
|
42
42
|
*/
|
|
43
43
|
export function getToolsList(cate_id?: number) {
|
|
44
44
|
return http.request<{ list: ToolItem[] }>({
|
|
45
|
-
url:
|
|
45
|
+
url: v1("tools/list"),
|
|
46
46
|
method: "GET",
|
|
47
47
|
data: cate_id ? { cate_id } : undefined,
|
|
48
48
|
});
|
|
@@ -53,7 +53,7 @@ export function getToolsList(cate_id?: number) {
|
|
|
53
53
|
*/
|
|
54
54
|
export function getToolsAll() {
|
|
55
55
|
return http.request<{ list: ToolItem[] }>({
|
|
56
|
-
url:
|
|
56
|
+
url: v1("tools/all"),
|
|
57
57
|
method: "GET",
|
|
58
58
|
});
|
|
59
59
|
}
|
|
@@ -64,7 +64,7 @@ export function getToolsAll() {
|
|
|
64
64
|
*/
|
|
65
65
|
export function recordToolClick(id: number) {
|
|
66
66
|
return http.request<null>({
|
|
67
|
-
url:
|
|
67
|
+
url: v1("tools/click"),
|
|
68
68
|
method: "GET",
|
|
69
69
|
data: { id },
|
|
70
70
|
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 用户相关接口
|
|
3
|
+
* 控制器:User (extends Auth,需要登录)
|
|
4
|
+
*/
|
|
5
|
+
import { http } from "@hlw-uni/mp-core";
|
|
6
|
+
import { v1 } from "./config";
|
|
7
|
+
|
|
8
|
+
/** 后端返回的完整用户实体类型 */
|
|
9
|
+
export interface UserInfo {
|
|
10
|
+
uid: string;
|
|
11
|
+
nickname: string;
|
|
12
|
+
avatar_url: string;
|
|
13
|
+
phone: string;
|
|
14
|
+
score: number;
|
|
15
|
+
vip_time: number;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* 获取或刷新当前登录用户信息 (预留)
|
|
20
|
+
* GET plugin-qz/api.v1.user/info
|
|
21
|
+
*/
|
|
22
|
+
export function getUserInfo() {
|
|
23
|
+
return http.request<{ data: UserInfo }>({
|
|
24
|
+
url: v1("user/info"),
|
|
25
|
+
method: "GET",
|
|
26
|
+
});
|
|
27
|
+
}
|
|
@@ -3,15 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { defineStore } from "pinia";
|
|
5
5
|
import { ref, computed } from "vue";
|
|
6
|
-
|
|
7
|
-
export interface UserInfo {
|
|
8
|
-
uid: string;
|
|
9
|
-
nickname: string;
|
|
10
|
-
avatar_url: string;
|
|
11
|
-
phone: string;
|
|
12
|
-
score: number;
|
|
13
|
-
vip_time: number;
|
|
14
|
-
}
|
|
6
|
+
import type { UserInfo } from "@/api/user";
|
|
15
7
|
|
|
16
8
|
export const useUserStore = defineStore(
|
|
17
9
|
"user",
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"@dcloudio/uni-components": "3.0.0-4080420251103001",
|
|
14
14
|
"@dcloudio/uni-mp-weixin": "3.0.0-4080420251103001",
|
|
15
15
|
"@hlw-uni/mp-core": "^1.0.3",
|
|
16
|
+
"@hlw-uni/mp-vue": "^1.0.0",
|
|
16
17
|
"@vueuse/core": "^10.9.0",
|
|
17
18
|
"pinia": "^2.1.7",
|
|
18
19
|
"pinia-plugin-unistorage": "^0.1.2",
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* 控制器:Ad (extends Base,无需登录)
|
|
4
4
|
*/
|
|
5
5
|
import { http } from "@hlw-uni/mp-core";
|
|
6
|
-
import {
|
|
6
|
+
import { v1 } from "./config";
|
|
7
7
|
|
|
8
8
|
/** 广告单元 */
|
|
9
9
|
export interface AdUnit {
|
|
@@ -25,7 +25,7 @@ export interface AdConfigResult {
|
|
|
25
25
|
*/
|
|
26
26
|
export function getAdConfig() {
|
|
27
27
|
return http.request<AdConfigResult>({
|
|
28
|
-
url:
|
|
28
|
+
url: v1("ad/config"),
|
|
29
29
|
method: "GET",
|
|
30
30
|
});
|
|
31
31
|
}
|
|
@@ -7,10 +7,13 @@
|
|
|
7
7
|
* 使用方式:
|
|
8
8
|
* api("ad/config") // => "/plugin-qz/api.v1.ad/config" (默认版本)
|
|
9
9
|
* api("ad/config", "v2") // => "/plugin-qz/api.v2.ad/config" (指定版本)
|
|
10
|
+
* v1("ad/config") // => "/plugin-qz/api.v1.ad/config" (语法糖)
|
|
11
|
+
* v2("ad/config") // => "/plugin-qz/api.v2.ad/config" (语法糖)
|
|
10
12
|
*/
|
|
11
13
|
|
|
12
14
|
/** 插件名称(从 .env 读取) */
|
|
13
15
|
export const PLUGIN_NAME = import.meta.env.VITE_PLUGIN_NAME;
|
|
16
|
+
if (!PLUGIN_NAME) throw new Error("[api] 请在 .env 中配置 VITE_PLUGIN_NAME");
|
|
14
17
|
|
|
15
18
|
/** 默认 API 版本 */
|
|
16
19
|
export const API_VERSION = "v1";
|
|
@@ -28,5 +31,16 @@ export const API_VERSION = "v1";
|
|
|
28
31
|
*/
|
|
29
32
|
export function api(path: string, version: string = API_VERSION): string {
|
|
30
33
|
const i = path.indexOf("/");
|
|
31
|
-
|
|
34
|
+
if (i === -1) throw new Error(`[api] path 格式错误,需含 "/": "${path}"`);
|
|
35
|
+
return `/${PLUGIN_NAME}/api.${version}.${path.slice(0, i)}/${path.slice(i + 1)}`;
|
|
32
36
|
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* 语法糖:固定版本的路径构建器
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* v1("ad/config") // => "/plugin-qz/api.v1.ad/config"
|
|
43
|
+
* v2("help/list") // => "/plugin-qz/api.v2.help/list"
|
|
44
|
+
*/
|
|
45
|
+
export const v1 = (path: string) => api(path, "v1");
|
|
46
|
+
export const v2 = (path: string) => api(path, "v2");
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* 控制器:Feedback (extends Auth,需要登录)
|
|
4
4
|
*/
|
|
5
5
|
import { http } from "@hlw-uni/mp-core";
|
|
6
|
-
import {
|
|
6
|
+
import { v1 } from "./config";
|
|
7
7
|
|
|
8
8
|
/** 反馈类型 */
|
|
9
9
|
export interface FeedbackType {
|
|
@@ -55,7 +55,7 @@ export interface FeedbackStats {
|
|
|
55
55
|
*/
|
|
56
56
|
export function getFeedbackTypes() {
|
|
57
57
|
return http.request<{ list: FeedbackType[] }>({
|
|
58
|
-
url:
|
|
58
|
+
url: v1("feedback/types"),
|
|
59
59
|
method: "GET",
|
|
60
60
|
});
|
|
61
61
|
}
|
|
@@ -70,7 +70,7 @@ export function submitFeedback(data: {
|
|
|
70
70
|
images?: string[] | string;
|
|
71
71
|
}) {
|
|
72
72
|
return http.request<{ id: number }>({
|
|
73
|
-
url:
|
|
73
|
+
url: v1("feedback/submit"),
|
|
74
74
|
method: "POST",
|
|
75
75
|
data,
|
|
76
76
|
});
|
|
@@ -81,7 +81,7 @@ export function submitFeedback(data: {
|
|
|
81
81
|
*/
|
|
82
82
|
export function getMyFeedback(page = 1, limit = 20) {
|
|
83
83
|
return http.request<{ list: FeedbackItem[]; total: number; page: number; limit: number }>({
|
|
84
|
-
url:
|
|
84
|
+
url: v1("feedback/my"),
|
|
85
85
|
method: "GET",
|
|
86
86
|
data: { page, limit },
|
|
87
87
|
});
|
|
@@ -92,7 +92,7 @@ export function getMyFeedback(page = 1, limit = 20) {
|
|
|
92
92
|
*/
|
|
93
93
|
export function getFeedbackDetail(id: number) {
|
|
94
94
|
return http.request<{ data: FeedbackDetail }>({
|
|
95
|
-
url:
|
|
95
|
+
url: v1("feedback/detail"),
|
|
96
96
|
method: "GET",
|
|
97
97
|
data: { id },
|
|
98
98
|
});
|
|
@@ -103,7 +103,7 @@ export function getFeedbackDetail(id: number) {
|
|
|
103
103
|
*/
|
|
104
104
|
export function appendFeedback(feedback_id: number, content: string) {
|
|
105
105
|
return http.request<{ time: string }>({
|
|
106
|
-
url:
|
|
106
|
+
url: v1("feedback/append"),
|
|
107
107
|
method: "POST",
|
|
108
108
|
data: { feedback_id, content },
|
|
109
109
|
});
|
|
@@ -114,7 +114,7 @@ export function appendFeedback(feedback_id: number, content: string) {
|
|
|
114
114
|
*/
|
|
115
115
|
export function getFeedbackStats() {
|
|
116
116
|
return http.request<FeedbackStats>({
|
|
117
|
-
url:
|
|
117
|
+
url: v1("feedback/stats"),
|
|
118
118
|
method: "GET",
|
|
119
119
|
});
|
|
120
120
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* 控制器:Help (extends Base,无需登录)
|
|
4
4
|
*/
|
|
5
5
|
import { http } from "@hlw-uni/mp-core";
|
|
6
|
-
import {
|
|
6
|
+
import { v1 } from "./config";
|
|
7
7
|
|
|
8
8
|
/** 帮助分类 */
|
|
9
9
|
export interface HelpCategory {
|
|
@@ -30,7 +30,7 @@ export interface HelpArticle {
|
|
|
30
30
|
*/
|
|
31
31
|
export function getHelpCates() {
|
|
32
32
|
return http.request<{ list: HelpCategory[] }>({
|
|
33
|
-
url:
|
|
33
|
+
url: v1("help/cates"),
|
|
34
34
|
method: "GET",
|
|
35
35
|
});
|
|
36
36
|
}
|
|
@@ -41,7 +41,7 @@ export function getHelpCates() {
|
|
|
41
41
|
*/
|
|
42
42
|
export function getHelpList(cate_id?: number) {
|
|
43
43
|
return http.request<{ list: HelpArticle[] }>({
|
|
44
|
-
url:
|
|
44
|
+
url: v1("help/list"),
|
|
45
45
|
method: "GET",
|
|
46
46
|
data: cate_id ? { cate_id } : undefined,
|
|
47
47
|
});
|
|
@@ -53,7 +53,7 @@ export function getHelpList(cate_id?: number) {
|
|
|
53
53
|
*/
|
|
54
54
|
export function getHelpDetail(id: number) {
|
|
55
55
|
return http.request<{ data: HelpArticle }>({
|
|
56
|
-
url:
|
|
56
|
+
url: v1("help/detail"),
|
|
57
57
|
method: "GET",
|
|
58
58
|
data: { id },
|
|
59
59
|
});
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* 控制器:Login (extends Base,无需登录)
|
|
4
4
|
*/
|
|
5
5
|
import { http } from "@hlw-uni/mp-core";
|
|
6
|
-
import type { UserInfo } from "
|
|
7
|
-
import {
|
|
6
|
+
import type { UserInfo } from "./user";
|
|
7
|
+
import { v1 } from "./config";
|
|
8
8
|
|
|
9
9
|
/** 登录响应数据 */
|
|
10
10
|
export interface LoginResult {
|
|
@@ -18,7 +18,7 @@ export interface LoginResult {
|
|
|
18
18
|
*/
|
|
19
19
|
export function login(code: string, nickname?: string, avatar_url?: string) {
|
|
20
20
|
return http.request<LoginResult>({
|
|
21
|
-
url:
|
|
21
|
+
url: v1("login/in"),
|
|
22
22
|
method: "POST",
|
|
23
23
|
data: { code, nickname, avatar_url },
|
|
24
24
|
});
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* 控制器:Notice (extends Base,无需登录)
|
|
4
4
|
*/
|
|
5
5
|
import { http } from "@hlw-uni/mp-core";
|
|
6
|
-
import {
|
|
6
|
+
import { v1 } from "./config";
|
|
7
7
|
|
|
8
8
|
/** 通知公告 */
|
|
9
9
|
export interface NoticeItem {
|
|
@@ -23,7 +23,7 @@ export interface NoticeItem {
|
|
|
23
23
|
*/
|
|
24
24
|
export function getNoticeList(type?: string) {
|
|
25
25
|
return http.request<{ list: NoticeItem[] }>({
|
|
26
|
-
url:
|
|
26
|
+
url: v1("notice/list"),
|
|
27
27
|
method: "GET",
|
|
28
28
|
data: type ? { type } : undefined,
|
|
29
29
|
});
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* 控制器:Tools (extends Base,无需登录)
|
|
4
4
|
*/
|
|
5
5
|
import { http } from "@hlw-uni/mp-core";
|
|
6
|
-
import {
|
|
6
|
+
import { v1 } from "./config";
|
|
7
7
|
|
|
8
8
|
/** 工具分类 */
|
|
9
9
|
export interface ToolsCategory {
|
|
@@ -31,7 +31,7 @@ export interface ToolItem {
|
|
|
31
31
|
*/
|
|
32
32
|
export function getToolsCates() {
|
|
33
33
|
return http.request<{ list: ToolsCategory[] }>({
|
|
34
|
-
url:
|
|
34
|
+
url: v1("tools/cates"),
|
|
35
35
|
method: "GET",
|
|
36
36
|
});
|
|
37
37
|
}
|
|
@@ -42,7 +42,7 @@ export function getToolsCates() {
|
|
|
42
42
|
*/
|
|
43
43
|
export function getToolsList(cate_id?: number) {
|
|
44
44
|
return http.request<{ list: ToolItem[] }>({
|
|
45
|
-
url:
|
|
45
|
+
url: v1("tools/list"),
|
|
46
46
|
method: "GET",
|
|
47
47
|
data: cate_id ? { cate_id } : undefined,
|
|
48
48
|
});
|
|
@@ -53,7 +53,7 @@ export function getToolsList(cate_id?: number) {
|
|
|
53
53
|
*/
|
|
54
54
|
export function getToolsAll() {
|
|
55
55
|
return http.request<{ list: ToolItem[] }>({
|
|
56
|
-
url:
|
|
56
|
+
url: v1("tools/all"),
|
|
57
57
|
method: "GET",
|
|
58
58
|
});
|
|
59
59
|
}
|
|
@@ -64,7 +64,7 @@ export function getToolsAll() {
|
|
|
64
64
|
*/
|
|
65
65
|
export function recordToolClick(id: number) {
|
|
66
66
|
return http.request<null>({
|
|
67
|
-
url:
|
|
67
|
+
url: v1("tools/click"),
|
|
68
68
|
method: "GET",
|
|
69
69
|
data: { id },
|
|
70
70
|
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 用户相关接口
|
|
3
|
+
* 控制器:User (extends Auth,需要登录)
|
|
4
|
+
*/
|
|
5
|
+
import { http } from "@hlw-uni/mp-core";
|
|
6
|
+
import { v1 } from "./config";
|
|
7
|
+
|
|
8
|
+
/** 后端返回的完整用户实体类型 */
|
|
9
|
+
export interface UserInfo {
|
|
10
|
+
uid: string;
|
|
11
|
+
nickname: string;
|
|
12
|
+
avatar_url: string;
|
|
13
|
+
phone: string;
|
|
14
|
+
score: number;
|
|
15
|
+
vip_time: number;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* 获取或刷新当前登录用户信息 (预留)
|
|
20
|
+
* GET plugin-qz/api.v1.user/info
|
|
21
|
+
*/
|
|
22
|
+
export function getUserInfo() {
|
|
23
|
+
return http.request<{ data: UserInfo }>({
|
|
24
|
+
url: v1("user/info"),
|
|
25
|
+
method: "GET",
|
|
26
|
+
});
|
|
27
|
+
}
|
|
@@ -3,15 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { defineStore } from "pinia";
|
|
5
5
|
import { ref, computed } from "vue";
|
|
6
|
-
|
|
7
|
-
export interface UserInfo {
|
|
8
|
-
uid: string;
|
|
9
|
-
nickname: string;
|
|
10
|
-
avatar_url: string;
|
|
11
|
-
phone: string;
|
|
12
|
-
score: number;
|
|
13
|
-
vip_time: number;
|
|
14
|
-
}
|
|
6
|
+
import type { UserInfo } from "@/api/user";
|
|
15
7
|
|
|
16
8
|
export const useUserStore = defineStore(
|
|
17
9
|
"user",
|
|
@@ -23,8 +15,8 @@ export const useUserStore = defineStore(
|
|
|
23
15
|
const isLoggedIn = computed(() => !!token.value);
|
|
24
16
|
|
|
25
17
|
/** 设置登录态 */
|
|
26
|
-
function setLogin(
|
|
27
|
-
token.value =
|
|
18
|
+
function setLogin(_token: string, user: UserInfo) {
|
|
19
|
+
token.value = _token;
|
|
28
20
|
userInfo.value = user;
|
|
29
21
|
}
|
|
30
22
|
|