feature: 放弃自己研发的代码定位功能,集成vite官方的devtool工具

This commit is contained in:
pixelMax(奇淼
2024-07-26 13:38:21 +08:00
parent 055198ccd5
commit 5c7d121e67
6 changed files with 4 additions and 138 deletions
-3
View File
@@ -15,9 +15,6 @@ import run from '@/core/gin-vue-admin.js'
import auth from '@/directive/auth'
import { store } from '@/pinia'
import App from './App.vue'
import { initDom } from './utils/positionToCode'
initDom()
const app = createApp(App)
app.config.productionTip = false
-36
View File
@@ -1,36 +0,0 @@
export const initDom = () => {
if (import.meta.env.MODE === 'development') {
document.onmousedown = function(e) {
if (e.shiftKey && e.altKey && e.button === 0) {
e.preventDefault()
sendRequestToOpenFileInEditor(getFilePath(e))
}
}
}
}
const getFilePath = (e) => {
let element = e
if (e.target) {
element = e.target
}
if (!element || !element.getAttribute) return null
if (element.getAttribute('code-location')) {
return element.getAttribute('code-location')
}
return getFilePath(element.parentNode)
}
const sendRequestToOpenFileInEditor = (filePath) => {
const protocol = window.location.protocol
? window.location.protocol
: 'http:'
const hostname = window.location.hostname
? window.location.hostname
: 'localhost'
const port = window.location.port ? window.location.port : '80'
fetch(`${protocol}//${hostname}:${port}/gvaPositionCode?filePath=${filePath}`)
.catch((error) => {
console.log(error)
})
}