fix:修复okr路由解析错误

This commit is contained in:
weifashi 2023-09-04 18:37:14 +08:00
parent 7b2b026bad
commit a38fa4625f
9 changed files with 21 additions and 25 deletions

View File

@ -176,7 +176,7 @@ services:
okr: okr:
container_name: "dootask-okr-${APP_ID}" container_name: "dootask-okr-${APP_ID}"
image: "kuaifan/doookr:0.0.6" image: "kuaifan/doookr:0.0.7"
environment: environment:
TZ: "${TIMEZONE:-PRC}" TZ: "${TIMEZONE:-PRC}"
DOO_TASK_URL: "http://${APP_IPPR}.3" DOO_TASK_URL: "http://${APP_IPPR}.3"

View File

@ -2,8 +2,6 @@ const isElectron = !!(window && window.process && window.process.type);
const isEEUiApp = window && window.navigator && /eeui/i.test(window.navigator.userAgent); const isEEUiApp = window && window.navigator && /eeui/i.test(window.navigator.userAgent);
import microappInit from "./microapp" import microappInit from "./microapp"
microappInit()
import {switchLanguage as $L} from "./language"; import {switchLanguage as $L} from "./language";
import './functions/common' import './functions/common'
@ -210,6 +208,9 @@ Vue.mixin(mixin)
let app; let app;
store.dispatch("init").then(action => { store.dispatch("init").then(action => {
microappInit();
app = new Vue({ app = new Vue({
router, router,
store, store,

View File

@ -96,7 +96,7 @@ export default {
handler(to) { handler(to) {
if(to.name == 'manage-apps'){ if(to.name == 'manage-apps'){
this.appData = { this.appData = {
path: to.hash path: to.hash || to.fullPath
} }
} }
}, },
@ -120,6 +120,7 @@ export default {
getAppData(){ getAppData(){
return { return {
type: 'init', type: 'init',
url: this.url,
vues: { vues: {
Vue, Vue,
store, store,

View File

@ -1,11 +1,7 @@
import microApp from '@micro-zoe/micro-app' import microApp from '@micro-zoe/micro-app'
const getUrl = (s) => { const getUrl = (url) => {
let url = $A.apiUrl('../' + s) return import.meta.env.VITE_OKR_WEB_URL || $A.apiUrl(url);
if (url.indexOf('http') == -1) {
url = window.location.origin + url
}
return import.meta.env.VITE_OKR_WEB_URL || url;
} }
export default function() { export default function() {
@ -21,7 +17,7 @@ export default function() {
route = urls.replace(match[0].replace("@vite/client",""),""); route = urls.replace(match[0].replace("@vite/client",""),"");
} }
// 这里 /basename/ 需要和子应用vite.config.js中base的配置保持一致 // 这里 /basename/ 需要和子应用vite.config.js中base的配置保持一致
code = code.replace( eval(`/(from|import)(\\s*['"])(${route.replace(/\//g,"\\/")})/g`) , all => { code = code.replace(new RegExp(`(from|import)(\\s*['"])(${route.replace(/\//g,"\\/")})`,'g') , all => {
return all.replace(route, urls) return all.replace(route, urls)
}) })
} }
@ -44,7 +40,7 @@ export default function() {
microApp.preFetch([ microApp.preFetch([
{ {
name: 'micro-app', name: 'micro-app',
url: getUrl("/apps/okr"), url: getUrl("../apps/okr"),
disableSandbox: true disableSandbox: true
} }
]) ])

View File

@ -474,11 +474,7 @@ export default {
// okr // okr
okrUrl() { okrUrl() {
let url = $A.apiUrl("../apps/okr") return import.meta.env.VITE_OKR_WEB_URL || $A.apiUrl("../apps/okr")
if (url.indexOf('http') == -1) {
url = window.location.origin + url
}
return import.meta.env.VITE_OKR_WEB_URL || url
}, },
/** /**

View File

@ -356,7 +356,7 @@ export default {
case 'okr': case 'okr':
case 'okrAnalyze': case 'okrAnalyze':
this.goForward({ this.goForward({
path: '/manage/apps/' + (item.value == 'okr' ? '/#/list' : '/#/analysis'), path: '/manage/apps/okr/' + (item.value == 'okr' ? 'list' : 'analysis'),
}); });
break; break;
case 'report': case 'report':

View File

@ -26,11 +26,7 @@ export default {
if (to.name == 'manage-apps') { if (to.name == 'manage-apps') {
this.$nextTick(() => { this.$nextTick(() => {
this.loading = false; this.loading = false;
let url = $A.apiUrl("../apps/okr") this.appUrl = import.meta.env.VITE_OKR_WEB_URL || $A.apiUrl("../apps/okr")
if (url.indexOf('http') == -1) {
url = window.location.origin + url
}
this.appUrl = import.meta.env.VITE_OKR_WEB_URL || url
this.path = this.$route.query.path || ''; this.path = this.$route.query.path || '';
}) })
} }

View File

@ -3639,7 +3639,7 @@ export default {
if (link_id > 0) { if (link_id > 0) {
if (window.innerWidth < 910) { if (window.innerWidth < 910) {
$A.goForward({ $A.goForward({
path:'/manage/apps/#/okrDetails?data='+link_id, path:'/manage/apps/okr/okrDetails?data=' + link_id,
}); });
}else{ }else{
state.okrWindow = { state.okrWindow = {

8
vite.config.js vendored
View File

@ -68,7 +68,13 @@ export default defineConfig(({command, mode}) => {
chunkSizeWarningLimit: 3000, chunkSizeWarningLimit: 3000,
}, },
plugins: [ plugins: [
createVuePlugin(), createVuePlugin({
template: {
compilerOptions: {
isCustomElement: (tag) => tag.includes('micro-app') ,
}
}
}),
vitePluginRequire(), vitePluginRequire(),
vitePluginFileCopy([{ vitePluginFileCopy([{
src: resolve(__dirname, 'resources/assets/statics/public'), src: resolve(__dirname, 'resources/assets/statics/public'),