@@ -3,43 +3,57 @@ import { isUrl } from "@/helper/validate";
33import { message } from "@/service/common" ;
44import { circuits , videoList } from "@/service/video" ;
55import { NButton , NInput , NInputGroup , NInputGroupLabel , NSelect , NTooltip } from "naive-ui" ;
6- import { defineComponent , onActivated , ref } from "vue" ;
6+ import { defineComponent , onActivated , onMounted , reactive , ref } from "vue" ;
7+ import { useRoute } from "vue-router" ;
78
89export default defineComponent ( {
910 props : { } ,
1011 emits : [ ] ,
1112 setup : ( props , ctx ) => {
12- const circuit = ref < string > ( circuits [ 0 ] . value ) ;
13- const url = ref < string > ( "" ) ;
13+ const route = useRoute ( ) ;
14+ const form = reactive ( {
15+ circuit : circuits [ 0 ] . value ,
16+ url : "" ,
17+ } ) ;
1418 const iframeSrc = ref < string > ( "" ) ;
1519 const iptEl = ref < HTMLInputElement > ( ) ;
1620
1721 function handleParse ( check = true ) {
1822 if ( check ) {
19- if ( ! url . value ) {
23+ if ( ! form . url ) {
2024 message . error ( "请先输入播放地址" ) ;
2125 return ;
2226 }
23- if ( ! isUrl ( url . value ) ) {
27+ if ( ! isUrl ( form . url ) ) {
2428 message . error ( "播放地址输入错误" ) ;
2529 return ;
2630 }
2731 }
28- iframeSrc . value = circuit . value . replace ( "__URL__" , url . value ) ;
32+ iframeSrc . value = form . circuit . replace ( "__URL__" , form . url ) ;
2933 }
3034
3135 onActivated ( ( ) => {
3236 iptEl . value ?. focus ( ) ;
3337 } ) ;
3438
39+ onMounted ( ( ) => {
40+ const { url, circuit } = route . query ;
41+ if ( url ) {
42+ form . url = url as string ;
43+ }
44+ if ( circuit ) {
45+ form . circuit = circuit as string ;
46+ }
47+ } ) ;
48+
3549 return ( ) => (
3650 < div >
3751 < div class = "mar-b-5-item" >
3852 < NInputGroup >
3953 < NInputGroupLabel size = "large" > 播放地址</ NInputGroupLabel >
4054 < NInput
4155 size = "large"
42- v-model = { [ url . value , "value" ] }
56+ v-model = { [ form . url , "value" ] }
4357 onKeydown = { e => {
4458 if ( e . key === "Enter" ) {
4559 e . preventDefault ( ) ;
@@ -60,12 +74,12 @@ export default defineComponent({
6074 handleParse ( false ) ;
6175 } }
6276 options = { circuits }
63- v-model = { [ circuit . value , "value" ] }
77+ v-model = { [ form . circuit , "value" ] }
6478 />
6579 </ NInputGroup >
6680 </ div >
6781 < div class = "mar-b-7-item d-flex direction-column" >
68- { url . value ? (
82+ { form . url ? (
6983 < NButton
7084 block
7185 size = "large"
0 commit comments