mirror of
https://github.com/yangjian102621/geekai.git
synced 2025-09-18 01:06:39 +08:00
opt: optimize the formula show styles
This commit is contained in:
parent
264e77f383
commit
6aa1d27711
@ -154,7 +154,7 @@ func authorizeMiddleware(s *AppServer, client *redis.Client) gin.HandlerFunc {
|
||||
}
|
||||
|
||||
token, err := jwt.Parse(tokenString, func(token *jwt.Token) (interface{}, error) {
|
||||
if _, ok := token.Method.(*jwt.SigningMethodHMAC); !ok {
|
||||
if _, ok := token.Method.(*jwt.SigningMethodHMAC); !ok && needLogin(c) {
|
||||
return nil, fmt.Errorf("unexpected signing method: %v", token.Header["alg"])
|
||||
}
|
||||
if isAdminApi {
|
||||
|
@ -1,6 +1,10 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Person struct {
|
||||
Name string
|
||||
@ -14,9 +18,27 @@ type Student struct {
|
||||
|
||||
func main() {
|
||||
|
||||
stu := Student{Person: Person{
|
||||
Name: "xiaoming",
|
||||
Age: 12,
|
||||
}, School: "xxxxx soll"}
|
||||
fmt.Println(stu.Name, stu.Age, stu.School)
|
||||
text := `
|
||||
开始创作您的LOGO了!基于您提供的描述,我将设计一个主题内容为一个小人推着一个购物车的卡通风格LOGO。稍等片刻,您的创意即将变为现实。
|
||||
{"prompt":"Create a cartoon-style logo featuring a character pushing a shopping cart. The design should be colorful, vibrant, and engaging, showcasing the character in a dynamic and cheerful pose. The shopping cart should be noticeable but not overpower the character. Use bright and welcoming colors to make the logo inviting and fun. The character can be stylized in a cute and approachable manner, suitable for a wide range of audiences. Ensure the logo is clear and easily recognizable at small sizes.","size":"1024x1024"}
|
||||
|
||||
|
||||

|
||||
|
||||
[下载1](https://filesystem.site/cdn/download/20240320/JQIliW99JMPZRjMkgS2PlWNlfUtqDu.webp)
|
||||
|
||||
这是为您设计的卡通风格LOGO,主题是一个小人推着购物车。请查看图像,看它是否满足您的需求。如果您对这个设计满意,请访问 [Vectorizer.ai](https://vectorizer.ai/) 将其转换为矢量图,以便在不同大小和格式下保持清晰度。如果您觉得需要进一步的调整或改进,请告诉我,我们可以继续优化设计。`
|
||||
pattern := `!\[([^\]]*)]\(([^)]+)\)`
|
||||
re := regexp.MustCompile(pattern)
|
||||
matches := re.FindAllStringSubmatch(text, -1)
|
||||
|
||||
// 下载图片并替换链接地址
|
||||
for _, match := range matches {
|
||||
imageURL := match[2]
|
||||
fmt.Println(imageURL)
|
||||
// 对于相同地址的图片,已经被替换了,就不再重复下载了
|
||||
if !strings.Contains(text, imageURL) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -82,6 +82,7 @@ import {useRouter} from 'vue-router';
|
||||
import {ArrowDown, ArrowRight, Expand, Fold} from "@element-plus/icons-vue";
|
||||
import {httpGet} from "@/utils/http";
|
||||
import {ElMessage} from "element-plus";
|
||||
import {removeAdminToken} from "@/store/session";
|
||||
|
||||
const message = ref(5);
|
||||
const sysTitle = ref(process.env.VUE_APP_TITLE)
|
||||
@ -153,6 +154,7 @@ onMounted(() => {
|
||||
|
||||
const logout = function () {
|
||||
httpGet("/api/admin/logout").then(() => {
|
||||
removeAdminToken()
|
||||
router.replace('/admin/login')
|
||||
}).catch((e) => {
|
||||
ElMessage.error("注销失败: " + e.message);
|
||||
|
@ -39,7 +39,7 @@ export function removeUserToken() {
|
||||
}
|
||||
|
||||
export function getAdminToken() {
|
||||
return Storage.get(AdminTokenKey)
|
||||
return Storage.get(AdminTokenKey) ?? ""
|
||||
}
|
||||
|
||||
export function setAdminToken(token) {
|
||||
|
@ -167,7 +167,7 @@ export function isImage(url) {
|
||||
}
|
||||
|
||||
export function processContent(content) {
|
||||
//process img url
|
||||
// 如果是图片链接地址,则直接替换成图片标签
|
||||
const linkRegex = /(https?:\/\/\S+)/g;
|
||||
const links = content.match(linkRegex);
|
||||
if (links) {
|
||||
@ -181,20 +181,31 @@ export function processContent(content) {
|
||||
}
|
||||
}
|
||||
|
||||
// 处理引用块
|
||||
if (content.indexOf("\n") === -1) {
|
||||
const lines = content.split("\n")
|
||||
if (lines.length <= 1) {
|
||||
return content
|
||||
}
|
||||
|
||||
const texts = content.split("\n")
|
||||
const lines = []
|
||||
for (let txt of texts) {
|
||||
lines.push(txt)
|
||||
if (txt.startsWith(">")) {
|
||||
lines.push("\n")
|
||||
const texts = []
|
||||
// 定义匹配数学公式的正则表达式
|
||||
const formulaRegex = /^\s*[a-z|A-Z]+[^=]+\s*=\s*[^=]+$/;
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
// 处理引用块换行
|
||||
if (lines[i].startsWith(">")) {
|
||||
texts.push(lines[i])
|
||||
texts.push("\n")
|
||||
continue
|
||||
}
|
||||
console.log(formulaRegex.test(lines[i]))
|
||||
// 识别并处理数学公式,需要排除那些已经被识别出来的公式
|
||||
if (i > 0 && formulaRegex.test(lines[i]) && lines[i - 1].indexOf("$$") === -1) {
|
||||
texts.push("$$")
|
||||
texts.push(lines[i])
|
||||
texts.push("$$")
|
||||
continue
|
||||
}
|
||||
texts.push(lines[i])
|
||||
}
|
||||
return lines.join("\n")
|
||||
return texts.join("\n")
|
||||
}
|
||||
|
||||
export function escapeHTML(html) {
|
||||
@ -203,3 +214,23 @@ export function escapeHTML(html) {
|
||||
.replace(/>/g, ">");
|
||||
}
|
||||
|
||||
// 处理数学公式
|
||||
export function processMathFormula(input) {
|
||||
const arr = []
|
||||
const lines = input.split("\n")
|
||||
if (lines.length <= 1) {
|
||||
return input
|
||||
}
|
||||
// 定义匹配数学公式的正则表达式
|
||||
const mathFormulaRegex = /[+\-*/^()\d.]/;
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
if (i > 0 && mathFormulaRegex.test(lines) && lines[i - 1].indexOf("$$") === -1) {
|
||||
arr.push("$$")
|
||||
arr.push(lines[i])
|
||||
arr.push("$$")
|
||||
} else {
|
||||
arr.push(lines[i])
|
||||
}
|
||||
}
|
||||
return arr.join("\n")
|
||||
}
|
||||
|
@ -817,7 +817,7 @@ const logout = function () {
|
||||
activelyClose.value = true;
|
||||
httpGet('/api/user/logout').then(() => {
|
||||
removeUserToken()
|
||||
location.reload()
|
||||
router.push("/login")
|
||||
}).catch(() => {
|
||||
ElMessage.error('注销失败!');
|
||||
})
|
||||
|
@ -17,6 +17,7 @@
|
||||
<el-image v-if="scope.row.vip" :src="vipImg" style="height: 20px;position: relative; top:5px; left: 5px"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="nickname" label="昵称"/>
|
||||
<el-table-column prop="power" label="剩余算力"/>
|
||||
<el-table-column label="状态" width="80">
|
||||
<template #default="scope">
|
||||
|
Loading…
Reference in New Issue
Block a user