feat: first commit
This commit is contained in:
commit
8a85cf5b78
64 files changed
+7832
No files matched your search
@@ -0,0 +1,13 @@
|
||||
<script setup lang="ts">
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="background absolute w-full h-full top-0 left-0 z-[-1]"></div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.background {
|
||||
background: linear-gradient(57deg, var(--td-bg-color-component) 23.27%, var(--td-brand-color) 89.08%);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,73 @@
|
||||
<script setup lang="ts">
|
||||
import Background from '@/pages/common/components/Background.vue'
|
||||
import Copyright from '@/components/Copyright.vue'
|
||||
import { LockOnIcon, UserIcon } from 'tdesign-icons-vue-next'
|
||||
import { reactive, ref } from 'vue'
|
||||
import type { CreateTokenRequest } from '@/model/token'
|
||||
import { MessagePlugin } from 'tdesign-vue-next'
|
||||
import { useAppStore } from '@/stores/app'
|
||||
|
||||
const loginForm = reactive<CreateTokenRequest>({
|
||||
password: '',
|
||||
email: ''
|
||||
})
|
||||
|
||||
const canRegister = ref(false)
|
||||
|
||||
const loading = ref(false)
|
||||
const appStore = useAppStore()
|
||||
|
||||
const handleLogin = async () => {
|
||||
if (!loginForm.email || !loginForm.password) {
|
||||
MessagePlugin.error('用户名或密码不能为空')
|
||||
return
|
||||
}
|
||||
try {
|
||||
await appStore.login(loginForm)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="w-[100vw] h-[100vh] px-20 flex items-center">
|
||||
<Background></Background>
|
||||
<div class="w-[400px]">
|
||||
<div class="text-4xl font-bold mb-12">欢迎到<br />Yili Admin</div>
|
||||
<div class="mb-12 flex items-center gap-2" v-if="canRegister">
|
||||
买有账号?<TLink>注册新账号</TLink>
|
||||
</div>
|
||||
<div class="flex flex-col gap-6 mb-11">
|
||||
<TInput size="large" placeholder="用户名/邮箱" v-model="loginForm.email" clearable >
|
||||
<template #prefix-icon>
|
||||
<UserIcon></UserIcon>
|
||||
</template>
|
||||
</TInput>
|
||||
<TInput
|
||||
size="large"
|
||||
placeholder="密码"
|
||||
type="password"
|
||||
v-model="loginForm.password"
|
||||
clearable
|
||||
@enter="handleLogin"
|
||||
>
|
||||
<template #prefix-icon>
|
||||
<LockOnIcon></LockOnIcon>
|
||||
</template>
|
||||
</TInput>
|
||||
<div class="flex justify-between items-center">
|
||||
<TCheckbox>记住账号</TCheckbox>
|
||||
<TLink>忘记密码?</TLink>
|
||||
</div>
|
||||
</div>
|
||||
<TButton size="large" :block="true" @click="handleLogin" :loading="loading">
|
||||
{{ loading ? '登录中' : '登录' }}
|
||||
</TButton>
|
||||
<Copyright />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped></style>
|
||||
@@ -0,0 +1,46 @@
|
||||
<script setup lang="ts">
|
||||
import { uploadFile } from '@/api/file'
|
||||
import { ref, watch } from 'vue'
|
||||
import type { UploadFile } from 'tdesign-vue-next'
|
||||
|
||||
// 接收 props
|
||||
const props = defineProps<{
|
||||
modelValue: string
|
||||
}>()
|
||||
|
||||
// 定义 emit
|
||||
const emit = defineEmits<{
|
||||
'update:modelValue': [string | undefined]
|
||||
}>()
|
||||
|
||||
// 初始化 fileList,根据 props.modalValue 来判断
|
||||
const fileList = ref<UploadFile[]>(props.modelValue ? [{ url: props.modelValue }] : [])
|
||||
|
||||
// 监听 fileList 的变化,并深度监听
|
||||
watch(fileList, () => {
|
||||
// 确保 fileList 不为空,并且有文件
|
||||
if (fileList.value.length > 0 && fileList.value[0].url) {
|
||||
emit('update:modelValue', fileList.value[0].url)
|
||||
} else {
|
||||
emit('update:modelValue', undefined) // 如果没有文件,发送 undefined
|
||||
}
|
||||
}, { deep: true })
|
||||
|
||||
watch(() => props.modelValue, (value) => {
|
||||
if (value) {
|
||||
fileList.value = [{ url: value }]
|
||||
} else {
|
||||
fileList.value = []
|
||||
}
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<TUpload theme="image" accept="image/jpeg,image/png" :request-method="uploadFile" v-model="fileList">
|
||||
</TUpload>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,26 @@
|
||||
<script setup lang="ts">
|
||||
import { UserIcon } from 'tdesign-icons-vue-next'
|
||||
|
||||
defineProps<{
|
||||
title: string
|
||||
number: number | string
|
||||
color: string
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
class="w-full p-4 bg-white rounded-lg flex gap-4 items-center cursor-pointer shadow-md hover:bg-[var(--bg-color)] hover:text-white transition-all"
|
||||
:style="`--bg-color: ${color}`"
|
||||
>
|
||||
<slot name="icon">
|
||||
<UserIcon size="64"></UserIcon>
|
||||
</slot>
|
||||
<div class="flex-1 flex flex-col gap-2 items-end">
|
||||
<div class="text-xl font-bold">{{ title }}</div>
|
||||
<div class="text-3xl font-bold">{{ number }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped></style>
|
||||
@@ -0,0 +1,48 @@
|
||||
<script setup lang="ts">
|
||||
import InfoCard from '@/pages/dashboard/components/InfoCard.vue'
|
||||
import { MoneyIcon, ServiceIcon, TaskIcon, UserIcon } from 'tdesign-icons-vue-next'
|
||||
import { getDashboardOverview } from '@/api/dashboard'
|
||||
import { onMounted, ref } from 'vue'
|
||||
import type { DashboardOverview } from '@/model/dashboard'
|
||||
|
||||
const data = ref<DashboardOverview>({
|
||||
contactCount: 0,
|
||||
orderCount: 0,
|
||||
totalAmount: 0,
|
||||
totalVisitor: 0
|
||||
})
|
||||
const fetchData = async () => {
|
||||
data.value = await getDashboardOverview()
|
||||
}
|
||||
|
||||
onMounted(fetchData)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="w-full h-full">
|
||||
<div class="grid grid-cols-4 gap-8">
|
||||
<InfoCard title="今日登录用户" :number="data.totalVisitor" color="#40c9c6">
|
||||
<template #icon>
|
||||
<UserIcon size="64"></UserIcon>
|
||||
</template>
|
||||
</InfoCard>
|
||||
<InfoCard title="今日订单总数" :number="data.orderCount" color="#36a3f7">
|
||||
<template #icon>
|
||||
<TaskIcon size="64"></TaskIcon>
|
||||
</template>
|
||||
</InfoCard>
|
||||
<InfoCard title="交易总额" :number="data.totalAmount + '元'" color="#f4516c">
|
||||
<template #icon>
|
||||
<MoneyIcon size="64"></MoneyIcon>
|
||||
</template>
|
||||
</InfoCard>
|
||||
<InfoCard title="联系客服数量" :number="data.contactCount" color="#34bfa3">
|
||||
<template #icon>
|
||||
<ServiceIcon size="64"></ServiceIcon>
|
||||
</template>
|
||||
</InfoCard>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped></style>
|
||||
@@ -0,0 +1,72 @@
|
||||
<script setup lang="ts">
|
||||
import type { User } from '@/model/user'
|
||||
import { computed, onMounted, ref, watch } from 'vue'
|
||||
import type { Role } from '@/model/role'
|
||||
import { setUserRoles } from '@/api/user'
|
||||
import { MessagePlugin } from 'tdesign-vue-next'
|
||||
|
||||
const props = defineProps<{
|
||||
user: (User | null)
|
||||
}>()
|
||||
|
||||
|
||||
const roles = ref<string[]>([])
|
||||
|
||||
watch(() => props.user, (user) => {
|
||||
if (user) {
|
||||
roles.value = user.roles.map(role => role.name)
|
||||
}
|
||||
})
|
||||
|
||||
const allRoles = ref<Role[]>()
|
||||
|
||||
const fetchAllRoles = async () => {
|
||||
|
||||
|
||||
}
|
||||
|
||||
onMounted(fetchAllRoles)
|
||||
|
||||
const options = computed(() => {
|
||||
return allRoles.value?.map(role => {
|
||||
return {
|
||||
label: role.label,
|
||||
value: role.name
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
const emit = defineEmits<{
|
||||
success: [void],
|
||||
cancel: [void]
|
||||
}>()
|
||||
|
||||
const handleConfirm = async () => {
|
||||
await setUserRoles(props.user!.id, roles.value)
|
||||
MessagePlugin.success('设置成功')
|
||||
emit('success')
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<TDialog>
|
||||
<TForm v-if="user">
|
||||
<TFormItem label="用户">
|
||||
<div>{{ user.name }}</div>
|
||||
</TFormItem>
|
||||
<TFormItem label="角色">
|
||||
<TSelect v-model="roles" :options="options" multiple></TSelect>
|
||||
</TFormItem>
|
||||
</TForm>
|
||||
<template #footer>
|
||||
<TSpace>
|
||||
<TButton @click="handleConfirm">确定</TButton>
|
||||
<TButton theme="default" @click="() => emit('cancel')">取消</TButton>
|
||||
</TSpace>
|
||||
</template>
|
||||
</TDialog>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,135 @@
|
||||
<script setup lang="ts">
|
||||
|
||||
import RegularPage from '@/components/RegularPage.vue'
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { useSearchable } from '@/composables/useSearchable'
|
||||
import type { User, UserSearchFilter } from '@/model/user'
|
||||
import { searchUsers } from '@/api/user'
|
||||
import type { BaseTableColumns } from 'tdesign-vue-next'
|
||||
import RoleSettingDialog from '@/pages/user/components/RoleSettingDialog.vue'
|
||||
|
||||
|
||||
const {
|
||||
data,
|
||||
loading,
|
||||
pagination,
|
||||
onPageChange,
|
||||
fetchData
|
||||
} = useSearchable<UserSearchFilter, User>(searchUsers)
|
||||
|
||||
const columns: BaseTableColumns = [
|
||||
{
|
||||
title: '用户编号',
|
||||
colKey: 'id',
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
title: '用户名',
|
||||
colKey: 'name',
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
title: '角色',
|
||||
colKey: 'roles',
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
colKey: 'operation',
|
||||
width: 100,
|
||||
},
|
||||
]
|
||||
|
||||
onMounted(fetchData)
|
||||
|
||||
const roleSettingDialogVisible = ref(false)
|
||||
|
||||
const selectUser = ref<User | null>(null)
|
||||
|
||||
const showRoleSettingDialog = (user: User) => {
|
||||
selectUser.value = user
|
||||
roleSettingDialogVisible.value = true
|
||||
}
|
||||
|
||||
const handleRoleSettingSuccess = () => {
|
||||
fetchData()
|
||||
roleSettingDialogVisible.value = false
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<RegularPage title="用户管理">
|
||||
<template #action-area>
|
||||
<TButton>创建用户</TButton>
|
||||
</template>
|
||||
<template #search-area>
|
||||
<TForm label-align="left" label-width="80px">
|
||||
<TRow :gutter="[64, 32]">
|
||||
<TCol :span="3">
|
||||
<TFormItem label="用户编号">
|
||||
<TInput placeholder="请输入需要搜索的用户姓名"></TInput>
|
||||
</TFormItem>
|
||||
</TCol>
|
||||
<TCol :span="3">
|
||||
<TFormItem label="用户名">
|
||||
<TInput placeholder="请输入需要搜索的用户姓名"></TInput>
|
||||
</TFormItem>
|
||||
</TCol>
|
||||
<TCol :span="3">
|
||||
<TFormItem label="手机号码">
|
||||
<TInput placeholder="请输入需要搜索的用户姓名"></TInput>
|
||||
</TFormItem>
|
||||
</TCol>
|
||||
<TCol :span="3">
|
||||
<TFormItem label="手机号码">
|
||||
<TInput placeholder="请输入需要搜索的用户姓名"></TInput>
|
||||
</TFormItem>
|
||||
</TCol>
|
||||
<TCol :span="3">
|
||||
<TFormItem label="角色">
|
||||
<TSelect placeholder="请选择角色"></TSelect>
|
||||
</TFormItem>
|
||||
</TCol>
|
||||
<TCol :span="3">
|
||||
<TFormItem label="平台">
|
||||
<TSelect placeholder="请选择平台"></TSelect>
|
||||
</TFormItem>
|
||||
</TCol>
|
||||
<TCol :span="3">
|
||||
<TSpace>
|
||||
<TButton>搜索</TButton>
|
||||
<TButton theme="default">重置</TButton>
|
||||
</TSpace>
|
||||
</TCol>
|
||||
</TRow>
|
||||
</TForm>
|
||||
</template>
|
||||
<TTable
|
||||
:loading="loading"
|
||||
row-key="index"
|
||||
:data="data"
|
||||
:columns="columns"
|
||||
cell-empty-content="-"
|
||||
:pagination="{ total: pagination.total, current: pagination.page, pageSize: pagination.size, onChange: onPageChange }"
|
||||
|
||||
>
|
||||
<template #roles="{row}">
|
||||
<TSpace>
|
||||
<TTag v-for="role in row.roles" :key="role.id" theme="success" variant="light">{{ role.label }}</TTag>
|
||||
</TSpace>
|
||||
</template>
|
||||
<template #operation="{row}">
|
||||
<TSpace :size="1">
|
||||
<TButton variant="text" size="small" theme="primary">编辑</TButton>
|
||||
<TButton variant="text" size="small" theme="primary">设置平台</TButton>
|
||||
<TButton variant="text" size="small" theme="primary" @click="() => showRoleSettingDialog(row)">设置角色</TButton>
|
||||
</TSpace>
|
||||
</template>
|
||||
</TTable>
|
||||
<RoleSettingDialog v-model:visible="roleSettingDialogVisible" :user="selectUser" @cancel="roleSettingDialogVisible = false" @success="handleRoleSettingSuccess"></RoleSettingDialog>
|
||||
</RegularPage>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
Reference in new issue
Block a user