Skip to content

Commit

Permalink
feat: Feature/pro docs (vbenjs#70)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
anncwb and vince292007 authored Jul 28, 2024
1 parent 14538f7 commit 376fd17
Show file tree
Hide file tree
Showing 225 changed files with 7,737 additions and 1,790 deletions.
2 changes: 1 addition & 1 deletion .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"privatePackages": { "version": true, "tag": true },
"linked": [],
"access": "restricted",
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": []
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/action-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@ jobs:

- name: Test and Build
run: |
pnpm run test
pnpm run test:unit
pnpm run build
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
# run: git config --global user.email "[email protected]" && git config --global user.name "Your Name"

- name: Vitest tests
run: pnpm run test
run: pnpm run test:unit

# - name: Upload coverage
# uses: codecov/codecov-action@v4
Expand Down
3 changes: 2 additions & 1 deletion .ls-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ls:
.css: kebab-case | pointcase
.d.ts: kebab-case | pointcase
# shadcn 自动生成文件为 PascalCase 格式
packages/@vben-core/ui-kit/shadcn-ui/src/components/ui:
packages/@core/ui-kit/shadcn-ui/src/components/ui:
.vue: PascalCase

ignore:
Expand All @@ -25,3 +25,4 @@ ignore:
- .vscode
- .idea
- node_modules
- .cache
5 changes: 3 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@
"**/CVS": true,
"**/.stylelintcache": true,
"**/.DS_Store": true,
"**/vite.config.mts.*": true
"**/vite.config.mts.*": true,
"**/tea.yaml": true
},
"files.watcherExclude": {
"**/.git/objects/**": true,
Expand Down Expand Up @@ -190,7 +191,7 @@
"eslint.config.mjs": ".eslintignore,.prettierignore,.stylelintignore,.commitlintrc.*,.prettierrc.*,stylelint.config.*,.lintstagedrc.mjs,.ls-lint*,cspell.json",
"tailwind.config.mjs": "postcss.*"
},
"commentTranslate.hover.enabled": true,
"commentTranslate.hover.enabled": false,
"i18n-ally.keystyle": "nested",
"commentTranslate.multiLineMerge": true
}
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2024-present, Vben Admin
Copyright (c) 2024-present, Vben

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:

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

<h1>Vue vben admin</h1>
<h1>Vue Vben Admin</h1>
</div>

**English** | [中文](./README.zh-CN.md)
Expand Down
14 changes: 14 additions & 0 deletions apps/backend-mock/middleware/1.api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export default defineEventHandler((event) => {
// setResponseHeaders(event, {
// 'Access-Control-Allow-Credentials': 'true',
// 'Access-Control-Allow-Headers': '*',
// 'Access-Control-Allow-Methods': 'GET,HEAD,PUT,PATCH,POST,DELETE',
// 'Access-Control-Allow-Origin': '*',
// 'Access-Control-Expose-Headers': '*',
// });
if (event.method === 'OPTIONS') {
event.node.res.statusCode = 204;
event.node.res.statusMessage = 'No Content.';
return 'OK';
}
});
12 changes: 12 additions & 0 deletions apps/backend-mock/nitro.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,16 @@ import errorHandler from './error';
export default defineNitroConfig({
devErrorHandler: errorHandler,
errorHandler: '~/error',
routeRules: {
'/api/**': {
cors: true,
headers: {
'Access-Control-Allow-Credentials': 'true',
'Access-Control-Allow-Headers': '*',
'Access-Control-Allow-Methods': 'GET,HEAD,PUT,PATCH,POST,DELETE',
'Access-Control-Allow-Origin': '*',
'Access-Control-Expose-Headers': '*',
},
},
},
});
28 changes: 14 additions & 14 deletions apps/backend-mock/utils/mock-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,26 +80,26 @@ const createDemosMenus = (role: 'admin' | 'super' | 'user') => {
icon: 'mdi:button-cursor',
title: 'page.demos.access.adminVisible',
},
name: 'AccessAdminVisible',
path: 'admin-visible',
name: 'AccessAdminVisibleDemo',
path: '/demos/access/admin-visible',
},
super: {
component: '/demos/access/super-visible',
meta: {
icon: 'mdi:button-cursor',
title: 'page.demos.access.superVisible',
},
name: 'AccessSuperVisible',
path: 'super-visible',
name: 'AccessSuperVisibleDemo',
path: '/demos/access/super-visible',
},
user: {
component: '/demos/access/user-visible',
meta: {
icon: 'mdi:button-cursor',
title: 'page.demos.access.userVisible',
},
name: 'AccessUserVisible',
path: 'user-visible',
name: 'AccessUserVisibleDemo',
path: '/demos/access/user-visible',
},
};

Expand All @@ -117,35 +117,35 @@ const createDemosMenus = (role: 'admin' | 'super' | 'user') => {
redirect: '/demos/access',
children: [
{
name: 'Access',
path: 'access',
name: 'AccessDemos',
path: '/demosaccess',
meta: {
icon: 'mdi:cloud-key-outline',
title: 'page.demos.access.backendPermissions',
},
redirect: '/demos/access/page-control',
children: [
{
name: 'AccessPageControl',
path: 'page-control',
name: 'AccessPageControlDemo',
path: '/demos/access/page-control',
component: '/demos/access/index',
meta: {
icon: 'mdi:page-previous-outline',
title: 'page.demos.access.pageAccess',
},
},
{
name: 'AccessButtonControl',
path: 'button-control',
name: 'AccessButtonControlDemo',
path: '/demos/access/button-control',
component: '/demos/access/button-control',
meta: {
icon: 'mdi:button-cursor',
title: 'page.demos.access.buttonControl',
},
},
{
name: 'AccessMenuVisible403',
path: 'menu-visible-403',
name: 'AccessMenuVisible403Demo',
path: '/demos/access/menu-visible-403',
component: '/demos/access/menu-visible-403',
meta: {
authority: ['no-body'],
Expand Down
9 changes: 4 additions & 5 deletions apps/web-antd/.env
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
VITE_PORT = 5555
# 应用标题
VITE_GLOB_APP_TITLE=Vben Admin

# spa-title
VITE_GLOB_APP_TITLE = Vben Admin

VITE_APP_NAMESPACE = web-antd
# 应用命名空间,用于缓存、store等功能的前缀,确保隔离
VITE_APP_NAMESPACE=vben-web-antd
5 changes: 2 additions & 3 deletions apps/web-antd/.env.analyze
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@

# public path
VITE_PUBLIC_PATH = /
VITE_BASE=/

# Basic interface address SPA
VITE_GLOB_API_URL=/api

VITE_VISUALIZER = true
VITE_VISUALIZER=true
15 changes: 13 additions & 2 deletions apps/web-antd/.env.development
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
VITE_PUBLIC_PATH = /
# 端口号
VITE_PORT=5555

VITE_BASE=/

# 接口地址
VITE_GLOB_API_URL=/api

VITE_NITRO_MOCK = true
# 是否开启 Nitro Mock服务,true 为开启,false 为关闭
VITE_NITRO_MOCK=true

# 是否打开 devtools,true 为打开,false 为关闭
VITE_DEVTOOLS=false

# 是否注入全局loading
VITE_INJECT_APP_LOADING=true
19 changes: 13 additions & 6 deletions apps/web-antd/.env.production
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
# public path
VITE_PUBLIC_PATH = /
VITE_BASE=/

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

VITE_COMPRESS = gzip
# 是否开启压缩,可以设置为 none, brotli, gzip
VITE_COMPRESS=gzip

VITE_PWA = false
# 是否开启 PWA
VITE_PWA=false

# vue-router 的模式
VITE_ROUTER_HISTORY=hash

# 是否注入全局loading
VITE_INJECT_APP_LOADING=true
13 changes: 13 additions & 0 deletions apps/web-antd/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@
<!-- 由 vite 注入 VITE_GLOB_APP_TITLE 变量,在 .env 文件内配置 -->
<title><%= VITE_GLOB_APP_TITLE %></title>
<link rel="icon" href="/favicon.ico" />
<script>
// 生产环境下注入百度统计
if (window._VBEN_ADMIN_PRO_APP_CONF_) {
var _hmt = _hmt || [];
(function () {
var hm = document.createElement('script');
hm.src =
'https://hm.baidu.com/hm.js?d20a01273820422b6aa2ee41b6c9414d';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(hm, s);
})();
}
</script>
</head>
<body>
<div id="app"></div>
Expand Down
2 changes: 1 addition & 1 deletion apps/web-antd/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"ant-design-vue": "^4.2.3",
"dayjs": "^1.11.12",
"pinia": "2.1.7",
"vue": "^3.4.33",
"vue": "^3.4.34",
"vue-router": "^4.4.0"
}
}
33 changes: 33 additions & 0 deletions apps/web-antd/src/api/core/auth.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { requestClient } from '#/api/request';

export namespace AuthApi {
/** 登录接口参数 */
export interface LoginParams {
password: string;
username: string;
}

/** 登录接口返回值 */
export interface LoginResult {
accessToken: string;
desc: string;
realName: string;
refreshToken: string;
userId: string;
username: string;
}
}

/**
* 登录
*/
export async function login(data: AuthApi.LoginParams) {
return requestClient.post<AuthApi.LoginResult>('/auth/login', data);
}

/**
* 获取用户权限码
*/
export async function getAccessCodes() {
return requestClient.get<string[]>('/auth/codes');
}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { RouteRecordStringComponent } from '@vben/types';

import { requestClient } from '#/apis/request';
import { requestClient } from '#/api/request';

/**
* 获取用户所有菜单
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { UserInfo } from '@vben/types';

import { requestClient } from '#/apis/request';
import { requestClient } from '#/api/request';

/**
* 获取用户信息
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { requestClient } from '#/apis/request';
import { requestClient } from '#/api/request';

/**
* 模拟任意状态码
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export * from './core';
export * from './demos';
export type * from './types';
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,19 @@
*/
import type { HttpResponse } from '@vben/request';

import { useAppConfig } from '@vben/hooks';
import { preferences } from '@vben/preferences';
import { RequestClient } from '@vben/request';

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

import { useAccessStore } from '#/store';

/**
* 创建请求实例
* Create a request instance
*/
function createRequestClient() {
const { apiURL } = useAppConfig(import.meta.env, import.meta.env.PROD);

function createRequestClient(baseURL: string) {
const client = new RequestClient({
baseURL: import.meta.env.VITE_GLOB_API_URL,
baseURL,
// 为每个请求携带 Authorization
makeAuthorization: () => {
return {
Expand All @@ -43,6 +42,13 @@ function createRequestClient() {
};
},
makeErrorMessage: (msg) => message.error(msg),

makeRequestHeaders: () => {
return {
// 为每个请求携带 Accept-Language
'Accept-Language': preferences.app.locale,
};
},
});
client.addResponseInterceptor<HttpResponse>((response) => {
const { data: responseData, status } = response;
Expand All @@ -56,9 +62,4 @@ function createRequestClient() {
return client;
}

const requestClient = createRequestClient();

// 其他配置的请求方法
// const { request: xxxRequest } = createRequest();

export { requestClient };
export const requestClient = createRequestClient(apiURL);
Loading

0 comments on commit 376fd17

Please sign in to comment.