Skip to content

Commit 1c09447

Browse files
author
申蛟隆
committed
issue fixed
1 parent 869340f commit 1c09447

File tree

3 files changed

+38
-8
lines changed

3 files changed

+38
-8
lines changed

dist/client.js

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4290,7 +4290,7 @@ var require_document = __commonJS({
42904290
"out/frameworks/element-ui/document.js"(exports2) {
42914291
"use strict";
42924292
Object.defineProperty(exports2, "__esModule", { value: true });
4293-
var docUrl = "http://element-cn.eleme.io";
4293+
var docUrl = "http://element.eleme.io";
42944294
exports2.default = () => {
42954295
return {
42964296
"el-row": `[element\uFF1A${docUrl}/#/zh-CN/component/layout](${docUrl}/#/zh-CN/component/layout)
@@ -22719,25 +22719,40 @@ var require_framework = __commonJS({
2271922719
definitionOutFile(document, file) {
2272022720
return __awaiter(this, void 0, void 0, function* () {
2272122721
let filePath = file.path;
22722+
let isAbsolute = false;
22723+
if (filePath.includes(this.frameworkProvider.explorer.prefix.alias)) {
22724+
isAbsolute = true;
22725+
}
2272222726
filePath = filePath.replace(this.frameworkProvider.explorer.prefix.alias, this.frameworkProvider.explorer.prefix.path);
2272322727
if (/(.*\/.*|[^.]+)\..*$/gi.test(filePath)) {
22724-
let tempFile = path.resolve(document.uri.fsPath || "", "../", filePath);
22728+
let tempFile = "";
22729+
if (isAbsolute) {
22730+
tempFile = path.join(this.frameworkProvider.explorer.projectRootPath, filePath);
22731+
} else {
22732+
tempFile = path.join(document.uri.path || "", "../", filePath);
22733+
}
2272522734
if (fs.existsSync(tempFile)) {
2272622735
return Promise.resolve(new vscode_12.Location(vscode_12.Uri.file(tempFile), new vscode_12.Position(0, 0)));
2272722736
}
2272822737
} else {
2272922738
const postfix = ["vue", "js", "css", "scss", "less"];
2273022739
for (let i = 0; i < postfix.length; i++) {
2273122740
const post = postfix[i];
22732-
let tempFile = path.resolve(document.uri.fsPath || "", "../", filePath);
22733-
if (tempFile.endsWith("/")) {
22741+
let tempFile = "";
22742+
if (isAbsolute) {
22743+
tempFile = path.join(this.frameworkProvider.explorer.projectRootPath, filePath);
22744+
} else {
22745+
tempFile = path.join(document.uri.path || "", "../", filePath);
22746+
}
22747+
if (tempFile.endsWith(path.sep)) {
2273422748
tempFile = tempFile + "index." + post;
2273522749
if (fs.existsSync(tempFile)) {
2273622750
return Promise.resolve(new vscode_12.Location(vscode_12.Uri.file(tempFile), new vscode_12.Position(0, 0)));
2273722751
}
2273822752
} else {
2273922753
let indexFile = tempFile + path.sep + "index." + post;
2274022754
tempFile += "." + post;
22755+
tempFile = (0, util_1.winRootPathHandle)(tempFile);
2274122756
if (fs.existsSync(tempFile)) {
2274222757
return Promise.resolve(new vscode_12.Location(vscode_12.Uri.file(tempFile), new vscode_12.Position(0, 0)));
2274322758
}

src/framework.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -787,11 +787,20 @@ export class vueHelperDefinitionProvider implements DefinitionProvider {
787787
let filePath = file.path
788788

789789
// 1. 根据文件目录查询是否存在相应文件
790+
let isAbsolute = false
791+
if (filePath.includes(this.frameworkProvider.explorer.prefix.alias)) {
792+
isAbsolute = true
793+
}
790794
filePath = filePath.replace(this.frameworkProvider.explorer.prefix.alias, this.frameworkProvider.explorer.prefix.path)
791795

792796
// 文件存在后缀,则直接查找
793797
if (/(.*\/.*|[^.]+)\..*$/gi.test(filePath)) {
794-
let tempFile = path.resolve(document.uri.fsPath || '', '../', filePath)
798+
let tempFile = ''
799+
if (isAbsolute) {
800+
tempFile = path.join(this.frameworkProvider.explorer.projectRootPath, filePath)
801+
} else {
802+
tempFile = path.join(document.uri.path || '', '../', filePath)
803+
}
795804
if (fs.existsSync(tempFile)) {
796805
return Promise.resolve(new Location(Uri.file(tempFile), new Position(0, 0)))
797806
}
@@ -801,15 +810,21 @@ export class vueHelperDefinitionProvider implements DefinitionProvider {
801810
for (let i = 0; i < postfix.length; i++) {
802811
const post = postfix[i]
803812
// 相对路径处理
804-
let tempFile = path.resolve(document.uri.fsPath || '', '../', filePath)
805-
if (tempFile.endsWith('/')) {
813+
let tempFile = ''
814+
if (isAbsolute) {
815+
tempFile = path.join(this.frameworkProvider.explorer.projectRootPath, filePath)
816+
} else {
817+
tempFile = path.join(document.uri.path || '', '../', filePath)
818+
}
819+
if (tempFile.endsWith(path.sep)) {
806820
tempFile = tempFile + 'index.' + post
807821
if (fs.existsSync(tempFile)) {
808822
return Promise.resolve(new Location(Uri.file(tempFile), new Position(0, 0)))
809823
}
810824
} else {
811825
let indexFile = tempFile + path.sep + 'index.' + post
812826
tempFile += '.' + post
827+
tempFile = winRootPathHandle(tempFile)
813828
if (fs.existsSync(tempFile)) {
814829
return Promise.resolve(new Location(Uri.file(tempFile), new Position(0, 0)))
815830
}

src/frameworks/element-ui/document.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const docUrl = 'http://element-cn.eleme.io'
1+
const docUrl = 'http://element.eleme.io'
22

33
export default () => {
44
return {

0 commit comments

Comments
 (0)