File tree Expand file tree Collapse file tree 6 files changed +427
-49
lines changed
Expand file tree Collapse file tree 6 files changed +427
-49
lines changed Original file line number Diff line number Diff line change @@ -60,14 +60,19 @@ const getDelay = (proxy: any) => {
6060 return history [ history . length - 1 ] [ 'delay' ]
6161}
6262
63+ export interface ProxyGroupInfo {
64+ name : string ;
65+ icon ?: string ;
66+ }
67+
6368export default function createProxiesApi ( proxy : any ) {
6469 return {
6570 // 获取分组延迟
6671 async getDelay ( group : any , url : any , timeout : any ) {
6772 await proxy . $http . get ( '/group/' + group + '/delay?timeout=' + timeout + "&url=" + url ) ;
6873 } ,
6974 // 获取分组列表
70- async getGroups ( ) {
75+ async getGroups ( ) : Promise < ProxyGroupInfo [ ] > {
7176 // 获取所有节点分组列表
7277 const data = await proxy . $http . get ( '/proxies' ) ;
7378 const proxies = data [ 'proxies' ]
@@ -78,7 +83,7 @@ export default function createProxiesApi(proxy: any) {
7883 }
7984
8085 // 获取分组
81- const proxyGroup : any [ ] = [ ]
86+ const proxyGroup : ProxyGroupInfo [ ] = [ ]
8287 for ( const name of proxies [ 'GLOBAL' ] [ 'all' ] ) {
8388 if ( excludeGroupName [ name ] ) {
8489 continue
@@ -90,7 +95,10 @@ export default function createProxiesApi(proxy: any) {
9095 if ( ! ! group [ 'hidden' ] ) {
9196 continue
9297 }
93- proxyGroup . push ( name )
98+ proxyGroup . push ( {
99+ name,
100+ icon : typeof group [ 'icon' ] === 'string' ? group [ 'icon' ] : undefined ,
101+ } )
94102 }
95103
96104 return proxyGroup
Original file line number Diff line number Diff line change @@ -162,8 +162,10 @@ proxies:
162162 sort-off : Sort by latency
163163 vertical-on : Switch grouping to left-right style
164164 vertical-off : Switch grouping to drop-down style
165+ full-view : Switch grouping to full-view style
165166 direct : Currently in direct mode
166167 loading : Testing...
168+ selected-label : Selected
167169
168170profiles :
169171 title : Profiles
Original file line number Diff line number Diff line change @@ -162,8 +162,10 @@ proxies:
162162 sort-off : Сортировать по задержке
163163 vertical-on : Переключить группировку на горизонтальную
164164 vertical-off : Переключить группировку на выпадающую
165+ full-view : Переключить группировку на полный просмотр
165166 direct : В настоящее время прямой режим
166167 loading : Тестирование...
168+ selected-label : Выбрано
167169
168170profiles :
169171 title : Профили
Original file line number Diff line number Diff line change @@ -162,8 +162,10 @@ proxies:
162162 sort-off : 按延迟排序
163163 vertical-on : 切换分组为左右样式
164164 vertical-off : 切换分组为下拉样式
165+ full-view : 切换分组为全视图样式
165166 direct : 当前处于直连模式
166167 loading : 测试中。。。
168+ selected-label : 当前节点
167169
168170profiles :
169171 title : 订阅
Original file line number Diff line number Diff line change 11import { defineStore } from 'pinia' ;
22import { defaultPersist } from "@/types/persist" ;
33
4+ export type ProxyViewMode = 'horizontal' | 'dropdown' | 'full' ;
5+
46export const useProxiesStore = defineStore ( 'proxies' , {
57 state : ( ) => ( {
68 isHide : false ,
79 isSort : false ,
8- isVertical : false ,
10+ viewMode : 'full' as ProxyViewMode ,
911 active : '' ,
1012 now : "" ,
13+ groupExpansion : { } as Record < string , boolean > ,
1114 } ) ,
1215 actions : {
1316 setHide ( isHide : boolean ) {
@@ -16,15 +19,24 @@ export const useProxiesStore = defineStore('proxies', {
1619 setSort ( isSort : boolean ) {
1720 this . isSort = isSort ;
1821 } ,
19- setVertical ( isVertical : boolean ) {
20- this . isVertical = isVertical ;
22+ setViewMode ( viewMode : ProxyViewMode ) {
23+ this . viewMode = viewMode ;
2124 } ,
2225 setActive ( active : string ) {
2326 this . active = active ;
2427 } ,
2528 setNow ( now : string ) {
2629 this . now = now ;
2730 } ,
31+ setGroupExpansionState ( group : string , expanded : boolean ) {
32+ this . groupExpansion = {
33+ ...this . groupExpansion ,
34+ [ group ] : expanded ,
35+ } ;
36+ } ,
37+ replaceGroupExpansions ( expansions : Record < string , boolean > ) {
38+ this . groupExpansion = expansions ;
39+ } ,
2840 } ,
2941 persist : defaultPersist ,
3042} ) ;
You can’t perform that action at this time.
0 commit comments