Commit 7cf98e4a authored by 牛文敏's avatar 牛文敏
Browse files

init

parent 8e92e524
File added
<!doctype html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Vue App</title><script defer="defer" src="/js/chunk-vendors.24f0b0cc.js"></script><script defer="defer" src="/js/app.9ffb6509.js"></script><link href="/css/app.b2d625b8.css" rel="stylesheet"></head><body><div id="app"></div></body></html>
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -3,12 +3,13 @@ ...@@ -3,12 +3,13 @@
"version": "0.1.0", "version": "0.1.0",
"private": true, "private": true,
"scripts": { "scripts": {
"serve": "vue-cli-service serve", "dev": "vue-cli-service serve",
"build": "vue-cli-service build", "build": "vue-cli-service build",
"lint": "vue-cli-service lint" "lint": "vue-cli-service lint"
}, },
"dependencies": { "dependencies": {
"core-js": "^3.8.3", "core-js": "^3.8.3",
"pinia": "^2.1.7",
"vue": "^3.2.13" "vue": "^3.2.13"
}, },
"devDependencies": { "devDependencies": {
......
public/favicon.ico

4.19 KB | W: | H:

public/favicon.ico

17.9 KB | W: | H:

public/favicon.ico
public/favicon.ico
public/favicon.ico
public/favicon.ico
  • 2-up
  • Swipe
  • Onion skin
<!DOCTYPE html>
<html lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title><%= htmlWebpackPlugin.options.title %></title>
</head>
<body>
<noscript>
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>
<template> <template>
<img alt="Vue logo" src="./assets/logo.png"> <img alt="Vue logo" src="./assets/logo.png">
<HelloWorld msg="Welcome to Your Vue.js App"/> <Suspense>
<InstallServer msg="Welcome to Your Vue.js App" />
</Suspense>
</template> </template>
<script> <script>
import HelloWorld from './components/HelloWorld.vue' import InstallServer from './components/InstallServer.vue'
export default { export default {
name: 'App', name: 'App',
components: { components: {
HelloWorld InstallServer
} }
} }
</script> </script>
......
function checkStatus(response) {
return new Promise((resolve, reject) => {
const json = response.json();
// [200,299]
if (response.ok) {
return json.then(resolve, reject);
}
if(response.status !== 200){
alert("接口请求失败!")
}
json.then(reject);
});
}
export default function fetch(input, init) {
if (!init) {
init = {};
}
init.headers = {
'Content-Type': 'application/json',
...init.headers
};
return window.fetch(`/${input}`, init).then(checkStatus);
}
/* 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: #1d2023;
--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-soft);
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: 16px;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
/* Chrome, Safari, Edge, Opera */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
margin: 0;
}
/* Firefox */
input[type='number'] {
-moz-appearance: textfield;
}
src/assets/logo.png

6.69 KB | W: | H:

src/assets/logo.png

17.9 KB | W: | H:

src/assets/logo.png
src/assets/logo.png
src/assets/logo.png
src/assets/logo.png
  • 2-up
  • Swipe
  • Onion skin
<template>
<div class="hello">
<h1>{{ msg }}</h1>
<p>
For a guide and recipes on how to configure / customize this project,<br>
check out the
<a href="https://cli.vuejs.org" target="_blank" rel="noopener">vue-cli documentation</a>.
</p>
<h3>Installed CLI Plugins</h3>
<ul>
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-babel" target="_blank" rel="noopener">babel</a></li>
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-eslint" target="_blank" rel="noopener">eslint</a></li>
</ul>
<h3>Essential Links</h3>
<ul>
<li><a href="https://vuejs.org" target="_blank" rel="noopener">Core Docs</a></li>
<li><a href="https://forum.vuejs.org" target="_blank" rel="noopener">Forum</a></li>
<li><a href="https://chat.vuejs.org" target="_blank" rel="noopener">Community Chat</a></li>
<li><a href="https://twitter.com/vuejs" target="_blank" rel="noopener">Twitter</a></li>
<li><a href="https://news.vuejs.org" target="_blank" rel="noopener">News</a></li>
</ul>
<h3>Ecosystem</h3>
<ul>
<li><a href="https://router.vuejs.org" target="_blank" rel="noopener">vue-router</a></li>
<li><a href="https://vuex.vuejs.org" target="_blank" rel="noopener">vuex</a></li>
<li><a href="https://github.com/vuejs/vue-devtools#vue-devtools" target="_blank" rel="noopener">vue-devtools</a></li>
<li><a href="https://vue-loader.vuejs.org" target="_blank" rel="noopener">vue-loader</a></li>
<li><a href="https://github.com/vuejs/awesome-vue" target="_blank" rel="noopener">awesome-vue</a></li>
</ul>
</div>
</template>
<script>
export default {
name: 'HelloWorld',
props: {
msg: String
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h3 {
margin: 40px 0 0;
}
ul {
list-style-type: none;
padding: 0;
}
li {
display: inline-block;
margin: 0 10px;
}
a {
color: #42b983;
}
</style>
<template>
<div style="display: flex; flex-direction: column; align-items: center; height: 80vh;">
<div style="display: flex; margin-bottom: 20px; flex-direction: column;">
<h2>设备信息</h2>
<table border="1" cellspacing="0" width="500" height="50">
<tr>
<td width="100">芯片型号:</td>
<td>{{ data.chipInfo }}</td>
</tr>
</table>
</div>
<h2>线刷包</h2>
<div style="display: flex; flex-direction: row; height: 30px;">
<p style="margin: 0px;">如果是rockchip线刷包,请直接点击重启:</p>
<button @click="reboot">重启</button>
</div>
<div style="display: flex; margin-bottom: 20px; flex-direction: column;">
<h2>请选择刷机参数</h2>
<table cellpadding="5px">
<tbody>
<tr v-for="(value) in packageInfoArray.model_database" :key="value.boxid">
<td style="text-align: left;">
<input type="radio" :value="value.boxid" name="boxid" :checked="index === 0"/>
</td>
<td style="text-align: left;">
<label>boxid: {{ value.boxid }}</label>
</td>
<td style="text-align: left;">
<label>soc: {{ value.soc }}</label>
</td>
<td style="text-align: left;">
<label>model: {{ value.model }}</label>
</td>
<td style="text-align: left;">
<label>dtb: {{ value.dtb }}</label>
</td>
</tr>
</tbody>
</table>
</div>
<button style="align-items: end; margin-bottom: 20px;" @click="submitForm">提交</button>
<textarea id="texts" style="width: 800px; height: 100%; margin-bottom: 20px; padding: 20px;" disabled v-model="outputTextarea">
</textarea>
<div style="display: flex; flex-direction: row; height: 30px;">
<p style="margin: 0px;">提交数据后是否成功,如果不成功请关机设备后重启重新选择刷机参数:</p>
<button @click="powerOff">关机</button>
</div>
</div>
</template>
<script setup>
import { useStore } from '@/stores'
import { ref,onMounted } from 'vue'
const data = ref({})
const packageInfoArray = ref({})
const store = useStore()
const deviceData = () => {
store.get('getInfo')
.then((res) => {
if(parseInt(JSON.parse(res.packageInfo).code, 10) !== 0){
console.log(parseInt(JSON.parse(res.packageInfo).code, 10))
alert("获取设备信息失败!")
}
data.value = res
packageInfoArray.value = JSON.parse(data.value.packageInfo)
})
.catch((error) => {
console.error(error);
});
};
onMounted(deviceData)
const warning = '请根据您的设备型号,以及芯片型号选择正确的boxid进行刷机,若不知,可以重复尝试,注意:您在提交一组数据之后需要等待结果返回并进行关机重启之后。才可以选其他参数进行提交!!!'
const outputTextarea = ref(warning);
const submitForm = () => {
const radioButtons = document.getElementsByName("boxid");
let isChecked = false;
outputTextarea.value = '写入emmc信息输出:写入中,请耐心等待....';
for (let i = 0; i < radioButtons.length; i++) {
if (radioButtons[i].checked) {
store.post('armbianInstall', {
body: JSON.stringify({
'boxid': radioButtons[i].value,
})
}).then((res) => {
if(res.code === 401){
outputTextarea.value = warning;
alert("请求参数错误");
}else if(res.code === 102){
outputTextarea.value = '安装信息输出:安装中,请耐心等待....';
alert("正在处理中")
}else if(res.code === 403){
outputTextarea.value = "安装信息输出:"+warning;
alert("禁止访问,请关机重启后再进行");
}else if(res.code === 200){
outputTextarea.value = res.result
alert("安装成功!请点击关机后重启设备!")
}else{
outputTextarea.value = "写入emmc失败!!请选择正确的参数进行提交\n"
alert("写入emmc出错,请检查参数是否选择正确,可点击关机后重启设备重新选择!")
}
})
.catch((error) => {
console.error(error);
});
isChecked = true;
break;
}
}
if (!isChecked) {
outputTextarea.value = warning;
alert("请选择一个参数后提交!");
return;
}
};
const reboot = () => {
store.post('initDev').then((res) => {
if(res.code === 401){
alert("请求参数错误")
}else if(res.code === 102){
alert("正在处理中")
}else if(res.code === 403){
alert("禁止访问,请关机重启后再进行")
}
})
.catch((error) => {
console.error(error);
});
}
const powerOff = () => {
store.post('powerOff').then((res) => {
if(res.code === 401){
alert("请求参数错误")
}else if(res.code === 102){
alert("正在处理中")
}else if(res.code === 403){
alert("禁止访问,请关机重启后再进行")
}
})
.catch((error) => {
console.error(error);
});
}
</script>
<style>
</style>
import { createApp } from 'vue' import { createApp } from 'vue'
import { createPinia } from 'pinia'
import App from './App.vue' import App from './App.vue'
createApp(App).mount('#app') const app = createApp(App)
const pinia = createPinia()
app.use(pinia)
app.mount('#app')
import { createRouter, createWebHistory } from 'vue-router'
import { useStore } from '../stores'
import HomeView from '../views/HomeView.vue'
import NetView from '../views/NetView.vue'
import AuthView from '../views/AuthView.vue'
import SettingsView from '../views/SettingsView.vue'
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
routes: [
{
path: '/',
name: 'home',
component: HomeView,
meta: {
requiresAuth: true
}
},
{
path: '/net',
name: 'net',
component: NetView,
meta: {
requiresAuth: true
}
},
{
path: '/settings',
name: 'settings',
component: SettingsView,
meta: {
requiresAuth: true
}
},
{
path: '/auth',
name: 'auth',
component: AuthView
},
{
path: '/:path(.*)',
redirect: '/'
}
]
})
router.beforeEach((to) => {
const store = useStore()
if (to.meta.requiresAuth && !store.logged) return '/auth'
if (to.name === 'auth' && store.logged) return '/'
})
export default router
import { defineStore } from 'pinia'
import fetch from '@/api'
export const useStore = defineStore('main', {
actions: {
logout() {
window.location.href = '/'
},
get(path, init) {
if (!init) {
init = {}
}
return fetch(path, init).catch((err) => {
if (err) {
this.logout()
}
})
},
post(path, init) {
if (!init) {
init = {}
}
init.method = 'POST'
return fetch(path, init).catch((err) => {
if (err) {
this.logout()
}
})
}
},
persist: true
})
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment