feat: 新增扫码登录功能并优化 SSE、请求拦截与多页面适配

This commit is contained in:
Ray.Hao committed 2026-08-23 16:24:59 +08:00
1 parent 484e7047f5
commit 907b07f552
30 files changed
+259 -142

No files matched your search

+3 -5
View File
@@ -72,9 +72,7 @@
</wd-form>
<view class="popup-actions">
<wd-button type="info" variant="plain" @click="closeConfigDialog">取消</wd-button>
<wd-button :loading="isSubmitting" @click="submitConfigForm">
保存
</wd-button>
<wd-button :loading="isSubmitting" @click="submitConfigForm">保存</wd-button>
</view>
</view>
</wd-popup>
@@ -154,7 +152,7 @@ function loadConfigList() {
function fetchConfigList() {
loadMoreState.value = "loading";
ConfigAPI.getPage(queryParams)
.then((data: any) => {
.then((data) => {
pageData.value = data.list;
total.value = data.total;
queryParams.pageNum++;
@@ -205,7 +203,7 @@ function closeConfigDialog() {
}
// 操作菜单分发
function handleActionSelect({ item }: { item: any }) {
function handleActionSelect({ item }: { item: { name: string } }) {
const value = item.name;
const configItem = currentActionItem.value;
if (value === "编辑") {
+17 -8
View File
@@ -104,9 +104,10 @@ import { onLoad } from "@dcloudio/uni-app";
import { toFormSchema } from "@/utils/form";
import { findOptionChain } from "@/utils/tree";
import { useToast, useDialog } from "@wot-ui/ui";
import type { CascaderOption } from "@wot-ui/ui/components/wd-cascader/types";
import DeptAPI, { type DeptQuery, DeptItem, DeptForm } from "@/api/dept";
import { hasPermission } from "@/utils/permission";
import CustomTree from "@/components/custom-tree/index.vue";
import CustomTree, { type TreeOption } from "@/components/custom-tree/index.vue";
definePage({
name: "dept",
@@ -140,10 +141,10 @@ const formData = reactive<DeptForm>({ ...initialFormData });
// 转换为树组件数据格式
const treeData = computed(() => deptList.value.map((dept) => transformDeptToTree(dept)));
function transformDeptToTree(dept: DeptItem): any {
function transformDeptToTree(dept: DeptItem): TreeOption {
return {
value: String(dept.id),
label: dept.name,
label: dept.name ?? "",
id: dept.id,
name: dept.name,
status: dept.status,
@@ -158,10 +159,16 @@ const parentOptions = ref<OptionType[]>([]);
const parentLabel = ref("");
// 上级部门确认选择
const handleParentConfirm = ({ value, selectedOptions }: any) => {
const handleParentConfirm = ({
value,
selectedOptions,
}: {
value: string | number;
selectedOptions: CascaderOption[];
}) => {
parentSelected.value = value;
formData.parentId = Number(value) || 0;
parentLabel.value = selectedOptions.map((item: any) => item.label).join("/");
parentLabel.value = selectedOptions.map((item) => String(item.label ?? "")).join("/");
};
const rules = toFormSchema({
@@ -185,7 +192,7 @@ function loadDeptList() {
}
// 操作菜单分发
function handleActionSelect({ item }: { item: any }) {
function handleActionSelect({ item }: { item: { name: string } }) {
const value = item.name;
const dept = currentActionItem.value;
if (value === "新增子部门") {
@@ -206,7 +213,7 @@ function handleActionSelect({ item }: { item: any }) {
}
// 处理节点操作按钮点击
function handleNodeAction(node: any) {
function handleNodeAction(node: TreeOption) {
const dept: DeptItem = {
id: node.id,
name: node.label,
@@ -272,7 +279,9 @@ function handleAddChild(dept: DeptItem) {
formData.parentId = dept.id!;
parentSelected.value = dept.id!;
parentLabel.value =
findOptionChain(treeData.value, dept.id!)?.map((option) => option.label).join("/") ||
findOptionChain(treeData.value, dept.id!)
?.map((option) => option.label)
.join("/") ||
dept.name ||
"";
}
+2 -2
View File
@@ -147,7 +147,7 @@ function loadDictTypeList() {
function fetchDictTypeList() {
loadMoreState.value = "loading";
DictAPI.getPage(queryParams)
.then((data: any) => {
.then((data) => {
pageData.value = data.list;
total.value = data.total;
queryParams.pageNum++;
@@ -249,7 +249,7 @@ function showDictActions(item: DictTypeItem) {
actionSheetVisible.value = true;
}
function handleActionSelect({ item }: { item: any }) {
function handleActionSelect({ item }: { item: { name: string } }) {
pendingAction.value[item.name]?.();
}
+5 -5
View File
@@ -163,7 +163,7 @@ function fetchItemList() {
loadMoreState.value = "loading";
DictAPI.getItemPage(dictCode.value, queryParams)
.then((data: any) => {
.then((data) => {
pageData.value = data.list;
total.value = data.total;
queryParams.pageNum++;
@@ -264,7 +264,7 @@ function showItemActions(item: DictDataItem) {
actionSheetVisible.value = true;
}
function handleActionSelect({ item }: { item: any }) {
function handleActionSelect({ item }: { item: { name: string } }) {
pendingAction.value[item.name]?.();
}
@@ -276,9 +276,9 @@ onReachBottom(() => {
}
});
onLoad((query: any) => {
dictCode.value = String((query as any)?.dictCode || "");
pageTitle.value = String((query as any)?.title || "字典数据");
onLoad((query) => {
dictCode.value = String(query?.dictCode || "");
pageTitle.value = String(query?.title || "字典数据");
if (pageTitle.value) {
uni.setNavigationBarTitle({ title: pageTitle.value });
}
+24 -11
View File
@@ -81,7 +81,11 @@
<wd-radio value="B">按钮</wd-radio>
</wd-radio-group>
</wd-form-item>
<wd-form-item v-if="formData.type === 'C' || formData.type === 'M'" prop="routePath" title="路由路径">
<wd-form-item
v-if="formData.type === 'C' || formData.type === 'M'"
prop="routePath"
title="路由路径"
>
<wd-input v-model="formData.routePath" placeholder="system 或 /system" />
</wd-form-item>
<wd-form-item v-if="formData.type === 'E'" prop="externalUrl" title="外链地址">
@@ -136,7 +140,8 @@ import { findOptionChain } from "@/utils/tree";
import { useToast, useDialog } from "@wot-ui/ui";
import MenuAPI, { type MenuQuery, MenuItem, MenuForm } from "@/api/menu";
import { hasPermission } from "@/utils/permission";
import CustomTree from "@/components/custom-tree/index.vue";
import CustomTree, { type TreeOption } from "@/components/custom-tree/index.vue";
import type { CascaderOption } from "@wot-ui/ui/components/wd-cascader/types";
definePage({
name: "menu",
@@ -175,10 +180,10 @@ const formData = reactive<MenuForm>({ ...initialFormData });
// 转换为树组件数据格式
const treeData = computed(() => menuList.value.map((menu: MenuItem) => transformMenuToTree(menu)));
function transformMenuToTree(menu: MenuItem): any {
function transformMenuToTree(menu: MenuItem): TreeOption {
return {
value: menu.id,
label: menu.name,
value: menu.id ?? "",
label: menu.name ?? "",
id: menu.id,
name: menu.name,
type: menu.type,
@@ -221,10 +226,16 @@ const parentOptions = ref<OptionType[]>([]);
const parentLabel = ref("");
// 上级菜单确认选择
const handleParentConfirm = ({ value, selectedOptions }: any) => {
const handleParentConfirm = ({
value,
selectedOptions,
}: {
value: string | number;
selectedOptions: CascaderOption[];
}) => {
parentSelected.value = value;
formData.parentId = String(value) || "0";
parentLabel.value = selectedOptions.map((item: any) => item.label).join("/");
parentLabel.value = selectedOptions.map((item) => String(item.label ?? "")).join("/");
};
const rules = toFormSchema({
@@ -236,13 +247,13 @@ const rules = toFormSchema({
const handleSearch = () => loadMenuList();
function loadMenuList() {
MenuAPI.getList(queryParams).then((data: any) => {
MenuAPI.getList(queryParams).then((data) => {
menuList.value = data;
});
}
// 操作菜单分发
function handleActionSelect({ item }: { item: any }) {
function handleActionSelect({ item }: { item: { name: string } }) {
const value = item.name;
const menu = currentActionItem.value;
if (value === "新增子菜单") {
@@ -263,7 +274,7 @@ function handleActionSelect({ item }: { item: any }) {
}
// 处理节点操作按钮点击
function handleNodeAction(node: any) {
function handleNodeAction(node: TreeOption) {
const menu: MenuItem = {
id: node.id,
name: node.label,
@@ -330,7 +341,9 @@ function handleAddChild(menu: MenuItem) {
formData.parentId = menu.id!;
parentSelected.value = menu.id!;
parentLabel.value =
findOptionChain(treeData.value, menu.id!)?.map((option) => option.label).join("/") ||
findOptionChain(treeData.value, menu.id!)
?.map((option) => option.label)
.join("/") ||
menu.name ||
"";
}
+2 -4
View File
@@ -134,9 +134,7 @@
</wd-form>
<view class="popup-actions">
<wd-button type="info" variant="plain" @click="closeNoticeForm">取消</wd-button>
<wd-button :loading="isSubmitting" @click="submitNoticeForm">
保存
</wd-button>
<wd-button :loading="isSubmitting" @click="submitNoticeForm">保存</wd-button>
</view>
</view>
</wd-popup>
@@ -390,7 +388,7 @@ function showNoticeActions(item: NoticeItem) {
actionSheetVisible.value = true;
}
function handleActionSelect({ item }: { item: any }) {
function handleActionSelect({ item }: { item: { name: string } }) {
pendingAction.value[item.name]?.();
}
+3 -1
View File
@@ -10,7 +10,9 @@
<view class="action-bar">
<view class="action-bar__left">
<wd-button type="" size="small" variant="plain" @click="handleSelectAll">全选</wd-button>
<wd-button type="" size="small" variant="plain" @click="handleClearAll">取消全选</wd-button>
<wd-button type="" size="small" variant="plain" @click="handleClearAll">
取消全选
</wd-button>
</view>
</view>
</view>
+2 -2
View File
@@ -254,7 +254,7 @@ function closeRoleDialog() {
}
// 操作菜单分发
function handleActionSelect({ item }: { item: any }) {
function handleActionSelect({ item }: { item: { name: string } }) {
const value = item.name;
const role = currentActionItem.value;
if (value === "编辑") {
@@ -267,7 +267,7 @@ function handleActionSelect({ item }: { item: any }) {
msg: `确定要删除角色「${role.name}」吗?`,
headerImage: "warning",
}).then(async () => {
await RoleAPI.deleteByIds(String(item.id));
await RoleAPI.deleteByIds(String(role.id));
toast.success("删除成功");
loadRoleList();
});
+25 -15
View File
@@ -202,10 +202,7 @@
<wd-button type="info" variant="plain" @click="resetPwdDialog.visible = false">
取消
</wd-button>
<wd-button
:loading="resetPwdDialog.isSubmitting"
@click="handleResetPassword"
>
<wd-button :loading="resetPwdDialog.isSubmitting" @click="handleResetPassword">
确认
</wd-button>
</view>
@@ -217,6 +214,7 @@
<script lang="ts" setup>
import { onLoad, onReachBottom } from "@dcloudio/uni-app";
import { LoadMoreState } from "@wot-ui/ui/components/wd-loadmore/types";
import type { CascaderOption } from "@wot-ui/ui/components/wd-cascader/types";
import { toFormSchema } from "@/utils/form";
import { findOptionChain } from "@/utils/tree";
import { useQueue, useToast, useDialog } from "@wot-ui/ui";
@@ -261,7 +259,7 @@ const initialFormData: UserForm = {
};
const formData = reactive<UserForm>({ ...initialFormData });
const roleOptions = ref<Record<string, any>[]>([]);
const roleOptions = ref<OptionType[]>([]);
const deptOptions = ref<OptionType[]>([]);
// 部门选择器状态
@@ -274,14 +272,25 @@ const showRolePicker = ref(false);
const roleLabel = ref("");
// 部门确认选择
const handleDeptConfirm = ({ value, selectedOptions }: any) => {
formData.deptId = value;
deptLabel.value = selectedOptions.map((item: any) => item.label).join("/");
const handleDeptConfirm = ({
value,
selectedOptions,
}: {
value: string | number;
selectedOptions: CascaderOption[];
}) => {
formData.deptId = Number(value);
deptLabel.value = selectedOptions.map((item) => String(item.label ?? "")).join("/");
};
// 角色确认选择
const handleRoleConfirm = ({ selectedItems }: any) => {
roleLabel.value = selectedItems.map((item: any) => item.label).join("、");
const handleRoleConfirm = ({
selectedItems,
}: {
value: (string | number)[];
selectedItems: OptionType[];
}) => {
roleLabel.value = selectedItems.map((item) => item.label).join("、");
};
const rules = toFormSchema({
@@ -336,7 +345,7 @@ function resetUserFilter() {
function fetchUserList() {
loadMoreState.value = "loading";
UserAPI.getPage(queryParams)
.then((data: any) => {
.then((data) => {
pageData.value = data.list;
total.value = data.total;
queryParams.pageNum++;
@@ -371,11 +380,12 @@ async function openUserDialog(user?: UserItem) {
const chain = findOptionChain(deptData, data.deptId);
deptLabel.value = chain ? chain.map((option) => option.label).join("/") : user.deptName || "";
}
// 回显角色
// 回显角色(roleIds 与选项 value 统一转字符串比较,兼容数字/字符串ID)
if (data.roleIds && data.roleIds.length > 0) {
const roleIds = data.roleIds.map(String);
const names = roleOptions.value
.filter((r: any) => data.roleIds.includes(r.value))
.map((r: any) => r.label);
.filter((r) => roleIds.includes(String(r.value)))
.map((r) => r.label);
roleLabel.value = names.join("、");
}
}
@@ -464,7 +474,7 @@ function showUserActions(item: UserItem) {
actionSheetVisible.value = true;
}
function handleActionSelect({ item }: { item: any }) {
function handleActionSelect({ item }: { item: { name: string } }) {
pendingAction.value[item.name]?.();
}