refactor: 界面优化和使用sse替换websocket
This commit is contained in:
1 parent
0288b5a08d
commit
c9fbc441bd
31 files changed
+546
-916
No files matched your search
@@ -67,7 +67,9 @@
|
||||
</wd-form>
|
||||
<view class="popup-actions">
|
||||
<wd-button type="info" plain @click="closeConfigDialog">取消</wd-button>
|
||||
<wd-button type="primary" :loading="submitting" @click="submitConfigForm">保存</wd-button>
|
||||
<wd-button type="primary" :loading="isSubmitting" @click="submitConfigForm">
|
||||
保存
|
||||
</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</wd-popup>
|
||||
@@ -100,7 +102,7 @@ const toast = useToast();
|
||||
const { messageBox } = useMessage();
|
||||
const loadMoreState = ref<LoadMoreState>("loading");
|
||||
const formRef = ref();
|
||||
const submitting = ref(false);
|
||||
const isSubmitting = ref(false);
|
||||
|
||||
const queryParams = reactive<ConfigPageQuery>({ pageNum: 1, pageSize: 10, keywords: "" });
|
||||
const total = ref(0);
|
||||
@@ -169,7 +171,7 @@ async function openConfigDialog(id?: number) {
|
||||
function submitConfigForm() {
|
||||
formRef.value.validate().then(({ valid }: { valid: boolean }) => {
|
||||
if (!valid) return;
|
||||
submitting.value = true;
|
||||
isSubmitting.value = true;
|
||||
const action = formData.id ? ConfigAPI.update(formData.id, formData) : ConfigAPI.add(formData);
|
||||
action
|
||||
.then(() => {
|
||||
@@ -178,7 +180,7 @@ function submitConfigForm() {
|
||||
loadConfigList();
|
||||
})
|
||||
.finally(() => {
|
||||
submitting.value = false;
|
||||
isSubmitting.value = false;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@
|
||||
</wd-form>
|
||||
<view class="popup-actions">
|
||||
<wd-button type="info" plain @click="closeDeptDialog">取消</wd-button>
|
||||
<wd-button type="primary" :loading="submitting" @click="submitDeptForm">保存</wd-button>
|
||||
<wd-button type="primary" :loading="isSubmitting" @click="submitDeptForm">保存</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</wd-popup>
|
||||
@@ -95,7 +95,7 @@ import CustomTree from "@/components/custom-tree/index.vue";
|
||||
const toast = useToast();
|
||||
const { messageBox } = useMessage();
|
||||
const formRef = ref();
|
||||
const submitting = ref(false);
|
||||
const isSubmitting = ref(false);
|
||||
|
||||
const queryParams = reactive<DeptQuery>({ keywords: "" });
|
||||
const deptList = ref<DeptItem[]>([]);
|
||||
@@ -301,7 +301,7 @@ function handleAddChild(dept: DeptItem) {
|
||||
function submitDeptForm() {
|
||||
formRef.value.validate().then(({ valid }: { valid: boolean }) => {
|
||||
if (!valid) return;
|
||||
submitting.value = true;
|
||||
isSubmitting.value = true;
|
||||
const action = formData.id ? DeptAPI.update(formData.id, formData) : DeptAPI.add(formData);
|
||||
action
|
||||
.then(() => {
|
||||
@@ -310,7 +310,7 @@ function submitDeptForm() {
|
||||
loadDeptList();
|
||||
})
|
||||
.finally(() => {
|
||||
submitting.value = false;
|
||||
isSubmitting.value = false;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@
|
||||
</wd-form>
|
||||
<view class="popup-actions">
|
||||
<wd-button type="info" plain @click="closeDictDialog">取消</wd-button>
|
||||
<wd-button type="primary" :loading="submitting" @click="submitDictForm">保存</wd-button>
|
||||
<wd-button type="primary" :loading="isSubmitting" @click="submitDictForm">保存</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</wd-popup>
|
||||
@@ -102,7 +102,7 @@ const toast = useToast();
|
||||
const { messageBox } = useMessage();
|
||||
const loadMoreState = ref<LoadMoreState>("loading");
|
||||
const formRef = ref();
|
||||
const submitting = ref(false);
|
||||
const isSubmitting = ref(false);
|
||||
|
||||
const queryParams = reactive<DictTypePageQuery>({ pageNum: 1, pageSize: 10, keywords: "" });
|
||||
const total = ref(0);
|
||||
@@ -169,7 +169,7 @@ async function openDictDialog(id?: string) {
|
||||
function submitDictForm() {
|
||||
formRef.value.validate().then(({ valid }: { valid: boolean }) => {
|
||||
if (!valid) return;
|
||||
submitting.value = true;
|
||||
isSubmitting.value = true;
|
||||
const id = formData.id;
|
||||
const action = id ? DictAPI.update(id, formData) : DictAPI.create(formData);
|
||||
action
|
||||
@@ -179,7 +179,7 @@ function submitDictForm() {
|
||||
loadDictTypeList();
|
||||
})
|
||||
.finally(() => {
|
||||
submitting.value = false;
|
||||
isSubmitting.value = false;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@
|
||||
</wd-form>
|
||||
<view class="popup-actions">
|
||||
<wd-button type="info" plain @click="closeItemDialog">取消</wd-button>
|
||||
<wd-button type="primary" :loading="submitting" @click="submitItemForm">保存</wd-button>
|
||||
<wd-button type="primary" :loading="isSubmitting" @click="submitItemForm">保存</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</wd-popup>
|
||||
@@ -112,7 +112,7 @@ const pageTitle = ref<string>("字典数据");
|
||||
|
||||
const loadMoreState = ref<LoadMoreState>("loading");
|
||||
const formRef = ref();
|
||||
const submitting = ref(false);
|
||||
const isSubmitting = ref(false);
|
||||
|
||||
const queryParams = reactive<DictItemPageQuery>({ pageNum: 1, pageSize: 10, keywords: "" });
|
||||
const total = ref(0);
|
||||
@@ -187,7 +187,7 @@ function submitItemForm() {
|
||||
return;
|
||||
}
|
||||
|
||||
submitting.value = true;
|
||||
isSubmitting.value = true;
|
||||
const id = formData.id;
|
||||
const action = id
|
||||
? DictAPI.updateItem(dictCode.value, id, formData)
|
||||
@@ -200,7 +200,7 @@ function submitItemForm() {
|
||||
loadItemList();
|
||||
})
|
||||
.finally(() => {
|
||||
submitting.value = false;
|
||||
isSubmitting.value = false;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -23,18 +23,13 @@
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed } from "vue";
|
||||
import { useRouter } from "uni-mini-router";
|
||||
import { useNavbar } from "@/composables/useNavbar";
|
||||
import { useNavigation } from "@/composables/useNavigation";
|
||||
import { menuConfig } from "@/config/menu";
|
||||
import { checkLogin, isLoggedIn } from "@/utils/auth";
|
||||
import { hasPermission as checkPermission } from "@/utils/permission";
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
const navbar = useNavbar({ hasTabbar: true });
|
||||
|
||||
// 是否已登录
|
||||
const isLogged = computed(() => isLoggedIn());
|
||||
const navbar = useNavbar();
|
||||
const { handleNavClick } = useNavigation();
|
||||
|
||||
// 检查是否有权限
|
||||
const hasPermission = (perm: string) => {
|
||||
@@ -51,31 +46,6 @@ const visibleGridList = computed(() => {
|
||||
}))
|
||||
.filter((group) => group.children.length > 0);
|
||||
});
|
||||
|
||||
// 处理导航点击
|
||||
function handleNavClick(item: any) {
|
||||
// 未登录时跳转登录页
|
||||
if (!isLogged.value) {
|
||||
uni.navigateTo({ url: "/pages/login/index" });
|
||||
return;
|
||||
}
|
||||
// 已登录但访问受限时,仍做一次登录校验(防 token 过期)
|
||||
if (!checkLogin()) return;
|
||||
|
||||
try {
|
||||
if (
|
||||
typeof item?.url === "string" &&
|
||||
(item.url.startsWith("http://") || item.url.startsWith("https://"))
|
||||
) {
|
||||
uni.navigateTo({ url: `/pages/webview/index?url=${encodeURIComponent(item.url)}` });
|
||||
return;
|
||||
}
|
||||
|
||||
router.push({ path: item.url });
|
||||
} catch {
|
||||
// 路由跳转失败已由拦截器处理
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<route lang="json">
|
||||
|
||||
@@ -101,7 +101,7 @@
|
||||
</scroll-view>
|
||||
<view class="popup-actions">
|
||||
<wd-button type="info" plain @click="closeMenuDialog">取消</wd-button>
|
||||
<wd-button type="primary" :loading="submitting" @click="submitMenuForm">保存</wd-button>
|
||||
<wd-button type="primary" :loading="isSubmitting" @click="submitMenuForm">保存</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</wd-popup>
|
||||
@@ -130,7 +130,7 @@ import CustomTree from "@/components/custom-tree/index.vue";
|
||||
const toast = useToast();
|
||||
const { messageBox } = useMessage();
|
||||
const formRef = ref();
|
||||
const submitting = ref(false);
|
||||
const isSubmitting = ref(false);
|
||||
|
||||
const queryParams = reactive<MenuQuery>({ keywords: "" });
|
||||
const menuList = ref<MenuItem[]>([]);
|
||||
@@ -364,7 +364,7 @@ function handleAddChild(menu: MenuItem) {
|
||||
function submitMenuForm() {
|
||||
formRef.value.validate().then(({ valid }: { valid: boolean }) => {
|
||||
if (!valid) return;
|
||||
submitting.value = true;
|
||||
isSubmitting.value = true;
|
||||
const action = formData.id ? MenuAPI.update(formData.id, formData) : MenuAPI.add(formData);
|
||||
action
|
||||
.then(() => {
|
||||
@@ -373,7 +373,7 @@ function submitMenuForm() {
|
||||
loadMenuList();
|
||||
})
|
||||
.finally(() => {
|
||||
submitting.value = false;
|
||||
isSubmitting.value = false;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -133,7 +133,9 @@
|
||||
</wd-form>
|
||||
<view class="popup-actions">
|
||||
<wd-button type="info" plain @click="closeNoticeForm">取消</wd-button>
|
||||
<wd-button type="primary" :loading="submitting" @click="submitNoticeForm">保存</wd-button>
|
||||
<wd-button type="primary" :loading="isSubmitting" @click="submitNoticeForm">
|
||||
保存
|
||||
</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</wd-popup>
|
||||
@@ -169,7 +171,7 @@ const toast = useToast();
|
||||
const { messageBox } = useMessage();
|
||||
const loadMoreState = ref<LoadMoreState>("loading");
|
||||
const formRef = ref();
|
||||
const submitting = ref(false);
|
||||
const isSubmitting = ref(false);
|
||||
|
||||
const queryParams = reactive<NoticePageQuery>({ pageNum: 1, pageSize: 10 });
|
||||
const total = ref(0);
|
||||
@@ -290,7 +292,7 @@ function closeNoticeForm() {
|
||||
function submitNoticeForm() {
|
||||
formRef.value.validate().then(({ valid }: { valid: boolean }) => {
|
||||
if (!valid) return;
|
||||
submitting.value = true;
|
||||
isSubmitting.value = true;
|
||||
const id = formData.id;
|
||||
const action = id ? NoticeAPI.update(id, formData) : NoticeAPI.add(formData);
|
||||
action
|
||||
@@ -300,7 +302,7 @@ function submitNoticeForm() {
|
||||
loadNoticeList();
|
||||
})
|
||||
.finally(() => {
|
||||
submitting.value = false;
|
||||
isSubmitting.value = false;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
<!-- 固定底部操作栏 -->
|
||||
<view class="bottom-bar">
|
||||
<wd-button type="info" plain @click="handleCancel">取消</wd-button>
|
||||
<wd-button type="primary" :loading="submitting" @click="handleSubmit">保存</wd-button>
|
||||
<wd-button type="primary" :loading="isSubmitting" @click="handleSubmit">保存</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
@@ -84,7 +84,7 @@ import CustomTree from "@/components/custom-tree/index.vue";
|
||||
import type { TreeOption } from "@/components/custom-tree/index.vue";
|
||||
|
||||
const toast = useToast();
|
||||
const submitting = ref(false);
|
||||
const isSubmitting = ref(false);
|
||||
const roleId = ref<number>(0);
|
||||
const roleName = ref("");
|
||||
const menuList = ref<MenuItem[]>([]);
|
||||
@@ -148,13 +148,13 @@ function handleCancel() {
|
||||
|
||||
// 提交
|
||||
async function handleSubmit() {
|
||||
submitting.value = true;
|
||||
isSubmitting.value = true;
|
||||
try {
|
||||
await RoleAPI.updateRoleMenus(roleId.value, checkedKeys.value.map(Number));
|
||||
toast.success("保存成功");
|
||||
uni.navigateBack();
|
||||
} finally {
|
||||
submitting.value = false;
|
||||
isSubmitting.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@
|
||||
</wd-form>
|
||||
<view class="popup-actions">
|
||||
<wd-button type="info" plain @click="closeRoleDialog">取消</wd-button>
|
||||
<wd-button type="primary" :loading="submitting" @click="submitRoleForm">保存</wd-button>
|
||||
<wd-button type="primary" :loading="isSubmitting" @click="submitRoleForm">保存</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</wd-popup>
|
||||
@@ -120,7 +120,7 @@ const toast = useToast();
|
||||
const { messageBox } = useMessage();
|
||||
const loadMoreState = ref<LoadMoreState>("loading");
|
||||
const formRef = ref();
|
||||
const submitting = ref(false);
|
||||
const isSubmitting = ref(false);
|
||||
|
||||
const queryParams = reactive<RolePageQuery>({ pageNum: 1, pageSize: 10, keywords: "" });
|
||||
const total = ref(0);
|
||||
@@ -198,7 +198,7 @@ async function openRoleDialog(id?: number) {
|
||||
function submitRoleForm() {
|
||||
formRef.value.validate().then(({ valid }: { valid: boolean }) => {
|
||||
if (!valid) return;
|
||||
submitting.value = true;
|
||||
isSubmitting.value = true;
|
||||
const action = formData.id ? RoleAPI.update(formData.id, formData) : RoleAPI.add(formData);
|
||||
action
|
||||
.then(() => {
|
||||
@@ -207,7 +207,7 @@ function submitRoleForm() {
|
||||
loadRoleList();
|
||||
})
|
||||
.finally(() => {
|
||||
submitting.value = false;
|
||||
isSubmitting.value = false;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
>
|
||||
<!-- 主信息行 -->
|
||||
<view class="flex-start">
|
||||
<image class="user-card__avatar" :src="item.avatar" mode="aspectFill" />
|
||||
<image class="user-card__avatar" :src="item.avatar" mode="aspectFill" lazy-load />
|
||||
<view class="user-card__main">
|
||||
<view class="flex-start mt-12rpx">
|
||||
<text class="user-card__name">{{ item.nickname }}</text>
|
||||
@@ -149,7 +149,7 @@
|
||||
</wd-form>
|
||||
<view class="popup-actions">
|
||||
<wd-button type="info" plain @click="closeUserDialog">取消</wd-button>
|
||||
<wd-button type="primary" :loading="submitting" @click="submitUserForm">保存</wd-button>
|
||||
<wd-button type="primary" :loading="isSubmitting" @click="submitUserForm">保存</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</wd-popup>
|
||||
@@ -187,7 +187,7 @@
|
||||
<wd-button type="info" plain @click="resetPwdDialog.visible = false">取消</wd-button>
|
||||
<wd-button
|
||||
type="primary"
|
||||
:loading="resetPwdDialog.submitting"
|
||||
:loading="resetPwdDialog.isSubmitting"
|
||||
@click="handleResetPassword"
|
||||
>
|
||||
确认
|
||||
@@ -213,7 +213,7 @@ const { messageBox } = useMessage();
|
||||
const { closeOutside } = useQueue();
|
||||
const loadMoreState = ref<LoadMoreState>("loading");
|
||||
const formRef = ref();
|
||||
const submitting = ref(false);
|
||||
const isSubmitting = ref(false);
|
||||
|
||||
const sortValue = ref(0);
|
||||
const sortOptions = ref([
|
||||
@@ -394,7 +394,7 @@ async function openUserDialog(id?: number) {
|
||||
function submitUserForm() {
|
||||
formRef.value.validate().then(({ valid }: { valid: boolean }) => {
|
||||
if (!valid) return;
|
||||
submitting.value = true;
|
||||
isSubmitting.value = true;
|
||||
const action = formData.id ? UserAPI.update(formData.id, formData) : UserAPI.add(formData);
|
||||
action
|
||||
.then(() => {
|
||||
@@ -403,7 +403,7 @@ function submitUserForm() {
|
||||
loadUserList();
|
||||
})
|
||||
.finally(() => {
|
||||
submitting.value = false;
|
||||
isSubmitting.value = false;
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -421,7 +421,7 @@ const pendingAction = ref<Record<string, () => void>>({});
|
||||
|
||||
const resetPwdDialog = reactive({
|
||||
visible: false,
|
||||
submitting: false,
|
||||
isSubmitting: false,
|
||||
userId: undefined as number | undefined,
|
||||
});
|
||||
const resetPwdForm = reactive({ password: "" });
|
||||
@@ -493,7 +493,7 @@ async function handleResetPassword() {
|
||||
if (!valid || valid.valid === false) return;
|
||||
if (!resetPwdDialog.userId) return;
|
||||
|
||||
resetPwdDialog.submitting = true;
|
||||
resetPwdDialog.isSubmitting = true;
|
||||
try {
|
||||
await UserAPI.resetPassword(resetPwdDialog.userId, resetPwdForm.password);
|
||||
toast.success("密码重置成功");
|
||||
@@ -501,7 +501,7 @@ async function handleResetPassword() {
|
||||
} catch (error) {
|
||||
// API 已处理错误提示
|
||||
} finally {
|
||||
resetPwdDialog.submitting = false;
|
||||
resetPwdDialog.isSubmitting = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user