@@ -72,6 +72,9 @@ const I18N = {
7272 'session.delete' : '删除' ,
7373 'session.rename.prompt' : '输入新的会话名称:' ,
7474 'session.delete.confirm' : '确定删除这个会话吗?此操作不可撤销。' ,
75+ 'session.delete.default_hint' : '默认会话不可删除' ,
76+ 'confirm.ok' : '确定' ,
77+ 'confirm.cancel' : '取消' ,
7578 'panel.routing' : '模型路由' ,
7679 'panel.mode' : '权限模式' ,
7780 'panel.sandbox' : '沙箱' ,
@@ -150,6 +153,9 @@ const I18N = {
150153 'session.delete' : 'Delete' ,
151154 'session.rename.prompt' : 'Enter a new conversation name:' ,
152155 'session.delete.confirm' : 'Delete this conversation? This cannot be undone.' ,
156+ 'session.delete.default_hint' : 'The default conversation cannot be deleted' ,
157+ 'confirm.ok' : 'Confirm' ,
158+ 'confirm.cancel' : 'Cancel' ,
153159 'panel.routing' : 'Routing' ,
154160 'panel.mode' : 'Permission' ,
155161 'panel.sandbox' : 'Sandbox' ,
@@ -195,6 +201,8 @@ createApp({
195201 skillInstalling : false , skillMsg : '' , skillErr : false ,
196202 skillQuery : '' , skillResults : [ ] , skillSearching : false , skillSearched : false ,
197203 toast : '' , toastTimer : null , // 顶部临时提示(如压缩完成)
204+ confirmBox : null , // 自定义确认弹窗:null=关闭;{ text, danger, onYes } 时显示(不用浏览器原生 confirm)
205+ promptBox : null , // 自定义输入弹窗:null=关闭;{ title, value, placeholder, onOk } 时显示(不用浏览器原生 prompt)
198206 input : '' ,
199207 connected : false ,
200208 openIdx : - 1 , // 当前流式 assistant 消息下标
@@ -517,6 +525,25 @@ createApp({
517525 if ( this . toastTimer ) clearTimeout ( this . toastTimer ) ;
518526 this . toastTimer = setTimeout ( ( ) => { this . toast = '' ; } , 3500 ) ;
519527 } ,
528+ // askConfirm 弹 app 内自定义确认框(替代浏览器原生 confirm):opts = { text, danger, onYes }。
529+ askConfirm ( opts ) { this . confirmBox = opts ; } ,
530+ confirmYes ( ) {
531+ const cb = this . confirmBox ;
532+ this . confirmBox = null ;
533+ if ( cb && cb . onYes ) cb . onYes ( ) ;
534+ } ,
535+ confirmNo ( ) { this . confirmBox = null ; } ,
536+ // askPrompt 弹 app 内自定义输入框(替代浏览器原生 prompt):opts = { title, value, placeholder, onOk }。
537+ askPrompt ( opts ) {
538+ this . promptBox = { title : '' , value : '' , placeholder : '' , ...opts } ;
539+ this . $nextTick ( ( ) => { if ( this . $refs . promptInput ) { this . $refs . promptInput . focus ( ) ; this . $refs . promptInput . select ( ) ; } } ) ;
540+ } ,
541+ promptOk ( ) {
542+ const cb = this . promptBox ;
543+ this . promptBox = null ;
544+ if ( cb && cb . onOk ) cb . onOk ( ( cb . value || '' ) . trim ( ) ) ;
545+ } ,
546+ promptCancel ( ) { this . promptBox = null ; } ,
520547 async openSkill ( ) {
521548 this . skillShow = true ; this . skillMsg = '' ; this . skillTab = 'installed' ;
522549 this . skillResults = [ ] ; this . skillSearched = false ; this . skillQuery = '' ;
@@ -782,12 +809,21 @@ createApp({
782809 toggleMenu ( id ) { this . menuOpen = this . menuOpen === id ? null : id ; } ,
783810 renameSession ( s ) {
784811 this . menuOpen = null ;
785- const title = window . prompt ( this . t ( 'session.rename.prompt' ) , s . title || '' ) ;
786- if ( title != null && title . trim ( ) ) this . post ( '/api/session-rename' , { id : s . id , title : title . trim ( ) } ) ;
812+ this . askPrompt ( {
813+ title : this . t ( 'session.rename.prompt' ) ,
814+ value : s . title || '' ,
815+ onOk : ( title ) => { if ( title ) this . post ( '/api/session-rename' , { id : s . id , title } ) ; } ,
816+ } ) ;
787817 } ,
788818 deleteSession ( s ) {
789819 this . menuOpen = null ;
790- if ( window . confirm ( this . t ( 'session.delete.confirm' ) ) ) this . post ( '/api/session-delete' , { id : s . id } ) ;
820+ if ( s . id === 'default' ) { this . showToast ( this . t ( 'session.delete.default_hint' ) ) ; return ; } // 默认会话不可删,即时反馈(issue #141)
821+ // 用 app 内自定义确认弹窗,不用浏览器原生 confirm。
822+ this . askConfirm ( {
823+ text : this . t ( 'session.delete.confirm' ) ,
824+ danger : true ,
825+ onYes : ( ) => this . post ( '/api/session-delete' , { id : s . id } ) ,
826+ } ) ;
791827 } ,
792828 setLang ( lang ) { this . post ( '/api/lang' , { lang } ) ; } ,
793829 setModel ( role ) { this . post ( '/api/model' , { role } ) ; } ,
0 commit comments