diff --git a/src/App.vue b/src/App.vue index 17bc2e6..a3f574b 100644 --- a/src/App.vue +++ b/src/App.vue @@ -10,5 +10,5 @@ diff --git a/src/axios/axios.js b/src/axios/axios.js index 8705a16..a1cde0d 100644 --- a/src/axios/axios.js +++ b/src/axios/axios.js @@ -1,33 +1,38 @@ - -import axios from 'axios'; +import axios from "axios"; // 基本配置 const instance = axios.create({ baseURL: import.meta.env.VITE_APP_BASE_API, // 根据实际情况修改API地址 -// timeout: 5000 // 设置超时时间,单位为ms + // timeout: 5000 // 设置超时时间,单位为ms }); // 请求拦截器 -instance.interceptors.request.use(config => { - config.headers['Authorization'] = localStorage.getItem('token'); // 设置请求头部分,这里举例使用了localStorage存储的token作为身份标识 - return config; -}, error => { - console.log(error); - return Promise.reject(error); -}); +instance.interceptors.request.use( + (config) => { + config.headers["Authorization"] = localStorage.getItem("token"); // 设置请求头部分,这里举例使用了localStorage存储的token作为身份标识 + return config; + }, + (error) => { + console.log(error); + return Promise.reject(error); + } +); // 响应拦截器 -instance.interceptors.response.use(response => { - const data = response.data; - //if (data && data.code !== 200) { // 根据接口返回的状态码判断是否有错误 - // alert(`Error code ${data.code}: ${data.message}`); // 自定义错误提示 - // return Promise.reject(new Error(data.message)); - //} else { - return data; - //} -}, error => { - console.log(error); - alert(`Error: ${error.message}`); // 自定义错误提示 - return Promise.reject(error); -}); +instance.interceptors.response.use( + (response) => { + const data = response.data; + //if (data && data.code !== 200) { // 根据接口返回的状态码判断是否有错误 + // alert(`Error code ${data.code}: ${data.message}`); // 自定义错误提示 + // return Promise.reject(new Error(data.message)); + //} else { + return data; + //} + }, + (error) => { + console.log(error); + alert(`Error: ${error.message}`); // 自定义错误提示 + return Promise.reject(error); + } +); export default instance; diff --git a/src/components/AppFooter.vue b/src/components/AppFooter.vue index abaab2b..9a04435 100644 --- a/src/components/AppFooter.vue +++ b/src/components/AppFooter.vue @@ -1,15 +1,32 @@ @@ -17,35 +34,39 @@ diff --git a/src/components/AppHeader.vue b/src/components/AppHeader.vue index 9390f45..51c2350 100644 --- a/src/components/AppHeader.vue +++ b/src/components/AppHeader.vue @@ -1,5 +1,4 @@ diff --git a/src/pages/projects/[id]/push.vue b/src/pages/projects/[id]/push.vue index 373e34d..d34f4e0 100644 --- a/src/pages/projects/[id]/push.vue +++ b/src/pages/projects/[id]/push.vue @@ -2,9 +2,8 @@

推送

- - -

+ +

- + - + - -
- + -
diff --git a/src/pages/projects/index.vue b/src/pages/projects/index.vue index 19708e8..9c72fb4 100644 --- a/src/pages/projects/index.vue +++ b/src/pages/projects/index.vue @@ -1,44 +1,101 @@ @@ -51,9 +108,7 @@ export default { data() { return { - searchstates: [ - { state: "所有", abbr: "public" }, - ], + searchstates: [{ state: "所有", abbr: "public" }], typeitems: [ { name: "所有", type: "" }, { name: "Scratch", type: "scratch" }, @@ -76,7 +131,7 @@ export default { authorid: "", type: "scratch", state: "public", - tag: '', + tag: "", }, }; }, diff --git a/src/pages/projects/my.vue b/src/pages/projects/my.vue index fefd562..4e75426 100644 --- a/src/pages/projects/my.vue +++ b/src/pages/projects/my.vue @@ -1,69 +1,152 @@ -{{ info.username }} {{ info.profile.country }} - -
继续加载 - +
+ 继续加载 - - - - +
- 本页加载用时{{ - Math.abs(usetime / 1000) - }}秒 + 本页加载用时{{ + Math.abs(usetime / 1000) + }}秒
- + {{ info.title }} + {{ info.title }} - {{ - info.username - }} + {{ info.username }} - -
+
继续加载

- 我们使用这种方式促进Scratch及其社区的发展,这些内容是按照署名-相同方式共享 2.0 - 通用协议传播的,您可以在https://creativecommons.org/licenses/by-sa/2.0/查看协议全文。 + 我们使用这种方式促进Scratch及其社区的发展,这些内容是按照署名-相同方式共享 2.0 通用协议传播的,您可以在https://creativecommons.org/licenses/by-sa/2.0/查看协议全文。 -
+ diff --git a/src/pages/tools/comparer.vue b/src/pages/tools/comparer.vue index 9005437..c53cad3 100644 --- a/src/pages/tools/comparer.vue +++ b/src/pages/tools/comparer.vue @@ -1,37 +1,86 @@ @@ -71,9 +125,9 @@ import { ref } from "vue"; var blob1; var blob2; var name1 = "项目1"; -var name2 = "项目2" +var name2 = "项目2"; var name2; -var final=ref(0); +var final = ref(0); var resultjson = ref({ assets: { objectSameAmount0: 0, @@ -94,9 +148,9 @@ var resultjson = ref({ }); var proj0samularty = 0; var proj1samularty = 0; -var progresstext = ref('开始比对'); +var progresstext = ref("开始比对"); function printpage() { - window.print() + window.print(); } async function c() { if (blob1 && blob2) { @@ -122,22 +176,26 @@ async function c() { var s = `
项目1: ${name1}
项目2: ${name2} -
项目1 的相同素材总数: ${result.assets.objectSameAmount0 - } -
项目2 的相同素材总数: ${result.assets.objectSameAmount1 - } -
项目1 的素材总数: ${result.assets.objectAmount0 - } -
项目2 的素材总数: ${result.assets.objectAmount1 - } +
项目1 的相同素材总数: ${ + result.assets.objectSameAmount0 + } +
项目2 的相同素材总数: ${ + result.assets.objectSameAmount1 + } +
项目1 的素材总数: ${ + result.assets.objectAmount0 + } +
项目2 的素材总数: ${ + result.assets.objectAmount1 + }
项目1 相同素材占比: ${+( - (result.assets.objectSameAmount0 / result.assets.objectAmount0) * - 100 - ).toFixed(4)}% + (result.assets.objectSameAmount0 / result.assets.objectAmount0) * + 100 + ).toFixed(4)}%
项目2 相同素材占比: ${+( - (result.assets.objectSameAmount1 / result.assets.objectAmount1) * - 100 - ).toFixed(4)}% + (result.assets.objectSameAmount1 / result.assets.objectAmount1) * + 100 + ).toFixed(4)}% `; // for (const key in result.assets.objectSameKey0) { // s += ` - ${result.assets.objectSameKey0[key]}` @@ -148,24 +206,29 @@ async function c() { s += ` - ${result.assets.objectSameKey0[key]}`; } s += ` -
项目1 的项目树总数: ${result.code.code0length - } -
项目2 的项目树总数: ${result.code.code1length - } -
项目1 的项目树相同总数: ${result.code.code0.length - } -
项目2 的项目树相同总数: ${result.code.code1.length - } +
项目1 的项目树总数: ${ + result.code.code0length + } +
项目2 的项目树总数: ${ + result.code.code1length + } +
项目1 的项目树相同总数: ${ + result.code.code0.length + } +
项目2 的项目树相同总数: ${ + result.code.code1.length + }
项目1 的项目树相同占比: ${+( - (proj0samularty / result.code.code0length) * - 100 - ).toFixed(4)}% + (proj0samularty / result.code.code0length) * + 100 + ).toFixed(4)}%
项目2 的项目树相同占比: ${+( - (proj1samularty / result.code.code1length) * - 100 - ).toFixed(4)}% -
项目 抄袭可能性: ${final * 100 - }%`; + (proj1samularty / result.code.code1length) * + 100 + ).toFixed(4)}% +
项目 抄袭可能性: ${ + final * 100 + }%`; } //document.getElementById("show").innerHTML = s; } @@ -261,8 +324,9 @@ class Block { } // 转换成字符串 toFormatedString(indent = 0) { - let ret = `${this.topLevel ? "function " : ""}${this.opcode}()${this.topLevel ? "" : ";" - }`; + let ret = `${this.topLevel ? "function " : ""}${this.opcode}()${ + this.topLevel ? "" : ";" + }`; if (this.opcode === "control_if" || this.opcode === "control_if_else") { ret = "if(true){"; } else if ( @@ -294,7 +358,7 @@ class Block { } } -async function compareCode(project0, project1, progress = () => { }) { +async function compareCode(project0, project1, progress = () => {}) { let total = 0; let cur = 0; async function makeCodeTree(project) { @@ -323,7 +387,7 @@ async function compareCode(project0, project1, progress = () => { }) { }); } else if (block.opcode) { switch ( - block.opcode // Some special hat blocks. + block.opcode // Some special hat blocks. ) { case "procedures_definition": case "control_start_as_clone": @@ -439,7 +503,7 @@ async function compareCode(project0, project1, progress = () => { }) { * @param {Object} h1 Second object * @returns {Promise<{o0:number,o1:number,o0l:number,o1l:number}>} The result */ -async function compareAssets({ o0, o1, h0, h1, progress = () => { } }) { +async function compareAssets({ o0, o1, h0, h1, progress = () => {} }) { console.log(o0, o1); const result = { objectSameAmount0: 0, @@ -504,7 +568,7 @@ async function transferSb2IfNeed(proj) { * @param {Function} progress A function which will be invoked while comparing, taking a progress message as an argument. * @returns {Promise} The result. */ -async function compare(project0, project1, progress = () => { }) { +async function compare(project0, project1, progress = () => {}) { progress({ text: "正在转换工程版本", progress: 0 }); // minilog.disable() const [zip0, zip1] = await Promise.all([ diff --git a/src/plugins/index.js b/src/plugins/index.js index be6e2da..35757a3 100644 --- a/src/plugins/index.js +++ b/src/plugins/index.js @@ -5,13 +5,10 @@ */ // Plugins -import vuetify from './vuetify' -import pinia from '@/stores' -import router from '@/router' +import vuetify from "./vuetify"; +import pinia from "@/stores"; +import router from "@/router"; -export function registerPlugins (app) { - app - .use(vuetify) - .use(router) - .use(pinia) +export function registerPlugins(app) { + app.use(vuetify).use(router).use(pinia); } diff --git a/src/plugins/vuetify.js b/src/plugins/vuetify.js index e13e35e..34cf0a1 100644 --- a/src/plugins/vuetify.js +++ b/src/plugins/vuetify.js @@ -5,19 +5,20 @@ */ // Styles -import '@mdi/font/css/materialdesignicons.css' -import 'vuetify/styles' +import "@mdi/font/css/materialdesignicons.css"; +import "vuetify/styles"; // Composables -import { createVuetify } from 'vuetify' -import { VNumberInput } from 'vuetify/labs/VNumberInput' +import { createVuetify } from "vuetify"; +import { VNumberInput } from "vuetify/labs/VNumberInput"; // https://vuetifyjs.com/en/introduction/why-vuetify/#feature-guides -export default createVuetify({components: { - VNumberInput, -}, +export default createVuetify({ + components: { + VNumberInput, + }, theme: { - defaultTheme: 'dark', + defaultTheme: "dark", }, -}) +}); diff --git a/src/stores/app.js b/src/stores/app.js index 7429543..650dce6 100644 --- a/src/stores/app.js +++ b/src/stores/app.js @@ -1,8 +1,8 @@ // Utilities -import { defineStore } from 'pinia' +import { defineStore } from "pinia"; -export const useAppStore = defineStore('app', { +export const useAppStore = defineStore("app", { state: () => ({ // }), -}) +}); diff --git a/src/stores/index.js b/src/stores/index.js index 1536252..7b11dba 100644 --- a/src/stores/index.js +++ b/src/stores/index.js @@ -1,4 +1,4 @@ // Utilities -import { createPinia } from 'pinia' +import { createPinia } from "pinia"; -export default createPinia() +export default createPinia(); diff --git a/src/stores/openEdit.js b/src/stores/openEdit.js index 22810ad..b631db5 100644 --- a/src/stores/openEdit.js +++ b/src/stores/openEdit.js @@ -1,11 +1,11 @@ -export default function open(id,type) { - if (type == 'scratch') { - window.open('/scratch/editor.html#' + id) +export default function open(id, type) { + if (type == "scratch") { + window.open("/scratch/editor.html#" + id); } - if (type == 'python') { - window.open('/python/edit.html?id=' + id) + if (type == "python") { + window.open("/python/edit.html?id=" + id); } - if (type == 'text') { - window.open('/python/edit.html?id=' + id) + if (type == "text") { + window.open("/python/edit.html?id=" + id); } } diff --git a/src/stores/useRecaptcha.js b/src/stores/useRecaptcha.js index e3f0d44..0994e69 100644 --- a/src/stores/useRecaptcha.js +++ b/src/stores/useRecaptcha.js @@ -1,19 +1,25 @@ -export function initRecaptcha(id,product) { - console.log(import.meta.env.VITE_APP_GEEID) - initGeetest4({ - captchaId: import.meta.env.VITE_APP_GEEID, - product: product||'float' - }, function (captchaObj) { - window.gt4 = captchaObj - captchaObj.appendTo(`#${id}`); - captchaObj.onReady(function () { - console.log(`Challenge Ready`); - }).onSuccess(function () { - console.log(`Challenge Success`); - }).onError(function () { - console.log(`Challenge Error`); - }) - }); +export function initRecaptcha(id, product) { + console.log(import.meta.env.VITE_APP_GEEID); + initGeetest4( + { + captchaId: import.meta.env.VITE_APP_GEEID, + product: product || "float", + }, + function (captchaObj) { + window.gt4 = captchaObj; + captchaObj.appendTo(`#${id}`); + captchaObj + .onReady(function () { + console.log(`Challenge Ready`); + }) + .onSuccess(function () { + console.log(`Challenge Success`); + }) + .onError(function () { + console.log(`Challenge Error`); + }); + } + ); } export function getResponse() { @@ -23,6 +29,3 @@ export function getResponse() { export function resetCaptcha() { window.gt4.reset(); } - - - diff --git a/src/stores/user.js b/src/stores/user.js index 307e765..9248fbf 100644 --- a/src/stores/user.js +++ b/src/stores/user.js @@ -8,25 +8,25 @@ var islogin = ref(false); const loaduser = () => { //try { console.log("加载用户信息"); - if (localStorage.getItem("token") && localStorage.getItem("token")!='{}') { - token.value = localStorage.getItem("token"); - console.log(token.value); - user.value = jwtDecode(token.value); - islogin.value = true; - } else { - islogin.value = false; - user.value = {}; - } - console.log("用户登录信息----------"); - console.log("token:" + token.value); - console.log(user.value); - console.log("是否登录:" + islogin.value); + if (localStorage.getItem("token") && localStorage.getItem("token") != "{}") { + token.value = localStorage.getItem("token"); + console.log(token.value); + user.value = jwtDecode(token.value); + islogin.value = true; + } else { + islogin.value = false; + user.value = {}; + } + console.log("用户登录信息----------"); + console.log("token:" + token.value); + console.log(user.value); + console.log("是否登录:" + islogin.value); //} catch (error) { // console.log(error); //} }; //const refresh = async () => { - //try { +//try { // console.log("刷新token"); // console.log(token.value); // if (localStorage.getItem("user")) { @@ -66,7 +66,7 @@ const loaduser = () => { // } //}; const setuser = (data) => { - localStorage.setItem("token",data); + localStorage.setItem("token", data); console.log("用户登录信息----------"); console.log(data); loaduser();