Skip to content

Commit 1f4a7d5

Browse files
author
Taois
committed
fix: 刷新丢失分类
1 parent 3f7fc1b commit 1f4a7d5

6 files changed

Lines changed: 230 additions & 73 deletions

File tree

dashboard/src/components/VideoList.vue

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -812,6 +812,12 @@ const getClassListHash = (classList) => {
812812
return JSON.stringify(classList.class.map(c => c.type_id || c.id || ''));
813813
};
814814
815+
const isValidActiveKey = (key, classList = props.classList) => {
816+
if (!key) return false;
817+
if (key === "recommendTuijian404") return hasRecommendVideos.value;
818+
return classList?.class?.some(item => String(item.type_id) === String(key));
819+
};
820+
815821
watch(() => props.classList, (newClassList, oldClassList) => {
816822
// 防止递归更新
817823
if (isClassListUpdating) {
@@ -862,12 +868,17 @@ watch(() => props.classList, (newClassList, oldClassList) => {
862868
return;
863869
}
864870
865-
const newActiveKey = getDefaultActiveKey();
866-
871+
const requestedActiveKey = props.sourceRoute?.query?.activeKey || props.returnToActiveKey;
872+
const newActiveKey = isValidActiveKey(requestedActiveKey, newClassList)
873+
? requestedActiveKey
874+
: getDefaultActiveKey();
875+
867876
if (activeKey.value !== newActiveKey) {
868877
activeKey.value = newActiveKey;
869878
getListData(newActiveKey);
870-
emit('activeKeyChange', newActiveKey);
879+
if (!requestedActiveKey) {
880+
emit('activeKeyChange', newActiveKey);
881+
}
871882
}
872883
} catch (error) {
873884
console.error('classList watch处理失败:', error);
@@ -889,14 +900,12 @@ watch(() => props.sourceRoute?.query?.activeKey, (newActiveKey) => {
889900
if (newActiveKey && newActiveKey !== activeKey.value) {
890901
console.log('[DEBUG] sourceRoute activeKey changed:', newActiveKey, 'current:', activeKey.value);
891902
activeKey.value = newActiveKey;
892-
903+
893904
// 如果当前分类没有数据,则重新加载
894905
if (!listData[newActiveKey] || listData[newActiveKey].length === 0) {
895906
console.log('[DEBUG] 重新加载分类数据:', newActiveKey);
896907
getListData(newActiveKey);
897908
}
898-
899-
emit('activeKeyChange', newActiveKey);
900909
}
901910
}, { immediate: true });
902911

dashboard/src/components/actions/InputAction.vue

Lines changed: 83 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -46,46 +46,63 @@
4646
</a-space>
4747
</template>
4848

49-
<a-space v-if="quickSelectOptions.length > 0" wrap class="quick-select-options">
50-
<a-tag
51-
v-for="option in quickSelectOptions"
52-
:key="option.value"
53-
color="arcoblue"
54-
checkable
55-
@click="selectQuickOption(option)"
56-
>
57-
{{ option.name }}
58-
</a-tag>
59-
</a-space>
49+
<div class="input-field-stack">
50+
<div v-if="quickSelectOptions.length > 0" class="quick-select-options">
51+
<a-tag
52+
v-for="option in quickSelectOptions"
53+
:key="option.value"
54+
color="arcoblue"
55+
checkable
56+
:checked="isQuickOptionSelected(option)"
57+
@click="selectQuickOption(option)"
58+
>
59+
{{ option.name }}
60+
</a-tag>
61+
</div>
6062

61-
<div v-if="!isMultiLine" class="input-inline-row">
6263
<a-input
64+
v-if="!isMultiLine"
6365
ref="inputRef"
6466
v-model="inputValue"
67+
class="input-with-editor"
6568
:type="inputType"
6669
:placeholder="config.tip || '请输入内容...'"
6770
:status="hasError ? 'error' : undefined"
6871
allow-clear
6972
@keyup.enter="handleSubmit"
7073
@input="handleInput"
71-
/>
72-
<a-button class="input-inline-action" @click="openTextEditor">大文本</a-button>
74+
>
75+
<template #suffix>
76+
<a-button
77+
type="text"
78+
size="mini"
79+
class="input-editor-icon-button"
80+
title="打开大文本编辑器"
81+
@click.stop="openTextEditor"
82+
>
83+
<template #icon>
84+
<IconEdit />
85+
</template>
86+
</a-button>
87+
</template>
88+
</a-input>
89+
90+
<template v-else>
91+
<a-textarea
92+
ref="inputRef"
93+
v-model="inputValue"
94+
:placeholder="config.tip || '请输入内容...'"
95+
:auto-size="{ minRows: Number(config.multiLine) || 4, maxRows: 10 }"
96+
:status="hasError ? 'error' : undefined"
97+
allow-clear
98+
@input="handleInput"
99+
/>
100+
101+
<a-button size="small" class="text-editor-button" @click="openTextEditor">
102+
打开大文本编辑器
103+
</a-button>
104+
</template>
73105
</div>
74-
75-
<a-textarea
76-
v-else
77-
ref="inputRef"
78-
v-model="inputValue"
79-
:placeholder="config.tip || '请输入内容...'"
80-
:auto-size="{ minRows: Number(config.multiLine) || 4, maxRows: 10 }"
81-
:status="hasError ? 'error' : undefined"
82-
allow-clear
83-
@input="handleInput"
84-
/>
85-
86-
<a-button v-if="isMultiLine" size="small" class="text-editor-button" @click="openTextEditor">
87-
打开大文本编辑器
88-
</a-button>
89106
</a-form-item>
90107
</a-form>
91108

@@ -119,14 +136,16 @@
119136
<ActionShell
120137
:visible="showTextEditor"
121138
title="大文本编辑器"
122-
:width="800"
139+
:width="720"
140+
custom-class="action-text-editor-modal"
123141
@close="closeTextEditor"
124142
>
125143
<a-textarea
126144
ref="textEditorRef"
127145
v-model="editorText"
146+
class="action-text-editor-textarea"
128147
placeholder="请输入文本内容..."
129-
:auto-size="{ minRows: 10, maxRows: 16 }"
148+
:auto-size="{ minRows: 9, maxRows: 13 }"
130149
/>
131150

132151
<template #footer>
@@ -143,6 +162,7 @@
143162

144163
<script>
145164
import { ref, computed, watch, nextTick, onMounted, onUnmounted } from 'vue'
165+
import { IconEdit } from '@arco-design/web-vue/es/icon'
146166
import ActionShell from './shared/ActionShell.vue'
147167
import ActionMessage from './shared/ActionMessage.vue'
148168
import ActionMedia from './shared/ActionMedia.vue'
@@ -167,7 +187,8 @@ export default {
167187
ActionMessage,
168188
ActionMedia,
169189
ActionTimeout,
170-
ActionFooter
190+
ActionFooter,
191+
IconEdit
171192
},
172193
props: {
173194
config: {
@@ -751,10 +772,14 @@ export default {
751772
validateInput(inputValue.value)
752773
}
753774
775+
const isQuickOptionSelected = (option) => {
776+
return String(inputValue.value) === String(option.value)
777+
}
778+
754779
const selectQuickOption = (option) => {
755780
inputValue.value = option.value
756781
validateInput(option.value)
757-
782+
758783
// 如果只允许快速选择,直接提交
759784
if (props.config.onlyQuickSelect) {
760785
nextTick(() => {
@@ -911,6 +936,7 @@ export default {
911936
handleReset,
912937
handleImageClick,
913938
selectQuickOption,
939+
isQuickOptionSelected,
914940
// 大文本编辑器相关
915941
textEditorRef,
916942
showTextEditor,
@@ -928,25 +954,40 @@ export default {
928954
width: 100%;
929955
}
930956
931-
.quick-select-options {
932-
margin-bottom: 12px;
957+
.input-field-stack {
958+
display: flex;
959+
flex-direction: column;
960+
gap: 10px;
961+
width: 100%;
933962
}
934963
935-
.input-inline-row {
964+
.quick-select-options {
936965
display: flex;
966+
flex-wrap: wrap;
937967
align-items: flex-start;
938968
gap: 8px;
939969
width: 100%;
940-
margin-top: 4px;
941970
}
942971
943-
.input-inline-row :deep(.arco-input-wrapper) {
944-
flex: 1;
945-
min-width: 0;
972+
.input-with-editor {
973+
width: 100%;
974+
}
975+
976+
.input-editor-icon-button {
977+
color: var(--color-text-2);
978+
}
979+
980+
.input-editor-icon-button:hover {
981+
color: rgb(var(--primary-6));
982+
background: var(--color-fill-2);
983+
}
984+
985+
.action-text-editor-textarea {
986+
width: 100%;
946987
}
947988
948-
.input-inline-action {
949-
flex-shrink: 0;
989+
.action-text-editor-textarea :deep(textarea) {
990+
line-height: 1.55;
950991
}
951992
952993
.input-extra {

0 commit comments

Comments
 (0)