Skip to content

Commit 04b002c

Browse files
authored
feat: 更新layout、网络、图标库基建,优化首页布局 (#12)
* chore: 安装并配置ic与mdi图标库 * feat: 将网络配置中“一秒时长”的常变量导出 * feat: 将页面背景改回vant的灰色风格 * feat: 允许通过prop隐藏导航栏返回按钮 * feat: 为导航栏添加一个右侧内容的slot * feat: 优化首页布局,清理无效路由,在顶栏右侧添加搜索按钮 * fix: 修复CI错误 * fix: 修复导航栏右侧按钮点击热区问题 * fix: 改用更符合语义的emit事件名 * revert: 依据产品方案变化移除首页的搜索按钮 * fix: 修复vant命令式组件样式丢失BUG * fix: 补全缺失的导出项 * fix: 根据后端字段名调整更改网络基建 * fix: 为网络请求示例添加mutation进行态控制 * revert: 不再导出ONE_SECOND
2 parents 6d19def + a6b3a7d commit 04b002c

File tree

15 files changed

+140
-25
lines changed

15 files changed

+140
-25
lines changed

apps/admin/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
"preview": "vite preview"
1212
},
1313
"dependencies": {
14+
"@iconify-json/ic": "catalog:frontend",
15+
"@iconify-json/mdi": "catalog:frontend",
1416
"@tanstack/vue-query": "catalog:frontend",
1517
"@vueuse/core": "catalog:frontend",
1618
"api": "workspace:*",
@@ -36,6 +38,7 @@
3638
"type-fest": "catalog:types",
3739
"typescript": "catalog:infra",
3840
"unplugin-auto-import": "^21.0.0",
41+
"unplugin-icons": "catalog:infra",
3942
"unplugin-vue-components": "^31.0.0",
4043
"vite": "^7.3.1",
4144
"vue-tsc": "catalog:infra"

apps/admin/src/constants/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
export * from "./query-key";
22
export * from "./response-code";
3+
export * from "./ui";

apps/admin/src/layouts/default-layout/index.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
flex-direction: column;
44
height: 100svh;
55
overflow: hidden;
6-
background-color: #fff2ef;
6+
background-color: var(--van-background);
77

88
&__main {
99
flex: 1;

apps/admin/src/layouts/default-layout/index.vue

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,15 @@
33
<van-nav-bar
44
v-if="!isNil(navbarTitle)"
55
:title="navbarTitle"
6-
left-arrow
6+
:left-arrow="props.showBack"
77
class="default-layout__navbar"
88
@click-left="handleBackClick"
9-
/>
9+
@click-right="emit('clickNavbarRight')"
10+
>
11+
<template #right>
12+
<slot name="right" />
13+
</template>
14+
</van-nav-bar>
1015
<slot name="header" />
1116
<main class="default-layout__main">
1217
<slot />
@@ -36,13 +41,25 @@ interface DefaultLayoutProps {
3641
* @default true
3742
*/
3843
showNavbar?: boolean;
44+
/**
45+
* 是否显示返回上一页的按钮
46+
*
47+
* @default true
48+
*/
49+
showBack?: boolean;
3950
}
4051
4152
const props = withDefaults(defineProps<DefaultLayoutProps>(), {
4253
title: undefined,
43-
showNavbar: true
54+
showNavbar: true,
55+
showBack: true
4456
});
4557
58+
const emit = defineEmits<{
59+
/** 点击导航栏右侧插槽 */
60+
clickNavbarRight: [];
61+
}>();
62+
4663
useTitleMeta();
4764
4865
const router = useRouter();

apps/admin/src/main.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import "./global.scss";
2+
import "vant/es/toast/style";
3+
import "vant/es/dialog/style";
24

35
import { VueQueryPlugin } from "@tanstack/vue-query";
46
import dayjs from "dayjs";

apps/admin/src/pages/example/example-how-to-request.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<van-field v-model="account" label="账号"></van-field>
33
<van-field v-model="password" label="密码"></van-field>
4-
<van-button @click="handleLoginClick">登录</van-button>
4+
<van-button :loading="isPending" @click="handleLoginClick">登录</van-button>
55

66
<van-field v-model="userId" label="要查询的用户的ID"></van-field>
77
<van-button :loading="isFetching" @click="handleRefreshClick">刷新</van-button>
@@ -26,7 +26,7 @@ const account = ref("");
2626
/** 密码 */
2727
const password = ref("");
2828
// 登录(示例)(这里不用写jsdoc /** */,没效果)
29-
const { mutate: mutateLogin } = useMutation({
29+
const { mutate: mutateLogin, isPending } = useMutation({
3030
mutationFn: () =>
3131
walkAdminService.LoginExample({
3232
// 这个大括号就是请求参数。是body json还是query params取决于接口的定义(LoginExample)里面是data还是params
Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,46 @@
11
<template>
2-
<default-layout :show-navbar="false">
2+
<default-layout
3+
title="精弘毅行管理后台"
4+
:show-back="false"
5+
@click-navbar-right="handleSearchClick"
6+
>
37
<admin-info />
48
<section :class="styles.main">
59
<van-cell-group title="签到">
610
<van-cell title="扫码签到" is-link />
711
<van-cell title="输入签到" is-link />
812
</van-cell-group>
913

10-
<van-cell-group title="起终点人员管理">
11-
<van-cell title="单人登记" is-link />
14+
<van-cell-group title="数据大盘">
15+
<van-cell title="屏峰可视化地图" is-link />
16+
<van-cell title="莫干山可视化地图" is-link />
17+
<van-cell title="数据表格" is-link />
18+
</van-cell-group>
19+
20+
<van-cell-group title="人员管理">
1221
<van-cell title="重组队伍" is-link to="/team-rebuild" />
1322
<div :class="styles.functionButtonContainer">
14-
<van-button type="primary" plain :class="styles.functionButton" block>
23+
<van-button type="primary" :class="styles.functionButton" block>
1524
待出发→进行中
1625
</van-button>
17-
<van-button type="primary" plain :class="styles.functionButton" block>
18-
直接提交队伍
19-
</van-button>
2026
</div>
2127
</van-cell-group>
22-
23-
<van-cell-group title="数据大盘">
24-
<van-cell title="屏峰地图可视化" is-link />
25-
<van-cell title="莫干山地图可视化" is-link />
26-
<van-cell title="表格数据查看" is-link />
27-
</van-cell-group>
2828
</section>
2929
</default-layout>
3030
</template>
3131

3232
<script setup lang="ts">
33+
import { useRouter } from "vue-router";
34+
3335
import DefaultLayout from "@/layouts/default-layout/index.vue";
3436
3537
import AdminInfo from "./components/admin-info/index.vue";
3638
import styles from "./index.module.scss";
39+
40+
const router = useRouter();
41+
42+
/** 前往搜索页 */
43+
const handleSearchClick = () => {
44+
router.push("/team-list");
45+
};
3746
</script>

apps/admin/src/utils/service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ axiosInstance.interceptors.response.use(
1616
// TODO:请求错误全局处理
1717
default:
1818
}
19-
throw new RequestError(body.msg, body.code);
19+
throw new RequestError(body.message, body.code);
2020
}
2121
return response;
2222
},

apps/admin/tsconfig.app.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"extends": "@vue/tsconfig/tsconfig.dom.json",
33
"compilerOptions": {
44
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
5-
"types": ["vite/client"],
5+
"types": ["vite/client", "unplugin-icons/types/vue"],
66
"lib": ["ESNext", "DOM", "DOM.Iterable"],
77
"paths": {
88
"@/*": ["./src/*"]

apps/admin/types/components.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ declare module 'vue' {
1414
VanCell: typeof import('vant/es')['Cell']
1515
VanCellGroup: typeof import('vant/es')['CellGroup']
1616
VanConfigProvider: typeof import('vant/es')['ConfigProvider']
17+
VanIcon: typeof import('vant/es')['Icon']
1718
VanNavBar: typeof import('vant/es')['NavBar']
1819
}
1920
}

0 commit comments

Comments
 (0)