|
@@ -1,13 +1,13 @@
|
|
|
<template>
|
|
|
<div class="magic-editor" :style="themeStyle" @contextmenu.prevent="" ref="root">
|
|
|
<!-- 顶部区域 -->
|
|
|
- <magic-header :themeStyle="themeStyle"/>
|
|
|
- <magic-main ref="componentMain" @onLoad="init"/>
|
|
|
+ <magic-header :themeStyle="themeStyle" v-if="loadFinish"/>
|
|
|
+ <magic-main ref="componentMain" @onLoad="init" v-if="loadFinish"/>
|
|
|
<!-- 状态条 -->
|
|
|
- <magic-status-bar :config="config" />
|
|
|
- <magic-login v-model:value="showLogin" />
|
|
|
+ <magic-status-bar :config="config" v-if="loadFinish" />
|
|
|
+ <magic-login v-model:value="showLogin" v-if="loadFinish"/>
|
|
|
<!-- 消息通知区域 -->
|
|
|
- <magic-notify />
|
|
|
+ <magic-notify v-if="loadFinish" />
|
|
|
<div class="magic-mounts"></div>
|
|
|
</div>
|
|
|
</template>
|
|
@@ -27,11 +27,11 @@ import JavaClass from '../scripts/editor/java-class.js'
|
|
|
import MagicWebSocket from '../scripts/websocket.js'
|
|
|
import Socket from '../scripts/constants/socket.js'
|
|
|
import Message from '../scripts/constants/message.js'
|
|
|
-import { randomString, replaceURL } from '../scripts/utils.js'
|
|
|
+import { loadPlugin, randomString, replaceURL } from '../scripts/utils.js'
|
|
|
import store from '../scripts/store.js'
|
|
|
import * as monaco from 'monaco-editor'
|
|
|
import modal from './common/dialog/magic-modal.js'
|
|
|
-import $i from '../scripts/i18n.js'
|
|
|
+import { default as $i, add as i18nAdd} from '../scripts/i18n.js'
|
|
|
initializeMagicScript()
|
|
|
provide('bus', bus)
|
|
|
self.MonacoEnvironment = {
|
|
@@ -52,6 +52,7 @@ props.config.header = props.config.header || {}
|
|
|
const showLogin = ref(false)
|
|
|
const componentMain = ref(null)
|
|
|
const root = ref(null)
|
|
|
+const loadFinish = ref(false)
|
|
|
provide('ELEMENT_ROOT', root)
|
|
|
provide('activateUserFiles', ref({}))
|
|
|
let websocket = null
|
|
@@ -69,9 +70,31 @@ if (constants.BASE_URL.startsWith('http')) { // http开头
|
|
|
}
|
|
|
request.setBaseURL(constants.BASE_URL)
|
|
|
bus.status('message.loadClass')
|
|
|
-Promise.all([JavaClass.initClasses(), JavaClass.initImportClass()]).then(()=> bus.status('message.loadClassFinish')).catch((e)=>{
|
|
|
+provide('i18n.format', $i)
|
|
|
+const installPlugin = () => {
|
|
|
+ return new Promise(resolve => {
|
|
|
+ request.sendGet('/plugins').success(plugins => Promise.all((plugins || []).filter(it => it.javascriptFilename).map(plugin => new Promise(r => {
|
|
|
+ bus.status('plugin.loading', true, plugin.name)
|
|
|
+ loadPlugin(replaceURL(link + '/plugins/' + plugin.javascriptFilename)).then(() => {
|
|
|
+ constants.PLUGINS.push(window['MagicTask']({
|
|
|
+ 'i18n': { add: i18nAdd, format: $i },
|
|
|
+ request,
|
|
|
+ constants,
|
|
|
+ Message,
|
|
|
+ bus
|
|
|
+ }))
|
|
|
+ bus.status('plugin.loaded', true, plugin.name)
|
|
|
+ r();
|
|
|
+ })
|
|
|
+ }))).then(() => resolve())).error(() => resolve())
|
|
|
+ })
|
|
|
+}
|
|
|
+Promise.all([JavaClass.initClasses(), JavaClass.initImportClass(), installPlugin()]).then(()=> bus.status('message.loadClassFinish')).catch((e)=>{
|
|
|
bus.status('message.loadClassError')
|
|
|
-}).finally(() => hideLoadingElement)
|
|
|
+}).finally(() => {
|
|
|
+ loadFinish.value = true
|
|
|
+ hideLoadingElement()
|
|
|
+})
|
|
|
const options = props.config.options || []
|
|
|
provide('options', options)
|
|
|
if(options.length === 0){
|
|
@@ -86,20 +109,17 @@ const onLogin = () => {
|
|
|
}
|
|
|
bus.$on(Message.LOGINED, onLogin)
|
|
|
const checkUpdate = () => {
|
|
|
- fetch('http://124.223.103.66:8082/magic-api/update/version').then(r => r.text().then(text => {
|
|
|
-
|
|
|
- }))
|
|
|
- fetch('https://img.shields.io/maven-metadata/v.json?label=maven-central&metadataUrl=https%3A%2F%2Frepo1.maven.org%2Fmaven2%2Forg%2Fssssssss%2Fmagic-api%2Fmaven-metadata.xml')
|
|
|
+ fetch('https://console.ssssssss.org.cn/latest?group=org.ssssssss&artifactId=magic-api')
|
|
|
.then(response => {
|
|
|
if(response.status === 200){
|
|
|
response.json().then(json => {
|
|
|
- if (constants.config.version !== json.value.replace('v', '')) {
|
|
|
- bus.status('message.newVersionRelease', true, json.value)
|
|
|
+ if (json.version && json.version !== 'unknown' && constants.config.version !== json.version) {
|
|
|
+ bus.status('message.newVersionRelease', true, json.version)
|
|
|
if (json.value !== store.get(constants.IGNORE_VERSION)) {
|
|
|
bus.$emit(Message.NOTIFY, {
|
|
|
title: $i('message.tips'),
|
|
|
icon: 'warning',
|
|
|
- content: $i('message.versionUpdate', json.value),
|
|
|
+ content: $i('message.versionUpdate', json.version),
|
|
|
buttons: [{
|
|
|
title: $i('message.changelog'),
|
|
|
onClick: () => {
|
|
@@ -108,7 +128,7 @@ const checkUpdate = () => {
|
|
|
}, {
|
|
|
title: $i('message.ignore'),
|
|
|
onClick: () => {
|
|
|
- store.set(constants.IGNORE_VERSION, json.value)
|
|
|
+ store.set(constants.IGNORE_VERSION, json.version)
|
|
|
}
|
|
|
}]
|
|
|
})
|