Skip to content

Commit

Permalink
1修复菜单显示错误
Browse files Browse the repository at this point in the history
2允许为每个网站自定义请求头
3修复若干bug,新增若干bug
  • Loading branch information
luoxianxu committed May 15, 2023
1 parent bc019ef commit 7222516
Show file tree
Hide file tree
Showing 15 changed files with 196 additions and 128 deletions.
1 change: 1 addition & 0 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<data android:scheme="http" />
<data android:scheme="https" />
<data android:scheme="ftp" />
<data android:mimeType="*/*"/>
</intent-filter>
</activity>
<activity
Expand Down
48 changes: 22 additions & 26 deletions App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@
// import {
// ADBlock
// } from './utils/ADBlock.js';
import settingConfigFile from '@/utils/settingConfig.js';
import settingConfigFile from '@/utils/settingConfig.js';
export default {
globalData: {
// appUpdate: update,
isAd: url => {
return false;
// return ADBlock.isAd(url);
},
settingConfig:settingConfigFile,
settingConfig: settingConfigFile,
Dlan: {},
lastPage:[],
lastPage: [],
},
onLaunch: function() {
this.globalData.Dlan = uni.requireNativePlugin('JX-Dlna');
let settingConfig = uni.getStorageSync('settingConfig');
if (!settingConfig) {
uni.setStorageSync('settingConfig', this.globalData.settingConfig);
Expand All @@ -37,30 +37,20 @@ import settingConfigFile from '@/utils/settingConfig.js';
'Mozilla/5.0 (Linux; Android 7.1.2; V1923A Build/N2G47O; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/68.0.3440.70 Mobile Safari/537.36 SCRIPT/2.0';
plus.navigator.setUserAgent(ua, false);
if (arg) {
if (typeof arg == 'string') {
arg = JSON.parse(arg);
}
if (arg.url) {
uni.$emit('OPEN-Shortcut', {
url: arg.url
});
}
if (arg.targeturl) {
uni.navigateTo({
url: '/pages/browser/browser?url=' + arg.targeturl,
animationType: 'fade-in'
});
}
}
this.getIntentData(arg)
plus.navigator.closeSplashscreen();
},
onShow: function() {
plus.globalEvent.addEventListener('newintent', () => {
let arg = plus.runtime.arguments;
this.getIntentData(arg)
});
},
methods:{
getIntentData(arg){
if (typeof arg == 'string') {
try {
arg = JSON.parse(arg);
Expand All @@ -74,15 +64,21 @@ import settingConfigFile from '@/utils/settingConfig.js';
animationType: 'fade-in'
});
}
if (arg.url) {
uni.navigateTo({
url: '/pages/browser/browser?url=' + arg.url,
animationType: 'fade-in'
});
}
if (typeof arg === 'string' && arg.length > 0) {
uni.navigateTo({
url: '/pages/browser/browser?url=' + arg,
animationType: 'fade-in'
});
}
});
}
}
};
</script>

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ uni.navigateTo({
| $emit |加载链接 | LOAD-URL | Object<{url:string}> |
| $emit |触发网页清除广告 | AD | - |
| $emit |清除网页缓存 | CLEAR-CACHE | - |
| $on |网页长按事件返回消息 | WEB-ACTION | ```Object<{type:string,from:string,hostname:string,className:string,href:string,text:string,src:string}>``` |

| $on |网页长按事件返回消息 | WEB-ACTION | ```Object<any>``` |



Expand Down
38 changes: 38 additions & 0 deletions androidPrivacy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"version" : "1",
"prompt" : "none",
"title" : "服务协议和隐私政策",
"message" : "  请你务必审慎阅读、充分理解“服务协议”和“隐私政策”各条款,包括但不限于:为了更好的向你提供服务,我们需要收集你的设备标识、操作日志等信息用于分析、优化应用性能。<br/>  你可阅读<a href=\"\">《服务协议》</a>和<a href=\"\">《隐私政策》</a>了解详细信息。如果你同意,请点击下面按钮开始接受我们的服务。",
"buttonAccept" : "同意并接受",
"buttonRefuse" : "暂不同意",
"hrefLoader" : "system|default",
"backToExit" : "false",
"second" : {
"title" : "确认提示",
"message" : "  进入应用前,你需先同意<a href=\"\">《服务协议》</a>和<a href=\"\">《隐私政策》</a>,否则将退出应用。",
"buttonAccept" : "同意并继续",
"buttonRefuse" : "退出应用"
},
"disagreeMode" : {
"support" : false,
"loadNativePlugins" : false,
"visitorEntry" : true,
"showAlways" : false
},
"styles" : {
"backgroundColor" : "#00FF00",
"borderRadius" : "5px",
"title" : {
"color" : "#ff00ff"
},
"buttonAccept" : {
"color" : "#ffff00"
},
"buttonRefuse" : {
"color" : "#00ffff"
},
"buttonVisitor" : {
"color" : "#00ffff"
}
}
}
3 changes: 1 addition & 2 deletions components/menu/menu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
data() {
return {};
},
methods: {
clipText(text) {
uni.setClipboardData({
Expand Down Expand Up @@ -172,7 +171,7 @@
color: #999;
overflow: hidden;
text-overflow: ellipsis;
max-height: 15px;
max-height: 18px;
}
.btn {
Expand Down
4 changes: 3 additions & 1 deletion locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -219,5 +219,7 @@
"website.tips.1":"Current site Settings",
"website.tips.2":"Reset",
"website.tips.3":"Successful",
"website.tips.4":"Statistics"
"website.tips.4":"Statistics",
"website.tips.5":"输入JSON类型",
"webite.additionalHttpHeaders":"Additional Http Headers"
}
4 changes: 3 additions & 1 deletion locale/zh-Hans.json
Original file line number Diff line number Diff line change
Expand Up @@ -218,5 +218,7 @@
"website.tips.1":"当前网站设置",
"website.tips.2":"重置",
"website.tips.3":"已重置",
"website.tips.4":"载入中"
"website.tips.4":"载入中",
"website.tips.5":"输入json格式",
"webite.additionalHttpHeaders":"自定义请求头"
}
4 changes: 2 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name" : "Script Browser",
"appid" : "",
"description" : "一款专门用于网页游戏的浏览器,提供本地脚本运行环境",
"versionName" : "2.6.1",
"versionCode" : 2601,
"versionName" : "2.6.2",
"versionCode" : 2602,
"transformPx" : false,
"screenOrientation" : [
"portrait-primary",
Expand Down
39 changes: 30 additions & 9 deletions pages/browser/browser.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@
},
onShow() {
this.windowResize();
if(this.webviewList[this.WVindex]){
if (this.webviewList[this.WVindex]) {
this.webviewList[this.WVindex].resume()
}
},
onUnload() {
this.offListener();
Expand Down Expand Up @@ -155,7 +155,7 @@
fontSize: '18px',
float: 'right',
onclick: this.websiteInfo,
color:'#55aa7f'
color: '#55aa7f'
} //网站信息
// { float: 'right', fontSrc: '_www/static/iconfont.ttf', text: '\ue609', fontSize: '18px' ,onclick:this.canback}
]
Expand Down Expand Up @@ -356,8 +356,18 @@
wv.addEventListener('loaded', setList)
wv.addEventListener('close', setList)
},
// 获取单独网站配置文件
getWebsiteConfig(url) {
let websiteSetting = uni.getStorageSync('websiteSetting') || {}
for (let key in websiteSetting) {
if (url.indexOf(websiteSetting) > -1) {
return websiteSetting[key]
}
}
return null;
},
createWebView(url, _id) {
let id = _id || this.uuid();
uni.navigateTo({
url: '../popup/popup?from=back'
Expand All @@ -379,6 +389,7 @@
cachemode: 'cacheElseNetwork',
hardwareAccelerated: true,
plusrequire: 'ahead',
videoFullscreen: 'landscape-primary',
progress: {
color: '#4580ee',
height: '2px'
Expand All @@ -393,7 +404,15 @@
);
this.currentWV++;
wv.loadURL(url);
let config = this.getWebsiteConfig(url)
let additionalHttpHeaders = {}
try {
additionalHttpHeaders = JSON.parse(config.additionalHttpHeaders)
} catch (e) {
//TODO handle the exception
}
wv.loadURL(url, additionalHttpHeaders);
let currentWebview = this.currentWebview;
currentWebview.append(wv);
Expand Down Expand Up @@ -474,7 +493,7 @@
}
// 加载新数据停止下拉刷新
wv.endPullToRefresh();
this.setTitltData();
});
wv.addEventListener('loaded', e => {
Expand Down Expand Up @@ -565,6 +584,7 @@
j++;
}
this.dragWebview();
this.setTitltData();
},
// 设置拖着
dragWebview() {
Expand Down Expand Up @@ -735,12 +755,13 @@
plus.nativeUI.toast(this.$t("browser.tips.6"));
this.createWebView(e.url);
} else if (e.type == -1) {
this.webviewList[this.WVindex].loadURL(e.url);
this.webviewList[this.WVindex] ? this.webviewList[this.WVindex].loadURL(e.url) : this
.webviewList[this.webviewList.length - 1].loadURL(e.url)
}
});
// 点击书签
uni.$on('BOOK-MARK', e => {
console.log('BOOK-MARK', this.webviewList);
if (this.webviewList.length > 0) {
this.webviewList[this.WVindex].loadURL(e.url);
}
Expand Down Expand Up @@ -907,7 +928,7 @@
}
};`);
})
// 监听资源加载
this.webviewList[this.WVindex].listenResourceLoading('', evt => {
if (this.settingConfig.resLog) {
Expand Down
15 changes: 11 additions & 4 deletions pages/main/main.vue
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,11 @@
onShow() {
app.globalData.LoadResource = []
let homebookmark = uni.getStorageSync('homebookmark') || this.defaultBookmark;
let homebookmark = uni.getStorageSync('homebookmark');
if (!homebookmark) {
uni.setStorageSync('homebookmark', this.defaultBookmark)
homebookmark = this.defaultBookmark;
}
homebookmark = homebookmark.map((e) => {
return {
...e,
Expand Down Expand Up @@ -295,8 +299,8 @@
inputsearch(e) {
let val = e.detail.value;
this.showHistory = []
if (!val)return;
if (!val) return;
debounce((val) => {
searchKeyword(val).then(res => {
Expand Down Expand Up @@ -493,15 +497,18 @@
justify-content: space-between;
transform: scale(0);
opacity: 0;
.tips{
.tips {
font-size: 10px;
}
.btns {
display: flex;
width: 25%;
justify-content: space-between;
align-items: center;
font-size: 12px;
.btn {
border-radius: 10px;
padding: 0 10px;
Expand Down
6 changes: 1 addition & 5 deletions pages/popup/popup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export default {
this.tag = options.type;
this.src = decodeURIComponent(options.src);
this.href = decodeURIComponent(options.href);
this.text = options.text;
this.className = options.className;
this.hostname = options.hostname
Expand All @@ -49,11 +50,6 @@ export default {
this.bgcolor = 'rgba(0,0,0,.5)'
this.from = 'bg'
}
// else if(options.from == 'webdata'){
// let data = JSON.parse(decodeURI(options.jsonback));
// uni.$emit('WEB-MESSAGE',data)
// uni.navigateBack()
// }
},
methods: {
close() {
Expand Down

0 comments on commit 7222516

Please sign in to comment.