Done work

This commit is contained in:
bluemangoo 2023-08-08 19:15:10 +08:00
commit c373fc7143
Signed by: Bluemangoo
GPG Key ID: F2F7E46880A1C4CF
13 changed files with 362 additions and 0 deletions

30
.gitignore vendored Normal file
View File

@ -0,0 +1,30 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
.DS_Store
dist
dist-ssr
coverage
*.local
/cypress/videos/
/cypress/screenshots/
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
package-lock.json

BIN
.prettierrc.json Normal file

Binary file not shown.

3
.vscode/extensions.json vendored Normal file
View File

@ -0,0 +1,3 @@
{
"recommendations": ["Vue.volar", "Vue.vscode-typescript-vue-plugin"]
}

29
README.md Normal file
View File

@ -0,0 +1,29 @@
# bing-point-getter
This template should help get you started developing with Vue 3 in Vite.
## Recommended IDE Setup
[VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin).
## Customize configuration
See [Vite Configuration Reference](https://vitejs.dev/config/).
## Project Setup
```sh
npm install
```
### Compile and Hot-Reload for Development
```sh
npm run dev
```
### Compile and Minify for Production
```sh
npm run build
```

15
index.html Normal file
View File

@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<!--Power By Vite-->
<meta charset="UTF-8">
<link rel="icon" href="/favicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="referrer" content="no-referrer">
<title>Bing Points Getter</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
</body>
</html>

17
package.json Normal file
View File

@ -0,0 +1,17 @@
{
"name": "bing-point-getter",
"version": "0.0.0",
"private": true,
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
},
"dependencies": {
"vue": "^3.2.45"
},
"devDependencies": {
"@vitejs/plugin-vue": "^4.0.0",
"vite": "^4.0.0"
}
}

BIN
public/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

139
src/App.vue Normal file
View File

@ -0,0 +1,139 @@
<script>
export default {
name: "app",
data() {
return {
times: 3,
oneTime: 10,
delay: 5000,
onRunning: false,
slowLoad: false,
typeOn: "运行状态:<span style='color: green'>运行中</span>",
typeOff: "运行状态:<span style='color: red'>已停止</span>",
thread: null,
command: { stop: false, slowLoad: false },
task: async function(command) {
const normalRandom = (mean, std) => {
let u = 0.0, v = 0.0, w = 0.0, c = 0.0;
do {
//-1,1
u = Math.random() * 2 - 1.0;
v = Math.random() * 2 - 1.0;
w = u * u + v * v;
} while (w === 0.0 || w >= 1.0);
//Box-Muller
c = Math.sqrt((-2 * Math.log(w)) / w);
return mean + (u * c) * std;
};
this.onRunning = true;
const sleep = (delay) => new Promise((resolve) => setTimeout(resolve, delay));
const search = () => {
let time = Math.floor(Date.now()).toString();
let search = "";
for (let timeElement of time) {
search += timeElement;
search += " ";
}
return search;
};
if (command.slowLoad) {
document.getElementById("iframes").innerHTML = "";
for (let iframe = 1; iframe <= this.oneTime; iframe++) {
document.getElementById("iframes").innerHTML += `<span id="${iframe}"></span>`;
}
}
for (let time = 1; time <= this.times; time++) {
if (command.stop) {
return;
}
let innerHTML = "";
if(!command.slowLoad) {
document.getElementById("iframes").innerHTML = "";
}
for (let iframe = 1; iframe <= this.oneTime; iframe++) {
if (command.slowLoad) {
document.getElementById(iframe.toString()).innerHTML = `<iframe src="https://www.bing.com/search?q=${search()}"></iframe>`;
} else {
innerHTML += `<iframe src="https://www.bing.com/search?q=${search()}"></iframe>`;
}
if (command.stop) {
return;
}
if (command.slowLoad) {
await sleep(normalRandom(this.delay / this.times, this.delay / 5 / this.times));
}else {
await sleep(normalRandom(5, 3));
}
if (command.stop) {
return;
}
}
if(!command.slowLoad) {
document.getElementById("iframes").innerHTML = innerHTML;
}
if (command.stop) {
return;
}
if (time !== this.times) {
if (command.slowLoad) {
await sleep(normalRandom(this.delay / this.times, this.delay / 5 / this.times));
} else {
await sleep(normalRandom(this.delay, this.delay / 10));
}
}
if (command.stop) {
return;
}
}
this.onRunning = false;
document.getElementById("type").innerHTML = this.typeOff;
}
};
},
methods: {
start: async function() {
if (this.onRunning) {
return;
}
this.command = { stop: false, slowLoad: this.slowLoad };
this.thread = new Promise(() => this.task(this.command));
document.getElementById("type").innerHTML = this.typeOn;
},
stop: function() {
this.command.stop = true;
this.thread = null;
this.command = null;
this.onRunning = false;
document.getElementById("type").innerHTML = this.typeOff;
}
}
};
</script>
<template>
<p>
<span>运行次数</span><input type="number" v-model="times"><br>
<span>单次加载</span><input type="number" v-model="oneTime"><br>
<span>循环延时</span><input type="number" v-model="delay"><br>
<span>慢速加载 (BETA)</span><input type="checkbox" v-model="slowLoad"><br>
<button v-on:click="start">开始</button>
<button v-on:click="stop">停止</button>
<br><br>
<span id="type">运行状态<span style="color: orange">未运行</span></span>
</p>
<div id="iframes"></div>
<div class="footer">Bing Point Getter: Jan 25 Version</div>
</template>
<style scoped>
.footer {
background-color: #ffffff;
position: fixed;
bottom: 0;
width: 100%;
height: 50px;
z-index: 9999;
}
</style>

74
src/assets/base.css Normal file
View File

@ -0,0 +1,74 @@
/* color palette from <https://github.com/vuejs/theme> */
:root {
--vt-c-white: #ffffff;
--vt-c-white-soft: #f8f8f8;
--vt-c-white-mute: #f2f2f2;
--vt-c-black: #181818;
--vt-c-black-soft: #222222;
--vt-c-black-mute: #282828;
--vt-c-indigo: #2c3e50;
--vt-c-divider-light-1: rgba(60, 60, 60, 0.29);
--vt-c-divider-light-2: rgba(60, 60, 60, 0.12);
--vt-c-divider-dark-1: rgba(84, 84, 84, 0.65);
--vt-c-divider-dark-2: rgba(84, 84, 84, 0.48);
--vt-c-text-light-1: var(--vt-c-indigo);
--vt-c-text-light-2: rgba(60, 60, 60, 0.66);
--vt-c-text-dark-1: var(--vt-c-white);
--vt-c-text-dark-2: rgba(235, 235, 235, 0.64);
}
/* semantic color variables for this project */
:root {
--color-background: var(--vt-c-white);
--color-background-soft: var(--vt-c-white-soft);
--color-background-mute: var(--vt-c-white-mute);
--color-border: var(--vt-c-divider-light-2);
--color-border-hover: var(--vt-c-divider-light-1);
--color-heading: var(--vt-c-text-light-1);
--color-text: var(--vt-c-text-light-1);
--section-gap: 160px;
}
@media (prefers-color-scheme: dark) {
:root {
--color-background: var(--vt-c-black);
--color-background-soft: var(--vt-c-black-soft);
--color-background-mute: var(--vt-c-black-mute);
--color-border: var(--vt-c-divider-dark-2);
--color-border-hover: var(--vt-c-divider-dark-1);
--color-heading: var(--vt-c-text-dark-1);
--color-text: var(--vt-c-text-dark-2);
}
}
*,
*::before,
*::after {
box-sizing: border-box;
margin: 0;
position: relative;
font-weight: normal;
}
body {
min-height: 100vh;
color: var(--color-text);
background: var(--color-background);
transition: color 0.5s, background-color 0.5s;
line-height: 1.6;
font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu,
Cantarell, 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
font-size: 15px;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

1
src/assets/logo.svg Normal file
View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 261.76 226.69" xmlns:v="https://vecta.io/nano"><path d="M161.096.001l-30.225 52.351L100.647.001H-.005l130.877 226.688L261.749.001z" fill="#41b883"/><path d="M161.096.001l-30.225 52.351L100.647.001H52.346l78.526 136.01L209.398.001z" fill="#34495e"/></svg>

After

Width:  |  Height:  |  Size: 308 B

33
src/assets/main.css Normal file
View File

@ -0,0 +1,33 @@
@import './base.css';
#app {
max-width: 1280px;
margin: 0 auto;
padding: 2rem;
font-weight: normal;
}
a,
.green {
text-decoration: none;
color: hsla(160, 100%, 37%, 1);
transition: 0.4s;
}
@media (hover: hover) {
a:hover {
background-color: hsla(160, 100%, 37%, 0.2);
}
}
@media (min-width: 1024px) {
body {
place-items: center;
}
#app {
grid-template-columns: 1fr 1fr;
padding: 3rem 2rem;
}
}

6
src/main.js Normal file
View File

@ -0,0 +1,6 @@
import { createApp } from "vue";
import App from "./App.vue";
import "./assets/main.css";
createApp(App).mount("#app");

15
vite.config.js Normal file
View File

@ -0,0 +1,15 @@
import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
// https://vitejs.dev/config/
export default defineConfig({
base: '/bing-point/',
plugins: [vue()],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
}
})