From 3783e749342686b588adac06a9df5bfd4b437055 Mon Sep 17 00:00:00 2001
From: dzc <2388224167@qq.com>
Date: Thu, 12 Mar 2026 16:07:01 +0800
Subject: [PATCH] =?UTF-8?q?feat:=E5=B0=8F=E7=A8=8B=E5=BA=8F=E8=8F=9C?=
=?UTF-8?q?=E5=8D=95=E7=AE=A1=E7=90=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/api/app/app-menu.ts | 40 +++++++
src/api/login/index.ts | 147 +++++++++++++------------
src/views/biz/app/app-menu/form.vue | 146 +++++++++++++++++++++++++
src/views/biz/app/app-menu/index.vue | 154 +++++++++++++++++++++++++++
4 files changed, 413 insertions(+), 74 deletions(-)
create mode 100644 src/api/app/app-menu.ts
create mode 100644 src/views/biz/app/app-menu/form.vue
create mode 100644 src/views/biz/app/app-menu/index.vue
diff --git a/src/api/app/app-menu.ts b/src/api/app/app-menu.ts
new file mode 100644
index 0000000..67c8057
--- /dev/null
+++ b/src/api/app/app-menu.ts
@@ -0,0 +1,40 @@
+import request from "/@/utils/request"
+
+export function fetchList(query?: Object) {
+ return request({
+ url: "/app/app-menu/page",
+ method: "get",
+ params: query,
+ })
+}
+
+export function addObj(obj?: Object) {
+ return request({
+ url: "/app/app-menu",
+ method: "post",
+ data: obj,
+ })
+}
+
+export function getObj(id?: string) {
+ return request({
+ url: "/app/app-menu/" + id,
+ method: "get",
+ })
+}
+
+export function delObjs(ids?: Object) {
+ return request({
+ url: "/app/app-menu",
+ method: "delete",
+ data: ids,
+ })
+}
+
+export function putObj(obj?: Object) {
+ return request({
+ url: "/app/app-menu",
+ method: "put",
+ data: obj,
+ })
+}
diff --git a/src/api/login/index.ts b/src/api/login/index.ts
index 828f1f4..f09033a 100644
--- a/src/api/login/index.ts
+++ b/src/api/login/index.ts
@@ -1,171 +1,170 @@
-import request from '/@/utils/request';
-import {Session} from '/@/utils/storage';
-import {validateNull} from '/@/utils/validate';
-import {useUserInfo} from '/@/stores/userInfo';
-import other from '/@/utils/other';
+import request from "/@/utils/request"
+import { Session } from "/@/utils/storage"
+import { validateNull } from "/@/utils/validate"
+import { useUserInfo } from "/@/stores/userInfo"
+import other from "/@/utils/other"
/**
* https://www.ietf.org/rfc/rfc6749.txt
* OAuth 协议 4.3.1 要求格式为 form 而不是 JSON 注意!
*/
-const FORM_CONTENT_TYPE = 'application/x-www-form-urlencoded';
+const FORM_CONTENT_TYPE = "application/x-www-form-urlencoded"
// 登录方式
export enum LoginTypeEnum {
PASSWORD,
MOBILE,
REGISTER,
- EXPIRE
+ EXPIRE,
}
// 登录错误信息
export enum LoginErrorEnum {
- CREDENTIALS_EXPIRED = 'credentials_expired'// 密码过期
+ CREDENTIALS_EXPIRED = "credentials_expired", // 密码过期
}
-
/**
* 登录
* @param data
*/
export const login = (data: any) => {
- const basicAuth = 'Basic ' + window.btoa(import.meta.env.VITE_OAUTH2_PASSWORD_CLIENT);
- Session.set('basicAuth', basicAuth);
+ const basicAuth = "Basic " + window.btoa(import.meta.env.VITE_OAUTH2_PASSWORD_CLIENT)
+ Session.set("basicAuth", basicAuth)
// 密码加密
- const encPassword = other.encryption(data.password, import.meta.env.VITE_PWD_ENC_KEY);
- const { username, randomStr, code, grant_type, scope } = data;
+ const encPassword = other.encryption(data.password, import.meta.env.VITE_PWD_ENC_KEY)
+ const { username, randomStr, code, grant_type, scope } = data
return request({
- url: '/auth/oauth2/token',
- method: 'post',
+ url: "/auth/oauth2/token",
+ method: "post",
params: { username, randomStr, code, grant_type, scope },
data: { password: encPassword },
headers: {
skipToken: true,
Authorization: basicAuth,
- 'Content-Type': FORM_CONTENT_TYPE,
+ "Content-Type": FORM_CONTENT_TYPE,
},
- });
-};
+ })
+}
export const loginByMobile = (mobile: any, code: any) => {
- const grant_type = 'mobile';
- const scope = 'server';
- const basicAuth = 'Basic ' + window.btoa(import.meta.env.VITE_OAUTH2_MOBILE_CLIENT);
- Session.set('basicAuth', basicAuth);
+ const grant_type = "mobile"
+ const scope = "server"
+ const basicAuth = "Basic " + window.btoa(import.meta.env.VITE_OAUTH2_MOBILE_CLIENT)
+ Session.set("basicAuth", basicAuth)
return request({
- url: '/auth/oauth2/token',
+ url: "/auth/oauth2/token",
headers: {
skipToken: true,
Authorization: basicAuth,
- 'Content-Type': FORM_CONTENT_TYPE,
+ "Content-Type": FORM_CONTENT_TYPE,
},
- method: 'post',
- params: { mobile: 'SMS@' + mobile, code: code, grant_type, scope },
- });
-};
+ method: "post",
+ params: { mobile: "SMS@" + mobile, code: code, grant_type, scope },
+ })
+}
export const loginBySocial = (state: string, code: string) => {
- const grant_type = 'mobile';
- const scope = 'server';
- const basicAuth = 'Basic ' + window.btoa(import.meta.env.VITE_OAUTH2_SOCIAL_CLIENT);
- Session.set('basicAuth', basicAuth);
+ const grant_type = "mobile"
+ const scope = "server"
+ const basicAuth = "Basic " + window.btoa(import.meta.env.VITE_OAUTH2_SOCIAL_CLIENT)
+ Session.set("basicAuth", basicAuth)
return request({
- url: '/auth/oauth2/token',
+ url: "/auth/oauth2/token",
headers: {
skipToken: true,
Authorization: basicAuth,
- 'Content-Type': FORM_CONTENT_TYPE,
+ "Content-Type": FORM_CONTENT_TYPE,
},
- method: 'post',
- params: { mobile: state + '@' + code, code: code, grant_type, scope },
- });
-};
+ method: "post",
+ params: { mobile: state + "@" + code, code: code, grant_type, scope },
+ })
+}
export const sendMobileCode = (mobile: string) => {
return request({
- url: '/admin/sysMessage/send/smsCode',
- method: 'get',
- params: { mobile }
- });
-};
+ url: "/admin/sysMessage/send/smsCode",
+ method: "get",
+ params: { mobile },
+ })
+}
export const refreshTokenApi = (refresh_token: string) => {
- const grant_type = 'refresh_token';
- const scope = 'server';
+ const grant_type = "refresh_token"
+ const scope = "server"
// 获取当前选中的 basic 认证信息
- const basicAuth = Session.get('basicAuth');
+ const basicAuth = Session.get("basicAuth")
return request({
- url: '/auth/oauth2/token',
+ url: "/auth/oauth2/token",
headers: {
skipToken: true,
Authorization: basicAuth,
- 'Content-Type': FORM_CONTENT_TYPE,
+ "Content-Type": FORM_CONTENT_TYPE,
},
- method: 'post',
+ method: "post",
params: { refresh_token, grant_type, scope },
- });
-};
+ })
+}
/**
* 校验令牌,若有效期小于半小时自动续期
* @param refreshLock
*/
export const checkToken = (refreshTime: number, refreshLock: boolean) => {
- const basicAuth = Session.get('basicAuth');
+ const basicAuth = Session.get("basicAuth")
request({
- url: '/auth/token/check_token',
+ url: "/auth/token/check_token",
headers: {
skipToken: true,
Authorization: basicAuth,
- 'Content-Type': FORM_CONTENT_TYPE,
+ "Content-Type": FORM_CONTENT_TYPE,
},
- method: 'get',
+ method: "get",
params: { token: Session.getToken() },
})
.then((response) => {
if (validateNull(response) || response.code === 1) {
- clearInterval(refreshTime);
- return;
+ clearInterval(refreshTime)
+ return
}
- const expire = Date.parse(response.data.expiresAt);
+ const expire = Date.parse(response.data.expiresAt)
if (expire) {
- const expiredPeriod = expire - new Date().getTime();
+ const expiredPeriod = expire - new Date().getTime()
//小于半小时自动续约
if (expiredPeriod <= 30 * 60 * 1000) {
if (!refreshLock) {
- refreshLock = true;
+ refreshLock = true
useUserInfo()
.refreshToken()
.catch(() => {
- clearInterval(refreshTime);
- });
- refreshLock = false;
+ clearInterval(refreshTime)
+ })
+ refreshLock = false
}
}
}
})
.catch(() => {
// 发生异常关闭定时器
- clearInterval(refreshTime);
- });
-};
+ clearInterval(refreshTime)
+ })
+}
/**
* 获取用户信息
*/
export const getUserInfo = () => {
return request({
- url: '/admin/user/info',
- method: 'get',
- });
-};
+ url: "/admin/user/info",
+ method: "get",
+ })
+}
export const logout = () => {
return request({
- url: '/auth/token/logout',
- method: 'delete',
- });
-};
+ url: "/auth/token/logout",
+ method: "delete",
+ })
+}
diff --git a/src/views/biz/app/app-menu/form.vue b/src/views/biz/app/app-menu/form.vue
new file mode 100644
index 0000000..4936a73
--- /dev/null
+++ b/src/views/biz/app/app-menu/form.vue
@@ -0,0 +1,146 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 排序
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/views/biz/app/app-menu/index.vue b/src/views/biz/app/app-menu/index.vue
new file mode 100644
index 0000000..d697d71
--- /dev/null
+++ b/src/views/biz/app/app-menu/index.vue
@@ -0,0 +1,154 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ $t("common.queryBtn") }}
+
+
+ {{ $t("common.resetBtn") }}
+
+
+
+
+
+
+
+ 新 增
+
+
+ 删除
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 编辑
+ 删除
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file