-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
155 changed files
with
1,317 additions
and
1,729 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
module.exports = { | ||
root: true, | ||
extends: ['@vben'], | ||
rules: { | ||
'no-undef': 'off', | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
import { withInstall } from '/@/utils'; | ||
import basicUpload from './src/BasicUpload.vue'; | ||
import uploadImage from './src/components/ImageUpload.vue'; | ||
import avatarUpload from './src/AvatarUpload.vue'; | ||
|
||
export const ImageUpload = withInstall(uploadImage); | ||
export const BasicUpload = withInstall(basicUpload); | ||
export const AvatarUpload = withInstall(avatarUpload); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
<template> | ||
<div> | ||
<Upload | ||
v-model:file-list="fileList" | ||
name="file" | ||
list-type="picture-card" | ||
class="avatar-uploader" | ||
:action="uploadUrl" | ||
:before-upload="beforeUpload" | ||
:headers="requestHeaders" | ||
@preview="handlePreview" | ||
@change="handleChange" | ||
> | ||
<img v-if="previewImage" :src="previewImage" alt="logo" /> | ||
<div v-if="fileList.length < 1"> | ||
<loading-outlined v-if="loading" /> | ||
<plus-outlined v-else /> | ||
<div class="ant-upload-text">上传</div> | ||
</div> | ||
</Upload> | ||
<Modal :visible="previewVisible" :footer="null" @cancel="handleCancel"> | ||
<img alt="example" style="width: 100%" :src="previewImage" /> | ||
</Modal> | ||
|
||
<Modal :visible="previewVisible" :footer="null" @cancel="handleCancel"> | ||
<img alt="example" style="width: 100%" :src="previewImage" /> | ||
</Modal> | ||
</div> | ||
</template> | ||
<script lang="ts" setup> | ||
import { Upload, Modal } from 'ant-design-vue'; | ||
import { PlusOutlined, LoadingOutlined } from '@ant-design/icons-vue'; | ||
import { useMessage } from '/@/hooks/web/useMessage'; | ||
import { uploadUrl } from '/@/api/sys/upload'; | ||
import { getToken } from '/@/utils/auth'; | ||
import { ref, watch } from 'vue'; | ||
interface FileItem { | ||
uid?: string; | ||
name?: string; | ||
status?: string; | ||
response?: string; | ||
percent?: number; | ||
url?: string; | ||
preview?: string; | ||
originFileObj?: any; | ||
} | ||
function getBase64(file: File) { | ||
return new Promise((resolve, reject) => { | ||
const reader = new FileReader(); | ||
reader.readAsDataURL(file); | ||
reader.onload = () => resolve(reader.result); | ||
reader.onerror = (error) => reject(error); | ||
}); | ||
} | ||
const props = defineProps({ | ||
avatar: { | ||
type: String, | ||
}, | ||
}); | ||
const fileList = ref<FileItem[]>([]); | ||
const emit = defineEmits(['change']); | ||
const { createMessage } = useMessage(); | ||
const requestHeaders = { | ||
authorization: 'Bearer ' + getToken(), | ||
}; | ||
const loading = ref<boolean>(false); | ||
const previewVisible = ref<boolean>(false); | ||
const previewImage = ref<string | undefined>(''); | ||
const handleCancel = () => { | ||
previewImage.value = ''; | ||
previewVisible.value = false; | ||
}; | ||
const handlePreview = async (file) => { | ||
if (!file.url && !file.preview) { | ||
file.preview = (await getBase64(file.originFileObj)) as string; | ||
} | ||
previewImage.value = file.url || file.preview; | ||
previewVisible.value = true; | ||
}; | ||
const handleChange = ({ fileList: newFileList }) => { | ||
let temp = newFileList[0]; | ||
if (temp?.response) { | ||
temp.url = temp.response; | ||
} | ||
emit('change', temp); | ||
}; | ||
const beforeUpload = (file) => { | ||
const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png'; | ||
if (!isJpgOrPng) { | ||
createMessage.error('请选择正确的图片格式'); | ||
} | ||
const isLt2M = file.size / 1024 / 1024 < 1; | ||
if (!isLt2M) { | ||
createMessage.error('图片大小请小于1M'); | ||
} | ||
return isJpgOrPng && isLt2M; | ||
}; | ||
watch( | ||
() => props.avatar, | ||
(val) => { | ||
fileList.value = val ? [{ url: val }] : []; | ||
}, | ||
); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,10 @@ | ||
# app | ||
APP_NAME = Nest Admin | ||
|
||
# server port | ||
PORT = 5001 | ||
APP_PORT = 5001 | ||
APP_LOCALE = zh-CN | ||
WS_PORT = 5002 | ||
WS_PATH = ws-api | ||
|
||
# global prefix, using in router、redis | ||
GLOBAL_PREFIX = api | ||
|
||
# specify id as the root administrator | ||
ADMIN_ROLE_ID = 1 | ||
# user password salt | ||
USER_PWD_SALT = kz!@#123 | ||
# user default password | ||
USER_DEFAULT_PWD = a123456 | ||
|
||
# minimum internal requirements protect id | ||
PROTECT_SYS_PERMMENU_MAX_ID = 1 | ||
PROTECT_SYS_DICTIONARY_MAX_ID = 1 | ||
|
||
# logger | ||
LOGGER_LEVEL = verbose | ||
LOGGER_MAX_FILES = 31 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.