Skip to content

Commit

Permalink
在电脑模式下更好地缩放网页
Browse files Browse the repository at this point in the history
  • Loading branch information
leaint committed May 13, 2024
1 parent 1ae992c commit 88227c3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ class GlobalWebViewSetting(private val lifecycleOwner: LifecycleOwner, context:
"return format(cur)}\n" +
"function getCur(){return format(cur)}"

val pc_mode_js = "(()=>{ let meta = document.createElement('meta');meta.name ='viewport';meta.content='minimum-scale=0.1, initial-scale=0.1, maximum-scale=10, user-scalable=yes';document.head.appendChild(meta); })();"

var externalFilesDir: File? = null
var externalCacheDir: File? = null
var externalIconCacheDir: File? = null
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/java/com/example/clock/ui/model/UIModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -990,6 +990,10 @@ class UIModel(

val webViewHolder = holderController.findHolder(tag) ?: return

if(webViewHolder.pc_mode) {
webViewHolder.webView?.get()?.evaluateJavascript(setting.pc_mode_js, null)
}

webViewHolder.change(WebViewHolder.UPDATE_LOADING_STATUS) {
it.isLoading = false
}
Expand Down

0 comments on commit 88227c3

Please sign in to comment.