mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-12 03:01:12 +00:00
no message
This commit is contained in:
parent
2905059947
commit
6e03a05e6d
@ -4,18 +4,18 @@
|
|||||||
v-for="(app, key) in apps"
|
v-for="(app, key) in apps"
|
||||||
:key="key"
|
:key="key"
|
||||||
v-model="app.isOpen"
|
v-model="app.isOpen"
|
||||||
:ref="`ref-${app.id}`"
|
:ref="`ref-${app.name}`"
|
||||||
:size="1200"
|
:size="1200"
|
||||||
:transparent="app.transparent"
|
:transparent="app.transparent"
|
||||||
:autoDarkTheme="app.autoDarkTheme"
|
:autoDarkTheme="app.autoDarkTheme"
|
||||||
:beforeClose="async () => { await onBeforeClose(app.id) }">
|
:beforeClose="async () => { await onBeforeClose(app.name) }">
|
||||||
<micro-app
|
<micro-app
|
||||||
v-if="app.isOpen && app.url"
|
v-if="app.isOpen && app.url"
|
||||||
:name="app.id"
|
:name="app.name"
|
||||||
:url="app.url"
|
:url="app.url"
|
||||||
:keep-alive="app.keepAlive"
|
:keep-alive="app.keepAlive"
|
||||||
:disable-scopecss="app.disableScopecss"
|
:disable-scopecss="app.disableScopecss"
|
||||||
:data="appData(app.id)"
|
:data="appData(app.name)"
|
||||||
@created="created"
|
@created="created"
|
||||||
@beforemount="beforemount"
|
@beforemount="beforemount"
|
||||||
@mounted="mounted"
|
@mounted="mounted"
|
||||||
@ -173,7 +173,7 @@ export default {
|
|||||||
|
|
||||||
// 加载结束
|
// 加载结束
|
||||||
finish(e) {
|
finish(e) {
|
||||||
const app = this.apps.find(({id}) => id == e.detail.name);
|
const app = this.apps.find(({name}) => name == e.detail.name);
|
||||||
if (app) {
|
if (app) {
|
||||||
app.isLoading = false
|
app.isLoading = false
|
||||||
}
|
}
|
||||||
@ -181,11 +181,11 @@ export default {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 应用数据
|
* 应用数据
|
||||||
* @param id
|
* @param name
|
||||||
* @returns {*}
|
* @returns {*}
|
||||||
*/
|
*/
|
||||||
appData(id) {
|
appData(name) {
|
||||||
const app = this.apps.find(item => item.id == id);
|
const app = this.apps.find(item => item.name == name);
|
||||||
if (!app) {
|
if (!app) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
@ -225,10 +225,10 @@ export default {
|
|||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
close: (destroy = false) => {
|
close: (destroy = false) => {
|
||||||
this.closeMicroApp(id, destroy)
|
this.closeMicroApp(name, destroy)
|
||||||
},
|
},
|
||||||
back: () => {
|
back: () => {
|
||||||
this.closeById(id)
|
this.closeByName(name)
|
||||||
},
|
},
|
||||||
nextZIndex: () => {
|
nextZIndex: () => {
|
||||||
if (typeof window.modalTransferIndex === 'number') {
|
if (typeof window.modalTransferIndex === 'number') {
|
||||||
@ -256,12 +256,12 @@ export default {
|
|||||||
let appConfig = {}
|
let appConfig = {}
|
||||||
if (config.url) {
|
if (config.url) {
|
||||||
appConfig = {
|
appConfig = {
|
||||||
id: `url-${await $A.getSHA256Hash(config.url)}`,
|
name: `url-${await $A.getSHA256Hash(config.url)}`,
|
||||||
url: config.url,
|
url: config.url,
|
||||||
}
|
}
|
||||||
delete config.url
|
delete config.url
|
||||||
} else {
|
} else {
|
||||||
const app = this.apps.find(item => item.id == id);
|
const app = this.apps.find(item => item.name == name);
|
||||||
if (!app) {
|
if (!app) {
|
||||||
$A.modalError("应用不存在");
|
$A.modalError("应用不存在");
|
||||||
return
|
return
|
||||||
@ -271,14 +271,14 @@ export default {
|
|||||||
appConfig.transparent = true
|
appConfig.transparent = true
|
||||||
appConfig.keepAlive = false
|
appConfig.keepAlive = false
|
||||||
|
|
||||||
const apps = (await $A.IDBArray("cacheMicroApps")).filter(item => item.id != appConfig.id);
|
const apps = (await $A.IDBArray("cacheMicroApps")).filter(item => item.name != appConfig.name);
|
||||||
apps.length > 50 && apps.splice(0, 10)
|
apps.length > 50 && apps.splice(0, 10)
|
||||||
apps.push(appConfig)
|
apps.push(appConfig)
|
||||||
await $A.IDBSet("cacheMicroApps", apps);
|
await $A.IDBSet("cacheMicroApps", apps);
|
||||||
|
|
||||||
await this.$store.dispatch('openChildWindow', {
|
await this.$store.dispatch('openChildWindow', {
|
||||||
name: `single-apps-${$A.randomString(6)}`,
|
name: `single-apps-${$A.randomString(6)}`,
|
||||||
path: `/single/apps/${appConfig.id}`,
|
path: `/single/apps/${appConfig.name}`,
|
||||||
force: false,
|
force: false,
|
||||||
config
|
config
|
||||||
});
|
});
|
||||||
@ -329,11 +329,11 @@ export default {
|
|||||||
* @param config
|
* @param config
|
||||||
*/
|
*/
|
||||||
async observeMicroApp(config) {
|
async observeMicroApp(config) {
|
||||||
const app = this.apps.find(({id}) => id == config.id);
|
const app = this.apps.find(({name}) => name == config.name);
|
||||||
if (app) {
|
if (app) {
|
||||||
// 更新微应用
|
// 更新微应用
|
||||||
if (app.url != config.url) {
|
if (app.url != config.url) {
|
||||||
await microApp.unmountApp(app.id, {destroy: true})
|
await microApp.unmountApp(app.name, {destroy: true})
|
||||||
app.isLoading = true
|
app.isLoading = true
|
||||||
}
|
}
|
||||||
Object.assign(app, config)
|
Object.assign(app, config)
|
||||||
@ -348,31 +348,31 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过ID关闭微应用
|
* 通过名称关闭微应用
|
||||||
* @param id
|
* @param name
|
||||||
*/
|
*/
|
||||||
closeById(id) {
|
closeByName(name) {
|
||||||
try {
|
try {
|
||||||
this.$refs[`ref-${id}`][0].onClose()
|
this.$refs[`ref-${name}`][0].onClose()
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.closeMicroApp(id)
|
this.closeMicroApp(name)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 关闭微应用
|
* 关闭微应用
|
||||||
* @param id
|
* @param name
|
||||||
* @param destroy
|
* @param destroy
|
||||||
*/
|
*/
|
||||||
closeMicroApp(id, destroy) {
|
closeMicroApp(name, destroy) {
|
||||||
const app = this.apps.find(item => item.id == id);
|
const app = this.apps.find(item => item.name == name);
|
||||||
if (!app) {
|
if (!app) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
app.isOpen = false
|
app.isOpen = false
|
||||||
if (destroy) {
|
if (destroy) {
|
||||||
microApp.unmountApp(app.id, {destroy: true})
|
microApp.unmountApp(app.name, {destroy: true})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -386,14 +386,14 @@ export default {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 关闭之前判断
|
* 关闭之前判断
|
||||||
* @param id
|
* @param name
|
||||||
* @returns {Promise<unknown>}
|
* @returns {Promise<unknown>}
|
||||||
*/
|
*/
|
||||||
onBeforeClose(id) {
|
onBeforeClose(name) {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
microApp.forceSetData(id, {type: 'beforeClose'}, array => {
|
microApp.forceSetData(name, {type: 'beforeClose'}, array => {
|
||||||
if (!array?.find(item => item === true)) {
|
if (!array?.find(item => item === true)) {
|
||||||
if (id === 'appstore') {
|
if (name === 'appstore') {
|
||||||
this.$store.dispatch("updateMicroAppsStatus");
|
this.$store.dispatch("updateMicroAppsStatus");
|
||||||
}
|
}
|
||||||
if ($A.isSubElectron) {
|
if ($A.isSubElectron) {
|
||||||
@ -414,7 +414,7 @@ export default {
|
|||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
const app = this.apps.findLast(item => item.isOpen)
|
const app = this.apps.findLast(item => item.isOpen)
|
||||||
if (app) {
|
if (app) {
|
||||||
this.closeById(app.id)
|
this.closeByName(app.name)
|
||||||
} else {
|
} else {
|
||||||
resolve()
|
resolve()
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2626,7 +2626,7 @@ export default {
|
|||||||
this.$store.dispatch("openMicroApp", {
|
this.$store.dispatch("openMicroApp", {
|
||||||
id: 'okr',
|
id: 'okr',
|
||||||
key: 'details',
|
key: 'details',
|
||||||
url: 'apps/okr/',
|
url: 'apps/okr/#details',
|
||||||
props: {type: 'details', id},
|
props: {type: 'details', id},
|
||||||
transparent: true,
|
transparent: true,
|
||||||
});
|
});
|
||||||
|
|||||||
@ -9,13 +9,13 @@ export default {
|
|||||||
components: { MicroApps },
|
components: { MicroApps },
|
||||||
|
|
||||||
async mounted() {
|
async mounted() {
|
||||||
const id = this.$route.params.appId;
|
const {name} = this.$route.params;
|
||||||
if (!id) {
|
if (!name) {
|
||||||
$A.modalError("应用不存在");
|
$A.modalError("应用不存在");
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const app = (await $A.IDBArray("cacheMicroApps")).reverse().find(item => item.id === id);
|
const app = (await $A.IDBArray("cacheMicroApps")).reverse().find(item => item.name === name);
|
||||||
if (!app) {
|
if (!app) {
|
||||||
$A.modalError("应用不存在");
|
$A.modalError("应用不存在");
|
||||||
return
|
return
|
||||||
|
|||||||
2
resources/assets/js/routes.js
vendored
2
resources/assets/js/routes.js
vendored
@ -155,7 +155,7 @@ export default [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'single-apps',
|
name: 'single-apps',
|
||||||
path: '/single/apps/:appId',
|
path: '/single/apps/:name',
|
||||||
component: () => import('./pages/single/apps.vue')
|
component: () => import('./pages/single/apps.vue')
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
6
resources/assets/js/store/actions.js
vendored
6
resources/assets/js/store/actions.js
vendored
@ -4654,7 +4654,7 @@ export default {
|
|||||||
* - keepAlive 是否开启微应用保活 (true/false),默认 true
|
* - keepAlive 是否开启微应用保活 (true/false),默认 true
|
||||||
* - disableScopecss 是否禁用样式隔离 (true/false),默认 false
|
* - disableScopecss 是否禁用样式隔离 (true/false),默认 false
|
||||||
*/
|
*/
|
||||||
openMicroApp({state}, data) {
|
async openMicroApp({state}, data) {
|
||||||
if (!data || !$A.isJson(data)) {
|
if (!data || !$A.isJson(data)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -4677,9 +4677,7 @@ export default {
|
|||||||
$A.modalWarning(`应用「${config.id}」未安装`);
|
$A.modalWarning(`应用「${config.id}」未安装`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (data.key) {
|
config.name = `${config.id}_${await $A.getSHA256Hash(config.url)}`
|
||||||
config.id += `_${data.key}`
|
|
||||||
}
|
|
||||||
emitter.emit('observeMicroApp:open', config);
|
emitter.emit('observeMicroApp:open', config);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
1
resources/assets/js/store/mutations.js
vendored
1
resources/assets/js/store/mutations.js
vendored
@ -304,7 +304,6 @@ export default {
|
|||||||
data.unshift({
|
data.unshift({
|
||||||
id: 'appstore',
|
id: 'appstore',
|
||||||
menu_items: [{
|
menu_items: [{
|
||||||
id: 'appstore',
|
|
||||||
location: "application/admin",
|
location: "application/admin",
|
||||||
label: $A.L("应用商店"),
|
label: $A.L("应用商店"),
|
||||||
icon: $A.mainUrl("images/application/appstore.svg"),
|
icon: $A.mainUrl("images/application/appstore.svg"),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user