优化web筛选

This commit is contained in:
晚风拂柳颜 2023-05-16 11:58:20 +08:00
parent c012416171
commit 4b36fd4a31
5 changed files with 47 additions and 10 deletions

View File

@ -6,7 +6,7 @@
import functools import functools
import json import json
import os import os
from urllib.parse import urljoin, unquote from urllib.parse import urljoin, unquote,quote
import requests import requests
from flask import Blueprint, abort, request, render_template, send_from_directory, render_template_string, jsonify, \ from flask import Blueprint, abort, request, render_template, send_from_directory, render_template_string, jsonify, \
make_response, redirect, \ make_response, redirect, \
@ -62,6 +62,7 @@ def web_index(web_name, theme):
tid = getParmas('tid') tid = getParmas('tid')
tname = getParmas('tname') tname = getParmas('tname')
url = getParmas('url') url = getParmas('url')
fl = getParmas('f')
player = getParmas('player') or 'mui' player = getParmas('player') or 'mui'
ctx['vod_id'] = vod_id ctx['vod_id'] = vod_id
ctx['vod_name'] = vod_name ctx['vod_name'] = vod_name
@ -70,7 +71,9 @@ def web_index(web_name, theme):
ctx['tid'] = tid ctx['tid'] = tid
ctx['tname'] = tname ctx['tname'] = tname
ctx['url'] = url ctx['url'] = url
print('tid:', tid) ctx['fl'] = quote(fl)
print('tid:', tid,'fl:',fl)
# print('f:', fl)
file_path = os.path.abspath(f'js/{web_name}.js') file_path = os.path.abspath(f'js/{web_name}.js')
print(file_path) print(file_path)

View File

@ -1 +1 @@
3.9.42beta2 3.9.42beta3

View File

@ -46,7 +46,7 @@
<div class="head clearfix"> <div class="head clearfix">
<a href="javascript:;" class="open-screen pull-right">展开 <i class="iconfont icon-moreunfold"></i></a> <a href="javascript:;" class="open-screen pull-right">展开 <i class="iconfont icon-moreunfold"></i></a>
<span class="text"> <span class="text">
已选择:最新-{{ctx.tname}} 已选择:{{ctx.tname}}
</span> </span>
<span class="all">,共检索到“{[sitems.total]}”条结果</span> <span class="all">,共检索到“{[sitems.total]}”条结果</span>
</div> </div>
@ -106,7 +106,7 @@ const app = createApp({
setup(props, context) { setup(props, context) {
onMounted(()=> { onMounted(()=> {
console.log('---onMounted---'); console.log('---onMounted---');
axios.get(`/vod?pwd=${pwd}&rule=${web_name}&t=${tid}&pg=${pg}&ac=videolist`).then((resp) => { axios.get(`/vod?pwd=${pwd}&rule=${web_name}&t=${tid}&pg=${pg}&ac=videolist&f=${fl}`).then((resp) => {
console.log(resp.data); console.log(resp.data);
sitems.value = resp.data; sitems.value = resp.data;
// 存浏览器session里然后其它页面好获取出来 // 存浏览器session里然后其它页面好获取出来
@ -141,6 +141,7 @@ const app = createApp({
const pg = '{{ctx.pg}}'; const pg = '{{ctx.pg}}';
const vod_id = '{{ctx.vod_id}}'; const vod_id = '{{ctx.vod_id}}';
const vod_name = '{{ctx.vod_name}}'; const vod_name = '{{ctx.vod_name}}';
const fl = '{{ctx.fl}}';
// console.log(web_name); // console.log(web_name);
const ctx_str = "ctxObj={{ctx|safe}}"; const ctx_str = "ctxObj={{ctx|safe}}";

View File

@ -60,7 +60,7 @@
<div class="stui-vodlist__box"> <div class="stui-vodlist__box">
<a class="stui-vodlist__thumb lazyload" :href="'{{ctx.path}}?vod_id='+item.vod_id+'&vod_name='+item.vod_name" :title="item.vod_name" :data-original="item.vod_pic"> <a class="stui-vodlist__thumb lazyload" :href="'{{ctx.path}}?vod_id='+item.vod_id+'&vod_name='+item.vod_name" :title="item.vod_name" :data-original="item.vod_pic">
<span class="play hidden-xs"></span> <span class="play hidden-xs"></span>
<span class="pic-text1 text-right"><b>{[item.no_use.type_name]}</b></span> <span class="pic-text1 text-right"><b>{[item.no_use?item.no_use.type_name:'']}</b></span>
<span class="pic-text text-right"><b>{[item.vod_remarks]}</b></span> <span class="pic-text text-right"><b>{[item.vod_remarks]}</b></span>
</a> </a>
<div class="stui-vodlist__detail"> <div class="stui-vodlist__detail">

View File

@ -248,11 +248,11 @@ const stuFilterComponent = {
<!-- 筛选 --> <!-- 筛选 -->
<ul class="clearfix" v-for="filters in now_filters"> <ul class="clearfix" v-for="filters in now_filters">
<li> <li>
<span>{[filters.name]}</span> <span>{[filters.name]}-{[filters.key]}</span>
</li> </li>
<li v-for="obj in filters.value"> <li v-for="obj in filters.value" :class="{ active: tellActive(obj,filters) }">
<a :href="ctx.path+'?tid='+item.type_id+'&tname='+item.type_name+'&filter='+obj.v">{[obj.n]}</a> <a :href="ctx.path+'?tid='+item.type_id+'&tname='+item.type_name+'&filter='+obj.v" @click.prevent="openFilterUrl(item,obj,filters)">{[obj.n]}</a>
</li> </li>
</ul> </ul>
@ -264,6 +264,7 @@ const stuFilterComponent = {
// console.log(props); // console.log(props);
const items = props.items; const items = props.items;
const tid = props.tid; const tid = props.tid;
const ctx = props.ctx;
const now_filters = computed(() => { const now_filters = computed(() => {
// console.log('计算now_filters'); // console.log('计算now_filters');
// items.value.class.find(it=>it.type_id===tid); // items.value.class.find(it=>it.type_id===tid);
@ -271,8 +272,40 @@ const stuFilterComponent = {
// console.log(now_filters); // console.log(now_filters);
return now_filters return now_filters
}); });
let p = new URLSearchParams(location.href.split('?')[1]);
let dict = Object.fromEntries(p.entries());
let f = dict.f || '{}';
try {
f = JSON.parse(f);
}catch (e) {
}
const methods = {
openFilterUrl(item,obj,filters){
// let url = ctx.path+'?tid='+item.type_id+'&tname='+item.type_name+'&filter='+obj.v;
// let p = new URLSearchParams(location.href.split('?')[1]);
// let dict = Object.fromEntries(p.entries());
// let f = dict.f || '{}';
try {
// f = JSON.parse(f);
f[filters.key] = obj.v;
f = JSON.stringify(f);
dict.f = f;
let new_p = new URLSearchParams(dict);
let url = ctx.path+'?'+new_p;
// console.log(url);
location.href = url;
}catch (e) {
console.log(`筛选发生错误:${e.message}`);
}
},
tellActive(obj,filters){
return f[filters.key] === obj.v;
}
}
return { return {
now_filters:now_filters ...methods,
now_filters
} }
}, },
props:{ props:{