mirror of
				https://github.com/caojiezi2003/live2d-widget.git
				synced 2025-10-31 10:22:48 +00:00 
			
		
		
		
	update
This commit is contained in:
		
							parent
							
								
									5431fe6b59
								
							
						
					
					
						commit
						444b47d4b3
					
				| @ -1,10 +1,10 @@ | |||||||
| <!DOCTYPE html> | <!DOCTYPE html> | ||||||
| <html> | <html> | ||||||
| <head> | <head> | ||||||
| <meta charset="UTF-8" /> | <meta charset="UTF-8"/> | ||||||
| <title>Live2D 看板娘 v1.2 / Demo</title> | <title>Live2D 看板娘 v1.2 / Demo</title> | ||||||
| <script src="https://cdn.jsdelivr.net/npm/jquery@3.3.1/dist/jquery.min.js"></script> | <script src="https://cdn.jsdelivr.net/npm/jquery@3.3.1/dist/jquery.min.js"></script> | ||||||
| <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css"> | <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css"/> | ||||||
| </head> | </head> | ||||||
| <body> | <body> | ||||||
| <!--<h2><a href="https://www.fghrsh.net/post/123.html" style="color: #38A3DB">Live2D 看板娘 v1.2</a> / Demo</h2>--> | <!--<h2><a href="https://www.fghrsh.net/post/123.html" style="color: #38A3DB">Live2D 看板娘 v1.2</a> / Demo</h2>--> | ||||||
|  | |||||||
| @ -30,8 +30,8 @@ function initWidget(waifuPath, apiPath) { | |||||||
| 	if (screen.width <= 768) return; | 	if (screen.width <= 768) return; | ||||||
| 	if (sessionStorage.getItem("waifu-display")) { | 	if (sessionStorage.getItem("waifu-display")) { | ||||||
| 		if (new Date().getTime() - sessionStorage.getItem("waifu-display") <= 86400000) return; | 		if (new Date().getTime() - sessionStorage.getItem("waifu-display") <= 86400000) return; | ||||||
| 		else sessionStorage.removeItem("waifu-display"); |  | ||||||
| 	} | 	} | ||||||
|  | 	sessionStorage.removeItem("waifu-display"); | ||||||
| 	sessionStorage.removeItem("waifu-text"); | 	sessionStorage.removeItem("waifu-text"); | ||||||
| 	$("body").append('<div id="waifu">\ | 	$("body").append('<div id="waifu">\ | ||||||
| 			<div id="waifu-tips"></div>\ | 			<div id="waifu-tips"></div>\ | ||||||
| @ -108,7 +108,7 @@ function initWidget(waifuPath, apiPath) { | |||||||
| 		window.Live2D.captureFrame = true; | 		window.Live2D.captureFrame = true; | ||||||
| 	}); | 	}); | ||||||
| 	$("#waifu-tool .fa-info-circle").click(function() { | 	$("#waifu-tool .fa-info-circle").click(function() { | ||||||
| 		window.open("https://github.com/stevenjoezhang/live2d-widget/"); | 		window.open("https://github.com/stevenjoezhang/live2d-widget"); | ||||||
| 	}); | 	}); | ||||||
| 	$("#waifu-tool .fa-times").click(function() { | 	$("#waifu-tool .fa-times").click(function() { | ||||||
| 		sessionStorage.setItem("waifu-display", new Date().getTime()); | 		sessionStorage.setItem("waifu-display", new Date().getTime()); | ||||||
| @ -119,9 +119,9 @@ function initWidget(waifuPath, apiPath) { | |||||||
| 	}); | 	}); | ||||||
| 	(function() { | 	(function() { | ||||||
| 		var text, | 		var text, | ||||||
| 			SiteIndexUrl = location.port ? location.protocol + "//" + location.hostname + ":" + location.port + "/" : location.protocol + "//" + location.hostname + "/"; // 自动获取主页
 | 			SiteIndexUrl = location.port ? `${location.protocol}//${location.hostname}:${location.port}/` : `${location.protocol}//${location.hostname}/`; //自动获取主页
 | ||||||
| 		//var SiteIndexUrl = "https://www.fghrsh.net/"; // 手动指定主页
 | 		//var SiteIndexUrl = "https://www.fghrsh.net/"; //手动指定主页
 | ||||||
| 		if (location.href == SiteIndexUrl) { // 如果是主页
 | 		if (location.href == SiteIndexUrl) { //如果是主页
 | ||||||
| 			var now = (new Date()).getHours(); | 			var now = (new Date()).getHours(); | ||||||
| 			if (now > 23 || now <= 5) { | 			if (now > 23 || now <= 5) { | ||||||
| 				text = "你是夜猫子呀?这么晚还不睡觉,明天起的来嘛"; | 				text = "你是夜猫子呀?这么晚还不睡觉,明天起的来嘛"; | ||||||
| @ -164,11 +164,11 @@ function initWidget(waifuPath, apiPath) { | |||||||
| 		} | 		} | ||||||
| 		showMessage(text, 7000, 8); | 		showMessage(text, 7000, 8); | ||||||
| 	})(); | 	})(); | ||||||
| 	/* 检测用户活动状态,并在空闲时 定时显示一言 */ | 	//检测用户活动状态,并在空闲时 定时显示一言
 | ||||||
| 	var getActed = false, | 	var getActed = false, | ||||||
| 		hitokotoTimer = null, | 		hitokotoTimer = null, | ||||||
| 		messageTimer = null, | 		messageTimer = null, | ||||||
| 		messageArray = ["已经过了这么久了呀,日子过得好快呢", "使用Chrome可以获得最佳浏览体验哦", "嗨~快来逗我玩吧!", "拿小拳拳锤你胸口", "她性格之奇特,绝非偶然"], | 		messageArray = ["已经过了这么久了呀,日子过得好快呢", "使用Chrome可以获得最佳浏览体验哦", "嗨~快来逗我玩吧!", "拿小拳拳锤你胸口"], | ||||||
| 		apiURL = ""; | 		apiURL = ""; | ||||||
| 	if ($(".fa-share-alt").is(":hidden")) messageArray.push("记得把小家加入Adblock白名单哦"); | 	if ($(".fa-share-alt").is(":hidden")) messageArray.push("记得把小家加入Adblock白名单哦"); | ||||||
| 	$(document).mousemove(function() { | 	$(document).mousemove(function() { | ||||||
| @ -190,7 +190,7 @@ function initWidget(waifuPath, apiPath) { | |||||||
| 	}, 1000); | 	}, 1000); | ||||||
| 
 | 
 | ||||||
| 	function showHitokoto() { | 	function showHitokoto() { | ||||||
| 		/* 增加 hitokoto.cn API */ | 		//增加 hitokoto.cn API
 | ||||||
| 		if (Math.random() < 0.6 && messageArray.length > 0) { | 		if (Math.random() < 0.6 && messageArray.length > 0) { | ||||||
| 			showMessage(messageArray[Math.floor(Math.random() * messageArray.length)], 6000, 9); | 			showMessage(messageArray[Math.floor(Math.random() * messageArray.length)], 6000, 9); | ||||||
| 		} else $.getJSON("https://v1.hitokoto.cn", function(result) { | 		} else $.getJSON("https://v1.hitokoto.cn", function(result) { | ||||||
| @ -231,9 +231,9 @@ function initWidget(waifuPath, apiPath) { | |||||||
| 		var modelId = localStorage.getItem("modelId"), | 		var modelId = localStorage.getItem("modelId"), | ||||||
| 			modelTexturesId = localStorage.getItem("modelTexturesId"); | 			modelTexturesId = localStorage.getItem("modelTexturesId"); | ||||||
| 		if (modelId == null) { | 		if (modelId == null) { | ||||||
| 			/* 首次访问加载 指定模型 的 指定材质 */ | 			//首次访问加载 指定模型 的 指定材质
 | ||||||
| 			var modelId = 1; // 模型 ID
 | 			var modelId = 1, //模型 ID
 | ||||||
| 			var modelTexturesId = 53 // 材质 ID
 | 				modelTexturesId = 53; //材质 ID
 | ||||||
| 		} | 		} | ||||||
| 		loadModel(modelId, modelTexturesId); | 		loadModel(modelId, modelTexturesId); | ||||||
| 		$.ajax({ | 		$.ajax({ | ||||||
| @ -283,16 +283,16 @@ function initWidget(waifuPath, apiPath) { | |||||||
| 		localStorage.setItem("modelId", modelId); | 		localStorage.setItem("modelId", modelId); | ||||||
| 		if (modelTexturesId === undefined) modelTexturesId = 0; | 		if (modelTexturesId === undefined) modelTexturesId = 0; | ||||||
| 		localStorage.setItem("modelTexturesId", modelTexturesId); | 		localStorage.setItem("modelTexturesId", modelTexturesId); | ||||||
| 		loadlive2d("live2d", apiURL + "/get/?id=" + modelId + "-" + modelTexturesId, console.log("live2d", "模型 " + modelId + "-" + modelTexturesId + " 加载完成")); | 		loadlive2d("live2d", `${apiURL}/get/?id=${modelId}-${modelTexturesId}`, console.log("live2d", `模型 ${modelId}-${modelTexturesId} 加载完成`)); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	function loadRandModel() { | 	function loadRandModel() { | ||||||
| 		var modelId = localStorage.getItem("modelId"), | 		var modelId = localStorage.getItem("modelId"), | ||||||
| 			modelTexturesId = localStorage.getItem("modelTexturesId"); | 			modelTexturesId = localStorage.getItem("modelTexturesId"); | ||||||
| 			// 可选 "rand"(随机), "switch"(顺序)
 | 			//可选 "rand"(随机), "switch"(顺序)
 | ||||||
| 		$.ajax({ | 		$.ajax({ | ||||||
| 			cache: false, | 			cache: false, | ||||||
| 			url: apiURL + "/rand_textures/?id=" + modelId + "-" + modelTexturesId, | 			url: `${apiURL}/rand_textures/?id=${modelId}-${modelTexturesId}`, | ||||||
| 			dataType: "json", | 			dataType: "json", | ||||||
| 			success: function(result) { | 			success: function(result) { | ||||||
| 				if (result.textures["id"] == 1 && (modelTexturesId == 1 || modelTexturesId == 0)) { | 				if (result.textures["id"] == 1 && (modelTexturesId == 1 || modelTexturesId == 0)) { | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 StevenJoeZhang
						StevenJoeZhang