Commit 70b9e0d4 by Sweet Zhang

按类型封装api

parent b09264c7
VITE_API_BASE_URL='http://139.224.145.34:9002/email/api' VITE_API_BASE_URL='/email/api'
\ No newline at end of file \ No newline at end of file
interface resPage {
page: number
pageSize: number
total: number
hasNextPage: boolean
pageTotal: number
}
interface itfRes {
code: number
msg: string | undefined
data: T
reason?: string
page?: resPage
}
import * as axios from 'axios'
declare module 'axios'
{interface AxiosResponse extends itfRes}
declare module '*.vue' {
import type { DefineComponent } from 'vue'
const component: DefineComponent<object, object, unknown>
export default component
}
// 分页类型
export interface Pagination<T> {
records?: T[]
total?: number
pageSize?: number
sortField?: string
sortOrder?: string
pageNo?: number
}
// 联系人类型 // 联系人类型
export interface Contact { export interface Contact extends Pagination<Contact> {
contactBizId?: string contactBizId?: string
name?: string name?: string
type?: string type?: string
...@@ -11,17 +21,19 @@ export interface Contact { ...@@ -11,17 +21,19 @@ export interface Contact {
} }
// 发件人类型 // 发件人类型
export interface Sender { export interface Sender extends Pagination<Sender> {
senderBizId?: string senderBizId?: string
email?: string email?: string
password?: string password?: string
displayName?: string displayName?: string
providerBizId?: string providerBizId?: string
active?: number active?: number
emailSenderConfigName?: string
emailSenderConfigEmail?: string
} }
// 变量类型 // 变量类型
export interface Variable { export interface Variable extends Pagination<Variable> {
id?: string id?: string
variableBizId?: string variableBizId?: string
variableNameCn?: string variableNameCn?: string
...@@ -30,7 +42,7 @@ export interface Variable { ...@@ -30,7 +42,7 @@ export interface Variable {
} }
// 变量模板类型 // 变量模板类型
export interface VariableTemplate { export interface VariableTemplate extends Pagination<VariableTemplate> {
variableGroupBizId?: string variableGroupBizId?: string
groupName?: string groupName?: string
description?: string description?: string
...@@ -39,7 +51,7 @@ export interface VariableTemplate { ...@@ -39,7 +51,7 @@ export interface VariableTemplate {
} }
// 邮件类型 // 邮件类型
export interface Email { export interface Email extends Pagination<Email> {
id?: string id?: string
sender?: string sender?: string
to?: string[] to?: string[]
...@@ -52,7 +64,7 @@ export interface Email { ...@@ -52,7 +64,7 @@ export interface Email {
} }
// 邮件表单类型 // 邮件表单类型
export interface EmailForm { export interface EmailForm extends Pagination<EmailForm> {
to: string to: string
cc: string cc: string
subject: string subject: string
...@@ -84,12 +96,27 @@ export interface ContactSessionId { ...@@ -84,12 +96,27 @@ export interface ContactSessionId {
} }
// 编辑-邮件联系人导入信息 // 编辑-邮件联系人导入信息
export interface EditContactImport { export interface EditContactImport extends Pagination<EditContactImport> {
receiveEmail?: string receiveEmail?: string
sessionId?: string sessionId?: string
source?: string source?: string
pageNo?: number }
pageSize?: number // 发送邮件
sortField?: string export interface SendEmail {
sortOrder?: string senderBizId?: string
recipientEmailList?: string[]
ccEmailList?: string[]
bccEmailList?: string[]
subject?: string
body?: string
}
//邮件服务商类型
export interface EmailProvider extends Pagination<EmailProvider> {
providerBizId?: string
providerName?: string
smtpHost?: string
smtpPort?: string
sslEnabled?: number
active?: number
description?: string
} }
import axios, { AxiosError } from 'axios' import axios, { type AxiosError, type AxiosResponse, type InternalAxiosRequestConfig } from 'axios'
// 定义统一的响应类型
export interface ApiResponse<T = object> {
code: number
message?: string
data: T
success: boolean
msg?: string
}
// 创建axios实例 // 创建axios实例
const request = axios.create({ const request = axios.create({
...@@ -14,7 +23,7 @@ const request = axios.create({ ...@@ -14,7 +23,7 @@ const request = axios.create({
// 请求拦截器 - 添加Authorization头 // 请求拦截器 - 添加Authorization头
request.interceptors.request.use( request.interceptors.request.use(
(config) => { (config: InternalAxiosRequestConfig) => {
// 从本地存储获取token // 从本地存储获取token
const token = localStorage.getItem('authToken') const token = localStorage.getItem('authToken')
...@@ -33,7 +42,7 @@ request.interceptors.request.use( ...@@ -33,7 +42,7 @@ request.interceptors.request.use(
// 响应拦截器 - 处理常见错误 // 响应拦截器 - 处理常见错误
request.interceptors.response.use( request.interceptors.response.use(
(response) => { (response: AxiosResponse) => {
// 直接返回响应数据 // 直接返回响应数据
return response.data return response.data
}, },
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
> >
<option v-for="sender in senders" :key="sender.senderBizId" :value="sender"> <option v-for="sender in senders" :key="sender.senderBizId" :value="sender">
{{ sender.email }} {{ sender.email }} - {{ sender.displayName }}
</option> </option>
</select> </select>
</div> </div>
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
type="text" type="text"
class="flex-1 px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500" class="flex-1 px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
placeholder="输入收件人邮箱,多个邮箱用逗号分隔" placeholder="输入收件人邮箱,多个邮箱用逗号分隔"
:disabled="!!selectedVariableTemplate"
/> />
<!-- 当选择模版有值时,不显示选择联系人按钮 --> <!-- 当选择模版有值时,不显示选择联系人按钮 -->
<button <button
...@@ -69,6 +70,7 @@ ...@@ -69,6 +70,7 @@
type="text" type="text"
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
placeholder="输入抄送人邮箱,多个邮箱用逗号分隔" placeholder="输入抄送人邮箱,多个邮箱用逗号分隔"
:disabled="!!selectedVariableTemplate"
/> />
</div> </div>
...@@ -261,12 +263,7 @@ import type { ...@@ -261,12 +263,7 @@ import type {
ImportRecord, ImportRecord,
} from '../types' } from '../types'
// 引入api接口,获取联系人列表、发件人列表、变量模版列表 // 引入api接口,获取联系人列表、发件人列表、变量模版列表
import { import { senderApi, variableGroupApi, contactApi, getContactList } from '../api/api'
getContactList,
getEmailSenderConfigList,
getEmailVariableGroupList,
getEmailVariableGroupDetail,
} from '../api/api'
// 引入弹窗组件 // 引入弹窗组件
import CommonModal from '@/components/CommonModal.vue' import CommonModal from '@/components/CommonModal.vue'
// 弹窗提示信息对象 // 弹窗提示信息对象
...@@ -301,28 +298,34 @@ const handleCancel = (triggerKey: string) => { ...@@ -301,28 +298,34 @@ const handleCancel = (triggerKey: string) => {
} }
// 初始化数据 // 初始化数据
const getSenders = () => { const getSenders = () => {
getEmailSenderConfigList({ senderApi
pageNo: 1, .getEmailSenderConfigList({
pageSize: 100, pageNo: 1,
}).then((res) => { pageSize: 100,
senders.value = res.data?.records || [] })
}) .then((res) => {
senders.value = res.data?.records || []
})
} }
const getContacts = () => { const getContacts = () => {
getContactList({ contactApi
pageNo: 1, .getContactList({
pageSize: 100, pageNo: 1,
}).then((res) => { pageSize: 100,
contacts.value = res.data?.records || [] })
}) .then((res) => {
contacts.value = res.data?.records || []
})
} }
const getGroups = () => { const getGroups = () => {
getEmailVariableGroupList({ variableGroupApi
pageNo: 1, .getEmailVariableGroupList({
pageSize: 100, pageNo: 1,
}).then((res) => { pageSize: 100,
groups.value = res.data?.records || [] })
}) .then((res) => {
groups.value = res.data?.records || []
})
} }
const senders = ref<Sender[]>([]) const senders = ref<Sender[]>([])
...@@ -388,9 +391,11 @@ const removeAttachment = (index: number) => { ...@@ -388,9 +391,11 @@ const removeAttachment = (index: number) => {
const applyVariableTemplate = () => { const applyVariableTemplate = () => {
if (!selectedVariableTemplate.value) return if (!selectedVariableTemplate.value) return
if (selectedVariableTemplate.value.variableGroupBizId) { if (selectedVariableTemplate.value.variableGroupBizId) {
getEmailVariableGroupDetail(selectedVariableTemplate.value.variableGroupBizId).then((res) => { variableGroupApi
variables.value = res.data?.emailVariableDtoList || [] .getEmailVariableGroupDetail(selectedVariableTemplate.value.variableGroupBizId)
}) .then((res) => {
variables.value = res.data?.emailVariableDtoList || []
})
} }
} }
......
...@@ -319,14 +319,7 @@ ...@@ -319,14 +319,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref, computed, onMounted } from 'vue' import { ref, computed, onMounted } from 'vue'
// 引入我们创建的api拦截器 // 引入我们创建的api拦截器
import { import { contactApi } from '@/api/api'
addContact,
editContact,
deleteContact,
getContactDetail,
getContactList,
getEmailSenderConfigList,
} from '@/api/api'
import type { Contact } from '@/types/index' import type { Contact } from '@/types/index'
// 引入弹窗组件 // 引入弹窗组件
import CommonModal from '@/components/CommonModal.vue' import CommonModal from '@/components/CommonModal.vue'
...@@ -355,7 +348,7 @@ const handleConfirm = (triggerKey: string) => { ...@@ -355,7 +348,7 @@ const handleConfirm = (triggerKey: string) => {
modalVisible.value = false modalVisible.value = false
console.log('用户确认操作', triggerKey) console.log('用户确认操作', triggerKey)
if (triggerKey === 'deleteContactModal' && form.value.contactBizId) { if (triggerKey === 'deleteContactModal' && form.value.contactBizId) {
deleteContact(form.value.contactBizId as string).then((res) => { contactApi.deleteContact(form.value.contactBizId as string).then((res) => {
if (res.code === 200) { if (res.code === 200) {
fetchContacts() fetchContacts()
openModal({ openModal({
...@@ -476,7 +469,7 @@ const totalPages = computed(() => { ...@@ -476,7 +469,7 @@ const totalPages = computed(() => {
const fetchContacts = async () => { const fetchContacts = async () => {
try { try {
isLoading.value = true isLoading.value = true
const data = await getContactList({ const data = await contactApi.getContactList({
pageNo: currentPage.value, pageNo: currentPage.value,
pageSize: pageSize.value, pageSize: pageSize.value,
sortField: sortBy.value, sortField: sortBy.value,
...@@ -614,7 +607,7 @@ const saveContact = async () => { ...@@ -614,7 +607,7 @@ const saveContact = async () => {
if (isEditing.value && form.value.contactBizId) { if (isEditing.value && form.value.contactBizId) {
// 更新现有联系人 // 更新现有联系人
editContact({ ...contactData }).then((res) => { contactApi.updateContact({ ...contactData }).then((res) => {
if (res.code === 200) { if (res.code === 200) {
openModal({ openModal({
title: '更新联系人成功', title: '更新联系人成功',
...@@ -631,7 +624,7 @@ const saveContact = async () => { ...@@ -631,7 +624,7 @@ const saveContact = async () => {
}) })
} else { } else {
// 添加新联系人 // 添加新联系人
await addContact(contactData).then((res) => { await contactApi.addContact(contactData).then((res) => {
if (res.code === 200) { if (res.code === 200) {
openModal({ openModal({
title: '添加联系人成功', title: '添加联系人成功',
......
...@@ -102,8 +102,8 @@ ...@@ -102,8 +102,8 @@
<td class="px-6 py-4 whitespace-nowrap">{{ sender.email }}</td> <td class="px-6 py-4 whitespace-nowrap">{{ sender.email }}</td>
<td class="px-6 py-4 whitespace-nowrap"> <td class="px-6 py-4 whitespace-nowrap">
{{ {{
providers.find((provider) => provider.providerBizId === sender.providerBizId) providers.find((i) => i.providerBizId === sender.providerBizId)?.providerName ||
?.providerName || '未知' '未知'
}} }}
</td> </td>
<td class="px-6 py-4 whitespace-nowrap">{{ sender.displayName }}</td> <td class="px-6 py-4 whitespace-nowrap">{{ sender.displayName }}</td>
...@@ -149,13 +149,7 @@ ...@@ -149,13 +149,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref, defineProps, defineEmits, onMounted } from 'vue' import { ref, defineProps, defineEmits, onMounted } from 'vue'
import { import { emailProviderApi, senderApi, getEmailSenderConfigList } from '@/api/api'
getEmailSenderConfigList,
getEmailProviderList,
deleteEmailSenderConfig,
addEmailSenderConfig,
editEmailSenderConfig,
} from '@/api/api'
import type { Sender } from '@/types/index' import type { Sender } from '@/types/index'
// 引入弹窗组件 // 引入弹窗组件
import CommonModal from '@/components/CommonModal.vue' import CommonModal from '@/components/CommonModal.vue'
...@@ -184,7 +178,7 @@ const handleConfirm = (triggerKey: string) => { ...@@ -184,7 +178,7 @@ const handleConfirm = (triggerKey: string) => {
modalVisible.value = false modalVisible.value = false
console.log('用户确认操作', triggerKey) console.log('用户确认操作', triggerKey)
if (triggerKey === 'deleteModal') { if (triggerKey === 'deleteModal') {
deleteEmailSenderConfig(editingSenderId.value).then((res) => { senderApi.deleteEmailSenderConfig(editingSenderId.value).then((res) => {
if (res.code === 200) { if (res.code === 200) {
openModal({ openModal({
title: '删除确认', title: '删除确认',
...@@ -235,22 +229,24 @@ const resetForm = () => { ...@@ -235,22 +229,24 @@ const resetForm = () => {
} }
} }
const getProviders = () => { const getProviders = () => {
getEmailProviderList({ emailProviderApi
providerName: '', .getEmailProviderList({
pageNo: 1, providerName: '',
pageSize: 100, })
}).then((res) => { .then((res) => {
providers.value = res.data?.records || [] providers.value = res.data?.records || []
}) })
} }
const getSenders = () => { const getSenders = () => {
getEmailSenderConfigList({ senderApi
emailSenderConfigName: '', .getEmailSenderConfigList({
pageNo: 1, emailSenderConfigName: '',
pageSize: 100, pageNo: 1,
}).then((res) => { pageSize: 100,
senders.value = res.data?.records || [] })
}) .then((res) => {
senders.value = res.data?.records || []
})
} }
const saveSender = () => { const saveSender = () => {
console.log(formData.value) console.log(formData.value)
...@@ -264,23 +260,25 @@ const saveSender = () => { ...@@ -264,23 +260,25 @@ const saveSender = () => {
if (editingSenderId.value) { if (editingSenderId.value) {
// 更新现有发件人 // 更新现有发件人
editEmailSenderConfig({ senderApi
senderBizId: editingSenderId.value, .editEmailSenderConfig({
...formData.value, senderBizId: editingSenderId.value,
}).then((res) => { ...formData.value,
if (res.code === 200) { })
getSenders() .then((res) => {
openModal({ if (res.code === 200) {
title: '更新确认', getSenders()
message: '发件人更新成功', openModal({
}) title: '更新确认',
} else { message: '发件人更新成功',
openModal({ })
title: '更新失败', } else {
message: res.msg || '更新失败', openModal({
}) title: '更新失败',
} message: res.msg || '更新失败',
}) })
}
})
} else { } else {
// 添加新发件人 // 添加新发件人
const newSender: Sender = { const newSender: Sender = {
...@@ -290,7 +288,7 @@ const saveSender = () => { ...@@ -290,7 +288,7 @@ const saveSender = () => {
displayName: formData.value.displayName || '', displayName: formData.value.displayName || '',
active: formData.value.active ?? 1, active: formData.value.active ?? 1,
} }
addEmailSenderConfig(newSender).then((res) => { senderApi.addEmailSenderConfig(newSender).then((res) => {
// 补充异常处理 // 补充异常处理
if (res.code === 200) { if (res.code === 200) {
getSenders() getSenders()
......
...@@ -290,17 +290,7 @@ ...@@ -290,17 +290,7 @@
import { ref, defineProps, defineEmits, onMounted } from 'vue' import { ref, defineProps, defineEmits, onMounted } from 'vue'
import type { Variable, VariableTemplate } from '../types' import type { Variable, VariableTemplate } from '../types'
import { import { variableApi, variableGroupApi } from '@/api/api'
getEmailVariableList,
addEmailVariable,
editEmailVariable,
deleteEmailVariable,
addEmailVariableGroup,
editEmailVariableGroup,
deleteEmailVariableGroup,
getEmailVariableGroupList,
getEmailVariableGroupDetail,
} from '@/api/api'
// 引入弹窗组件 // 引入弹窗组件
import CommonModal from '@/components/CommonModal.vue' import CommonModal from '@/components/CommonModal.vue'
...@@ -386,26 +376,29 @@ const saveVariable = () => { ...@@ -386,26 +376,29 @@ const saveVariable = () => {
if (editingVariableId.value) { if (editingVariableId.value) {
// 更新接口 // 更新接口
editEmailVariable({ variableApi
variableBizId: variableForm.value.variableBizId || '', .editEmailVariable({
variableNameCn: variableForm.value.variableNameCn, variableBizId: variableForm.value.variableBizId || '',
variableNameEn: variableForm.value.variableNameEn, variableNameCn: variableForm.value.variableNameCn,
description: variableForm.value.description, variableNameEn: variableForm.value.variableNameEn,
}).then(() => { description: variableForm.value.description,
// 更新本地变量列表 })
fetchVariables() .then(() => {
openModal({ // 更新本地变量列表
title: '成功', fetchVariables()
message: '变量更新成功', openModal({
title: '成功',
message: '变量更新成功',
})
}) })
})
} else { } else {
// 创建接口 // 创建接口
addEmailVariable({ variableApi
variableNameCn: variableForm.value.variableNameCn, .addEmailVariable({
variableNameEn: variableForm.value.variableNameEn, variableNameCn: variableForm.value.variableNameCn,
description: variableForm.value.description, variableNameEn: variableForm.value.variableNameEn,
}) description: variableForm.value.description,
})
.then((res) => { .then((res) => {
// 刷新变量列表 // 刷新变量列表
fetchVariables() fetchVariables()
...@@ -441,7 +434,8 @@ const editVariable = (variable: Variable) => { ...@@ -441,7 +434,8 @@ const editVariable = (variable: Variable) => {
const deleteVariable = (id: string, type?: string) => { const deleteVariable = (id: string, type?: string) => {
editingVariableId.value = id editingVariableId.value = id
if (id && type === 'confirmDelete') { if (id && type === 'confirmDelete') {
deleteEmailVariable(id) variableApi
.deleteEmailVariable(id)
.then(() => { .then(() => {
// 刷新变量列表 // 刷新变量列表
fetchVariables() fetchVariables()
...@@ -483,7 +477,8 @@ const fetchVariables = () => { ...@@ -483,7 +477,8 @@ const fetchVariables = () => {
pageNo: 1, pageNo: 1,
pageSize: 10, pageSize: 10,
} }
getEmailVariableList(params) variableApi
.getEmailVariableList(params)
.then((res) => { .then((res) => {
variables.value = res.data.records || [] variables.value = res.data.records || []
}) })
...@@ -508,7 +503,8 @@ const fetchVariableTemplates = () => { ...@@ -508,7 +503,8 @@ const fetchVariableTemplates = () => {
pageNo: 1, pageNo: 1,
pageSize: 10, pageSize: 10,
} }
getEmailVariableGroupList(params) variableGroupApi
.getEmailVariableGroupList(params)
.then((res) => { .then((res) => {
variableTemplates.value = res.data.records || [] variableTemplates.value = res.data.records || []
}) })
...@@ -581,12 +577,13 @@ const saveVariableTemplate = () => { ...@@ -581,12 +577,13 @@ const saveVariableTemplate = () => {
if (editingTemplateId.value) { if (editingTemplateId.value) {
console.log('更新变量模版', templateForm.value) console.log('更新变量模版', templateForm.value)
// 更新现有模板 // 更新现有模板
editEmailVariableGroup({ variableGroupApi
variableGroupBizId: editingTemplateId.value, .editEmailVariableGroup({
groupName: templateForm.value.groupName || '', variableGroupBizId: editingTemplateId.value,
description: templateForm.value.description || '', groupName: templateForm.value.groupName || '',
variableBizIdList: templateForm.value.variableBizIdList || [], description: templateForm.value.description || '',
}) variableBizIdList: templateForm.value.variableBizIdList || [],
})
.then(() => { .then(() => {
// 刷新变量模版列表 // 刷新变量模版列表
fetchVariableTemplates() fetchVariableTemplates()
...@@ -607,11 +604,12 @@ const saveVariableTemplate = () => { ...@@ -607,11 +604,12 @@ const saveVariableTemplate = () => {
}) })
} else { } else {
// 调用变量组保存接口 // 调用变量组保存接口
addEmailVariableGroup({ variableGroupApi
groupName: templateForm.value.groupName || '', .addEmailVariableGroup({
description: templateForm.value.description || '', groupName: templateForm.value.groupName || '',
variableBizIdList: templateForm.value.variableBizIdList || [], description: templateForm.value.description || '',
}) variableBizIdList: templateForm.value.variableBizIdList || [],
})
.then(() => { .then(() => {
// 刷新变量模版列表 // 刷新变量模版列表
fetchVariableTemplates() fetchVariableTemplates()
...@@ -638,7 +636,8 @@ const saveVariableTemplate = () => { ...@@ -638,7 +636,8 @@ const saveVariableTemplate = () => {
const deleteVariableTemplate = (id: string, type?: string) => { const deleteVariableTemplate = (id: string, type?: string) => {
editingTemplateId.value = id editingTemplateId.value = id
if (type === 'confirmDelete') { if (type === 'confirmDelete') {
deleteEmailVariableGroup(editingTemplateId.value) variableGroupApi
.deleteEmailVariableGroup(editingTemplateId.value)
.then(() => { .then(() => {
// 刷新变量模版列表 // 刷新变量模版列表
fetchVariableTemplates() fetchVariableTemplates()
......
{ {
"files": [],
"references": [
{
"path": "./tsconfig.node.json"
},
{
"path": "./tsconfig.app.json"
},
{
"path": "./tsconfig.vitest.json"
}
],
"compilerOptions": { "compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext",
"skipLibCheck": true, "skipLibCheck": true,
"strict": false "moduleResolution": "bundler",
} "allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "preserve",
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"composite": true,
"declaration": true,
"declarationMap": true,
"baseUrl": "/yd-email",
"paths": {
"@/*": ["src/*"],
"@/components/*": ["src/components/*"],
"@/views/*": ["src/views/*"],
"@/utils/*": ["src/utils/*"],
"@/api/*": ["src/api/*"],
"@/types/*": ["src/types/*"],
"@/stores/*": ["src/stores/*"],
"@/assets/*": ["src/assets/*"]
}
},
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue", "src/**/*.d.ts", "src/shims-vue.d.ts"],
"exclude": ["node_modules", "dist"]
} }
...@@ -3,7 +3,7 @@ import { defineConfig } from 'vite' ...@@ -3,7 +3,7 @@ import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue' import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx' import vueJsx from '@vitejs/plugin-vue-jsx'
import vueDevTools from 'vite-plugin-vue-devtools' import vueDevTools from 'vite-plugin-vue-devtools'
/**设置server转发 */ import { resolve } from 'path'
export default defineConfig({ export default defineConfig({
// 关键配置:设置基础路径为子目录 yd-email // 关键配置:设置基础路径为子目录 yd-email
...@@ -12,6 +12,7 @@ export default defineConfig({ ...@@ -12,6 +12,7 @@ export default defineConfig({
resolve: { resolve: {
alias: { alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)), '@': fileURLToPath(new URL('./src', import.meta.url)),
'@/components': resolve(__dirname, 'src/components'),
}, },
}, },
// 添加CSS配置 // 添加CSS配置
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment