fix: update gen code unit test (#1790)
This commit is contained in:
parent
cc8c643e46
commit
e35908b805
|
|
@ -16,7 +16,9 @@ import { createZip, writeZip } from './fszip'
|
||||||
|
|
||||||
// 支持file system api的条件:存在这个方法 && 不处于iframe中
|
// 支持file system api的条件:存在这个方法 && 不处于iframe中
|
||||||
export const isSupportFileSystemAccess =
|
export const isSupportFileSystemAccess =
|
||||||
Object.prototype.hasOwnProperty.call(window, 'showDirectoryPicker') && window.self === window.top
|
typeof window !== 'undefined' &&
|
||||||
|
Object.prototype.hasOwnProperty.call(window, 'showDirectoryPicker') &&
|
||||||
|
window.self === window.top
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取用户选择并授权的文件夹根路径
|
* 获取用户选择并授权的文件夹根路径
|
||||||
|
|
|
||||||
|
|
@ -10,10 +10,10 @@
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"module": "dist/index.js",
|
"module": "dist/index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@opentiny/tiny-engine-i18n-host": "^1.0.0",
|
"@opentiny/tiny-engine-i18n-host": "^2.8.0",
|
||||||
"@opentiny/vue": "^3.10.0",
|
"@opentiny/vue": "^3.20.0",
|
||||||
"@opentiny/vue-icon": "^3.10.0",
|
"@opentiny/vue-icon": "^3.20.0",
|
||||||
"axios": "^0.21.1",
|
"axios": "^0.30.1",
|
||||||
"axios-mock-adapter": "^1.19.0",
|
"axios-mock-adapter": "^1.19.0",
|
||||||
"vue": "^3.3.9",
|
"vue": "^3.3.9",
|
||||||
"vue-i18n": "^9.2.0-beta.3",
|
"vue-i18n": "^9.2.0-beta.3",
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { I18nInjectionKey } from 'vue-i18n'
|
import { I18nInjectionKey } from 'vue-i18n'
|
||||||
import { provide } from 'vue'
|
import { provide } from 'vue'
|
||||||
import i18n from './i18n'
|
import i18n from '@/i18n/index.js'
|
||||||
|
|
||||||
provide(I18nInjectionKey, i18n)
|
provide(I18nInjectionKey, i18n)
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -11,49 +11,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import MockAdapter from 'axios-mock-adapter'
|
|
||||||
|
|
||||||
export default (config) => {
|
export default (config) => {
|
||||||
const instance = axios.create(config)
|
const instance = axios.create(config)
|
||||||
const defaults = {}
|
const defaults = {}
|
||||||
let mock
|
|
||||||
|
|
||||||
if (typeof MockAdapter.prototype.proxy === 'undefined') {
|
|
||||||
MockAdapter.prototype.proxy = function ({ url, config = {}, proxy, response, handleData } = {}) {
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
||||||
let stream = this
|
|
||||||
const request = (proxy, any) => {
|
|
||||||
return (setting) => {
|
|
||||||
return new Promise((resolve) => {
|
|
||||||
config.responseType = 'json'
|
|
||||||
axios
|
|
||||||
.get(any ? proxy + setting.url + '.json' : proxy, config)
|
|
||||||
.then(({ data }) => {
|
|
||||||
if (typeof handleData === 'function') {
|
|
||||||
data = handleData.call(null, data, setting)
|
|
||||||
}
|
|
||||||
resolve([200, data])
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
resolve([error.response.status, error.response.data])
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (url === '*' && proxy && typeof proxy === 'string') {
|
|
||||||
stream = proxy === '*' ? this.onAny().passThrough() : this.onAny().reply(request(proxy, true))
|
|
||||||
} else {
|
|
||||||
if (proxy && typeof proxy === 'string') {
|
|
||||||
stream = this.onAny(url).reply(request(proxy))
|
|
||||||
} else if (typeof response === 'function') {
|
|
||||||
stream = this.onAny(url).reply(response)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return stream
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
request(config) {
|
request(config) {
|
||||||
|
|
@ -115,25 +76,6 @@ export default (config) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mock(config) {
|
|
||||||
if (!mock) {
|
|
||||||
mock = new MockAdapter(instance)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Array.isArray(config)) {
|
|
||||||
config.forEach((item) => {
|
|
||||||
mock.proxy(item)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
return mock
|
|
||||||
},
|
|
||||||
disableMock() {
|
|
||||||
if (mock) {
|
|
||||||
mock.restore()
|
|
||||||
}
|
|
||||||
mock = undefined
|
|
||||||
},
|
|
||||||
isMock() {
|
isMock() {
|
||||||
return typeof mock !== 'undefined'
|
return typeof mock !== 'undefined'
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import axios from './axios'
|
import axios from '@/http/axios.js'
|
||||||
import config from './config'
|
import config from '@/http/config.js'
|
||||||
|
|
||||||
export default (dataHandler) => {
|
export default (dataHandler) => {
|
||||||
const http = axios(config)
|
const http = axios(config)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import i18n from '@opentiny/tiny-engine-i18n-host'
|
import i18n from '@opentiny/tiny-engine-i18n-host'
|
||||||
import lowcode from '../lowcodeConfig/lowcode'
|
import lowcode from '@/lowcodeConfig/lowcode.js'
|
||||||
import locale from './locale.js'
|
import locale from '@/i18n/locale.js'
|
||||||
|
|
||||||
i18n.lowcode = lowcode
|
i18n.lowcode = lowcode
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import useHttp from '../http'
|
import useHttp from '@/http/index.js'
|
||||||
import dataSources from './dataSource.json'
|
import dataSources from '@/lowcodeConfig/dataSource.json'
|
||||||
|
|
||||||
const dataSourceMap = {}
|
const dataSourceMap = {}
|
||||||
|
|
||||||
|
|
@ -27,7 +27,7 @@ const createFn = (fnContent) => {
|
||||||
|
|
||||||
const globalDataHandle = dataSources.dataHandler
|
const globalDataHandle = dataSources.dataHandler
|
||||||
? createFn(dataSources.dataHandler.value)
|
? createFn(dataSources.dataHandler.value)
|
||||||
: Promise.resolve({ data: res })
|
: (res) => Promise.resolve({ data: res })
|
||||||
|
|
||||||
const load = (http, options, dataSource, shouldFetch) => (params, customUrl) => {
|
const load = (http, options, dataSource, shouldFetch) => (params, customUrl) => {
|
||||||
// 如果没有配置远程请求,则直接返回静态数据,返回前可能会有全局数据处理
|
// 如果没有配置远程请求,则直接返回静态数据,返回前可能会有全局数据处理
|
||||||
|
|
@ -84,7 +84,7 @@ dataSources.list.forEach((config) => {
|
||||||
http.interceptors.request.use(willFetch, errorHandler)
|
http.interceptors.request.use(willFetch, errorHandler)
|
||||||
http.interceptors.response.use(dataHandler, errorHandler)
|
http.interceptors.response.use(dataHandler, errorHandler)
|
||||||
|
|
||||||
if (import.meta.env.VITE_APP_MOCK === 'mock') {
|
if (import.meta.env?.VITE_APP_MOCK === 'mock') {
|
||||||
http.mock([
|
http.mock([
|
||||||
{
|
{
|
||||||
url: config.options?.uri,
|
url: config.options?.uri,
|
||||||
|
|
|
||||||
|
|
@ -13,10 +13,10 @@
|
||||||
import { getCurrentInstance, nextTick, provide, inject } from 'vue'
|
import { getCurrentInstance, nextTick, provide, inject } from 'vue'
|
||||||
import { useRouter, useRoute } from 'vue-router'
|
import { useRouter, useRoute } from 'vue-router'
|
||||||
import { I18nInjectionKey } from 'vue-i18n'
|
import { I18nInjectionKey } from 'vue-i18n'
|
||||||
import dataSourceMap from './dataSource'
|
import dataSourceMap from '@/lowcodeConfig/dataSource.js'
|
||||||
import * as utils from '../utils'
|
import * as utils from '@/utils.js'
|
||||||
import * as bridge from './bridge'
|
import * as bridge from '@/lowcodeConfig/bridge.js'
|
||||||
import { useStores } from './store'
|
import { useStores } from '@/lowcodeConfig/store.js'
|
||||||
|
|
||||||
export const lowcodeWrap = (props, context) => {
|
export const lowcodeWrap = (props, context) => {
|
||||||
const global = {}
|
const global = {}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import * as useDefinedStores from '@/stores'
|
import * as useDefinedStores from '@/stores/index.js'
|
||||||
|
|
||||||
const useStores = () => {
|
const useStores = () => {
|
||||||
const stores = {}
|
const stores = {}
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,7 @@
|
||||||
/**
|
|
||||||
* Copyright (c) 2023 - present TinyEngine Authors.
|
|
||||||
* Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd.
|
|
||||||
*
|
|
||||||
* Use of this source code is governed by an MIT-style license.
|
|
||||||
*
|
|
||||||
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
|
|
||||||
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { createApp } from 'vue'
|
import { createApp } from 'vue'
|
||||||
import router from './router'
|
import router from '@/router/index.js'
|
||||||
import { createPinia } from 'pinia'
|
import { createPinia } from 'pinia'
|
||||||
import App from './App.vue'
|
import App from '@/App.vue'
|
||||||
import 'element-plus/dist/index.css'
|
import 'element-plus/dist/index.css'
|
||||||
const pinia = createPinia()
|
const pinia = createPinia()
|
||||||
createApp(App).use(pinia).use(router).mount('#app')
|
createApp(App).use(pinia).use(router).mount('#app')
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ export default defineConfig({
|
||||||
},
|
},
|
||||||
plugins: [vue(), vueJsx()],
|
plugins: [vue(), vueJsx()],
|
||||||
define: {
|
define: {
|
||||||
'process.env': { ...process.env }
|
'process.env': {}
|
||||||
},
|
},
|
||||||
build: {
|
build: {
|
||||||
minify: true,
|
minify: true,
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"module": "dist/index.js",
|
"module": "dist/index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@opentiny/tiny-engine-i18n-host": "^1.0.0",
|
"@opentiny/tiny-engine-i18n-host": "^2.8.0",
|
||||||
"@opentiny/vue": "0.1.16",
|
"@opentiny/vue": "0.1.16",
|
||||||
"@opentiny/vue-icon": "0.1.16",
|
"@opentiny/vue-icon": "0.1.16",
|
||||||
"axios": "latest",
|
"axios": "latest",
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { I18nInjectionKey } from 'vue-i18n'
|
import { I18nInjectionKey } from 'vue-i18n'
|
||||||
import { provide } from 'vue'
|
import { provide } from 'vue'
|
||||||
import i18n from './i18n'
|
import i18n from '@/i18n/index.js'
|
||||||
|
|
||||||
provide(I18nInjectionKey, i18n)
|
provide(I18nInjectionKey, i18n)
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -11,49 +11,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import MockAdapter from 'axios-mock-adapter'
|
|
||||||
|
|
||||||
export default (config) => {
|
export default (config) => {
|
||||||
const instance = axios.create(config)
|
const instance = axios.create(config)
|
||||||
const defaults = {}
|
const defaults = {}
|
||||||
let mock
|
|
||||||
|
|
||||||
if (typeof MockAdapter.prototype.proxy === 'undefined') {
|
|
||||||
MockAdapter.prototype.proxy = function ({ url, config = {}, proxy, response, handleData } = {}) {
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
||||||
let stream = this
|
|
||||||
const request = (proxy, any) => {
|
|
||||||
return (setting) => {
|
|
||||||
return new Promise((resolve) => {
|
|
||||||
config.responseType = 'json'
|
|
||||||
axios
|
|
||||||
.get(any ? proxy + setting.url + '.json' : proxy, config)
|
|
||||||
.then(({ data }) => {
|
|
||||||
if (typeof handleData === 'function') {
|
|
||||||
data = handleData.call(null, data, setting)
|
|
||||||
}
|
|
||||||
resolve([200, data])
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
resolve([error.response.status, error.response.data])
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (url === '*' && proxy && typeof proxy === 'string') {
|
|
||||||
stream = proxy === '*' ? this.onAny().passThrough() : this.onAny().reply(request(proxy, true))
|
|
||||||
} else {
|
|
||||||
if (proxy && typeof proxy === 'string') {
|
|
||||||
stream = this.onAny(url).reply(request(proxy))
|
|
||||||
} else if (typeof response === 'function') {
|
|
||||||
stream = this.onAny(url).reply(response)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return stream
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
request(config) {
|
request(config) {
|
||||||
|
|
@ -115,25 +76,6 @@ export default (config) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mock(config) {
|
|
||||||
if (!mock) {
|
|
||||||
mock = new MockAdapter(instance)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Array.isArray(config)) {
|
|
||||||
config.forEach((item) => {
|
|
||||||
mock.proxy(item)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
return mock
|
|
||||||
},
|
|
||||||
disableMock() {
|
|
||||||
if (mock) {
|
|
||||||
mock.restore()
|
|
||||||
}
|
|
||||||
mock = undefined
|
|
||||||
},
|
|
||||||
isMock() {
|
isMock() {
|
||||||
return typeof mock !== 'undefined'
|
return typeof mock !== 'undefined'
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import axios from './axios'
|
import axios from '@/http/axios.js'
|
||||||
import config from './config'
|
import config from '@/http/config.js'
|
||||||
|
|
||||||
export default (dataHandler) => {
|
export default (dataHandler) => {
|
||||||
const http = axios(config)
|
const http = axios(config)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import i18n from '@opentiny/tiny-engine-i18n-host'
|
import i18n from '@opentiny/tiny-engine-i18n-host'
|
||||||
import lowcode from '../lowcodeConfig/lowcode'
|
import lowcode from '@/lowcodeConfig/lowcode.js'
|
||||||
import locale from './locale.js'
|
import locale from '@/i18n/locale.js'
|
||||||
|
|
||||||
i18n.lowcode = lowcode
|
i18n.lowcode = lowcode
|
||||||
i18n.global.mergeLocaleMessage('en_US', locale.en_US)
|
i18n.global.mergeLocaleMessage('en_US', locale.en_US)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import en_US from './en_US.json'
|
import en_US from '@/i18n/en_US.json'
|
||||||
import zh_CN from './zh_CN.json'
|
import zh_CN from '@/i18n/zh_CN.json'
|
||||||
|
|
||||||
export default { en_US, zh_CN }
|
export default { en_US, zh_CN }
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import useHttp from '../http'
|
import useHttp from '@/http/index.js'
|
||||||
import dataSources from './dataSource.json'
|
import dataSources from '@/lowcodeConfig/dataSource.json'
|
||||||
|
|
||||||
const dataSourceMap = {}
|
const dataSourceMap = {}
|
||||||
|
|
||||||
|
|
@ -27,7 +27,7 @@ const createFn = (fnContent) => {
|
||||||
|
|
||||||
const globalDataHandle = dataSources.dataHandler
|
const globalDataHandle = dataSources.dataHandler
|
||||||
? createFn(dataSources.dataHandler.value)
|
? createFn(dataSources.dataHandler.value)
|
||||||
: Promise.resolve({ data: res })
|
: (res) => Promise.resolve({ data: res })
|
||||||
|
|
||||||
const load = (http, options, dataSource, shouldFetch) => (params, customUrl) => {
|
const load = (http, options, dataSource, shouldFetch) => (params, customUrl) => {
|
||||||
// 如果没有配置远程请求,则直接返回静态数据,返回前可能会有全局数据处理
|
// 如果没有配置远程请求,则直接返回静态数据,返回前可能会有全局数据处理
|
||||||
|
|
@ -84,7 +84,7 @@ dataSources.list.forEach((config) => {
|
||||||
http.interceptors.request.use(willFetch, errorHandler)
|
http.interceptors.request.use(willFetch, errorHandler)
|
||||||
http.interceptors.response.use(dataHandler, errorHandler)
|
http.interceptors.response.use(dataHandler, errorHandler)
|
||||||
|
|
||||||
if (import.meta.env.VITE_APP_MOCK === 'mock') {
|
if (import.meta.env?.VITE_APP_MOCK === 'mock') {
|
||||||
http.mock([
|
http.mock([
|
||||||
{
|
{
|
||||||
url: config.options?.uri,
|
url: config.options?.uri,
|
||||||
|
|
|
||||||
|
|
@ -13,10 +13,10 @@
|
||||||
import { getCurrentInstance, nextTick, provide, inject } from 'vue'
|
import { getCurrentInstance, nextTick, provide, inject } from 'vue'
|
||||||
import { useRouter, useRoute } from 'vue-router'
|
import { useRouter, useRoute } from 'vue-router'
|
||||||
import { I18nInjectionKey } from 'vue-i18n'
|
import { I18nInjectionKey } from 'vue-i18n'
|
||||||
import dataSourceMap from './dataSource'
|
import dataSourceMap from '@/lowcodeConfig/dataSource.js'
|
||||||
import * as utils from '../utils'
|
import * as utils from '@/utils.js'
|
||||||
import * as bridge from './bridge'
|
import * as bridge from '@/lowcodeConfig/bridge.js'
|
||||||
import { useStores } from './store'
|
import { useStores } from '@/lowcodeConfig/store.js'
|
||||||
|
|
||||||
export const lowcodeWrap = (props, context) => {
|
export const lowcodeWrap = (props, context) => {
|
||||||
const global = {}
|
const global = {}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import * as useDefinedStores from '@/stores'
|
import * as useDefinedStores from '@/stores/index.js'
|
||||||
|
|
||||||
const useStores = () => {
|
const useStores = () => {
|
||||||
const stores = {}
|
const stores = {}
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,7 @@
|
||||||
/**
|
|
||||||
* Copyright (c) 2023 - present TinyEngine Authors.
|
|
||||||
* Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd.
|
|
||||||
*
|
|
||||||
* Use of this source code is governed by an MIT-style license.
|
|
||||||
*
|
|
||||||
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
|
|
||||||
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { createApp } from 'vue'
|
import { createApp } from 'vue'
|
||||||
import router from './router'
|
import router from '@/router/index.js'
|
||||||
import { createPinia } from 'pinia'
|
import { createPinia } from 'pinia'
|
||||||
import App from './App.vue'
|
import App from '@/App.vue'
|
||||||
|
|
||||||
const pinia = createPinia()
|
const pinia = createPinia()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ export default defineConfig({
|
||||||
},
|
},
|
||||||
plugins: [vue(), vueJsx()],
|
plugins: [vue(), vueJsx()],
|
||||||
define: {
|
define: {
|
||||||
'process.env': { ...process.env }
|
'process.env': {}
|
||||||
},
|
},
|
||||||
build: {
|
build: {
|
||||||
minify: true,
|
minify: true,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue