1+ <template >
2+ <div class =" container" >
3+ <h2 class =" title" >添加资源</h2 >
4+
5+ <div class =" m-4" style =" display : flex ; justify-content : space-between ;align-items : center ;" >
6+ <div style =" display : flex ;align-items : center ;" >
7+ <p style =" margin-right : 10px ;" >资源:</p >
8+ </div >
9+ <el-select append-to =" .home" v-model =" selectPathList" style =" width : 240px ;" multiple collapse-tags
10+ collapse-tags-tooltip placeholder =" Select" >
11+ <el-option v-for =" item in pathList" :key =" item" :label =" item" :value =" item" >
12+ </el-option >
13+ </el-select >
14+ </div >
15+
16+ <div class =" m-4" style =" display : flex ; justify-content : space-between ;align-items : center ;" >
17+ <div style =" display : flex ;align-items : center ;" >
18+ <p style =" margin-right : 10px ;" >保存至:</p >
19+ </div >
20+ <div style =" display : flex ;align-items : center ; gap : 10px ;" >
21+
22+ <el-tooltip v-if =" isNewLauncher" content =" 取消新建" placement =" top" >
23+ <Close theme =" outline" size =" 20" fill =" #333" @click =" handleNewLauncher" />
24+ </el-tooltip >
25+ <el-tooltip v-else content =" 新建编组" placement =" top" >
26+ <Add theme =" outline" size =" 20" fill =" #333" @click =" handleNewLauncher" />
27+ </el-tooltip >
28+
29+ <el-select v-if =" !isNewLauncher" append-to =" .home" v-model =" targetLauncher" style =" width : 240px ;"
30+ collapse-tags collapse-tags-tooltip placeholder =" Select" >
31+ <el-option v-for =" item in launchers" :key =" item.id" :label =" item.name" :value =" item.id" >
32+ </el-option >
33+ </el-select >
34+ <el-input v-else v-model =" newLauncherName" style =" width : 240px ;" placeholder =" 请输入新编组名称" ></el-input >
35+ </div >
36+ </div >
37+
38+ <!-- 按钮 -->
39+ <div style =" display : flex ; justify-content : flex-end ;gap :10px ;align-items : center ; margin-top : 20px ;" >
40+ <button class =" cancel-button" @click =" cancelDragDrop" >取消</button >
41+ <button class =" confirm-button" @click =" confirmDragDrop" >确定</button >
42+ </div >
43+
44+ </div >
45+ </template >
46+
47+ <script >
48+ import { enable , isEnabled , disable } from ' @tauri-apps/plugin-autostart' ;
49+ import { invoke } from " @tauri-apps/api/core" ;
50+ import { onMounted , inject , ref , nextTick } from ' vue' ;
51+ import { Help , Add , Close } from ' @icon-park/vue-next' ;
52+
53+ export default {
54+ props: {
55+ pathList: {
56+ type: Array ,
57+ required: true ,
58+ },
59+ },
60+ components: {
61+ Help,
62+ Add,
63+ Close
64+ },
65+ setup (props , { emit }) {
66+ const theme = inject (' theme' );
67+ const selectPathList = ref (props .pathList );
68+ const launchers = ref ([]);
69+ const targetLauncher = ref ({});
70+ const isNewLauncher = ref (false );
71+ const newLauncherName = ref (" " );
72+
73+ const queryLaunchers = async () => {
74+ const launchers_data = await invoke (" query_launchers" );
75+ launchers .value = [... launchers_data];
76+ };
77+
78+ const initTargetLauncher = async () => {
79+ if (launchers .value .length > 0 ) {
80+ targetLauncher .value = launchers .value [0 ];
81+ }
82+ };
83+
84+ const handleNewLauncher = async () => {
85+ isNewLauncher .value = ! isNewLauncher .value ;
86+
87+ }
88+
89+ const cancelDragDrop = async () => {
90+ emit (" cancel_drag_drop" );
91+ }
92+
93+ const confirmDragDrop = async () => {
94+ // todo
95+ console .log (" 保存" )
96+ emit (" confirm_drag_drop" );
97+ }
98+
99+ // 在组件挂载时加载主题
100+ onMounted (() => {
101+ queryLaunchers ();
102+ initTargetLauncher ();
103+ });
104+
105+ return {
106+ selectPathList,
107+ launchers,
108+ targetLauncher,
109+ isNewLauncher,
110+ handleNewLauncher,
111+ newLauncherName,
112+ cancelDragDrop,
113+ confirmDragDrop
114+ };
115+ }
116+ };
117+ </script >
118+
119+ <style scoped>
120+ .container {
121+ /* 最大宽度 */
122+ max-width : 1000px ;
123+ /* 最大高度 */
124+ max-height : 400px ;
125+ /* 纵向滚动条 */
126+ overflow-y : auto ;
127+ padding : 20px ;
128+ /* 可选:添加边框 */
129+ border : 1px solid #ccc ;
130+ /* 可选:圆角 */
131+ border-radius : 8px ;
132+ }
133+
134+
135+ .title {
136+ margin-top : 0px ;
137+ }
138+
139+ label {
140+ margin-right : 10px ;
141+ }
142+
143+ button {
144+ padding : 10px 20px ;
145+ background-color : #409eff ;;
146+ color : white ;
147+ border : none ;
148+ border-radius : 5px ;
149+ cursor : pointer ;
150+ border-color : #409eff ;
151+ }
152+
153+ button :hover {
154+ background-color : #0056b3 ;
155+ }
156+
157+ .cancel-button {
158+ background-color : #fff ;
159+ /* 背景色为白色 */
160+ border-color : #ccc ;
161+ /* 边框颜色为浅灰色 */
162+ color : #666 ;
163+ /* 字体颜色为深灰色 */
164+ }
165+
166+ .cancel-button :hover {
167+ background-color : #f5f5f5 ;
168+ /* 悬停时背景色为浅灰色 */
169+ border-color : #bbb ;
170+ /* 悬停时边框颜色为灰色 */
171+ color : #333 ;
172+ /* 悬停时字体颜色为更深的灰色 */
173+ }
174+
175+ .checkbox-label {
176+ /* display: flex; */
177+ align-items : center ;
178+ font-size : 16px ;
179+ cursor : pointer ;
180+ width : 100px ;
181+ }
182+
183+ input [type = " checkbox" ] {
184+ margin-left : 10px ;
185+ transform : scale (1.2 );
186+ /* 放大复选框大小 */
187+ cursor : pointer ;
188+ }
189+
190+ .confirm-button {
191+ background-color : #409eff ;
192+ border-color : #409eff ;
193+ color : #fff ;
194+ }
195+ .confirm-button :hover {
196+ background-color : #66b1ff ;
197+ border-color : #66b1ff ;
198+ }
199+ </style >
0 commit comments