@@ -196,15 +196,21 @@ const loadProxyConfig = () => {
196196 // 先加载历史记录
197197 loadProxyHistory ()
198198
199+ // 如果启用了代理播放且有配置地址
199200 if (proxyPlayEnabled && proxyPlay) {
200201 // 检查当前配置的代理是否已在历史记录中
201- const exists = proxyOptions .value .some (option => option .url === proxyPlay)
202- if (! exists) {
203- // 如果不在历史记录中,添加到选项列表
202+ const existingIndex = proxyOptions .value .findIndex (option => option .url === proxyPlay)
203+
204+ if (existingIndex !== - 1 ) {
205+ // 如果在历史记录中,将其移到最前面
206+ const currentOption = proxyOptions .value .splice (existingIndex, 1 )[0 ]
207+ proxyOptions .value .unshift (currentOption)
208+ } else {
209+ // 如果不在历史记录中,添加到最前面
204210 const proxyName = getProxyName (proxyPlay)
205211 proxyOptions .value .unshift ({
206212 value: proxyPlay,
207- label: proxyName,
213+ label: ` ${ proxyName} (当前) ` ,
208214 url: proxyPlay
209215 })
210216 }
@@ -215,6 +221,13 @@ const loadProxyConfig = () => {
215221 // 如果代理播放开关关闭,默认选择关闭
216222 currentProxyOption .value = ' disabled'
217223 }
224+
225+ console .log (' 代理播放配置加载完成:' , {
226+ enabled: proxyPlayEnabled,
227+ current: proxyPlay,
228+ optionsCount: proxyOptions .value .length ,
229+ selected: currentProxyOption .value
230+ })
218231 } catch (error) {
219232 console .error (' 加载代理播放配置失败:' , error)
220233 currentProxyOption .value = ' disabled'
@@ -224,20 +237,27 @@ const loadProxyConfig = () => {
224237// 加载代理播放地址历史记录
225238const loadProxyHistory = () => {
226239 try {
227- const history = JSON .parse (localStorage .getItem (' proxy-play-history' ) || ' []' )
240+ // 只从设置界面的存储位置加载
241+ const addressHistoryKey = ' address-history-proxy-play'
242+ const addressHistory = JSON .parse (localStorage .getItem (addressHistoryKey) || ' []' )
228243
229- // 添加历史记录到选项中(去重)
230- history .forEach (item => {
231- const exists = proxyOptions .value .some (option => option .url === item .url )
244+ // 添加历史记录到选项中
245+ addressHistory .forEach (item => {
246+ const url = item .url || item .value || ' '
247+ if (! url) return
248+
249+ const exists = proxyOptions .value .some (option => option .url === url)
232250 if (! exists) {
233- const proxyName = getProxyName (item . url )
251+ const proxyName = getProxyName (url)
234252 proxyOptions .value .push ({
235- value: item . url ,
253+ value: url,
236254 label: proxyName,
237- url: item . url
255+ url: url
238256 })
239257 }
240258 })
259+
260+ console .log (' 已加载代理播放历史记录:' , proxyOptions .value .length , ' 个选项' )
241261 } catch (error) {
242262 console .error (' 加载代理播放历史记录失败:' , error)
243263 }
@@ -248,30 +268,35 @@ const saveToProxyHistory = (url) => {
248268 if (! url || url === ' disabled' ) return
249269
250270 try {
251- const history = JSON .parse (localStorage .getItem (' proxy-play-history' ) || ' []' )
252271 const proxyName = getProxyName (url)
272+ const timestamp = Date .now ()
273+
274+ // 只保存到设置界面使用的存储位置
275+ const addressHistoryKey = ' address-history-proxy-play'
276+ const addressHistory = JSON .parse (localStorage .getItem (addressHistoryKey) || ' []' )
253277
254278 // 检查是否已存在
255- const existingIndex = history .findIndex (item => item .url === url)
279+ const existingIndex = addressHistory .findIndex (item => item .url === url)
256280
257281 if (existingIndex !== - 1 ) {
258282 // 如果存在,移到最前面
259- history .splice (existingIndex, 1 )
283+ addressHistory .splice (existingIndex, 1 )
260284 }
261285
262286 // 添加到最前面
263- history .unshift ({
287+ addressHistory .unshift ({
264288 url: url,
265- name: proxyName,
266- timestamp: Date .now ()
289+ timestamp: timestamp
267290 })
268291
269292 // 限制历史记录数量(最多保存10个)
270- if (history .length > 10 ) {
271- history .splice (10 )
293+ if (addressHistory .length > 10 ) {
294+ addressHistory .splice (10 )
272295 }
273296
274- localStorage .setItem (' proxy-play-history' , JSON .stringify (history))
297+ localStorage .setItem (addressHistoryKey, JSON .stringify (addressHistory))
298+
299+ console .log (' 已保存代理播放地址到历史记录:' , url)
275300 } catch (error) {
276301 console .error (' 保存代理播放历史记录失败:' , error)
277302 }
0 commit comments