diff --git a/docker-compose.yml b/docker-compose.yml index b70facd0a..3949dd4b8 100755 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -96,7 +96,7 @@ services: appstore: container_name: "dootask-appstore-${APP_ID}" privileged: true - image: "dootask/appstore:0.0.2" + image: "dootask/appstore:0.0.3" volumes: - shared_data:/usr/share/dootask - /var/run/docker.sock:/var/run/docker.sock diff --git a/resources/assets/js/components/MicroApps/index.vue b/resources/assets/js/components/MicroApps/index.vue index 2dd5ac8bf..0c76edf6a 100644 --- a/resources/assets/js/components/MicroApps/index.vue +++ b/resources/assets/js/components/MicroApps/index.vue @@ -7,14 +7,14 @@ :ref="`ref-${app.name}`" :size="1200" :transparent="app.transparent" - :autoDarkTheme="app.autoDarkTheme" + :autoDarkTheme="app.auto_dark_theme" :beforeClose="async () => { await onBeforeClose(app.name) }"> item.name != appConfig.name); apps.length > 50 && apps.splice(0, 10) @@ -329,6 +331,14 @@ export default { * @param config */ async observeMicroApp(config) { + if (config.url_type === 'inline_blank') { + await this.inlineBlank(config) + return + } + if (config.url_type === 'external') { + await this.externalWindow(config) + return + } const app = this.apps.find(({name}) => name == config.name); if (app) { // 更新微应用 @@ -347,6 +357,79 @@ export default { } }, + /** + * 内联链接,在新窗口打开 + * @param config + * @returns {Promise} + */ + async inlineBlank(config) { + // 内联链接在新窗口打开固定参数 + config.url_type = 'inline'; + config.transparent = true + config.keep_alive = false + // + const path = `/single/apps/${config.name}` + const apps = (await $A.IDBArray("cacheMicroApps")).filter(item => item.name != config.name); + apps.length > 50 && apps.splice(0, 10) + apps.push(config) + await $A.IDBSet("cacheMicroApps", apps); + + if (this.$Electron) { + await this.$store.dispatch('openChildWindow', { + name: `single-apps-${$A.randomString(6)}`, + path: path, + force: false, + config: { + title: ' ', + parent: null, + width: Math.min(window.screen.availWidth, 1440), + height: Math.min(window.screen.availHeight, 900), + }, + }); + } else if (this.$isEEUIApp) { + await this.$store.dispatch('openAppChildPage', { + pageType: 'app', + pageTitle: ' ', + url: 'web.js', + params: { + url: $A.urlReplaceHash(path) + }, + }) + } else { + window.open($A.mainUrl(path.substring(1))) + } + }, + + /** + * 外部链接,在新窗口打开 + * @param url + * @returns {Promise} + */ + async externalWindow({url}) { + if (this.$Electron) { + await this.$store.dispatch('openChildWindow', { + name: `external-apps-${$A.randomString(6)}`, + path: url, + force: false, + config: { + title: ' ', + parent: null, + width: Math.min(window.screen.availWidth, 1440), + height: Math.min(window.screen.availHeight, 900), + }, + }); + } else if (this.$isEEUIApp) { + await this.$store.dispatch('openAppChildPage', { + pageType: 'app', + pageTitle: ' ', + url: 'web.js', + params: {url}, + }); + } else { + window.open(url) + } + }, + /** * 通过名称关闭微应用 * @param name diff --git a/resources/assets/js/store/actions.js b/resources/assets/js/store/actions.js index 000c4d0cf..b56f07975 100644 --- a/resources/assets/js/store/actions.js +++ b/resources/assets/js/store/actions.js @@ -4648,11 +4648,12 @@ export default { * @param data * - id 应用ID * - url 应用地址 - * - props 传递参数 + * - url_type 地址类型 * - transparent 是否透明模式 (true/false),默认 false - * - autoDarkTheme 是否自动适配深色主题 (true/false),默认 true - * - keepAlive 是否开启微应用保活 (true/false),默认 true - * - disableScopecss 是否禁用样式隔离 (true/false),默认 false + * - disable_scope_css 是否禁用样式隔离 (true/false),默认 false + * - auto_dark_theme 是否自动适配深色主题 (true/false),默认 true + * - keep_alive 是否开启微应用保活 (true/false),默认 true + * - props 传递参数 */ async openMicroApp({state}, data) { if (!data || !$A.isJson(data)) { @@ -4664,11 +4665,12 @@ export default { const config = { id: data.id, url: $A.mainUrl(data.url), - props: $A.isJson(data.props) ? data.props : {}, + url_type: data.url_type || 'inline', transparent: typeof data.transparent == 'boolean' ? data.transparent : false, - autoDarkTheme: typeof data.autoDarkTheme == 'boolean' ? data.autoDarkTheme : true, - keepAlive: typeof data.keepAlive == 'boolean' ? data.keepAlive : true, - disableScopecss: typeof data.disableScopecss == 'boolean' ? data.disableScopecss : false + disable_scope_css: typeof data.disable_scope_css == 'boolean' ? data.disable_scope_css : false, + auto_dark_theme: typeof data.auto_dark_theme == 'boolean' ? data.auto_dark_theme : true, + keep_alive: typeof data.keep_alive == 'boolean' ? data.keep_alive : true, + props: $A.isJson(data.props) ? data.props : {}, } if (!config.id) { return @@ -4678,6 +4680,14 @@ export default { return; } config.name = `${config.id}_${await $A.getSHA256Hash(config.url)}` + config.url = config.url.replace(/\{user_id}/g, state.userId) + .replace(/\{user_nickname}/g, encodeURIComponent(state.userInfo.nickname)) + .replace(/\{user_email}/g, encodeURIComponent(state.userInfo.email)) + .replace(/\{user_avatar}/g, encodeURIComponent(state.userInfo.userimg)) + .replace(/\{user_token}/g, encodeURIComponent(state.userToken)) + .replace(/\{system_theme}/g, state.systemConfig.themeName) + .replace(/\{system_lang}/g, languageName) + .replace(/\{system_base_url}/g, $A.mainUrl('').replace(/\/$/, '')); emitter.emit('observeMicroApp:open', config); }, diff --git a/resources/assets/js/store/getters.js b/resources/assets/js/store/getters.js index 8248d4ff6..d866e693a 100644 --- a/resources/assets/js/store/getters.js +++ b/resources/assets/js/store/getters.js @@ -286,7 +286,12 @@ export default { * @returns {Array} */ filterMicroAppsMenus: (state) => { - return state.microAppsMenus.filter(item => item.location === 'application') + return state.microAppsMenus.filter(item => { + if (item.only_admin === true && !state.userIsAdmin) { + return false + } + return item.location === 'application' + }) }, /** @@ -297,7 +302,12 @@ export default { * @returns {Array} */ filterMicroAppsMenusAdmin: (state) => { - return state.microAppsMenus.filter(item => item.location === 'application/admin') + return state.microAppsMenus.filter(item => { + if (item.only_admin === true && !state.userIsAdmin) { + return false + } + return item.location === 'application/admin' + }) }, /** @@ -308,6 +318,11 @@ export default { * @returns {Array} */ filterMicroAppsMenusMain: (state) => { - return state.microAppsMenus.filter(item => item.location === 'main/menu') + return state.microAppsMenus.filter(item => { + if (item.only_admin === true && !state.userIsAdmin) { + return false + } + return item.location === 'main/menu' + }) } } diff --git a/resources/assets/js/store/mutations.js b/resources/assets/js/store/mutations.js index c1d3e3287..7a733b91f 100644 --- a/resources/assets/js/store/mutations.js +++ b/resources/assets/js/store/mutations.js @@ -308,8 +308,8 @@ export default { label: $A.L("应用商店"), icon: $A.mainUrl("images/application/appstore.svg"), url: 'appstore/internal', - disableScopecss: true, - autoDarkTheme: false, + disable_scope_css: true, + auto_dark_theme: false, }] }) const ids = [];