Skip to content

Commit 376fd17

Browse files
anncwbvince292007
andauthored
feat: Feature/pro docs (vbenjs#70)
* chore: merge main * feat: update docs * feat: remove coze-assistant * feat: add watermark plugin * feat: update preferences * feat: update docs --------- Co-authored-by: vince <[email protected]>
1 parent 14538f7 commit 376fd17

File tree

225 files changed

+7737
-1790
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

225 files changed

+7737
-1790
lines changed

.changeset/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
},
1212
"privatePackages": { "version": true, "tag": true },
1313
"linked": [],
14-
"access": "restricted",
14+
"access": "public",
1515
"baseBranch": "main",
1616
"updateInternalDependencies": "patch",
1717
"ignore": []

.github/workflows/action-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,5 @@ jobs:
4545

4646
- name: Test and Build
4747
run: |
48-
pnpm run test
48+
pnpm run test:unit
4949
pnpm run build

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ jobs:
6868
# run: git config --global user.email "[email protected]" && git config --global user.name "Your Name"
6969

7070
- name: Vitest tests
71-
run: pnpm run test
71+
run: pnpm run test:unit
7272

7373
# - name: Upload coverage
7474
# uses: codecov/codecov-action@v4

.ls-lint.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ls:
77
.css: kebab-case | pointcase
88
.d.ts: kebab-case | pointcase
99
# shadcn 自动生成文件为 PascalCase 格式
10-
packages/@vben-core/ui-kit/shadcn-ui/src/components/ui:
10+
packages/@core/ui-kit/shadcn-ui/src/components/ui:
1111
.vue: PascalCase
1212

1313
ignore:
@@ -25,3 +25,4 @@ ignore:
2525
- .vscode
2626
- .idea
2727
- node_modules
28+
- .cache

.vscode/settings.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@
7171
"**/CVS": true,
7272
"**/.stylelintcache": true,
7373
"**/.DS_Store": true,
74-
"**/vite.config.mts.*": true
74+
"**/vite.config.mts.*": true,
75+
"**/tea.yaml": true
7576
},
7677
"files.watcherExclude": {
7778
"**/.git/objects/**": true,
@@ -190,7 +191,7 @@
190191
"eslint.config.mjs": ".eslintignore,.prettierignore,.stylelintignore,.commitlintrc.*,.prettierrc.*,stylelint.config.*,.lintstagedrc.mjs,.ls-lint*,cspell.json",
191192
"tailwind.config.mjs": "postcss.*"
192193
},
193-
"commentTranslate.hover.enabled": true,
194+
"commentTranslate.hover.enabled": false,
194195
"i18n-ally.keystyle": "nested",
195196
"commentTranslate.multiLineMerge": true
196197
}

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2024-present, Vben Admin
3+
Copyright (c) 2024-present, Vben
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
66

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![license](https://img.shields.io/github/license/anncwb/vue-vben-admin.svg)](LICENSE)
44

5-
<h1>Vue vben admin</h1>
5+
<h1>Vue Vben Admin</h1>
66
</div>
77

88
**English** | [中文](./README.zh-CN.md)

apps/backend-mock/middleware/1.api.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
export default defineEventHandler((event) => {
2+
// setResponseHeaders(event, {
3+
// 'Access-Control-Allow-Credentials': 'true',
4+
// 'Access-Control-Allow-Headers': '*',
5+
// 'Access-Control-Allow-Methods': 'GET,HEAD,PUT,PATCH,POST,DELETE',
6+
// 'Access-Control-Allow-Origin': '*',
7+
// 'Access-Control-Expose-Headers': '*',
8+
// });
9+
if (event.method === 'OPTIONS') {
10+
event.node.res.statusCode = 204;
11+
event.node.res.statusMessage = 'No Content.';
12+
return 'OK';
13+
}
14+
});

apps/backend-mock/nitro.config.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,16 @@ import errorHandler from './error';
33
export default defineNitroConfig({
44
devErrorHandler: errorHandler,
55
errorHandler: '~/error',
6+
routeRules: {
7+
'/api/**': {
8+
cors: true,
9+
headers: {
10+
'Access-Control-Allow-Credentials': 'true',
11+
'Access-Control-Allow-Headers': '*',
12+
'Access-Control-Allow-Methods': 'GET,HEAD,PUT,PATCH,POST,DELETE',
13+
'Access-Control-Allow-Origin': '*',
14+
'Access-Control-Expose-Headers': '*',
15+
},
16+
},
17+
},
618
});

apps/backend-mock/utils/mock-data.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -80,26 +80,26 @@ const createDemosMenus = (role: 'admin' | 'super' | 'user') => {
8080
icon: 'mdi:button-cursor',
8181
title: 'page.demos.access.adminVisible',
8282
},
83-
name: 'AccessAdminVisible',
84-
path: 'admin-visible',
83+
name: 'AccessAdminVisibleDemo',
84+
path: '/demos/access/admin-visible',
8585
},
8686
super: {
8787
component: '/demos/access/super-visible',
8888
meta: {
8989
icon: 'mdi:button-cursor',
9090
title: 'page.demos.access.superVisible',
9191
},
92-
name: 'AccessSuperVisible',
93-
path: 'super-visible',
92+
name: 'AccessSuperVisibleDemo',
93+
path: '/demos/access/super-visible',
9494
},
9595
user: {
9696
component: '/demos/access/user-visible',
9797
meta: {
9898
icon: 'mdi:button-cursor',
9999
title: 'page.demos.access.userVisible',
100100
},
101-
name: 'AccessUserVisible',
102-
path: 'user-visible',
101+
name: 'AccessUserVisibleDemo',
102+
path: '/demos/access/user-visible',
103103
},
104104
};
105105

@@ -117,35 +117,35 @@ const createDemosMenus = (role: 'admin' | 'super' | 'user') => {
117117
redirect: '/demos/access',
118118
children: [
119119
{
120-
name: 'Access',
121-
path: 'access',
120+
name: 'AccessDemos',
121+
path: '/demosaccess',
122122
meta: {
123123
icon: 'mdi:cloud-key-outline',
124124
title: 'page.demos.access.backendPermissions',
125125
},
126126
redirect: '/demos/access/page-control',
127127
children: [
128128
{
129-
name: 'AccessPageControl',
130-
path: 'page-control',
129+
name: 'AccessPageControlDemo',
130+
path: '/demos/access/page-control',
131131
component: '/demos/access/index',
132132
meta: {
133133
icon: 'mdi:page-previous-outline',
134134
title: 'page.demos.access.pageAccess',
135135
},
136136
},
137137
{
138-
name: 'AccessButtonControl',
139-
path: 'button-control',
138+
name: 'AccessButtonControlDemo',
139+
path: '/demos/access/button-control',
140140
component: '/demos/access/button-control',
141141
meta: {
142142
icon: 'mdi:button-cursor',
143143
title: 'page.demos.access.buttonControl',
144144
},
145145
},
146146
{
147-
name: 'AccessMenuVisible403',
148-
path: 'menu-visible-403',
147+
name: 'AccessMenuVisible403Demo',
148+
path: '/demos/access/menu-visible-403',
149149
component: '/demos/access/menu-visible-403',
150150
meta: {
151151
authority: ['no-body'],

apps/web-antd/.env

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
VITE_PORT = 5555
1+
# 应用标题
2+
VITE_GLOB_APP_TITLE=Vben Admin
23

3-
# spa-title
4-
VITE_GLOB_APP_TITLE = Vben Admin
5-
6-
VITE_APP_NAMESPACE = web-antd
4+
# 应用命名空间,用于缓存、store等功能的前缀,确保隔离
5+
VITE_APP_NAMESPACE=vben-web-antd

apps/web-antd/.env.analyze

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
21
# public path
3-
VITE_PUBLIC_PATH = /
2+
VITE_BASE=/
43

54
# Basic interface address SPA
65
VITE_GLOB_API_URL=/api
76

8-
VITE_VISUALIZER = true
7+
VITE_VISUALIZER=true

apps/web-antd/.env.development

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
1-
VITE_PUBLIC_PATH = /
1+
# 端口号
2+
VITE_PORT=5555
23

4+
VITE_BASE=/
5+
6+
# 接口地址
37
VITE_GLOB_API_URL=/api
48

5-
VITE_NITRO_MOCK = true
9+
# 是否开启 Nitro Mock服务,true 为开启,false 为关闭
10+
VITE_NITRO_MOCK=true
11+
12+
# 是否打开 devtools,true 为打开,false 为关闭
13+
VITE_DEVTOOLS=false
14+
15+
# 是否注入全局loading
16+
VITE_INJECT_APP_LOADING=true

apps/web-antd/.env.production

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
1-
# public path
2-
VITE_PUBLIC_PATH = /
1+
VITE_BASE=/
32

4-
# Basic interface address SPA
5-
VITE_GLOB_API_URL = https://mock-napi.vben.pro/api
3+
# 接口地址
4+
VITE_GLOB_API_URL=https://mock-napi.vben.pro/api
65

7-
VITE_COMPRESS = gzip
6+
# 是否开启压缩,可以设置为 none, brotli, gzip
7+
VITE_COMPRESS=gzip
88

9-
VITE_PWA = false
9+
# 是否开启 PWA
10+
VITE_PWA=false
11+
12+
# vue-router 的模式
13+
VITE_ROUTER_HISTORY=hash
14+
15+
# 是否注入全局loading
16+
VITE_INJECT_APP_LOADING=true

apps/web-antd/index.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,19 @@
1414
<!-- 由 vite 注入 VITE_GLOB_APP_TITLE 变量,在 .env 文件内配置 -->
1515
<title><%= VITE_GLOB_APP_TITLE %></title>
1616
<link rel="icon" href="/favicon.ico" />
17+
<script>
18+
// 生产环境下注入百度统计
19+
if (window._VBEN_ADMIN_PRO_APP_CONF_) {
20+
var _hmt = _hmt || [];
21+
(function () {
22+
var hm = document.createElement('script');
23+
hm.src =
24+
'https://hm.baidu.com/hm.js?d20a01273820422b6aa2ee41b6c9414d';
25+
var s = document.getElementsByTagName('script')[0];
26+
s.parentNode.insertBefore(hm, s);
27+
})();
28+
}
29+
</script>
1730
</head>
1831
<body>
1932
<div id="app"></div>

apps/web-antd/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"ant-design-vue": "^4.2.3",
4545
"dayjs": "^1.11.12",
4646
"pinia": "2.1.7",
47-
"vue": "^3.4.33",
47+
"vue": "^3.4.34",
4848
"vue-router": "^4.4.0"
4949
}
5050
}

apps/web-antd/src/api/core/auth.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { requestClient } from '#/api/request';
2+
3+
export namespace AuthApi {
4+
/** 登录接口参数 */
5+
export interface LoginParams {
6+
password: string;
7+
username: string;
8+
}
9+
10+
/** 登录接口返回值 */
11+
export interface LoginResult {
12+
accessToken: string;
13+
desc: string;
14+
realName: string;
15+
refreshToken: string;
16+
userId: string;
17+
username: string;
18+
}
19+
}
20+
21+
/**
22+
* 登录
23+
*/
24+
export async function login(data: AuthApi.LoginParams) {
25+
return requestClient.post<AuthApi.LoginResult>('/auth/login', data);
26+
}
27+
28+
/**
29+
* 获取用户权限码
30+
*/
31+
export async function getAccessCodes() {
32+
return requestClient.get<string[]>('/auth/codes');
33+
}

apps/web-antd/src/apis/core/menu.ts renamed to apps/web-antd/src/api/core/menu.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { RouteRecordStringComponent } from '@vben/types';
22

3-
import { requestClient } from '#/apis/request';
3+
import { requestClient } from '#/api/request';
44

55
/**
66
* 获取用户所有菜单

apps/web-antd/src/apis/core/user.ts renamed to apps/web-antd/src/api/core/user.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { UserInfo } from '@vben/types';
22

3-
import { requestClient } from '#/apis/request';
3+
import { requestClient } from '#/api/request';
44

55
/**
66
* 获取用户信息

apps/web-antd/src/apis/demos/status.ts renamed to apps/web-antd/src/api/demos/status.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { requestClient } from '#/apis/request';
1+
import { requestClient } from '#/api/request';
22

33
/**
44
* 模拟任意状态码
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
export * from './core';
22
export * from './demos';
3-
export type * from './types';

apps/web-antd/src/apis/request.ts renamed to apps/web-antd/src/api/request.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,19 @@
33
*/
44
import type { HttpResponse } from '@vben/request';
55

6+
import { useAppConfig } from '@vben/hooks';
67
import { preferences } from '@vben/preferences';
78
import { RequestClient } from '@vben/request';
89

910
import { message } from 'ant-design-vue';
1011

1112
import { useAccessStore } from '#/store';
1213

13-
/**
14-
* 创建请求实例
15-
* Create a request instance
16-
*/
17-
function createRequestClient() {
14+
const { apiURL } = useAppConfig(import.meta.env, import.meta.env.PROD);
15+
16+
function createRequestClient(baseURL: string) {
1817
const client = new RequestClient({
19-
baseURL: import.meta.env.VITE_GLOB_API_URL,
18+
baseURL,
2019
// 为每个请求携带 Authorization
2120
makeAuthorization: () => {
2221
return {
@@ -43,6 +42,13 @@ function createRequestClient() {
4342
};
4443
},
4544
makeErrorMessage: (msg) => message.error(msg),
45+
46+
makeRequestHeaders: () => {
47+
return {
48+
// 为每个请求携带 Accept-Language
49+
'Accept-Language': preferences.app.locale,
50+
};
51+
},
4652
});
4753
client.addResponseInterceptor<HttpResponse>((response) => {
4854
const { data: responseData, status } = response;
@@ -56,9 +62,4 @@ function createRequestClient() {
5662
return client;
5763
}
5864

59-
const requestClient = createRequestClient();
60-
61-
// 其他配置的请求方法
62-
// const { request: xxxRequest } = createRequest();
63-
64-
export { requestClient };
65+
export const requestClient = createRequestClient(apiURL);

0 commit comments

Comments
 (0)