Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Needing A live widget for android home screen #163

Open
Stretch379 opened this issue May 15, 2024 · 1 comment
Open

Needing A live widget for android home screen #163

Stretch379 opened this issue May 15, 2024 · 1 comment

Comments

@Stretch379
Copy link

shared_report.png

@nicocatxzc
Copy link

nicocatxzc commented Jul 26, 2024

shared_report.png

Change the code of loading parts of "autoload.js" to this:

//判断移动端用户方法
function isMobile() {
    var userAgent = navigator.userAgent || window.opera;

    if (/android/i.test(userAgent) || /iPad|iPhone|iPod/.test(userAgent) && !window.MSStream) {
        return true;
    }
}
// 加载 waifu.css live2d.min.js waifu-tips.js
if (isMobile()) {
	//移动端用户
	Promise.all([
		loadExternalResource(live2d_path + "waifu-mobie.css", "css"),
		loadExternalResource(live2d_path + "live2d.min.js", "js"),
		loadExternalResource(live2d_path + "waifu-tips.js", "js")
	]).then(() => {
		// 配置选项的具体用法见 README.md
		initWidget({
			waifuPath: live2d_path + "waifu-tips.json",
			//apiPath: "https://live2d.fghrsh.net/api/",
			cdnPath: "**Your javascript path**",
			tools: ["hitokoto", "asteroids", "switch-model", "switch-texture", "photo", "info", "quit"]
		});
	});
} else {
	//pc端用户
	Promise.all([
		loadExternalResource(live2d_path + "waifu.css", "css"),
		loadExternalResource(live2d_path + "live2d.min.js", "js"),
		loadExternalResource(live2d_path + "waifu-tips.js", "js")
	]).then(() => {
		initWidget({
			waifuPath: live2d_path + "waifu-tips.json",
			//apiPath: "https://live2d.fghrsh.net/api/",
			cdnPath: "**Your javascript path**",
			tools: ["hitokoto", "asteroids", "switch-model", "switch-texture", "photo", "info", "quit"]
		});
	});
}  

Then,copied the waifu.css and edit the part of it into this:

#waifu-toggle {
	background-color: #fa0;
	border-radius: 5px;
	bottom: 10px;
	color: #fff;
	cursor: pointer;
	font-size: 12px;
	left: -10px;
	margin-left: -100px;
	padding: 5px 2px 5px 5px;
	position: fixed;
	transition: margin-left 1s;
	width: 30px;
	writing-mode: vertical-rl;
}

And then renamd it into "waifu-mobie.css" for phone visitors to load it and show the live widget.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants