4848import { cloneDeep , set } from ' lodash'
4949import NodeContainer from ' @/workflow/common/NodeContainer.vue'
5050import { copyClick } from ' @/utils/clipboard'
51- import { ref , onMounted } from ' vue'
51+ import { ref , onMounted , watch } from ' vue'
5252import { t } from ' @/locales'
53+ import { useI18n } from ' vue-i18n'
5354const props = defineProps <{ nodeModel: any }>()
55+ const { locale } = useI18n ({ useScope: ' global' })
5456
5557const showicon = ref (false )
56- const globalFields = [
58+ const getGlobalFields = () => [
5759 { label: t (' workflow.nodes.startNode.currentTime' ), value: ' time' },
58- {
59- label: t (' views.application.form.historyRecord.label' ),
60- value: ' history_context' ,
61- },
60+ { label: t (' views.application.form.historyRecord.label' ), value: ' history_context' },
6261 { label: t (' aiChat.chatId' ), value: ' chat_id' },
63- {
64- label: t (' aiChat.chatUserId' ),
65- value: ' chat_user_id' ,
66- },
67- {
68- label: t (' aiChat.chatUserType' ),
69- value: ' chat_user_type' ,
70- },
71- {
72- label: t (' aiChat.chatUserGroup' ),
73- value: ' chat_user_group' ,
74- },
75- {
76- label: t (' views.chatUser.title' ),
77- value: ' chat_user' ,
78- },
62+ { label: t (' aiChat.chatUserId' ), value: ' chat_user_id' },
63+ { label: t (' aiChat.chatUserType' ), value: ' chat_user_type' },
64+ { label: t (' aiChat.chatUserGroup' ), value: ' chat_user_group' },
65+ { label: t (' views.chatUser.title' ), value: ' chat_user' },
7966]
8067
68+ const refreshStartQuestionField = () => {
69+ const questionFields = [{ label: t (' workflow.nodes.startNode.question' ), value: ' question' }]
70+ set (props .nodeModel .properties .config , ' fields' , questionFields )
71+ set (props .nodeModel .properties , ' fields' , questionFields )
72+ }
73+
8174const getRefreshFieldList = () => {
8275 const user_input_fields = props .nodeModel .graphModel .nodes
8376 .filter ((v : any ) => v .id === ' base-node' )
@@ -98,7 +91,7 @@ const getRefreshFieldList = () => {
9891}
9992const refreshFieldList = () => {
10093 const refreshFieldList = getRefreshFieldList ()
101- set (props .nodeModel .properties .config , ' globalFields' , [... globalFields , ... refreshFieldList ])
94+ set (props .nodeModel .properties .config , ' globalFields' , [... getGlobalFields () , ... refreshFieldList ])
10295}
10396
10497const refreshChatFieldList = () => {
@@ -179,6 +172,15 @@ const refreshLongTermConfig = () => {
179172props .nodeModel .graphModel .eventCenter .on (' refreshLongTermConfig' , refreshLongTermConfig )
180173
181174onMounted (() => {
175+ refreshStartQuestionField ()
176+ refreshChatFieldList ()
177+ refreshFieldList ()
178+ refreshFileUploadConfig ()
179+ refreshLongTermConfig ()
180+ })
181+
182+ watch (locale , () => {
183+ refreshStartQuestionField ()
182184 refreshChatFieldList ()
183185 refreshFieldList ()
184186 refreshFileUploadConfig ()
0 commit comments