feat: first commit

This commit is contained in:
ilhamtahir committed 2024-11-15 07:13:25 +08:00
commit 8a85cf5b78
64 files changed
+7832

No files matched your search

+3
View File
@@ -0,0 +1,3 @@
VITE_ENABLE_MOCK=false
VITE_API_PREFIX=/api
VITE_PROXY_ENDPOINT=http://localhost:8000
+1
View File
@@ -0,0 +1 @@
VITE_ENABLE_MOCK=true
+1
View File
@@ -0,0 +1 @@
VITE_ENABLE_MOCK=true
+18
View File
@@ -0,0 +1,18 @@
/* eslint-env node */
require('@rushstack/eslint-patch/modern-module-resolution')
module.exports = {
root: true,
'extends': [
'plugin:vue/vue3-essential',
'eslint:recommended',
'@vue/eslint-config-typescript',
'@vue/eslint-config-prettier/skip-formatting'
],
parserOptions: {
ecmaVersion: 'latest'
},
rules: {
"vue/multi-word-component-names": "off"
}
}
+31
View File
@@ -0,0 +1,31 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
.DS_Store
dist
dist-ssr
coverage
*.local
/cypress/videos/
/cypress/screenshots/
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
*.tsbuildinfo
dist.tar.gz
+8
View File
@@ -0,0 +1,8 @@
{
"$schema": "https://json.schemastore.org/prettierrc",
"semi": false,
"tabWidth": 2,
"singleQuote": true,
"printWidth": 100,
"trailingComma": "none"
}
+7
View File
@@ -0,0 +1,7 @@
{
"recommendations": [
"Vue.volar",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode"
]
}
+13
View File
@@ -0,0 +1,13 @@
# build stage
FROM node:lts-alpine as build-stage
WORKDIR /app
COPY package*.json ./
RUN npm config set registry https://registry.npm.taobao.org && npm install
COPY . .
RUN npm run build
# production stage
FROM nginx:stable-alpine as production-stage
COPY --from=build-stage /app/dist /usr/share/nginx/html
EXPOSE 8080
CMD ["nginx", "-g", "daemon off;"]
+11
View File
@@ -0,0 +1,11 @@
# yili-admin
一个致力于做简单的中后台框架
## 功能规划
- [ ] 登录
- [ ] 用户管理
- [ ] 角色管理
- [ ] 系统设置
+10
View File
@@ -0,0 +1,10 @@
/* eslint-disable */
/* prettier-ignore */
// @ts-nocheck
// noinspection JSUnusedGlobalSymbols
// Generated by unplugin-auto-import
// biome-ignore lint: disable
export {}
declare global {
}
+50
View File
@@ -0,0 +1,50 @@
/* eslint-disable */
// @ts-nocheck
// Generated by unplugin-vue-components
// Read more: https://github.com/vuejs/core/pull/3399
export {}
/* prettier-ignore */
declare module 'vue' {
export interface GlobalComponents {
Copyright: typeof import('./src/components/Copyright.vue')['default']
Device: typeof import('./src/components/Device.vue')['default']
RegularPage: typeof import('./src/components/RegularPage.vue')['default']
RouterLink: typeof import('vue-router')['RouterLink']
RouterView: typeof import('vue-router')['RouterView']
TAside: typeof import('tdesign-vue-next')['Aside']
TAvatar: typeof import('tdesign-vue-next')['Avatar']
TButton: typeof import('tdesign-vue-next')['Button']
TCard: typeof import('tdesign-vue-next')['Card']
TCheckbox: typeof import('tdesign-vue-next')['Checkbox']
TCol: typeof import('tdesign-vue-next')['Col']
TDialog: typeof import('tdesign-vue-next')['Dialog']
TDropdown: typeof import('tdesign-vue-next')['Dropdown']
TForm: typeof import('tdesign-vue-next')['Form']
TFormItem: typeof import('tdesign-vue-next')['FormItem']
THeader: typeof import('tdesign-vue-next')['Header']
THeadMenu: typeof import('tdesign-vue-next')['HeadMenu']
TIcon: typeof import('tdesign-vue-next')['Icon']
TImage: typeof import('tdesign-vue-next')['Image']
TImageViewer: typeof import('tdesign-vue-next')['ImageViewer']
TInput: typeof import('tdesign-vue-next')['Input']
TInputNumber: typeof import('tdesign-vue-next')['InputNumber']
TipTap: typeof import('./src/components/TipTap.vue')['default']
TLayout: typeof import('tdesign-vue-next')['Layout']
TLink: typeof import('tdesign-vue-next')['Link']
TMenu: typeof import('tdesign-vue-next')['Menu']
TMenuItem: typeof import('tdesign-vue-next')['MenuItem']
TPagination: typeof import('tdesign-vue-next')['Pagination']
TPopconfirm: typeof import('tdesign-vue-next')['Popconfirm']
TRow: typeof import('tdesign-vue-next')['Row']
TSelect: typeof import('tdesign-vue-next')['Select']
TSpace: typeof import('tdesign-vue-next')['Space']
TSwitch: typeof import('tdesign-vue-next')['Switch']
TTable: typeof import('tdesign-vue-next')['Table']
TTag: typeof import('tdesign-vue-next')['Tag']
TTagInput: typeof import('tdesign-vue-next')['TagInput']
TTextarea: typeof import('tdesign-vue-next')['Textarea']
TTree: typeof import('tdesign-vue-next')['Tree']
TUpload: typeof import('tdesign-vue-next')['Upload']
}
}
Vendored
+1
View File
@@ -0,0 +1 @@
/// <reference types="vite/client" />
+13
View File
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="icon" href="/favicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Yili Admin</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>
+58
View File
@@ -0,0 +1,58 @@
{
"name": "yili-admin",
"version": "0.0.0",
"private": true,
"type": "module",
"scripts": {
"dev": "vite",
"build": "run-p type-check \"build-only {@}\" --",
"preview": "vite preview",
"test:unit": "vitest",
"build-only": "vite build",
"type-check": "vue-tsc --build --force",
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
"format": "prettier --write src/"
},
"dependencies": {
"@tailwindcss/typography": "^0.5.15",
"@tiptap/pm": "^2.8.0",
"@tiptap/starter-kit": "^2.8.0",
"@tiptap/vue-3": "^2.8.0",
"axios": "^1.7.7",
"mockjs": "^1.1.0",
"pinia": "^2.2.2",
"pinia-plugin-persistedstate": "^4.0.2",
"tdesign-icons-vue-next": "^0.2.6",
"tdesign-vue-next": "^1.10.1",
"vue": "^3.5.8",
"vue-json-viewer": "3",
"vue-router": "^4.4.5"
},
"devDependencies": {
"@rushstack/eslint-patch": "^1.10.4",
"@tsconfig/node20": "^20.1.4",
"@types/jsdom": "^21.1.7",
"@types/node": "^20.16.5",
"@vitejs/plugin-vue": "^5.1.4",
"@vue/eslint-config-prettier": "^9.0.0",
"@vue/eslint-config-typescript": "^13.0.0",
"@vue/test-utils": "^2.4.6",
"@vue/tsconfig": "^0.5.1",
"autoprefixer": "^10.4.20",
"eslint": "^8.57.1",
"eslint-plugin-vue": "^9.28.0",
"jsdom": "^24.1.3",
"npm-run-all2": "^6.2.3",
"postcss": "^8.4.47",
"prettier": "^3.3.3",
"tailwindcss": "^3.4.12",
"typescript": "~5.4.5",
"unplugin-auto-import": "^0.18.3",
"unplugin-vue-components": "^0.27.4",
"vite": "^5.4.7",
"vite-plugin-mock": "^3.0.2",
"vite-plugin-vue-devtools": "^7.4.5",
"vitest": "^1.6.0",
"vue-tsc": "^2.1.6"
}
}
+5836
View File
File diff suppressed because it is too large. Load diff
+6
View File
@@ -0,0 +1,6 @@
export default {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

+10
View File
@@ -0,0 +1,10 @@
<script setup lang="ts">
</script>
<template>
<RouterView/>
</template>
<style scoped>
</style>
+6
View File
@@ -0,0 +1,6 @@
import httpClient from '@/api/httpClient'
import type { DashboardOverview } from '@/model/dashboard'
export const getDashboardOverview = () => {
return httpClient.get<DashboardOverview>('/dashboard/overview')
}
+24
View File
@@ -0,0 +1,24 @@
import type { RequestMethodResponse, UploadFile } from 'tdesign-vue-next'
import httpClient from '@/api/httpClient'
export const uploadFile = async (files: UploadFile): Promise<RequestMethodResponse> => {
return new Promise((resolve, reject) => {
httpClient.uploadFile<{
url: string
}>('/uploads', files.raw!).then(result=> {
resolve({
status: 'success',
response: {
url: result.url
}
})
}).catch((error) => {
reject({
status: 'fail',
error: error.message
})
})
})
}
+73
View File
@@ -0,0 +1,73 @@
import axios, { type AxiosInstance } from 'axios'
import type { ErrorResponse } from '@/model/base'
import { MessagePlugin } from 'tdesign-vue-next'
import { useAppStore } from '@/stores/app'
const client: AxiosInstance = axios.create({
baseURL: import.meta.env.VITE_API_PREFIX,
timeout: 1000
})
const handleError = (errorResponse: ErrorResponse) => {
MessagePlugin.error(errorResponse.message)
}
client.interceptors.response.use(
(response) => {
if (response.data.code) {
handleError(response.data)
return Promise.reject(response.data)
}
return response
},
(error) => {
const errorResponse = error.response.data as ErrorResponse
handleError(errorResponse)
return Promise.reject(errorResponse)
}
)
client.interceptors.request.use((config) => {
const appStore = useAppStore()
config.headers.set('Authorization', 'Bearer ' + appStore.token)
return config
})
export default {
get: async <T>(url: string, params?: any) => {
const response = await client.get<T>(url, {
params
})
return response.data as T
},
post: async <T>(url: string, data: Record<string, any>) => {
const response = await client.post<T>(url, data)
return response.data as T
},
delete: async (url: string) => {
await client.delete(url)
},
put: async <T>(url: string, data: Record<string, any> = {}) => {
const response = await client.put<T>(url, data)
return response.data as T
},
// 增加文件上传的方法
uploadFile: async <T>(url: string, file: File, data?: Record<string, any>) => {
const formData = new FormData()
formData.append('file', file)
// 如果有其他参数,添加到 FormData 中
if (data) {
Object.keys(data).forEach((key) => {
formData.append(key, data[key])
})
}
const response = await client.post<T>(url, formData, {
headers: {
'Content-Type': 'multipart/form-data'
}
})
return response.data as T
}
}
+6
View File
@@ -0,0 +1,6 @@
import httpClient from './httpClient'
import type { CreateTokenRequest } from '@/model/token'
export const createToken = (createTokenRequest: CreateTokenRequest) => {
return httpClient.post<{token: string}>('/tokens', createTokenRequest)
}
+15
View File
@@ -0,0 +1,15 @@
import httpClient from '@/api/httpClient'
import type { User, UserSearchFilter } from '@/model/user'
import type { PageResult } from '@/model/base'
export const getCurrentUser = () => {
return httpClient.get<User>('/users/current')
}
export const searchUsers = (userSearchFilter: UserSearchFilter) => {
return httpClient.get<PageResult<User>>('/users', userSearchFilter)
}
export const setUserRoles = (id: number, roles: string[]) => {
return httpClient.put<User>(`/users/${id}/roles`, { roles })
}
+1
View File
@@ -0,0 +1 @@
.marvel-device{display:inline-block;position:relative;-webkit-box-sizing:content-box !important;box-sizing:content-box !important}.marvel-device .screen{width:100%;position:relative;height:100%;z-index:3;background:white;overflow:hidden;display:block;border-radius:1px;-webkit-box-shadow:0 0 0 3px #111;box-shadow:0 0 0 3px #111}.marvel-device .top-bar,.marvel-device .bottom-bar{height:3px;background:black;width:100%;display:block}.marvel-device .middle-bar{width:3px;height:4px;top:0px;left:90px;background:black;position:absolute}.marvel-device.iphone8{width:375px;height:667px;padding:105px 24px;background:#d9dbdc;border-radius:56px;-webkit-box-shadow:inset 0 0 3px 0 rgba(0,0,0,0.2);box-shadow:inset 0 0 3px 0 rgba(0,0,0,0.2)}.marvel-device.iphone8:before{width:calc(100% - 12px);height:calc(100% - 12px);position:absolute;top:6px;content:'';left:6px;border-radius:50px;background:#f8f8f8;z-index:1}.marvel-device.iphone8:after{width:calc(100% - 16px);height:calc(100% - 16px);position:absolute;top:8px;content:'';left:8px;border-radius:48px;-webkit-box-shadow:inset 0 0 3px 0 rgba(0,0,0,0.1),inset 0 0 6px 3px #fff;box-shadow:inset 0 0 3px 0 rgba(0,0,0,0.1),inset 0 0 6px 3px #fff;z-index:2}.marvel-device.iphone8 .home{border-radius:100%;width:68px;height:68px;position:absolute;left:50%;margin-left:-34px;bottom:22px;z-index:3;background:#303233;background:linear-gradient(135deg, #303233 0%, #b5b7b9 50%, #f0f2f2 69%, #303233 100%)}.marvel-device.iphone8 .home:before{background:#f8f8f8;position:absolute;content:'';border-radius:100%;width:calc(100% - 8px);height:calc(100% - 8px);top:4px;left:4px}.marvel-device.iphone8 .top-bar{height:14px;background:#bfbfc0;position:absolute;top:68px;left:0}.marvel-device.iphone8 .bottom-bar{height:14px;background:#bfbfc0;position:absolute;bottom:68px;left:0}.marvel-device.iphone8 .sleep{position:absolute;top:190px;right:-4px;width:4px;height:66px;border-radius:0px 2px 2px 0px;background:#d9dbdc}.marvel-device.iphone8 .volume{position:absolute;left:-4px;top:188px;z-index:0;height:66px;width:4px;border-radius:2px 0px 0px 2px;background:#d9dbdc}.marvel-device.iphone8 .volume:before{position:absolute;left:2px;top:-78px;height:40px;width:2px;border-radius:2px 0px 0px 2px;background:inherit;content:'';display:block}.marvel-device.iphone8 .volume:after{position:absolute;left:0px;top:82px;height:66px;width:4px;border-radius:2px 0px 0px 2px;background:inherit;content:'';display:block}.marvel-device.iphone8 .camera{background:#3c3d3d;width:12px;height:12px;position:absolute;top:24px;left:50%;margin-left:-6px;border-radius:100%;z-index:3}.marvel-device.iphone8 .sensor{background:#3c3d3d;width:16px;height:16px;position:absolute;top:49px;left:134px;z-index:3;border-radius:100%}.marvel-device.iphone8 .speaker{background:#292728;width:70px;height:6px;position:absolute;top:54px;left:50%;margin-left:-35px;border-radius:6px;z-index:3}.marvel-device.iphone8.gold{background:#f9e7d3}.marvel-device.iphone8.gold .top-bar,.marvel-device.iphone8.gold .bottom-bar{background:white}.marvel-device.iphone8.gold .sleep,.marvel-device.iphone8.gold .volume{background:#f9e7d3}.marvel-device.iphone8.gold .home{background:#cebba9;background:linear-gradient(135deg, #cebba9 0%, #f9e7d3 50%, #cebba9 100%)}.marvel-device.iphone8.black{background:#464646;-webkit-box-shadow:inset 0 0 3px 0 rgba(0,0,0,0.7);box-shadow:inset 0 0 3px 0 rgba(0,0,0,0.7)}.marvel-device.iphone8.black:before{background:#080808}.marvel-device.iphone8.black:after{-webkit-box-shadow:inset 0 0 3px 0 rgba(0,0,0,0.1),inset 0 0 6px 3px #212121;box-shadow:inset 0 0 3px 0 rgba(0,0,0,0.1),inset 0 0 6px 3px #212121}.marvel-device.iphone8.black .top-bar,.marvel-device.iphone8.black .bottom-bar{background:#212121}.marvel-device.iphone8.black .volume,.marvel-device.iphone8.black .sleep{background:#464646}.marvel-device.iphone8.black .camera{background:#080808}.marvel-device.iphone8.black .home{background:#080808;background:linear-gradient(135deg, #080808 0%, #464646 50%, #080808 100%)}.marvel-device.iphone8.black .home:before{background:#080808}.marvel-device.iphone8.landscape{padding:24px 105px;height:375px;width:667px}.marvel-device.iphone8.landscape .sleep{top:100%;border-radius:0px 0px 2px 2px;right:190px;height:4px;width:66px}.marvel-device.iphone8.landscape .volume{width:66px;height:4px;top:-4px;left:calc(100% - 188px - 66px);border-radius:2px 2px 0px 0px}.marvel-device.iphone8.landscape .volume:before{width:40px;height:2px;top:2px;right:-78px;left:auto;border-radius:2px 2px 0px 0px}.marvel-device.iphone8.landscape .volume:after{left:-82px;width:66px;height:4px;top:0;border-radius:2px 2px 0px 0px}.marvel-device.iphone8.landscape .top-bar{width:14px;height:100%;left:calc(100% - 68px - 14px);top:0}.marvel-device.iphone8.landscape .bottom-bar{width:14px;height:100%;left:68px;top:0}.marvel-device.iphone8.landscape .home{top:50%;margin-top:-34px;margin-left:0;left:22px}.marvel-device.iphone8.landscape .sensor{top:134px;left:calc(100% - 49px - 16px)}.marvel-deviceLine truncated
+11
View File
@@ -0,0 +1,11 @@
@import "theme.css";
@import "scroll.css";
@import "devices.min.css";
@tailwind base;
@tailwind components;
@tailwind utilities;
html {
font-size:14px
}
+18
View File
@@ -0,0 +1,18 @@
::-webkit-scrollbar {
width: 8px;
background: transparent;
}
/* Track */
::-webkit-scrollbar-track {
background: transparent;
}
::-webkit-scrollbar-thumb {
border-radius: 6px;
border: 2px solid transparent;
background-clip: content-box;
background-color: var(--td-scrollbar-color);
}
/* Handle on hover */
::-webkit-scrollbar-thumb:hover {
background: #555;
}
+466
View File
@@ -0,0 +1,466 @@
:root,:root[theme-mode="light"] {
--brand-main: var(--td-brand-color-5);
--td-brand-color-light: var(--td-brand-color-1);
--td-brand-color-focus: var(--td-brand-color-2);
--td-brand-color-disabled: var(--td-brand-color-3);
--td-brand-color-hover: var(--td-brand-color-4);
--td-brand-color: var(--td-brand-color-5);
--td-brand-color-active: var(--td-brand-color-6);
--td-brand-color-1: #e8fbf4;
--td-brand-color-2: #c9ede2;
--td-brand-color-3: #9cd7c8;
--td-brand-color-4: #69beab;
--td-brand-color-5: #34a590;
--td-brand-color-6: #008875;
--td-brand-color-7: #006c5b;
--td-brand-color-8: #005245;
--td-brand-color-9: #003b31;
--td-brand-color-10: #002720;
--td-warning-color-1: #fef3e6;
--td-warning-color-2: #f9e0c7;
--td-warning-color-3: #f7c797;
--td-warning-color-4: #f2995f;
--td-warning-color-5: #ed7b2f;
--td-warning-color-6: #d35a21;
--td-warning-color-7: #ba431b;
--td-warning-color-8: #9e3610;
--td-warning-color-9: #842b0b;
--td-warning-color-10: #5a1907;
--td-warning-color: var(--td-warning-color-5);
--td-warning-color-hover: var(--td-warning-color-4);
--td-warning-color-focus: var(--td-warning-color-2);
--td-warning-color-active: var(--td-warning-color-6);
--td-warning-color-disabled: var(--td-warning-color-3);
--td-warning-color-light: var(--td-warning-color-1);
--td-error-color-1: #fdecee;
--td-error-color-2: #f9d7d9;
--td-error-color-3: #f8b9be;
--td-error-color-4: #f78d94;
--td-error-color-5: #f36d78;
--td-error-color-6: #e34d59;
--td-error-color-7: #c9353f;
--td-error-color-8: #b11f26;
--td-error-color-9: #951114;
--td-error-color-10: #680506;
--td-error-color: var(--td-error-color-6);
--td-error-color-hover: var(--td-error-color-5);
--td-error-color-focus: var(--td-error-color-2);
--td-error-color-active: var(--td-error-color-7);
--td-error-color-disabled: var(--td-error-color-3);
--td-error-color-light: var(--td-error-color-1);
--td-success-color-1: #e8f8f2;
--td-success-color-2: #bcebdc;
--td-success-color-3: #85dbbe;
--td-success-color-4: #48c79c;
--td-success-color-5: #00a870;
--td-success-color-6: #078d5c;
--td-success-color-7: #067945;
--td-success-color-8: #056334;
--td-success-color-9: #044f2a;
--td-success-color-10: #033017;
--td-success-color: var(--td-success-color-5);
--td-success-color-hover: var(--td-success-color-4);
--td-success-color-focus: var(--td-success-color-2);
--td-success-color-active: var(--td-success-color-6);
--td-success-color-disabled: var(--td-success-color-3);
--td-success-color-light: var(--td-success-color-1);
--td-gray-color-1: #f3f3f3;
--td-gray-color-2: #eee;
--td-gray-color-3: #e7e7e7;
--td-gray-color-4: #dcdcdc;
--td-gray-color-5: #c5c5c5;
--td-gray-color-6: #a6a6a6;
--td-gray-color-7: #8b8b8b;
--td-gray-color-8: #777;
--td-gray-color-9: #5e5e5e;
--td-gray-color-10: #4b4b4b;
--td-gray-color-11: #383838;
--td-gray-color-12: #2c2c2c;
--td-gray-color-13: #242424;
--td-gray-color-14: #181818;
--td-bg-color-container: #fff;
--td-bg-color-container-select: #fff;
--td-bg-color-page: var(--td-gray-color-2);
--td-bg-color-container-hover: var(--td-gray-color-1);
--td-bg-color-container-active: var(--td-gray-color-3);
--td-bg-color-secondarycontainer: var(--td-gray-color-1);
--td-bg-color-secondarycontainer-hover: var(--td-gray-color-2);
--td-bg-color-secondarycontainer-active: var(--td-gray-color-4);
--td-bg-color-component: var(--td-gray-color-3);
--td-bg-color-component-hover: var(--td-gray-color-4);
--td-bg-color-component-active: var(--td-gray-color-6);
--td-bg-color-component-disabled: var(--td-gray-color-2);
--td-component-stroke: var(--td-gray-color-3);
--td-component-border: var(--td-gray-color-4);
--td-font-white-1: #ffffff;
--td-font-white-2: rgba(255, 255, 255, 0.55);
--td-font-white-3: rgba(255, 255, 255, 0.35);
--td-font-white-4: rgba(255, 255, 255, 0.22);
--td-font-gray-1: rgba(0, 0, 0, 0.9);
--td-font-gray-2: rgba(0, 0, 0, 0.6);
--td-font-gray-3: rgba(0, 0, 0, 0.4);
--td-font-gray-4: rgba(0, 0, 0, 0.26);
--td-brand-color-light-hover: var(--td-brand-color-2);
--td-warning-color-light-hover: var(--td-warning-color-2);
--td-error-color-light-hover: var(--td-error-color-2);
--td-success-color-light-hover: var(--td-success-color-2);
--td-bg-color-secondarycomponent: var(--td-gray-color-4);
--td-bg-color-secondarycomponent-hover: var(--td-gray-color-5);
--td-bg-color-secondarycomponent-active: var(--td-gray-color-6);
--td-table-shadow-color: rgba(0, 0, 0, 8%);
--td-scrollbar-color: rgba(0, 0, 0, 10%);
--td-scrollbar-hover-color: rgba(0, 0, 0, 30%);
--td-scroll-track-color: #fff;
--td-bg-color-specialcomponent: #fff;
--td-border-level-1-color: var(--td-gray-color-3);
--td-border-level-2-color: var(--td-gray-color-4);
--td-shadow-inset-top: inset 0 0.5px 0 #dcdcdc;
--td-shadow-inset-right: inset 0.5px 0 0 #dcdcdc;
--td-shadow-inset-bottom: inset 0 -0.5px 0 #dcdcdc;
--td-shadow-inset-left: inset -0.5px 0 0 #dcdcdc;
--td-mask-active: rgba(0, 0, 0, 0.6);
--td-mask-disabled: rgba(255, 255, 255, 0.6);
/* 字体配置 */
--td-font-family: PingFang SC, Microsoft YaHei, Arial Regular;
--td-font-family-medium: PingFang SC, Microsoft YaHei, Arial Medium;
--td-font-size-link-small: 12px;
--td-font-size-link-medium: 14px;
--td-font-size-link-large: 16px;
--td-font-size-mark-small: 12px;
--td-font-size-mark-medium: 14px;
--td-font-size-body-small: 12px;
--td-font-size-body-medium: 14px;
--td-font-size-body-large: 16px;
--td-font-size-title-small: 14px;
--td-font-size-title-medium: 16px;
--td-font-size-title-large: 20px;
--td-font-size-headline-small: 24px;
--td-font-size-headline-medium: 28px;
--td-font-size-headline-large: 36px;
--td-font-size-display-medium: 48px;
--td-font-size-display-large: 64px;
--td-line-height-common: 8px;
--td-line-height-link-small: calc( var(--td-font-size-link-small) + var(--td-line-height-common) );
--td-line-height-link-medium: calc( var(--td-font-size-link-medium) + var(--td-line-height-common) );
--td-line-height-link-large: calc( var(--td-font-size-link-large) + var(--td-line-height-common) );
--td-line-height-mark-small: calc( var(--td-font-size-mark-small) + var(--td-line-height-common) );
--td-line-height-mark-medium: calc( var(--td-font-size-mark-medium) + var(--td-line-height-common) );
--td-line-height-body-small: calc( var(--td-font-size-body-small) + var(--td-line-height-common) );
--td-line-height-body-medium: calc( var(--td-font-size-body-medium) + var(--td-line-height-common) );
--td-line-height-body-large: calc( var(--td-font-size-body-large) + var(--td-line-height-common) );
--td-line-height-title-small: calc( var(--td-font-size-title-small) + var(--td-line-height-common) );
--td-line-height-title-medium: calc( var(--td-font-size-title-medium) + var(--td-line-height-common) );
--td-line-height-title-large: calc( var(--td-font-size-title-medium) + var(--td-line-height-common) );
--td-line-height-headline-small: calc( var(--td-font-size-headline-small) + var(--td-line-height-common) );
--td-line-height-headline-medium: calc( var(--td-font-size-headline-medium) + var(--td-line-height-common) );
--td-line-height-headline-large: calc( var(--td-font-size-headline-large) + var(--td-line-height-common) );
--td-line-height-display-medium: calc( var(--td-font-size-display-medium) + var(--td-line-height-common) );
--td-line-height-display-large: calc( var(--td-font-size-display-large) + var(--td-line-height-common) );
--td-font-link-small: var(--td-font-size-link-small) / var(--td-line-height-link-small) var(--td-font-family);
--td-font-link-medium: var(--td-font-size-link-medium) / var(--td-line-height-link-medium) var(--td-font-family);
--td-font-link-large: var(--td-font-size-link-large) / var(--td-line-height-link-large) var(--td-font-family);
--td-font-mark-small: 600 var(--td-font-size-mark-small) / var(--td-line-height-mark-small) var(--td-font-family);
--td-font-mark-medium: 600 var(--td-font-size-mark-medium) / var(--td-line-height-mark-medium) var(--td-font-family);
--td-font-body-small: var(--td-font-size-body-small) / var(--td-line-height-body-small) var(--td-font-family);
--td-font-body-medium: var(--td-font-size-body-medium) / var(--td-line-height-body-medium) var(--td-font-family);
--td-font-body-large: var(--td-font-size-body-large) / var(--td-line-height-body-large) var(--td-font-family);
--td-font-title-small: var(--td-font-size-title-small) / var(--td-line-height-title-small) var(--td-font-family);
--td-font-title-medium: var(--td-font-size-title-medium) / var(--td-line-height-title-medium) var(--td-font-family);
--td-font-title-large: var(--td-font-size-title-large) / var(--td-line-height-title-large) var(--td-font-family);
--td-font-headline-small: var(--td-font-size-headline-small) / var(--td-line-height-headline-small) var(--td-font-family);
--td-font-headline-medium: var(--td-font-size-headline-medium) / var(--td-line-height-headline-medium) var(--td-font-family);
--td-font-headline-large: var(--td-font-size-headline-large) / var(--td-line-height-headline-large) var(--td-font-family);
--td-font-display-medium: var(--td-font-size-display-medium) / var(--td-line-height-display-medium) var(--td-font-family);
--td-font-display-large: var(--td-font-size-display-large) / var(--td-line-height-display-large) var(--td-font-family);
/* 字体颜色 */
--td-text-color-primary: var(--td-font-gray-1);
--td-text-color-secondary: var(--td-font-gray-2);
--td-text-color-placeholder: var(--td-font-gray-3);
--td-text-color-disabled: var(--td-font-gray-4);
--td-text-color-anti: #fff;
--td-text-color-brand: var(--td-brand-color);
--td-text-color-link: var(--td-brand-color);
/* end 字体配置 */ /* 圆角配置 */
--td-radius-small: 2px;
--td-radius-default: 3px;
--td-radius-medium: 6px;
--td-radius-large: 9px;
--td-radius-extraLarge: 12px;
--td-radius-round: 999px;
--td-radius-circle: 50%;
/* end 圆角配置 *//* 阴影配置 */
--td-shadow-1: 0 1px 10px rgba(0, 0, 0, 0.05), 0 4px 5px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.12);
--td-shadow-2: 0 3px 14px 2px rgba(0, 0, 0, 0.05), 0 8px 10px 1px rgba(0, 0, 0, 0.06), 0 5px 5px -3px rgba(0, 0, 0, 0.1);
--td-shadow-3: 0 6px 30px 5px rgba(0, 0, 0, 0.05), 0 16px 24px 2px rgba(0, 0, 0, 0.04), 0 8px 10px -5px rgba(0, 0, 0, 0.08);
/* end 阴影配置 *//* 尺寸配置 */
--td-size-1: 2px;
--td-size-2: 4px;
--td-size-3: 6px;
--td-size-4: 8px;
--td-size-5: 12px;
--td-size-6: 16px;
--td-size-7: 20px;
--td-size-8: 24px;
--td-size-9: 28px;
--td-size-10: 32px;
--td-size-11: 36px;
--td-size-12: 40px;
--td-size-13: 48px;
--td-size-14: 56px;
--td-size-15: 64px;
--td-size-16: 72px;
--td-comp-size-xxxs: var(--td-size-6);
--td-comp-size-xxs: var(--td-size-7);
--td-comp-size-xs: var(--td-size-8);
--td-comp-size-s: var(--td-size-9);
--td-comp-size-m: var(--td-size-10);
--td-comp-size-l: var(--td-size-11);
--td-comp-size-xl: var(--td-size-12);
--td-comp-size-xxl: var(--td-size-13);
--td-comp-size-xxxl: var(--td-size-14);
--td-comp-size-xxxxl: var(--td-size-15);
--td-comp-size-xxxxxl: var(--td-size-16);
--td-pop-padding-s: var(--td-size-2);
--td-pop-padding-m: var(--td-size-3);
--td-pop-padding-l: var(--td-size-4);
--td-pop-padding-xl: var(--td-size-5);
--td-pop-padding-xxl: var(--td-size-6);
--td-comp-paddingLR-xxs: var(--td-size-1);
--td-comp-paddingLR-xs: var(--td-size-2);
--td-comp-paddingLR-s: var(--td-size-4);
--td-comp-paddingLR-m: var(--td-size-5);
--td-comp-paddingLR-l: var(--td-size-6);
--td-comp-paddingLR-xl: var(--td-size-8);
--td-comp-paddingLR-xxl: var(--td-size-10);
--td-comp-paddingTB-xxs: var(--td-size-1);
--td-comp-paddingTB-xs: var(--td-size-2);
--td-comp-paddingTB-s: var(--td-size-4);
--td-comp-paddingTB-m: var(--td-size-5);
--td-comp-paddingTB-l: var(--td-size-6);
--td-comp-paddingTB-xl: var(--td-size-8);
--td-comp-paddingTB-xxl: var(--td-size-10);
--td-comp-margin-xxs: var(--td-size-1);
--td-comp-margin-xs: var(--td-size-2);
--td-comp-margin-s: var(--td-size-4);
--td-comp-margin-m: var(--td-size-5);
--td-comp-margin-l: var(--td-size-6);
--td-comp-margin-xl: var(--td-size-7);
--td-comp-margin-xxl: var(--td-size-8);
--td-comp-margin-xxxl: var(--td-size-10);
--td-comp-margin-xxxxl: var(--td-size-12);
/* end 尺寸配置 */
}
:root[theme-mode="dark"] {
--brand-main: var(--td-brand-color-6);
--td-brand-color-light: var(--td-brand-color-1);
--td-brand-color-focus: var(--td-brand-color-2);
--td-brand-color-disabled: var(--td-brand-color-3);
--td-brand-color-hover: var(--td-brand-color-5);
--td-brand-color: var(--td-brand-color-6);
--td-brand-color-active: var(--td-brand-color-7);
--td-brand-color-1: #34a59020;
--td-brand-color-2: #003b31;
--td-brand-color-3: #005245;
--td-brand-color-4: #006c5b;
--td-brand-color-5: #008875;
--td-brand-color-6: #34a590;
--td-brand-color-7: #69beab;
--td-brand-color-8: #9cd7c8;
--td-brand-color-9: #c9ede2;
--td-brand-color-10: #e8fbf4;
--td-warning-color-1: #4f2a1d;
--td-warning-color-2: #582f21;
--td-warning-color-3: #733c23;
--td-warning-color-4: #a75d2b;
--td-warning-color-5: #cf6e2d;
--td-warning-color-6: #dc7633;
--td-warning-color-7: #e8935c;
--td-warning-color-8: #ecbf91;
--td-warning-color-9: #eed7bf;
--td-warning-color-10: #f3e9dc;
--td-error-color-1: #472324;
--td-error-color-2: #5e2a2d;
--td-error-color-3: #703439;
--td-error-color-4: #83383e;
--td-error-color-5: #a03f46;
--td-error-color-6: #c64751;
--td-error-color-7: #de6670;
--td-error-color-8: #ec888e;
--td-error-color-9: #edb1b6;
--td-error-color-10: #eeced0;
--td-success-color-1: #193a2a;
--td-success-color-2: #1a4230;
--td-success-color-3: #17533d;
--td-success-color-4: #0d7a55;
--td-success-color-5: #059465;
--td-success-color-6: #43af8a;
--td-success-color-7: #46bf96;
--td-success-color-8: #80d2b6;
--td-success-color-9: #b4e1d3;
--td-success-color-10: #deede8;
--td-gray-color-1: #f3f3f3;
--td-gray-color-2: #eee;
--td-gray-color-3: #e7e7e7;
--td-gray-color-4: #dcdcdc;
--td-gray-color-5: #c5c5c5;
--td-gray-color-6: #a6a6a6;
--td-gray-color-7: #8b8b8b;
--td-gray-color-8: #777;
--td-gray-color-9: #5e5e5e;
--td-gray-color-10: #4b4b4b;
--td-gray-color-11: #383838;
--td-gray-color-12: #2c2c2c;
--td-gray-color-13: #242424;
--td-gray-color-14: #181818;
--td-bg-color-page: var(--td-gray-color-14);
--td-bg-color-container: var(--td-gray-color-13);
--td-bg-color-container-hover: var(--td-gray-color-12);
--td-bg-color-container-active: var(--td-gray-color-10);
--td-bg-color-container-select: var(--td-gray-color-9);
--td-bg-color-secondarycontainer: var(--td-gray-color-12);
--td-bg-color-secondarycontainer-hover: var(--td-gray-color-11);
--td-bg-color-secondarycontainer-active: var(--td-gray-color-9);
--td-bg-color-component: var(--td-gray-color-11);
--td-bg-color-component-hover: var(--td-gray-color-10);
--td-bg-color-component-active: var(--td-gray-color-9);
--td-bg-color-component-disabled: var(--td-gray-color-12);
--td-component-stroke: var(--td-gray-color-11);
--td-component-border: var(--td-gray-color-9);
--td-font-white-1: rgba(255, 255, 255, 0.9);
--td-font-white-2: rgba(255, 255, 255, 0.55);
--td-font-white-3: rgba(255, 255, 255, 0.35);
--td-font-white-4: rgba(255, 255, 255, 0.22);
--td-font-gray-1: rgba(0, 0, 0, 0.9);
--td-font-gray-2: rgba(0, 0, 0, 0.6);
--td-font-gray-3: rgba(0, 0, 0, 0.4);
--td-font-gray-4: rgba(0, 0, 0, 0.26);
--td-gray-color-1: #f3f3f3;
--td-gray-color-2: #eee;
--td-gray-color-3: #e7e7e7;
--td-gray-color-4: #dcdcdc;
--td-gray-color-5: #c5c5c5;
--td-gray-color-6: #a6a6a6;
--td-gray-color-7: #8b8b8b;
--td-gray-color-8: #777;
--td-gray-color-9: #5e5e5e;
--td-gray-color-10: #4b4b4b;
--td-gray-color-11: #383838;
--td-gray-color-12: #2c2c2c;
--td-gray-color-13: #242424;
--td-gray-color-14: #181818;
--td-bg-color-page: var(--td-gray-color-14);
--td-bg-color-container: var(--td-gray-color-13);
--td-bg-color-container-hover: var(--td-gray-color-12);
--td-bg-color-container-active: var(--td-gray-color-10);
--td-bg-color-container-select: var(--td-gray-color-9);
--td-bg-color-secondarycontainer: var(--td-gray-color-12);
--td-bg-color-secondarycontainer-hover: var(--td-gray-color-11);
--td-bg-color-secondarycontainer-active: var(--td-gray-color-9);
--td-bg-color-component: var(--td-gray-color-11);
--td-bg-color-component-hover: var(--td-gray-color-10);
--td-bg-color-component-active: var(--td-gray-color-9);
--td-bg-color-secondarycomponent: var(--td-gray-color-10);
--td-bg-color-secondarycomponent-hover: var(--td-gray-color-9);
--td-bg-color-secondarycomponent-active: var(--td-gray-color-8);
--td-bg-color-component-disabled: var(--td-gray-color-12);
--td-component-stroke: var(--td-gray-color-11);
--td-component-border: var(--td-gray-color-9);
--td-font-white-1: rgba(255, 255, 255, 0.9);
--td-font-white-2: rgba(255, 255, 255, 0.55);
--td-font-white-3: rgba(255, 255, 255, 0.35);
--td-font-white-4: rgba(255, 255, 255, 0.22);
--td-font-gray-1: rgba(0, 0, 0, 0.9);
--td-font-gray-2: rgba(0, 0, 0, 0.6);
--td-font-gray-3: rgba(0, 0, 0, 0.4);
--td-font-gray-4: rgba(0, 0, 0, 0.26);
--td-text-color-primary: var(--td-font-white-1);
--td-text-color-secondary: var(--td-font-white-2);
--td-text-color-placeholder: var(--td-font-white-3);
--td-text-color-disabled: var(--td-font-white-4);
--td-text-color-anti: #fff;
--td-text-color-brand: var(--td-brand-color);
--td-text-color-link: var(--td-brand-color);
--td-table-shadow-color: rgba(0, 0, 0, 55%);
--td-scrollbar-color: rgba(255, 255, 255, 10%);
--td-scrollbar-hover-color: rgba(255, 255, 255, 30%);
--td-scroll-track-color: #333;
--td-bg-color-specialcomponent: transparent;
--td-border-level-1-color: var(--td-gray-color-11);
--td-border-level-2-color: var(--td-gray-color-9);
--td-mask-active: rgba(0, 0, 0, 0.4);
--td-mask-disabled: rgba(0, 0, 0, 0.6);
--td-shadow-inset-top: inset 0 0.5px 0 #5e5e5e;
--td-shadow-inset-right: inset 0.5px 0 0 #5e5e5e;
--td-shadow-inset-bottom: inset 0 -0.5px 0 #5e5e5e;
--td-shadow-inset-left: inset -0.5px 0 0 #5e5e5e;
/* 圆角配置 */
--td-radius-small: 2px;
--td-radius-default: 3px;
--td-radius-medium: 6px;
--td-radius-large: 9px;
--td-radius-extraLarge: 12px;
--td-radius-round: 999px;
--td-radius-circle: 50%;
/* end 圆角配置 *//* 阴影配置 */
--td-shadow-1: 0 1px 10px rgba(0, 0, 0, 0.05), 0 4px 5px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.12);
--td-shadow-2: 0 3px 14px 2px rgba(0, 0, 0, 0.05), 0 8px 10px 1px rgba(0, 0, 0, 0.06), 0 5px 5px -3px rgba(0, 0, 0, 0.1);
--td-shadow-3: 0 6px 30px 5px rgba(0, 0, 0, 0.05), 0 16px 24px 2px rgba(0, 0, 0, 0.04), 0 8px 10px -5px rgba(0, 0, 0, 0.08);
/* end 阴影配置 *//* 尺寸配置 */
--td-size-1: 2px;
--td-size-2: 4px;
--td-size-3: 6px;
--td-size-4: 8px;
--td-size-5: 12px;
--td-size-6: 16px;
--td-size-7: 20px;
--td-size-8: 24px;
--td-size-9: 28px;
--td-size-10: 32px;
--td-size-11: 36px;
--td-size-12: 40px;
--td-size-13: 48px;
--td-size-14: 56px;
--td-size-15: 64px;
--td-size-16: 72px;
--td-comp-size-xxxs: var(--td-size-6);
--td-comp-size-xxs: var(--td-size-7);
--td-comp-size-xs: var(--td-size-8);
--td-comp-size-s: var(--td-size-9);
--td-comp-size-m: var(--td-size-10);
--td-comp-size-l: var(--td-size-11);
--td-comp-size-xl: var(--td-size-12);
--td-comp-size-xxl: var(--td-size-13);
--td-comp-size-xxxl: var(--td-size-14);
--td-comp-size-xxxxl: var(--td-size-15);
--td-comp-size-xxxxxl: var(--td-size-16);
--td-pop-padding-s: var(--td-size-2);
--td-pop-padding-m: var(--td-size-3);
--td-pop-padding-l: var(--td-size-4);
--td-pop-padding-xl: var(--td-size-5);
--td-pop-padding-xxl: var(--td-size-6);
--td-comp-paddingLR-xxs: var(--td-size-1);
--td-comp-paddingLR-xs: var(--td-size-2);
--td-comp-paddingLR-s: var(--td-size-4);
--td-comp-paddingLR-m: var(--td-size-5);
--td-comp-paddingLR-l: var(--td-size-6);
--td-comp-paddingLR-xl: var(--td-size-8);
--td-comp-paddingLR-xxl: var(--td-size-10);
--td-comp-paddingTB-xxs: var(--td-size-1);
--td-comp-paddingTB-xs: var(--td-size-2);
--td-comp-paddingTB-s: var(--td-size-4);
--td-comp-paddingTB-m: var(--td-size-5);
--td-comp-paddingTB-l: var(--td-size-6);
--td-comp-paddingTB-xl: var(--td-size-8);
--td-comp-paddingTB-xxl: var(--td-size-10);
--td-comp-margin-xxs: var(--td-size-1);
--td-comp-margin-xs: var(--td-size-2);
--td-comp-margin-s: var(--td-size-4);
--td-comp-margin-m: var(--td-size-5);
--td-comp-margin-l: var(--td-size-6);
--td-comp-margin-xl: var(--td-size-7);
--td-comp-margin-xxl: var(--td-size-8);
--td-comp-margin-xxxl: var(--td-size-10);
--td-comp-margin-xxxxl: var(--td-size-12);
/* end 尺寸配置 */
}
+1
View File
@@ -0,0 +1 @@
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1726744757694" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4394" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M659.77002 969.890638 363.679441 969.890638 363.679441 644.667555 33.604864 76.752058l325.225129 0 155.319461 300.952306L669.480172 76.752058 989.844597 76.752058 659.77002 639.812991 659.77002 969.890638z" fill="#34a590" p-id="4395"></path></svg>

After

Width:  |  Height:  |  Size: 581 B

+13
View File
@@ -0,0 +1,13 @@
<script setup lang="ts">
</script>
<template>
<div class="text-[var(--td-text-color-secondary)] text-center w-full mt-7">
Copyright @ 2024 YiliAdmin. All Rights Reserved
</div>
</template>
<style scoped>
</style>
+41
View File
@@ -0,0 +1,41 @@
<script setup lang="ts">
import { ArrowLeftIcon } from 'tdesign-icons-vue-next'
defineProps<{
title: string
backIcon?: boolean
}>()
const slots = defineSlots<{
default: any
'action-area': any
'search-area': any
'back-icon': any
}>()
</script>
<template>
<TCard class="w-full min-h-full" :bordered="false" :header-bordered="true">
<template #header>
<div class="flex items-center gap-2">
<slot v-if="backIcon || slots['back-icon']" name="back-icon">
<TButton variant="text" size="small" @click="$router.back()">
<ArrowLeftIcon size="20"></ArrowLeftIcon>
</TButton>
</slot>
<div class="text-lg">{{ title }}</div>
</div>
</template>
<TSpace v-if="slots['action-area']" class="mb-6">
<slot name="action-area"> </slot>
</TSpace>
<div v-if="slots['search-area']" class="w-full mb-6 py-6">
<slot name="search-area"></slot>
</div>
<div class="w-full h-full overflow-hidden">
<slot> </slot>
</div>
</TCard>
</template>
<style scoped></style>
+38
View File
@@ -0,0 +1,38 @@
import type { BaseFilterRequest, BaseModel, PageResult, Paging } from '@/model/base'
import { reactive, type Ref, ref } from 'vue'
import type { PageInfo } from 'tdesign-vue-next'
export const useSearchable = <T extends BaseFilterRequest, D extends BaseModel>(api: (filter: Partial<T>) => Promise<PageResult<D>>, defaultFilter = {}) => {
const loading = ref(false)
const data: Ref<D[]> = ref([])
const pagination = reactive<Paging>({
page: 1,
size: 20,
})
const filter: Ref<Partial<T>> = ref(defaultFilter)
const fetchData = async (defaultFilter = {}) => {
loading.value = true
const result = await api({...filter.value, page: pagination.page, size: pagination.size, ...defaultFilter})
data.value = result.data
pagination.page = result.paging.page
pagination.size = result.paging.size
pagination.total = result.paging.total
loading.value = false
}
const onPageChange = (pageInfo: PageInfo): void => {
pagination.size = pageInfo.pageSize
pagination.page = pageInfo.current
fetchData()
}
return {
loading,
data,
pagination,
filter,
fetchData,
onPageChange
}
}
+41
View File
@@ -0,0 +1,41 @@
import type { Menu } from '@/model/menu'
import type { TreeOptionData } from 'tdesign-vue-next'
export const menuTree: Menu[] = [
{
name: 'dashboard',
path: 'dashboard',
icon: 'app',
title: '仪表盘',
permission: 'dashboard:list',
type: 'page',
component: () => import('@/pages/dashboard/index.vue'),
},
{
name: 'users',
path: 'users',
permission: 'user:list',
component: () => import('@/pages/user/index.vue'),
title: '用户',
icon: 'user',
type: 'page'
},
]
const buildPermissionOptions = (menu: Menu[]): TreeOptionData<string>[] => {
const options: TreeOptionData<string>[] = []
menu.forEach(item=>{
options.push({
label: item.title,
value: item.permission,
children: item.children ? buildPermissionOptions(item.children) : undefined
})
})
return options
}
export const permissionOptions = buildPermissionOptions(menuTree)
+22
View File
@@ -0,0 +1,22 @@
<script setup lang="ts">
import Header from '@/layouts/components/Header.vue'
import Content from '@/layouts/components/Content.vue'
import Sidebar from '@/layouts/components/Sidebar.vue'
</script>
<template>
<TLayout class="w-[100vw] h-[100vh]">
<Sidebar></Sidebar>
<TLayout>
<THeader>
<Header></Header>
</THeader>
<TLayout class="overflow-hidden">
<Content></Content>
</TLayout>
</TLayout>
</TLayout>
</template>
<style scoped></style>
+14
View File
@@ -0,0 +1,14 @@
<script setup lang="ts">
</script>
<template>
<div class="w-full h-[56px] flex items-center text-2xl cursor-pointer gap-2 font-bold">
<img src="@/assets/icons/logo.svg" class="w-[32px]" />
Yili Admin
</div>
</template>
<style scoped>
</style>
+13
View File
@@ -0,0 +1,13 @@
<script setup lang="ts">
</script>
<template>
<div class="w-full min-h-full overflow-y-auto pt-6 px-6">
<RouterView></RouterView>
</div>
</template>
<style scoped>
</style>
+30
View File
@@ -0,0 +1,30 @@
<script setup lang="ts">
import AppLogo from '@/layouts/components/AppLogo.vue'
import UserArea from '@/layouts/components/UserArea.vue'
import { asyncRoutes } from '@/router'
import { useRoute } from 'vue-router'
const route = useRoute()
</script>
<template>
<div class="w-full h-full">
<t-head-menu :value="route.name" theme="light" >
<template #logo>
<AppLogo></AppLogo>
</template>
<template v-for="route in asyncRoutes" :key="route.name">
<t-menu-item v-if="route.meta && !route.meta.hiddenInMenu" :value="route.name" :to="{name: route.name}">{{ route!.meta!.title }}</t-menu-item>
</template>
<template #operations>
<UserArea></UserArea>
</template>
</t-head-menu>
</div>
</template>
<style scoped>
</style>
+25
View File
@@ -0,0 +1,25 @@
<script setup lang="ts">
import UserArea from '@/layouts/components/UserArea.vue'
import { useRouter } from 'vue-router'
const router = useRouter()
</script>
<template>
<div class="w-full h-full flex items-center justify-between px-6">
<TSpace>
<!-- <TButton variant="text" shape="square">-->
<!-- <template #icon> <ViewListIcon /></template>-->
<!-- </TButton>-->
<TButton variant="text" @click="() => router.push({ name: 'platform-manage'
})">切换平台</TButton>
</TSpace>
<UserArea></UserArea>
</div>
</template>
<style scoped>
</style>
+17
View File
@@ -0,0 +1,17 @@
<script setup lang="ts">
import type { RouteRecordRaw } from 'vue-router'
defineProps<{
data: RouteRecordRaw
}>()
</script>
<template>
<t-menu-item v-if="data.meta && !data.meta.hiddenInMenu" :value="data.name" :to="data">
<template #icon>
<TIcon :name="data.meta.icon" />
</template>
{{ data.meta.title }}
</t-menu-item>
</template>
<style scoped></style>
+26
View File
@@ -0,0 +1,26 @@
<script setup lang="ts">
import AppLogo from '@/layouts/components/AppLogo.vue'
import MenuItem from '@/layouts/components/MenuItem.vue'
import { asyncRoutes } from '@/router'
import { useRoute } from 'vue-router'
const route = useRoute()
</script>
<template>
<TAside>
<TMenu :value="route.name">
<template #logo>
<AppLogo></AppLogo>
</template>
<MenuItem v-for="menu in asyncRoutes" :key="menu.name" :data="menu"></MenuItem>
</TMenu>
</TAside>
</template>
<style scoped>
:global(.t-default-menu__inner .t-menu__logo:not(:empty)) {
border-bottom: none;
}
</style>
+33
View File
@@ -0,0 +1,33 @@
<script setup lang="ts">
import { ChevronDownIcon } from 'tdesign-icons-vue-next'
import type { DropdownOption } from 'tdesign-vue-next'
import { useAppStore } from '@/stores/app'
const appStore = useAppStore()
const options: DropdownOption[] = [
{
content: '退出登录',
onClick() {
appStore.logout()
}
}
]
</script>
<template>
<div>
<TDropdown :options="options" :minColumnWidth="100">
<TButton variant="text">
<div class="flex gap-2 items-center">
<TAvatar size="24px" image="https://tdesign.gtimg.com/site/avatar.jpg"></TAvatar>
依力
<ChevronDownIcon />
</div>
</TButton>
</TDropdown>
</div>
</template>
<style scoped>
</style>
+17
View File
@@ -0,0 +1,17 @@
import { createApp } from 'vue'
import { createPinia } from 'pinia'
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
import 'tdesign-vue-next/es/style/index.css';
import '@/assets/css/main.css'
import App from './App.vue'
import router from './router'
const app = createApp(App)
const pinia = createPinia()
pinia.use(piniaPluginPersistedstate)
app.use(pinia)
app.use(router)
app.mount('#app')
+23
View File
@@ -0,0 +1,23 @@
export interface ErrorResponse {
code: number;
message: string;
}
export interface BaseModel {
id: number
createdTime: Date
updateTime: Date
}
export interface Paging {
page: number
size: number
total?: number
}
export interface BaseFilterRequest extends Partial<Paging>{
}
export interface PageResult<T> {
paging: Paging,
data: T[]
}
+6
View File
@@ -0,0 +1,6 @@
export interface DashboardOverview {
totalVisitor: number
orderCount: number
totalAmount: number
contactCount: number
}
+14
View File
@@ -0,0 +1,14 @@
import type { AsyncComponentLoader } from 'vue'
export interface Menu {
name: string
title: string
permission: string
type: 'btn' | 'menu' | 'page'
path: string,
icon?: string
children?: Menu[]
component?: AsyncComponentLoader
visible?: boolean
}
+17
View File
@@ -0,0 +1,17 @@
import type {BaseFilterRequest, BaseModel} from "@/model/base";
export interface Role extends BaseModel{
name: string
guardName: string
label: string
permissions: string[]
}
export interface RoleFilterRequest extends BaseFilterRequest{
name?: string
guardName?: string
}
export interface RoleCreateRequest extends Pick<Role, "name" | "label" | "permissions">{
}
+4
View File
@@ -0,0 +1,4 @@
export interface CreateTokenRequest {
email: string
password: string
}
+15
View File
@@ -0,0 +1,15 @@
import type { BaseFilterRequest, BaseModel } from '@/model/base'
import type { Role } from '@/model/role'
export interface User extends BaseModel{
name: string
email: string
avatar: string
roles: Role[]
permissions: string[]
}
export interface UserSearchFilter extends BaseFilterRequest {
name?: string
}
@@ -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>
+73
View File
@@ -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>
+46
View File
@@ -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>
+48
View File
@@ -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>
+135
View File
@@ -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>
+57
View File
@@ -0,0 +1,57 @@
import type { RouteRecordRaw } from 'vue-router'
import { createRouter, createWebHistory } from 'vue-router'
import { useAppStore } from '@/stores/app'
import Login from '@/pages/common/login.vue'
import Layout from '@/layouts/Layout.vue'
export const asyncRoutes: RouteRecordRaw[] = [
{
name: 'dashboard',
path: 'dashboard',
component: () => import('@/pages/dashboard/index.vue'),
meta: {
title: '仪表盘',
icon: 'app'
}
},
{
name: 'users',
path: 'users',
component: () => import('@/pages/user/index.vue'),
meta: {
title: '用户',
icon: 'user'
}
},
]
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
routes: [
{
name: 'layout',
component: Layout,
path: '/',
redirect: {
name: 'dashboard'
},
children: asyncRoutes
},
{
name: 'login',
path: '/login',
component: Login
}
]
})
router.beforeEach((to, from, next) => {
if (to.name !== 'login') {
const appStore = useAppStore()
appStore.isLogin ? next() : next({ name: 'login' })
return
}
next()
})
export default router
+58
View File
@@ -0,0 +1,58 @@
import { defineStore } from 'pinia'
import { computed, ref } from 'vue'
import { createToken } from '@/api/token'
import type { CreateTokenRequest } from '@/model/token'
import { useRouter } from 'vue-router'
import type { User } from '@/model/user'
import { getCurrentUser } from '@/api/user'
import { MessagePlugin } from 'tdesign-vue-next'
import { usePermissionStore } from '@/stores/permission'
export const useAppStore = defineStore(
'app',
() => {
const collapsed = ref(false)
const token = ref('')
const router = useRouter()
const permissionStore = usePermissionStore()
const currentUser = ref<User | null>(null)
const logout = () => {
token.value = ''
currentUser.value = null
router.push('/login')
}
const login = async (createTokenRequest: CreateTokenRequest) => {
try {
token.value = (await createToken(createTokenRequest)).token
currentUser.value = await getCurrentUser()
await permissionStore.setCurrentUserPermission(currentUser.value)
MessagePlugin.success('登录成功')
await router.push('/')
} catch (error) {
logout()
}
}
const isLogin = computed(() => !!token.value)
const toggleCollapsed = () => {
collapsed.value = !collapsed.value
}
return {
collapsed,
toggleCollapsed,
token,
login,
isLogin,
currentUser,
logout
}
},
{
persist: true
}
)
+61
View File
@@ -0,0 +1,61 @@
import { defineStore } from 'pinia'
import { ref, watch } from 'vue'
import type { User } from '@/model/user'
import { menuTree } from '@/constants/menu'
import type { Menu } from '@/model/menu'
import type { RouteRecordRaw } from 'vue-router'
import Layout from '@/layouts/Layout.vue'
export const usePermissionStore = defineStore('permission', () => {
const menu = ref<Menu[]>([])
const buildMenu = (menuTree: Menu[], permissions: string[]): Menu[] => {
const userMenu: Menu[] = []
menuTree.forEach(item => {
if (item.children) {
item.children = buildMenu(item.children, permissions)
}
if (item.permission && permissions.includes(item.permission)) {
userMenu.push(item)
}
})
return userMenu
}
const setCurrentUserPermission = async (currentUser: User) => {
menu.value = menuTree
}
const buildPermissionRoutes = (permissionMenu: Menu[]) => {
const asyncRouts: RouteRecordRaw[] = []
permissionMenu.forEach(item=>{
let children:RouteRecordRaw[] = []
if (item.children) {
children = buildPermissionRoutes(item.children)
}
if (item.type !== 'page') {
asyncRouts.push({
name: item.name,
path: item.path,
component: item.component ? item.component : Layout,
meta: {
title: item.title,
icon: item.icon,
permission: item.permission
},
children
})
}
})
return asyncRouts
}
watch(menu, (value) => {
buildPermissionRoutes(value)
})
return {
menu,
setCurrentUserPermission
}
})
+20
View File
@@ -0,0 +1,20 @@
/** @type {import('tailwindcss').Config} */
import typography from '@tailwindcss/typography'
export default {
content: [
"./index.html",
"./src/**/*.{vue,js,ts,jsx,tsx}",
],
theme: {
extend: {
colors: {
primary: 'var(--brand-main)',
}
},
},
plugins: [
typography,
],
}
+13
View File
@@ -0,0 +1,13 @@
{
"extends": "@vue/tsconfig/tsconfig.dom.json",
"include": ["env.d.ts", "src/**/*", "src/**/*.vue"],
"exclude": ["src/**/__tests__/*"],
"compilerOptions": {
"composite": true,
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
}
}
+14
View File
@@ -0,0 +1,14 @@
{
"files": [],
"references": [
{
"path": "./tsconfig.node.json"
},
{
"path": "./tsconfig.app.json"
},
{
"path": "./tsconfig.vitest.json"
}
]
}
+19
View File
@@ -0,0 +1,19 @@
{
"extends": "@tsconfig/node20/tsconfig.json",
"include": [
"vite.config.*",
"vitest.config.*",
"cypress.config.*",
"nightwatch.conf.*",
"playwright.config.*"
],
"compilerOptions": {
"composite": true,
"noEmit": true,
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
"module": "ESNext",
"moduleResolution": "Bundler",
"types": ["node"]
}
}
+11
View File
@@ -0,0 +1,11 @@
{
"extends": "./tsconfig.app.json",
"exclude": [],
"compilerOptions": {
"composite": true,
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.vitest.tsbuildinfo",
"lib": [],
"types": ["node", "jsdom"]
}
}
+11
View File
@@ -0,0 +1,11 @@
/// <reference types="vite/client" />
interface ImportMetaEnv {
readonly VITE_ENABLE_MOCK: 'true' | 'false'
readonly VITE_API_PREFIX: string
readonly VITE_PROXY_ENDPOINT: string
}
interface ImportMeta {
readonly env: ImportMetaEnv
}
+48
View File
@@ -0,0 +1,48 @@
import { fileURLToPath, URL } from 'node:url'
import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueDevTools from 'vite-plugin-vue-devtools'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { TDesignResolver } from 'unplugin-vue-components/resolvers'
// https://vitejs.dev/config/
export default defineConfig(({ command, mode }) => {
const env = loadEnv(mode, process.cwd(), '')
return {
plugins: [
vue(),
vueDevTools(),
AutoImport({
resolvers: [
TDesignResolver({
library: 'vue-next'
})
]
}),
Components({
resolvers: [
TDesignResolver({
library: 'vue-next'
})
]
}),
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
},
server: {
proxy: {
'/api': {
target: env.VITE_PROXY_ENDPOINT,
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, '')
}
}
}
}
})