Skip to content

Commit 2293209

Browse files
authored
fix(graph): use lang paths and load code with onMounted 🩹 (#22)
1 parent a827355 commit 2293209

5 files changed

Lines changed: 28 additions & 25 deletions

File tree

‎app/Console/Commands/LoadProLang.php‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,10 @@ private function updateLangFamily() {
179179
'Dylan' => array('ALGOL 60', 'EuLisp'),
180180
// Data : https://en.wikipedia.org/wiki/Lasso_(programming_language)
181181
'Lasso' => array('Dylan', 'Scala'),
182+
// Data : https://en.wikipedia.org/wiki/JavaScript
183+
'ActionScript' => array('JavaScript'),
184+
'CoffeeScript' => array('JavaScript'),
185+
'JavaScript' => array('Java', 'Self', 'AWK'),
182186
);
183187

184188
foreach ($langFamilies as $name => $value) {

‎resources/js/components/prolang/LangCard.vue‎

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -146,20 +146,17 @@
146146

147147
<script lang="ts" setup>
148148
import { codeToHtml } from "shiki"
149-
import { computed, ref } from "vue"
149+
import { computed, onMounted, ref } from "vue"
150150
import type { ProLangLanguage } from "@/types/main"
151151
152-
const code = ref<string | null>(null)
153-
const emits = defineEmits(["select-lang", "close"])
154-
155152
const props = defineProps<{
156153
lang: ProLangLanguage
157154
selectedLang: string | null
158155
}>()
159156
160-
const hasEnoughData = computed(() => {
161-
return props.lang.link || props.lang.mainRepository
162-
})
157+
const code = ref<string | null>(null)
158+
const emits = defineEmits(["select-lang", "close"])
159+
const hasEnoughData = computed(() => props.lang.link || props.lang.mainRepository)
163160
const castYears = JSON.parse(props.lang.years).join(", ")
164161
165162
async function setCodeHtml(codeStr: string, lang?: string) {
@@ -173,19 +170,19 @@ async function setCodeHtml(codeStr: string, lang?: string) {
173170
}
174171
175172
async function showCode() {
176-
if (code.value === null) {
177-
if (props.lang.rawCode) {
178-
await setCodeHtml(props.lang.rawCode)
179-
} else if (props.lang.rawCodeLink) {
180-
const resp = await fetch(props.lang.rawCodeLink)
181-
const text = await resp.text()
182-
183-
setCodeHtml(text)
184-
}
185-
}
186-
187173
emits("select-lang", props.lang.name)
188174
}
175+
176+
onMounted(async () => {
177+
if (props.lang.rawCode) {
178+
await setCodeHtml(props.lang.rawCode)
179+
} else if (props.lang.rawCodeLink) {
180+
const resp = await fetch(props.lang.rawCodeLink)
181+
const text = await resp.text()
182+
183+
setCodeHtml(text)
184+
}
185+
})
189186
</script>
190187

191188
<style lang="scss" scoped>

‎resources/js/components/prolang/LangGraphData.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ import type { Edges, Layouts, Nodes } from "v-network-graph"
22
import type { ProLangLanguage } from "@/types/main"
33

44
function langNameMatch(lang: ProLangLanguage, search: string) {
5-
return lang.name.toLowerCase().includes(search.toLowerCase())
5+
return lang.paths.some((p) => {
6+
return p.toLowerCase().includes(search.toLowerCase())
7+
})
68
}
79

810
export function isMemberOf(search: string, lang: ProLangLanguage): boolean {

‎resources/js/pages/LangFamily.vue‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,12 @@ const configs = reactive(
5353
node: {
5454
normal: {
5555
color: (n) => {
56-
if (hasName.value && n.name?.includes(hasName.value)) {
57-
return "#a45586"
56+
if (hasName.value) {
57+
const regex = new RegExp(`${hasName.value}`, "i")
58+
59+
if (n.name && regex.test(n.name)) {
60+
return "#a45586"
61+
}
5862
}
5963
return n.name === "Human" ? "#100d50" : "#08abff"
6064
},

‎resources/js/pages/LangHistory.vue‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,6 @@ function updateSelectedLang(value: string, forClose: boolean) {
8989
if (forClose) {
9090
selectedLang.value = ""
9191
} else {
92-
// if (searchLang.value.length > 0) {
93-
// searchLang.value = value
94-
// }
95-
9692
searchLang.value = value
9793
selectedLang.value = value
9894
}

0 commit comments

Comments
 (0)