6969</template >
7070
7171<script setup lang="ts">
72- import { computed , reactive , ref , watch } from " vue" ;
73- import yaml from " yaml" ;
74- import { QRCanvas } from " qrcanvas-vue" ;
75- import { loadVMess , dumpVMess } from " ~/components/url" ;
76- import { defaultQROptions } from " ~~/components/common" ;
77- import CodeEditor from " ~/components/code-editor.vue" ;
78- import {
79- createClientConfig ,
80- createServerConfig ,
81- } from " common-lib/src/v2fly-config" ;
72+ import { computed , reactive , ref , watch } from ' vue' ;
73+ import yaml from ' yaml' ;
74+ import { QRCanvas } from ' qrcanvas-vue' ;
75+ import { loadVMess , dumpVMess } from ' ~/components/url' ;
76+ import { defaultQROptions } from ' ~~/components/common' ;
77+ import CodeEditor from ' ~/components/code-editor.vue' ;
78+ import { createClientConfig , createServerConfig } from ' ~/util/v2fly-config' ;
8279
8380const editorList = ref <typeof CodeEditor >();
8481const editorDetail = ref <typeof CodeEditor >();
8582const state = reactive <{
86- editor: " list" | " detail" ;
83+ editor: ' list' | ' detail' ;
8784 urlList: string ;
8885 active: {
8986 /** Active 1-based line number, always >= 1 */
@@ -93,12 +90,12 @@ const state = reactive<{
9390 valid: boolean ;
9491 };
9592}>({
96- editor: " list" ,
97- urlList: " " ,
93+ editor: ' list' ,
94+ urlList: ' ' ,
9895 active: {
9996 line: 1 ,
100- url: " " ,
101- detail: " " ,
97+ url: ' ' ,
98+ detail: ' ' ,
10299 valid: true ,
103100 },
104101});
@@ -115,11 +112,11 @@ const optionsQR = computed(() => ({
115112watch (
116113 () => [state .active .line , state .urlList , state .editor ],
117114 () => {
118- if (state .editor !== " list" ) return ;
119- const url = state .urlList .split (" \n " )[state .active .line - 1 ];
120- let value = " " ;
115+ if (state .editor !== ' list' ) return ;
116+ const url = state .urlList .split (' \n ' )[state .active .line - 1 ];
117+ let value = ' ' ;
121118 let valid = true ;
122- if (url .startsWith (" vmess:" )) {
119+ if (url .startsWith (' vmess:' )) {
123120 let data: unknown ;
124121 ({ data , valid } = loadVMess (new URL (url )));
125122 value = yaml .stringify (data );
@@ -135,8 +132,8 @@ watch(
135132watch (
136133 () => state .active .detail ,
137134 (value ) => {
138- if (state .editor !== " detail" || ! editorList .value ) return ;
139- let url = " " ;
135+ if (state .editor !== ' detail' || ! editorList .value ) return ;
136+ let url = ' ' ;
140137 if (value ) {
141138 try {
142139 url = dumpVMess (yaml .parse (value )).toString ();
@@ -157,7 +154,7 @@ function onClientConfig() {
157154 try {
158155 const data = yaml .parse (state .active .detail );
159156 modal .value = {
160- title: " Client config" ,
157+ title: ' Client config' ,
161158 content: JSON .stringify (createClientConfig (data ), null , 2 ),
162159 };
163160 } catch {
@@ -170,7 +167,7 @@ function onServerConfig() {
170167 try {
171168 const data = yaml .parse (state .active .detail );
172169 modal .value = {
173- title: " Server config" ,
170+ title: ' Server config' ,
174171 content: JSON .stringify (createServerConfig (data ), null , 2 ),
175172 };
176173 } catch {
0 commit comments