pull/275/head
Bosn 7 years ago
parent 2f96d7d891
commit 4c59a95bd0

@ -1,2 +1,5 @@
ALTER TABLE `properties`
ADD COLUMN `pos` INT(10) NULL DEFAULT 2;
ADD COLUMN `pos` INT(10) NULL DEFAULT 2;
ALTER TABLE `interfaces`
ADD COLUMN `status` INT(10) NULL DEFAULT 200;

@ -59,6 +59,10 @@ export default class Interface extends Model<Interface> {
@Column(DataType.BIGINT(11))
priority: number
@Default(200)
@Column
status: number
@ForeignKey(() => User)
@Column
creatorId: number

@ -125,14 +125,13 @@ router.all('/app/mock/:repositoryId(\\d+)/:url(.+)', async (ctx) => {
}
let urlWithoutPrefixSlash = /(\/)?(.*)/.exec(url)[2]
let urlWithoutSearch
try {
let urlParts = new URL(url)
urlWithoutSearch = `${urlParts.origin}${urlParts.pathname}`
} catch (e) {
urlWithoutSearch = url
}
urlWithoutSearch
// let urlWithoutSearch
// try {
// let urlParts = new URL(url)
// urlWithoutSearch = `${urlParts.origin}${urlParts.pathname}`
// } catch (e) {
// urlWithoutSearch = url
// }
// DONE 2.3 腐烂的 KISSY
// KISSY 1.3.2 会把路径中的 // 替换为 /。在浏览器端拦截跨域请求时,需要 encodeURIComponent(url) 以防止 http:// 被替换为 http:/。但是同时也会把参数一起编码,导致 route 的 url 部分包含了参数。
// 所以这里重新解析一遍!!!
@ -140,8 +139,9 @@ router.all('/app/mock/:repositoryId(\\d+)/:url(.+)', async (ctx) => {
let repository = await Repository.findById(repositoryId)
let collaborators: Repository[] = (await repository.$get('collaborators')) as Repository[]
let itf
// console.log([urlWithoutPrefixSlash, '/' + urlWithoutPrefixSlash, urlWithoutSearch])
itf = await Interface.findOne({
const matchedItfList = await Interface.findAll({
attributes,
where: {
repositoryId: [repositoryId, ...collaborators.map(item => item.id)],
@ -152,6 +152,15 @@ router.all('/app/mock/:repositoryId(\\d+)/:url(.+)', async (ctx) => {
}
})
if (matchedItfList) {
for (const item of matchedItfList) {
itf = item
if (item.url === urlWithoutPrefixSlash) {
break
}
}
}
if (!itf) {
// try RESTFul API search...
let list = await Interface.findAll({

@ -32,7 +32,7 @@ export default class MigrateService {
const itf = await Interface.create({
moduleId: mod.id,
name: `${page.name}-${action.name}`,
description: action.introduction,
description: action.description,
url: action.requestUrl || '',
priority: iCounter++,
creatorId: curUserId,
@ -122,7 +122,8 @@ export default class MigrateService {
})
result = JSON.parse(result)
result = unescape(result.modelJSON)
// result = unescape(result.modelJSON)
result = result.modelJSON
const safeEval = require('notevil')
result = safeEval('(' + result + ')')
return await this.importRepoFromRAP1ProjectData(orgId, curUserId, result)

Loading…
Cancel
Save