Skip to content

Commit df1c565

Browse files
committed
2 parents be4750a + 1abff21 commit df1c565

File tree

43 files changed

+1532
-699
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1532
-699
lines changed

.env.base

Lines changed: 0 additions & 19 deletions
This file was deleted.

.env.dev

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,37 @@
1-
# 开发环境
1+
# 开发环境:本地只启动前端项目,依赖开发环境(后端、APP)
22
NODE_ENV=development
33

4-
VITE_DEV=false
4+
VITE_DEV=true
55

66
# 请求路径
7-
VITE_BASE_URL='http://localhost:48080'
7+
VITE_BASE_URL='http://api-dashboard.yudao.iocoder.cn'
88

99
# 上传路径
10-
VITE_UPLOAD_URL='http://localhost:48080/admin-api/infra/file/upload'
10+
VITE_UPLOAD_URL='http://api-dashboard.yudao.iocoder.cn/admin-api/infra/file/upload'
1111

1212
# 接口前缀
1313
VITE_API_BASEPATH=/dev-api
1414

1515
# 接口地址
1616
VITE_API_URL=/admin-api
1717

18-
# 打包路径
19-
VITE_BASE_PATH=/
20-
2118
# 是否删除debugger
22-
VITE_DROP_DEBUGGER=true
19+
VITE_DROP_DEBUGGER=false
2320

2421
# 是否删除console.log
2522
VITE_DROP_CONSOLE=false
2623

2724
# 是否sourcemap
28-
VITE_SOURCEMAP=false
25+
VITE_SOURCEMAP=true
26+
27+
# 打包路径
28+
VITE_BASE_PATH=/
2929

3030
# 输出路径
3131
VITE_OUT_DIR=dist
32+
33+
# 商城H5会员端域名
34+
VITE_MALL_H5_DOMAIN='http://mall.yudao.iocoder.cn'
35+
36+
# 验证码的开关
37+
VITE_APP_CAPTCHA_ENABLE=false
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
1-
# 本地开发环境
1+
# 本地开发环境:本地启动所有项目(前端、后端、APP)时使用,不依赖外部环境
22
NODE_ENV=development
33

44
VITE_DEV=true
55

66
# 请求路径
7-
VITE_BASE_URL='http://api-dashboard.yudao.iocoder.cn'
7+
VITE_BASE_URL='http://localhost:48080'
88

99
# 上传路径
10-
VITE_UPLOAD_URL='http://api-dashboard.yudao.iocoder.cn/admin-api/infra/file/upload'
10+
VITE_UPLOAD_URL='http://localhost:48080/admin-api/infra/file/upload'
1111

1212
# 接口前缀
1313
VITE_API_BASEPATH=/dev-api
1414

1515
# 接口地址
1616
VITE_API_URL=/admin-api
1717

18-
# 打包路径
19-
VITE_BASE_PATH=/
20-
21-
# 项目本地运行端口号, 与.vscode/launch.json配合
22-
VITE_PORT=80
23-
2418
# 是否删除debugger
2519
VITE_DROP_DEBUGGER=false
2620

2721
# 是否删除console.log
2822
VITE_DROP_CONSOLE=false
2923

3024
# 是否sourcemap
31-
VITE_SOURCEMAP=true
25+
VITE_SOURCEMAP=false
26+
27+
# 打包路径
28+
VITE_BASE_PATH=/
29+
30+
# 商城H5会员端域名
31+
VITE_MALL_H5_DOMAIN='http://localhost:3000'
3232

3333
# 验证码的开关
3434
VITE_APP_CAPTCHA_ENABLE=false

.env.pro renamed to .env.prod

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 生产环境
1+
# 生产环境:只在打包时使用
22
NODE_ENV=production
33

44
VITE_DEV=false
@@ -28,4 +28,7 @@ VITE_SOURCEMAP=false
2828
VITE_BASE_PATH=/
2929

3030
# 输出路径
31-
VITE_OUT_DIR=dist-pro
31+
VITE_OUT_DIR=dist-prod
32+
33+
# 商城H5会员端域名
34+
VITE_MALL_H5_DOMAIN='http://mall.yudao.iocoder.cn'

.env.stage

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 生产环境
1+
# 预发布环境:只在打包时使用
22
NODE_ENV=production
33

44
VITE_DEV=false
@@ -29,3 +29,6 @@ VITE_BASE_PATH='http://static-vue3.yudao.iocoder.cn/'
2929

3030
# 输出路径
3131
VITE_OUT_DIR=dist-stage
32+
33+
# 商城H5会员端域名
34+
VITE_MALL_H5_DOMAIN='http://mall.yudao.iocoder.cn'

.env.static renamed to .env.test

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 开发环境
1+
# 测试环境:只在打包时使用
22
NODE_ENV=production
33

44
VITE_DEV=false
@@ -28,4 +28,7 @@ VITE_SOURCEMAP=false
2828
VITE_BASE_PATH=/admin-ui-vue3/
2929

3030
# 输出路径
31-
VITE_OUT_DIR=dist-dev
31+
VITE_OUT_DIR=dist-test
32+
33+
# 商城H5会员端域名
34+
VITE_MALL_H5_DOMAIN='http://mall.yudao.iocoder.cn'

package.json

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,17 @@
66
"private": false,
77
"scripts": {
88
"i": "pnpm install",
9-
"dev": "vite --mode base",
10-
"front": "vite --mode front",
9+
"local-dev": "vite --mode local-dev",
10+
"dev": "vite --mode dev",
1111
"ts:check": "vue-tsc --noEmit",
12-
"build:pro": "node --max_old_space_size=8192 ./node_modules/vite/bin/vite.js build --mode pro",
12+
"build:local-dev": "node --max_old_space_size=8192 ./node_modules/vite/bin/vite.js build --mode local-dev",
1313
"build:dev": "node --max_old_space_size=8192 ./node_modules/vite/bin/vite.js build --mode dev",
14-
"build:base": "node --max_old_space_size=8192 ./node_modules/vite/bin/vite.js build --mode base",
14+
"build:test": "node --max_old_space_size=8192 ./node_modules/vite/bin/vite.js build --mode test",
1515
"build:stage": "node --max_old_space_size=8192 ./node_modules/vite/bin/vite.js build --mode stage",
16-
"build:static": "node --max_old_space_size=8192 ./node_modules/vite/bin/vite.js build --mode static",
17-
"build:front": "node --max_old_space_size=8192 ./node_modules/vite/bin/vite.js build --mode front",
18-
"serve:pro": "vite preview --mode pro",
16+
"build:prod": "node --max_old_space_size=8192 ./node_modules/vite/bin/vite.js build --mode prod",
1917
"serve:dev": "vite preview --mode dev",
20-
"preview": "pnpm build:base && vite preview",
18+
"serve:prod": "vite preview --mode prod",
19+
"preview": "pnpm build:local-dev && vite preview",
2120
"clean": "npx rimraf node_modules",
2221
"clean:cache": "npx rimraf node_modules/.cache",
2322
"lint:eslint": "eslint --fix --ext .js,.ts,.vue ./src",

src/components/AppLinkInput/AppLinkSelectDialog.vue

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,11 @@
2929
:key="appLinkIndex"
3030
:content="appLink.path"
3131
placement="bottom"
32+
:show-after="300"
3233
>
3334
<el-button
3435
class="m-b-8px m-r-8px m-l-0px!"
35-
:type="isSameLink(appLink.path, activeAppLink) ? 'primary' : 'default'"
36+
:type="isSameLink(appLink.path, activeAppLink.path) ? 'primary' : 'default'"
3637
@click="handleAppLinkSelected(appLink)"
3738
>
3839
{{ appLink.name }}
@@ -63,7 +64,7 @@
6364
</Dialog>
6465
</template>
6566
<script lang="ts" setup>
66-
import { APP_LINK_GROUP_LIST, APP_LINK_TYPE_ENUM } from './data'
67+
import { APP_LINK_GROUP_LIST, APP_LINK_TYPE_ENUM, AppLink } from './data'
6768
import { ButtonInstance, ScrollbarInstance } from 'element-plus'
6869
import { split } from 'lodash-es'
6970
import ProductCategorySelect from '@/views/mall/product/category/components/ProductCategorySelect.vue'
@@ -74,17 +75,23 @@ defineOptions({ name: 'AppLinkSelectDialog' })
7475
// 选中的分组,默认选中第一个
7576
const activeGroup = ref(APP_LINK_GROUP_LIST[0].name)
7677
// 选中的 APP 链接
77-
const activeAppLink = ref('')
78+
const activeAppLink = ref({} as AppLink)
7879
7980
/** 打开弹窗 */
8081
const dialogVisible = ref(false)
8182
const open = (link: string) => {
82-
activeAppLink.value = link
83+
activeAppLink.value.path = link
8384
dialogVisible.value = true
8485
8586
// 滚动到当前的链接
8687
const group = APP_LINK_GROUP_LIST.find((group) =>
87-
group.links.some((linkItem) => isSameLink(linkItem.path, link))
88+
group.links.some((linkItem) => {
89+
const sameLink = isSameLink(linkItem.path, link)
90+
if (sameLink) {
91+
activeAppLink.value = { ...linkItem, path: link }
92+
}
93+
return sameLink
94+
})
8895
)
8996
if (group) {
9097
// 使用 nextTick 的原因:可能 Dom 还没生成,导致滚动失败
@@ -94,17 +101,17 @@ const open = (link: string) => {
94101
defineExpose({ open })
95102
96103
// 处理 APP 链接选中
97-
const handleAppLinkSelected = (appLink: any) => {
98-
if (!isSameLink(appLink.path, activeAppLink.value)) {
99-
activeAppLink.value = appLink.path
104+
const handleAppLinkSelected = (appLink: AppLink) => {
105+
if (!isSameLink(appLink.path, activeAppLink.value.path)) {
106+
activeAppLink.value = appLink
100107
}
101108
switch (appLink.type) {
102109
case APP_LINK_TYPE_ENUM.PRODUCT_CATEGORY_LIST:
103110
detailSelectDialog.value.visible = true
104111
detailSelectDialog.value.type = appLink.type
105112
// 返显
106113
detailSelectDialog.value.id =
107-
getUrlNumberValue('id', 'http://127.0.0.1' + activeAppLink.value) || undefined
114+
getUrlNumberValue('id', 'http://127.0.0.1' + activeAppLink.value.path) || undefined
108115
break
109116
default:
110117
break
@@ -114,10 +121,12 @@ const handleAppLinkSelected = (appLink: any) => {
114121
// 处理绑定值更新
115122
const emit = defineEmits<{
116123
change: [link: string]
124+
appLinkChange: [appLink: AppLink]
117125
}>()
118126
const handleSubmit = () => {
119127
dialogVisible.value = false
120-
emit('change', activeAppLink.value)
128+
emit('change', activeAppLink.value.path)
129+
emit('appLinkChange', activeAppLink.value)
121130
}
122131
123132
// 分组标题引用列表
@@ -127,7 +136,7 @@ const groupTitleRefs = ref<HTMLInputElement[]>([])
127136
* @param scrollTop 滚动条的位置
128137
*/
129138
const handleScroll = ({ scrollTop }: { scrollTop: number }) => {
130-
const titleEl = groupTitleRefs.value.find((titleEl) => {
139+
const titleEl = groupTitleRefs.value.find((titleEl: HTMLInputElement) => {
131140
// 获取标题的位置信息
132141
const { offsetHeight, offsetTop } = titleEl
133142
// 判断标题是否在可视范围内
@@ -146,7 +155,7 @@ const linkScrollbar = ref<ScrollbarInstance>()
146155
// 处理分组选中
147156
const handleGroupSelected = (group: string) => {
148157
activeGroup.value = group
149-
const titleRef = groupTitleRefs.value.find((item) => item.textContent === group)
158+
const titleRef = groupTitleRefs.value.find((item: HTMLInputElement) => item.textContent === group)
150159
if (titleRef) {
151160
// 滚动分组标题
152161
linkScrollbar.value?.setScrollTop(titleRef.offsetTop)
@@ -160,8 +169,8 @@ const groupBtnRefs = ref<ButtonInstance[]>([])
160169
// 自动滚动分组按钮,确保分组按钮保持在可视区域内
161170
const scrollToGroupBtn = (group: string) => {
162171
const groupBtn = groupBtnRefs.value
163-
.map((btn) => btn['ref'])
164-
.find((ref) => ref.textContent === group)
172+
.map((btn: ButtonInstance) => btn['ref'])
173+
.find((ref: Node) => ref.textContent === group)
165174
if (groupBtn) {
166175
groupScrollbar.value?.setScrollTop(groupBtn.offsetTop)
167176
}
@@ -184,11 +193,11 @@ const detailSelectDialog = ref<{
184193
})
185194
// 处理详情选择
186195
const handleProductCategorySelected = (id: number) => {
187-
const url = new URL(activeAppLink.value, 'http://127.0.0.1')
196+
const url = new URL(activeAppLink.value.path, 'http://127.0.0.1')
188197
// 修改 id 参数
189198
url.searchParams.set('id', `${id}`)
190199
// 排除域名
191-
activeAppLink.value = `${url.pathname}${url.search}`
200+
activeAppLink.value.path = `${url.pathname}${url.search}`
192201
// 关闭对话框
193202
detailSelectDialog.value.visible = false
194203
// 重置 id

src/components/AppLinkInput/data.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
// APP 链接分组
2+
export interface AppLinkGroup {
3+
// 分组名称
4+
name: string
5+
// 链接列表
6+
links: AppLink[]
7+
}
8+
// APP 链接
9+
export interface AppLink {
10+
// 链接名称
11+
name: string
12+
// 链接地址
13+
path: string
14+
// 链接的类型
15+
type?: APP_LINK_TYPE_ENUM
16+
}
17+
118
// APP 链接类型(需要特殊处理,例如商品详情)
219
export const enum APP_LINK_TYPE_ENUM {
320
// 拼团活动
@@ -243,4 +260,4 @@ export const APP_LINK_GROUP_LIST = [
243260
}
244261
]
245262
}
246-
]
263+
] as AppLinkGroup[]

src/components/AppLinkInput/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const emit = defineEmits<{
3737
'update:modelValue': [link: string]
3838
}>()
3939
watch(
40-
() => appLink,
40+
() => appLink.value,
4141
() => emit('update:modelValue', appLink.value)
4242
)
4343
</script>

0 commit comments

Comments
 (0)