diff --git a/src/interceptors/route.ts b/src/interceptors/route.ts
index 6b61f5da8efbe08be738320646bff1c40e6e5eee..f67588e7fee382dd053988f791924d85c1888327 100644
--- a/src/interceptors/route.ts
+++ b/src/interceptors/route.ts
@@ -41,6 +41,7 @@ const navigateToInterceptor = {
// 注意,这里的url是 '/' 开头的,如 '/pages/index/index',跟 'pages.json' 里面的 path 不同
// 拦截前触发
async invoke(option) {
+ // debugger
const { url } = option
console.log('navigateToInterceptor invoke')
// console.log(url) // /pages/route-interceptor/index?name=feige&age=30
@@ -87,7 +88,7 @@ const navigateToInterceptor = {
} else {
// 当前页面需要登录,但是获取不到token,这个时候跳转到登录页面
uni.navigateTo({ url: '/pages/login/index' })
- return option
+ // return option
}
}
}
@@ -97,5 +98,7 @@ export const routeInterceptor = {
uni.addInterceptor('navigateTo', navigateToInterceptor)
uni.addInterceptor('reLaunch', navigateToInterceptor)
uni.addInterceptor('redirectTo', navigateToInterceptor)
+ uni.addInterceptor('switchTab', navigateToInterceptor)
+ uni.addInterceptor('navigateBack', navigateToInterceptor)
}
}
diff --git a/src/main.ts b/src/main.ts
index 8e4466ec8c5e204123a3111080e1607715b61cb2..87c1cb1f85a03a9585e79a07d6b87fd3c621b4f3 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -1,7 +1,12 @@
import { createSSRApp } from 'vue'
import App from './App.vue'
import store from './store'
-import { routeInterceptor, requestInterceptor, prototypeInterceptor } from './interceptors'
+import {
+ routeInterceptor,
+ requestInterceptor,
+ prototypeInterceptor
+} from './interceptors'
+import './utils/mockExtend'
import 'virtual:uno.css'
import '@/style/index.scss'
@@ -12,6 +17,6 @@ export function createApp() {
app.use(requestInterceptor)
app.use(prototypeInterceptor)
return {
- app,
+ app
}
}
diff --git a/src/pages.json b/src/pages.json
index 45baa8f9014e910c1d7a9499c88e00e02f762186..03729c9cda7ffb6bbd788d9319e0c4e3803d3a13 100644
--- a/src/pages.json
+++ b/src/pages.json
@@ -163,6 +163,14 @@
"path": "pages/role/show",
"type": "page"
},
+ {
+ "path": "pages/user/index",
+ "type": "page",
+ "layout": "default",
+ "style": {
+ "navigationBarTitleText": "用户管理"
+ }
+ },
{
"path": "pages/colab/detail/index",
"type": "page",
@@ -201,20 +209,6 @@
"style": {
"navigationBarTitleText": "系统设置"
}
- },
- {
- "path": "pages/task/components/ApprovePage",
- "type": "page",
- "style": {
- "navigationBarTitleText": "同意"
- }
- },
- {
- "path": "pages/task/components/RejectPage",
- "type": "page",
- "style": {
- "navigationBarTitleText": "拒绝"
- }
}
],
"subPackages": []
diff --git a/src/pages/user/index.vue b/src/pages/user/index.vue
new file mode 100644
index 0000000000000000000000000000000000000000..e014dc8ead5d8d3e4d3f674440b21c6863118e49
--- /dev/null
+++ b/src/pages/user/index.vue
@@ -0,0 +1,98 @@
+
+{
+ layout: 'default',
+ style: {
+ navigationBarTitleText: '用户管理'
+ }
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 编辑
+ 删除
+
+
+
+
+
+
+
+
+
+
diff --git a/src/pages/work/index.vue b/src/pages/work/index.vue
index ac664e6cc570d3c4ee873b981bf889fe09c3740d..fe91552c2874d43c3fef3c7a086c34a2cd5e89ef 100644
--- a/src/pages/work/index.vue
+++ b/src/pages/work/index.vue
@@ -3,8 +3,8 @@
{
layout: 'tabbar',
style: {
- navigationBarTitleText: '工作台',
- },
+ navigationBarTitleText: '工作台'
+ }
}
@@ -15,7 +15,7 @@
@focus="searchFocus"
@blur="searchBlur"
@search="search"
- maxlength="10"
+ :maxlength="10"
hide-cancel
light
/>
@@ -24,8 +24,16 @@
系统管理
-
-
+
+
@@ -33,17 +41,17 @@
diff --git a/src/service/user/UserApi.ts b/src/service/user/UserApi.ts
new file mode 100644
index 0000000000000000000000000000000000000000..0fa780578fb2b0c01f9d9cbb1db8feae855bfc7b
--- /dev/null
+++ b/src/service/user/UserApi.ts
@@ -0,0 +1,146 @@
+import { httpGet, httpPost } from '@/utils/http'
+import Mock from 'mockjs'
+
+export interface UserVO {
+ id: number
+ avatar: string
+ username: string
+ job: string
+ tel: string
+ email: string
+ deptInfo: string
+ // code: string
+ // sort: number
+ // data_scope: string
+ // data_scope_dept_ids: string
+ // status: number
+ // type: number
+ // remark: string
+ // createTime: string
+}
+
+const useMock = import.meta.env.VITE_USE_MOCK === 'true'
+
+// 模拟数据类型是数组
+const mockConfig = (type = 'array') => {
+ if (type === 'array') {
+ return {
+ 'data|10': [
+ {
+ 'id|+1': 1,
+ avatar: 'https://picsum.photos/150/150?random=1',
+ username: '@cname',
+ job: '前端开发',
+ tel: '@phone',
+ email: '@email',
+ deptInfo: '研发部',
+
+ code: '@word',
+ 'sort|1-100': 1,
+ data_scope: '@word',
+ data_scope_dept_ids: '@word',
+ 'status|1-2': 1,
+ 'type|1-2': '@word',
+ remark: '@sentence',
+ createTime: '@datetime'
+ }
+ ]
+ }
+ } else {
+ return {
+ data: {
+ id: 1,
+ name: '@name',
+ code: '@word',
+ 'sort|1-100': 1,
+ data_scope: '@word',
+ data_scope_dept_ids: '@word',
+ 'status|1-2': 1,
+ 'type|1-2': '@word',
+ remark: '@sentence',
+ createTime: '@datetime'
+ }
+ }
+ }
+}
+
+/*
+ *@Description: 获取用户列表
+ *@MethodAuthor: xiaohong
+ *@Date: 2024-11-27 18:48:44
+ */
+export const getList = (
+ query?: object
+): Promise<{ data: UserVO[]; total: number }> => {
+ if (useMock) {
+ return new Promise((resolve) => {
+ const data = Mock.mock(mockConfig('array'))
+ setTimeout(() => {
+ resolve({ data: data.data, total: 30 })
+ }, 2000)
+ })
+ } else {
+ return httpGet('/system/user/page', query)
+ }
+}
+/*
+ *@Description: 获取用户信息
+ *@MethodAuthor: xiaohong
+ *@Date: 2024-11-27 18:49:19
+ */
+export const getInfo = (id: number): Promise<{ data: UserVO }> => {
+ if (useMock) {
+ return new Promise((resolve) => {
+ const data = Mock.mock(mockConfig('object'))
+ resolve({ data: data.data })
+ })
+ } else {
+ return httpGet<{ data: UserVO }>('/system/user/get?id=' + id)
+ }
+}
+
+/*
+ *@Description: 新增用户
+ *@MethodAuthor: xiaohong
+ *@Date: 2024-11-27 18:49:30
+ */
+export const createUser = (data: object) => {
+ if (useMock) {
+ return new Promise((resolve) => {
+ const data = Mock.mock(mockConfig('object'))
+ resolve({ data: data.data })
+ })
+ } else {
+ return httpPost('/system/user/create', data)
+ }
+}
+/*
+ *@Description: 更新用户信息
+ *@MethodAuthor: xiaohong
+ *@Date: 2024-11-27 18:49:40
+ */
+export const updateUser = (data: object) => {
+ if (useMock) {
+ return new Promise((resolve) => {
+ const data = Mock.mock(mockConfig('object'))
+ resolve({ data: data.data })
+ })
+ } else {
+ return httpPost('/system/user/update', data)
+ }
+}
+
+/*
+ *@Description: 删除用户
+ *@MethodAuthor: xiaohong
+ *@Date: 2024-11-27 18:49:50
+ */
+export const deleteUser = (id: number) => {
+ if (useMock) {
+ return new Promise((resolve) => {
+ resolve({ data: null, code: 200, msg: '删除成功' })
+ })
+ } else {
+ return httpPost('/system/user/delete' + { id })
+ }
+}
diff --git a/src/types/auto-import.d.ts b/src/types/auto-import.d.ts
index 255cb5bea51b9d225f751de2359909feda8eeb3b..b5c1bff877f014e494ae747f7294a66d162849e9 100644
--- a/src/types/auto-import.d.ts
+++ b/src/types/auto-import.d.ts
@@ -94,7 +94,7 @@ declare global {
// for type re-export
declare global {
// @ts-ignore
- export type { Component, ComponentPublicInstance, ComputedRef, ExtractDefaultPropTypes, ExtractPropTypes, ExtractPublicPropTypes, InjectionKey, PropType, Ref, VNode, WritableComputedRef } from 'vue'
+ export type { Component, ComponentPublicInstance, ComputedRef, DirectiveBinding, ExtractDefaultPropTypes, ExtractPropTypes, ExtractPublicPropTypes, InjectionKey, PropType, Ref, MaybeRef, MaybeRefOrGetter, VNode, WritableComputedRef } from 'vue'
import('vue')
}
// for vue template auto import
@@ -156,6 +156,7 @@ declare module 'vue' {
readonly onUnload: UnwrapRef
readonly onUnmounted: UnwrapRef
readonly onUpdated: UnwrapRef
+ readonly onWatcherCleanup: UnwrapRef
readonly provide: UnwrapRef
readonly reactive: UnwrapRef
readonly readonly: UnwrapRef
@@ -173,91 +174,11 @@ declare module 'vue' {
readonly useAttrs: UnwrapRef
readonly useCssModule: UnwrapRef
readonly useCssVars: UnwrapRef
+ readonly useId: UnwrapRef
+ readonly useModel: UnwrapRef
readonly useRequest: UnwrapRef
readonly useSlots: UnwrapRef
- readonly useUpload: UnwrapRef
- readonly watch: UnwrapRef
- readonly watchEffect: UnwrapRef
- readonly watchPostEffect: UnwrapRef
- readonly watchSyncEffect: UnwrapRef
- }
-}
-declare module '@vue/runtime-core' {
- interface GlobalComponents {}
- interface ComponentCustomProperties {
- readonly EffectScope: UnwrapRef
- readonly computed: UnwrapRef
- readonly createApp: UnwrapRef
- readonly customRef: UnwrapRef
- readonly defineAsyncComponent: UnwrapRef
- readonly defineComponent: UnwrapRef
- readonly effectScope: UnwrapRef
- readonly getCurrentInstance: UnwrapRef
- readonly getCurrentScope: UnwrapRef
- readonly h: UnwrapRef
- readonly inject: UnwrapRef
- readonly isProxy: UnwrapRef
- readonly isReactive: UnwrapRef
- readonly isReadonly: UnwrapRef
- readonly isRef: UnwrapRef
- readonly markRaw: UnwrapRef
- readonly nextTick: UnwrapRef
- readonly onActivated: UnwrapRef
- readonly onAddToFavorites: UnwrapRef
- readonly onBackPress: UnwrapRef
- readonly onBeforeMount: UnwrapRef
- readonly onBeforeUnmount: UnwrapRef
- readonly onBeforeUpdate: UnwrapRef
- readonly onDeactivated: UnwrapRef
- readonly onError: UnwrapRef
- readonly onErrorCaptured: UnwrapRef
- readonly onHide: UnwrapRef
- readonly onLaunch: UnwrapRef
- readonly onLoad: UnwrapRef
- readonly onMounted: UnwrapRef
- readonly onNavigationBarButtonTap: UnwrapRef
- readonly onNavigationBarSearchInputChanged: UnwrapRef
- readonly onNavigationBarSearchInputClicked: UnwrapRef
- readonly onNavigationBarSearchInputConfirmed: UnwrapRef
- readonly onNavigationBarSearchInputFocusChanged: UnwrapRef
- readonly onPageNotFound: UnwrapRef
- readonly onPageScroll: UnwrapRef
- readonly onPullDownRefresh: UnwrapRef
- readonly onReachBottom: UnwrapRef
- readonly onReady: UnwrapRef
- readonly onRenderTracked: UnwrapRef
- readonly onRenderTriggered: UnwrapRef
- readonly onResize: UnwrapRef
- readonly onScopeDispose: UnwrapRef
- readonly onServerPrefetch: UnwrapRef
- readonly onShareAppMessage: UnwrapRef
- readonly onShareTimeline: UnwrapRef
- readonly onShow: UnwrapRef
- readonly onTabItemTap: UnwrapRef
- readonly onThemeChange: UnwrapRef
- readonly onUnhandledRejection: UnwrapRef
- readonly onUnload: UnwrapRef
- readonly onUnmounted: UnwrapRef
- readonly onUpdated: UnwrapRef
- readonly provide: UnwrapRef
- readonly reactive: UnwrapRef
- readonly readonly: UnwrapRef
- readonly ref: UnwrapRef
- readonly resolveComponent: UnwrapRef
- readonly shallowReactive: UnwrapRef
- readonly shallowReadonly: UnwrapRef
- readonly shallowRef: UnwrapRef
- readonly toRaw: UnwrapRef
- readonly toRef: UnwrapRef
- readonly toRefs: UnwrapRef
- readonly toValue: UnwrapRef
- readonly triggerRef: UnwrapRef
- readonly unref: UnwrapRef
- readonly useAttrs: UnwrapRef
- readonly useCssModule: UnwrapRef
- readonly useCssVars: UnwrapRef
- readonly useRequest: UnwrapRef
- readonly useSlots: UnwrapRef
+ readonly useTemplateRef: UnwrapRef
readonly useUpload: UnwrapRef
readonly watch: UnwrapRef
readonly watchEffect: UnwrapRef
diff --git a/src/types/uni-pages.d.ts b/src/types/uni-pages.d.ts
index 129422bbe24d97518fc6be1733d8c0ce4e761e21..08b9b57a4a79d673bf5744452525706973e8ad98 100644
--- a/src/types/uni-pages.d.ts
+++ b/src/types/uni-pages.d.ts
@@ -19,6 +19,7 @@ interface NavigateToOptions {
"/pages/role/edit" |
"/pages/role/index" |
"/pages/role/show" |
+ "/pages/user/index" |
"/pages/colab/detail/index" |
"/pages/my/contact-service/index" |
"/pages/my/helper/index" |
diff --git a/src/utils/index.ts b/src/utils/index.ts
index 2429634ab59e98c684ea322c0290772a88e9dde8..53a3d874f40458367999f02d67cb287e7ee41528 100644
--- a/src/utils/index.ts
+++ b/src/utils/index.ts
@@ -1,6 +1,6 @@
import { pages, subPackages, tabBar } from '@/pages.json'
import { isMp } from './platform'
-import {debug} from '@uni-helper/vite-plugin-uni-pages';
+import { debug } from '@uni-helper/vite-plugin-uni-pages'
const getLastPage = () => {
// getCurrentPages() 至少有1个元素,所以不再额外判断
@@ -82,7 +82,10 @@ export const getAllPages = (key = 'needLogin') => {
// 这里处理主包
const mainPages = [
...pages
- .filter((page) => page[key] || !!key)
+ .filter((page) => {
+ if (page.path.includes('login')) return false
+ return !!key || page[key]
+ })
.map((page) => ({
...page,
path: `/${page.path}`
@@ -95,7 +98,10 @@ export const getAllPages = (key = 'needLogin') => {
const { root } = subPageObj
subPageObj.pages
- .filter((page) => page[key] || !!key)
+ .filter((page) => {
+ if (page.path.includes('login')) return false
+ return !!key || page[key]
+ })
.forEach((page: { path: string } & Record) => {
subPages.push({
...page,
diff --git a/src/utils/mockExtend.ts b/src/utils/mockExtend.ts
new file mode 100644
index 0000000000000000000000000000000000000000..e601e4dde98e9007434a960e8a7efae20ef7fdbe
--- /dev/null
+++ b/src/utils/mockExtend.ts
@@ -0,0 +1,8 @@
+import Mock from 'mockjs'
+
+Mock.Random.extend({
+ phone: function () {
+ const phonePrefix = ['135', '157', '181']
+ return this.pick(phonePrefix) + Mock.mock(/\d{8}/)
+ }
+})