mirror of
				https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
				synced 2025-10-31 13:41:07 +08:00 
			
		
		
		
	节点预览可以预览原始订阅的节点了
This commit is contained in:
		
							parent
							
								
									b092d3fd6a
								
							
						
					
					
						commit
						6c552500c6
					
				| @ -139,6 +139,7 @@ function service() { | ||||
|     async function downloadSubscription(req, res) { | ||||
|         const {name} = req.params; | ||||
|         const {cache} = req.query; | ||||
|         const {raw} = req.query || "false"; | ||||
|         const platform = req.query.target || getPlatformFromHeaders(req.headers) || "JSON"; | ||||
|         const useCache = typeof cache === 'undefined' ? (platform === 'JSON' || platform === 'URI') : cache; | ||||
| 
 | ||||
| @ -148,7 +149,13 @@ function service() { | ||||
|         const sub = allSubs[name]; | ||||
|         if (sub) { | ||||
|             try { | ||||
|                 const output = await produceArtifact({type: 'subscription', item: sub, platform, useCache}); | ||||
|                 const output = await produceArtifact({ | ||||
|                     type: 'subscription', | ||||
|                     item: sub, | ||||
|                     platform, | ||||
|                     useCache, | ||||
|                     noProcessor: raw | ||||
|                 }); | ||||
|                 if (platform === 'JSON') { | ||||
|                     res.set("Content-Type", "application/json;charset=utf-8").send(output); | ||||
|                 } else { | ||||
| @ -289,6 +296,7 @@ function service() { | ||||
|     async function downloadCollection(req, res) { | ||||
|         const {name} = req.params; | ||||
|         const {cache} = req.query || "false"; | ||||
|         const {raw} = req.query || "false"; | ||||
|         const platform = req.query.target || getPlatformFromHeaders(req.headers) || "JSON"; | ||||
|         const useCache = typeof cache === 'undefined' ? (platform === 'JSON' || platform === 'URI') : cache; | ||||
| 
 | ||||
| @ -299,7 +307,13 @@ function service() { | ||||
| 
 | ||||
|         if (collection) { | ||||
|             try { | ||||
|                 const output = await produceArtifact({type: "collection", item: collection, platform, useCache}); | ||||
|                 const output = await produceArtifact({ | ||||
|                     type: "collection", | ||||
|                     item: collection, | ||||
|                     platform, | ||||
|                     useCache, | ||||
|                     noProcessor: raw | ||||
|                 }); | ||||
|                 if (platform === 'JSON') { | ||||
|                     res.set("Content-Type", "application/json;charset=utf-8").send(output); | ||||
|                 } else { | ||||
| @ -445,15 +459,19 @@ function service() { | ||||
|     function createRule(req, res) { | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     function deleteRule(req, res) { | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     function updateRule(req, res) { | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     function getAllRules(req, res) { | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     function getRule(req, res) { | ||||
| 
 | ||||
|     } | ||||
| @ -790,14 +808,20 @@ function service() { | ||||
|         return body; | ||||
|     } | ||||
| 
 | ||||
|     async function produceArtifact({type, item, platform, useCache} = {platform: "JSON", useCache: false}) { | ||||
|     async function produceArtifact({type, item, platform, useCache, noProcessor} = { | ||||
|         platform: "JSON", | ||||
|         useCache: false, | ||||
|         noProcessor: false | ||||
|     }) { | ||||
|         if (type === 'subscription') { | ||||
|             const sub = item; | ||||
|             const raw = await getResource(sub.url, useCache); | ||||
|             // parse proxies
 | ||||
|             let proxies = ProxyUtils.parse(raw); | ||||
|             // apply processors
 | ||||
|             proxies = await ProxyUtils.process(proxies, sub.process || []); | ||||
|             if (!noProcessor) { | ||||
|                 // apply processors
 | ||||
|                 proxies = await ProxyUtils.process(proxies, sub.process || []); | ||||
|             } | ||||
|             // produce
 | ||||
|             return ProxyUtils.produce(proxies, platform); | ||||
|         } else if (type === 'collection') { | ||||
| @ -812,16 +836,20 @@ function service() { | ||||
|                     const raw = await getResource(sub.url, useCache); | ||||
|                     // parse proxies
 | ||||
|                     let currentProxies = ProxyUtils.parse(raw) | ||||
|                     // apply processors
 | ||||
|                     currentProxies = await ProxyUtils.process(currentProxies, sub.process || []); | ||||
|                     if (!noProcessor) { | ||||
|                         // apply processors
 | ||||
|                         currentProxies = await ProxyUtils.process(currentProxies, sub.process || []); | ||||
|                     } | ||||
|                     // merge
 | ||||
|                     proxies = proxies.concat(currentProxies); | ||||
|                 } catch (err) { | ||||
|                     $.error(`处理组合订阅中的子订阅: ${sub.name}时出现错误:${err}! 该订阅已被跳过。`); | ||||
|                 } | ||||
|             } | ||||
|             // apply own processors
 | ||||
|             proxies = await ProxyUtils.process(proxies, collection.process || []); | ||||
|             if (!noProcessor) { | ||||
|                 // apply own processors
 | ||||
|                 proxies = await ProxyUtils.process(proxies, collection.process || []); | ||||
|             } | ||||
|             if (proxies.length === 0) { | ||||
|                 throw new Error(`组合订阅中不含有效节点!`); | ||||
|             } | ||||
| @ -2966,7 +2994,7 @@ var RuleUtils = (function () { | ||||
|             let matched; | ||||
|             try { | ||||
|                 matched = parser.test(raw); | ||||
|             } catch(err) { | ||||
|             } catch (err) { | ||||
|                 matched = false; | ||||
|             } | ||||
|             if (matched) { | ||||
|  | ||||
							
								
								
									
										4
									
								
								backend/sub-store.min.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								backend/sub-store.min.js
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							| @ -1024,22 +1024,6 @@ html, body { | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| .v-tabs-bar { | ||||
|   .v-slide-group__wrapper { | ||||
|     overflow: visible; | ||||
|     display: -webkit-inline-box; | ||||
|     contain: inherit; | ||||
| 
 | ||||
|     .v-slide-group__content { | ||||
|       z-index: 2; | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   .v-tab:not(:first-child) { | ||||
|     margin-left: 5px; | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| .v-expansion-panel { | ||||
|   &:before { | ||||
|     -webkit-box-shadow: none; | ||||
| @ -1503,4 +1487,10 @@ html, body { | ||||
|   .v-slide-group__wrapper { | ||||
|     contain: none; | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| .v-dialog > .v-card > .v-toolbar { | ||||
|   position: sticky; | ||||
|   top: 0; | ||||
|   z-index: 999; | ||||
| } | ||||
| @ -89,7 +89,7 @@ const flags = new Map([["AC", "🇦🇨"], ["AF", "🇦🇫"], ["AI", "🇦🇮" | ||||
| 
 | ||||
| export default { | ||||
|   name: "ProxyList", | ||||
|   props: ['url', 'sub'], | ||||
|   props: ['url', 'sub', 'raw'], | ||||
|   components: {VueQRCodeComponent}, | ||||
|   data: function () { | ||||
|     return { | ||||
| @ -114,7 +114,7 @@ export default { | ||||
|     }, | ||||
| 
 | ||||
|     async fetch() { | ||||
|       await axios.get(this.url).then(resp => { | ||||
|       await axios.get(this.raw ? `${this.url}?raw=true` : this.url).then(resp => { | ||||
|         let {data} = resp; | ||||
|         // eslint-disable-next-line no-debugger | ||||
|         this.proxies = data; | ||||
| @ -122,7 +122,7 @@ export default { | ||||
|         this.$store.commit("SET_ERROR_MESSAGE", err); | ||||
|       }); | ||||
| 
 | ||||
|       await axios.get(`${this.url}?target=URI`).then(resp => { | ||||
|       await axios.get(this.raw ? `${this.url}?target=URI&raw=true` : `${this.url}?target=URI`).then(resp => { | ||||
|         const {data} = resp; | ||||
|         this.uris = data.split("\n"); | ||||
|       }); | ||||
|  | ||||
| @ -118,27 +118,54 @@ | ||||
|       </v-card-text> | ||||
|     </v-card> | ||||
|     <v-dialog fullscreen hide-overlay transition="dialog-bottom-transition" v-model="showProxyList" scrollable> | ||||
|       <v-card> | ||||
|         <v-card-title class="pa-0"> | ||||
|           <v-toolbar> | ||||
|             <v-icon>mdi-cloud</v-icon> | ||||
|             <v-spacer></v-spacer> | ||||
|             <v-toolbar-title class="flex text-xs-center"> | ||||
|               <h4>节点列表</h4> | ||||
|             </v-toolbar-title> | ||||
|             <v-spacer></v-spacer> | ||||
|             <v-toolbar-items> | ||||
|               <v-btn icon @click="refreshProxyList" v-if="sub"> | ||||
|                 <v-icon>refresh</v-icon> | ||||
|               </v-btn> | ||||
|               <v-btn icon @click="showProxyList = false"> | ||||
|                 <v-icon>mdi-close</v-icon> | ||||
|               </v-btn> | ||||
|             </v-toolbar-items> | ||||
|           </v-toolbar> | ||||
|         </v-card-title> | ||||
|         <v-card-text class="pl-0 pr-0"> | ||||
|           <proxy-list :url="url" :sub="sub" ref="proxyList" :key="url"></proxy-list> | ||||
|       <v-card fluid> | ||||
|         <v-toolbar> | ||||
|           <v-icon>mdi-cloud</v-icon> | ||||
|           <v-spacer></v-spacer> | ||||
|           <v-toolbar-title> | ||||
|             <h4>节点列表</h4> | ||||
|           </v-toolbar-title> | ||||
|           <v-spacer></v-spacer> | ||||
|           <v-toolbar-items> | ||||
|             <v-btn icon @click="showProxyList = false"> | ||||
|               <v-icon>mdi-close</v-icon> | ||||
|             </v-btn> | ||||
|           </v-toolbar-items> | ||||
|           <template v-slot:extension> | ||||
|             <v-tabs | ||||
|                 grow | ||||
|                 centered | ||||
|                 v-model="tab" | ||||
|             > | ||||
|               <v-tabs-slider color="primary"/> | ||||
|               <v-tab | ||||
|                   key="raw" | ||||
|               > | ||||
|                 原始节点 | ||||
|               </v-tab> | ||||
|               <v-tab | ||||
|                   key="processed" | ||||
|               > | ||||
|                 生成节点 | ||||
|               </v-tab> | ||||
|             </v-tabs> | ||||
|           </template> | ||||
|         </v-toolbar> | ||||
|         <v-card-text> | ||||
|           <v-tabs-items | ||||
|               v-model="tab" | ||||
|           > | ||||
|             <v-tab-item key="raw"> | ||||
|               <v-card-text class="pl-0 pr-0"> | ||||
|                 <proxy-list :url="url" :sub="sub" :raw="true" ref="proxyList" :key="url + 'raw'"></proxy-list> | ||||
|               </v-card-text> | ||||
|             </v-tab-item> | ||||
|             <v-tab-item key="processed"> | ||||
|               <v-card-text class="pl-0 pr-0"> | ||||
|                 <proxy-list :url="url" :sub="sub" ref="proxyList" :key="url"></proxy-list> | ||||
|               </v-card-text> | ||||
|             </v-tab-item> | ||||
|           </v-tabs-items> | ||||
|         </v-card-text> | ||||
|       </v-card> | ||||
|     </v-dialog> | ||||
| @ -157,6 +184,7 @@ export default { | ||||
|       showProxyList: false, | ||||
|       url: "", | ||||
|       sub: [], | ||||
|       tab: 1, | ||||
|       editMenu: [ | ||||
|         { | ||||
|           title: "复制", | ||||
| @ -187,11 +215,11 @@ export default { | ||||
|       return BACKEND_BASE; | ||||
|     }, | ||||
|     subscriptions: { | ||||
|       get(){ | ||||
|       get() { | ||||
|         const subs = this.$store.state.subscriptions; | ||||
|         return Object.keys(subs).map(k => subs[k]); | ||||
|       }, | ||||
|       set(){ | ||||
|       set() { | ||||
| 
 | ||||
|       } | ||||
|     }, | ||||
| @ -272,4 +300,10 @@ export default { | ||||
| .invert { | ||||
|   filter: invert(100%); | ||||
| } | ||||
| 
 | ||||
| .v-dialog > .v-card > .v-toolbar { | ||||
|   position: sticky; | ||||
|   top: 0; | ||||
|   z-index: 999; | ||||
| } | ||||
| </style> | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Peng-YM
						Peng-YM