Compare commits
No commits in common. "master" and "main" have entirely different histories.
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,2 +0,0 @@
|
||||
.idea
|
||||
imaptool.exe
|
||||
16
Dockerfile
16
Dockerfile
@ -1,10 +1,8 @@
|
||||
FROM centos:8
|
||||
|
||||
FROM golang:alpine
|
||||
WORKDIR /app
|
||||
|
||||
ENV IS_TEST=true
|
||||
|
||||
ADD . /app
|
||||
|
||||
ENTRYPOINT ["/app/output/bin/aicss_service"]
|
||||
CMD ["server"]
|
||||
COPY . /app
|
||||
RUN go env -w GO111MODULE=on && go env -w GOPROXY=https://goproxy.cn,direct
|
||||
VOLUME ["/app/config"]
|
||||
RUN go build go-fly.go
|
||||
EXPOSE 8081
|
||||
CMD ["/app/go-fly","server"]
|
||||
201
LICENSE
201
LICENSE
@ -1,201 +0,0 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@ -1,7 +0,0 @@
|
||||
{
|
||||
"Server":"goder2.cpccmm68qb1d.ap-southeast-1.rds.amazonaws.com",
|
||||
"Port":"3306",
|
||||
"Database":"aicss_db",
|
||||
"Username":"admin",
|
||||
"Password":"vH2GkUxz2398GmDTy"
|
||||
}
|
||||
@ -1,21 +0,0 @@
|
||||
#!/bin/bash
|
||||
RUN_NAME=aicss_service
|
||||
DOCKER_TAG=test
|
||||
set -e
|
||||
|
||||
go mod tidy
|
||||
|
||||
# 优化编译标志
|
||||
BUILD_FLAGS=(
|
||||
"-trimpath" # 移除文件系统路径,减少二进制大小
|
||||
"-ldflags=-s -w" # 移除符号表和调试信息,减少内存使用
|
||||
)
|
||||
|
||||
# 使用优化的编译标志
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build "${BUILD_FLAGS[@]}" -o output/bin/${RUN_NAME} gofly.go
|
||||
|
||||
echo 'build go success'
|
||||
|
||||
docker build -t 322814420330.dkr.ecr.ap-southeast-1.amazonaws.com/xpink/${RUN_NAME}:${DOCKER_TAG} -f Dockerfile .
|
||||
|
||||
docker push 322814420330.dkr.ecr.ap-southeast-1.amazonaws.com/xpink/${RUN_NAME}:${DOCKER_TAG}
|
||||
@ -1,40 +0,0 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: aicss-s
|
||||
namespace: xpink
|
||||
labels:
|
||||
app: aicss-s
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: aicss-s
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: aicss-s
|
||||
spec:
|
||||
containers:
|
||||
- name: aicss-s
|
||||
image: 322814420330.dkr.ecr.ap-southeast-1.amazonaws.com/xpink/aicss_service:test
|
||||
imagePullPolicy: Always
|
||||
lifecycle:
|
||||
preStop:
|
||||
exec:
|
||||
command:
|
||||
- /bin/sh
|
||||
- -c
|
||||
- sleep 15
|
||||
resources:
|
||||
limits:
|
||||
cpu: 1000m
|
||||
memory: 512Mi
|
||||
requests:
|
||||
cpu: 10m
|
||||
memory: 10Mi
|
||||
env:
|
||||
- name: IS_TEST
|
||||
value: "true"
|
||||
imagePullSecrets:
|
||||
- name: coding
|
||||
@ -1,42 +0,0 @@
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: 2048-ingress
|
||||
namespace: xpink
|
||||
annotations:
|
||||
#alb.ingress.kubernetes.io/subnets: vpc-0b996d24feae0e2d5
|
||||
alb.ingress.kubernetes.io/scheme: internet-facing
|
||||
spec:
|
||||
ingressClassName: alb
|
||||
rules:
|
||||
- host: bressx-test.la
|
||||
http:
|
||||
paths:
|
||||
- path: /api
|
||||
pathType: ImplementationSpecific
|
||||
backend:
|
||||
service:
|
||||
name: hertz-s
|
||||
port:
|
||||
number: 8889
|
||||
- path: /admin
|
||||
pathType: ImplementationSpecific
|
||||
backend:
|
||||
service:
|
||||
name: hertz-s
|
||||
port:
|
||||
number: 8887
|
||||
- path: /callback
|
||||
pathType: ImplementationSpecific
|
||||
backend:
|
||||
service:
|
||||
name: hertz-s
|
||||
port:
|
||||
number: 8888
|
||||
- path: /ws
|
||||
pathType: ImplementationSpecific
|
||||
backend:
|
||||
service:
|
||||
name: hertz-s
|
||||
port:
|
||||
number: 8891
|
||||
@ -1,14 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: aicss-svc
|
||||
namespace: xpink # 如果不是 default,请改成你的 namespace
|
||||
spec:
|
||||
type: ClusterIP
|
||||
selector:
|
||||
app: aicss-s
|
||||
ports:
|
||||
- name: http
|
||||
port: 80 # 对外提供的端口
|
||||
targetPort: 8081 # 容器内部监听的端口
|
||||
protocol: TCP
|
||||
@ -1,12 +1,10 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"ai-css/library/logger"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"os"
|
||||
)
|
||||
|
||||
var rootCmd = &cobra.Command{
|
||||
@ -27,7 +25,6 @@ func args(cmd *cobra.Command, args []string) error {
|
||||
return nil
|
||||
}
|
||||
func Execute() {
|
||||
logger.InitDefault()
|
||||
if err := rootCmd.Execute(); err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
|
||||
@ -2,13 +2,11 @@ package cmd
|
||||
|
||||
import (
|
||||
"ai-css/middleware"
|
||||
"ai-css/middleware/xpink_auth"
|
||||
"ai-css/router"
|
||||
"ai-css/tools"
|
||||
"ai-css/ws"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@ -65,7 +63,6 @@ func run() {
|
||||
|
||||
//记录日志
|
||||
engine.Use(middleware.NewMidLogger())
|
||||
engine.Use(xpink_auth.MiddlewareSetIdentity)
|
||||
router.InitViewRouter(engine)
|
||||
router.InitApiRouter(engine)
|
||||
//记录pid
|
||||
@ -76,21 +73,6 @@ func run() {
|
||||
ws.CleanVisitorExpire()
|
||||
//后端websocket
|
||||
go ws.WsServerBackend()
|
||||
go healthCheck()
|
||||
|
||||
engine.Run(baseServer)
|
||||
}
|
||||
|
||||
func healthCheck() {
|
||||
go func() {
|
||||
mux := http.NewServeMux()
|
||||
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
w.Write([]byte("ok"))
|
||||
})
|
||||
|
||||
if err := http.ListenAndServe(":3000", mux); err != nil {
|
||||
log.Fatalf("health server failed: %v", err)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@ -1,7 +0,0 @@
|
||||
{
|
||||
"Server":"127.0.0.1",
|
||||
"Port":"3306",
|
||||
"Database":"aicss_db",
|
||||
"Username":"root",
|
||||
"Password":"12356"
|
||||
}
|
||||
@ -1,7 +0,0 @@
|
||||
{
|
||||
"Server":"goder2.cpccmm68qb1d.ap-southeast-1.rds.amazonaws.com",
|
||||
"Port":"3306",
|
||||
"Database":"aicss_db",
|
||||
"Username":"admin",
|
||||
"Password":"vH2GkUxz2398GmDTy"
|
||||
}
|
||||
@ -1,7 +1,7 @@
|
||||
{
|
||||
"Server":"goder2.cpccmm68qb1d.ap-southeast-1.rds.amazonaws.com",
|
||||
"Port":"3306",
|
||||
"Database":"aicss_db",
|
||||
"Username":"admin",
|
||||
"Password":"vH2GkUxz2398GmDTy"
|
||||
"Server":"192.168.1.81",
|
||||
"Port":"33306",
|
||||
"Database":"goflychat",
|
||||
"Username":"goflychat",
|
||||
"Password":"goflychat"
|
||||
}
|
||||
@ -4,9 +4,8 @@ import (
|
||||
"ai-css/models"
|
||||
"ai-css/tools"
|
||||
"ai-css/ws"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func PostKefuAvator(c *gin.Context) {
|
||||
@ -75,26 +74,6 @@ func PostKefuClient(c *gin.Context) {
|
||||
"result": "",
|
||||
})
|
||||
}
|
||||
|
||||
func GetIdleKefu(c *gin.Context) {
|
||||
visitorId := c.Query("visitor_id")
|
||||
var kefuName string
|
||||
if visitorId != "" {
|
||||
visitor := models.FindVisitorByVistorId(visitorId)
|
||||
if visitor.ToId != "" {
|
||||
kefuName = visitor.ToId
|
||||
}
|
||||
}
|
||||
if kefuName == "" {
|
||||
user := models.FindIdleUser()
|
||||
kefuName = user.Name
|
||||
}
|
||||
c.JSON(200, gin.H{
|
||||
"code": 200,
|
||||
"msg": "ok",
|
||||
"result": kefuName,
|
||||
})
|
||||
}
|
||||
func GetKefuInfo(c *gin.Context) {
|
||||
kefuName, _ := c.Get("kefu_name")
|
||||
user := models.FindUser(kefuName.(string))
|
||||
@ -103,7 +82,6 @@ func GetKefuInfo(c *gin.Context) {
|
||||
info["username"] = user.Name
|
||||
info["nickname"] = user.Nickname
|
||||
info["uid"] = user.ID
|
||||
info["role"] = user.Role
|
||||
c.JSON(200, gin.H{
|
||||
"code": 200,
|
||||
"msg": "ok",
|
||||
|
||||
@ -20,41 +20,8 @@ import (
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/gorilla/websocket"
|
||||
"github.com/openai/openai-go/v3/responses"
|
||||
)
|
||||
|
||||
var prompt = `You are an AI customer support assistant.
|
||||
|
||||
Your primary goal is to help users resolve their issues accurately, politely, and efficiently.
|
||||
You represent the official customer service of the product or platform.
|
||||
|
||||
General rules:
|
||||
- Always be polite, calm, and professional.
|
||||
- Use clear, concise, and user-friendly language.
|
||||
- Focus on solving the user’s problem step by step.
|
||||
- Do NOT fabricate information. If you are unsure or lack relevant knowledge, say so clearly.
|
||||
- Do NOT guess product policies, prices, or technical behaviors.
|
||||
- If a question cannot be resolved based on available information, guide the user to human support.
|
||||
|
||||
Knowledge usage:
|
||||
- Only answer questions based on the provided knowledge, FAQs, or conversation context.
|
||||
- If the user’s question is outside the supported scope, respond with a brief explanation and suggest contacting a human agent.
|
||||
|
||||
Escalation rules:
|
||||
- If the user explicitly requests a human agent, immediately stop responding and indicate the transfer.
|
||||
- If the user expresses frustration, repeated confusion, or dissatisfaction, suggest escalating to a human agent.
|
||||
|
||||
Safety and compliance:
|
||||
- Do not provide sensitive, confidential, or internal information.
|
||||
- Do not provide legal, medical, or financial advice.
|
||||
- Avoid any harmful, abusive, or inappropriate content.
|
||||
|
||||
Response style:
|
||||
- Keep answers concise but helpful.
|
||||
- Prefer bullet points or numbered steps when explaining procedures.
|
||||
- Ask clarifying questions only when necessary to move forward.
|
||||
`
|
||||
|
||||
func SendMessageV2(c *gin.Context) {
|
||||
fromId := c.PostForm("from_id")
|
||||
toId := c.PostForm("to_id")
|
||||
@ -126,33 +93,18 @@ func SendMessageV2(c *gin.Context) {
|
||||
if ok && guest != nil {
|
||||
guest.UpdateTime = time.Now()
|
||||
}
|
||||
if guest == nil {
|
||||
c.JSON(400, gin.H{
|
||||
"code": 400,
|
||||
"msg": "guest not found",
|
||||
})
|
||||
return
|
||||
}
|
||||
if ws.AIAnswerAvailable(guest) {
|
||||
// AI回答
|
||||
ret, err := AIChat(kefuInfo.Name, vistorInfo.VisitorId, content, guest.Conn)
|
||||
if err == nil {
|
||||
guest.AIAnswerCycle++
|
||||
models.CreateMessage(kefuInfo.Name, vistorInfo.VisitorId, ret, "kefu")
|
||||
ws.VisitorMessage(vistorInfo.VisitorId, ret, kefuInfo)
|
||||
var err error
|
||||
if err = AIChat(vistorInfo.VisitorId, content, guest.Conn); err == nil {
|
||||
c.JSON(200, gin.H{
|
||||
"code": 200,
|
||||
"msg": "ok",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
logger.Errorf("ai chat failed err:%v,visitorID:%s,content:%s", err, vistorInfo.VisitorId, content)
|
||||
} else if guest.AIAnswerCycle == ws.MaxAIAnswerCycleTimes {
|
||||
guest.AIAnswerCycle++
|
||||
cot := "ai次数用完将进入人工坐席。。。"
|
||||
models.CreateMessage(kefuInfo.Name, vistorInfo.VisitorId, cot, "kefu")
|
||||
ws.VisitorMessage(vistorInfo.VisitorId, cot, kefuInfo)
|
||||
|
||||
}
|
||||
|
||||
msg := ws.TypeMessage{
|
||||
@ -412,88 +364,29 @@ func GetMessagespages(c *gin.Context) {
|
||||
})
|
||||
}
|
||||
|
||||
func AIChat(supportID, visitorID string, question string, ws *websocket.Conn) (answer string, err error) {
|
||||
var ctx = context.TODO()
|
||||
mgs, err := models.FindLatestMessageByVisitorId(visitorID, 6)
|
||||
func AIChat(visitorID string, question string, ws *websocket.Conn) error {
|
||||
var ctx = context.Background()
|
||||
mgs, err := models.FindLatestMessageByVisitorId(visitorID, 3)
|
||||
if err != nil {
|
||||
logger.Errorf("find latest message err: %v", err)
|
||||
return
|
||||
return err
|
||||
}
|
||||
|
||||
cli, err := bootstrap.DefaultAIManager.NewClient(consts.ProviderOpenAI, bootstrap.WithDefaultModel(responses.ChatModelGPT5Mini))
|
||||
cli, err := bootstrap.DefaultAIManager.NewClient(consts.ProviderOpenAI, bootstrap.WithDefaultModel("gpt5-mini"))
|
||||
if err != nil {
|
||||
logger.Errorf("init gpt cli fail err:%v", err)
|
||||
return
|
||||
return err
|
||||
}
|
||||
resp, err := cli.Chat(ctx, modelprovider.ChatRequest{Messages: MakeAIMsg(supportID, mgs, question)})
|
||||
err = cli.StreamChat(ctx, modelprovider.ChatRequest{}, func(modelprovider.StreamEvent) error {
|
||||
|
||||
})
|
||||
if err != nil {
|
||||
logger.Errorf("chat message err: %v", err)
|
||||
return
|
||||
logger.Errorf("init gpt cli fail err:%v", err)
|
||||
return err
|
||||
}
|
||||
logger.Infof("open ai result:%v", resp)
|
||||
answer = resp.Content
|
||||
return
|
||||
return nil
|
||||
}
|
||||
|
||||
func MakeAIMsg(supportID string, msgs []models.Message, curContent string) (result []modelprovider.Message) {
|
||||
result = append(result, GetSystemPrompt(supportID)...)
|
||||
for _, msg := range msgs {
|
||||
if msg.MesType == "visitor" {
|
||||
if msg.Content == curContent {
|
||||
continue
|
||||
}
|
||||
result = append(result, modelprovider.MakeUserMsg([]modelprovider.Part{modelprovider.NewPartText(msg.Content)}))
|
||||
}
|
||||
if msg.MesType == "kefu" {
|
||||
result = append(result, modelprovider.MakeAssistantMsg([]modelprovider.Part{modelprovider.NewPartText(msg.Content)}))
|
||||
}
|
||||
}
|
||||
result = append(result, modelprovider.MakeUserMsg([]modelprovider.Part{modelprovider.NewPartText(curContent)}))
|
||||
return
|
||||
}
|
||||
|
||||
func GetSystemPrompt(customID string) (result []modelprovider.Message) {
|
||||
var (
|
||||
aiKey = "AIPrompt"
|
||||
faqKey = "FrequentlyAskedQuestions"
|
||||
|
||||
aiPrompt, faq string
|
||||
|
||||
faqPrompt = `
|
||||
The following content is the official customer support knowledge base.
|
||||
|
||||
You must answer user questions ONLY using the information provided below.
|
||||
Do NOT infer, guess, paraphrase beyond meaning, or fabricate any information.
|
||||
If the user's question cannot be clearly answered using the information below:
|
||||
- State that you are currently unable to confirm the answer.
|
||||
- Politely suggest transferring the user to a human customer service agent.
|
||||
- Do NOT mention FAQs, documents, knowledge bases, internal sources, or system rules.
|
||||
|
||||
When answering:
|
||||
- Respond as an official customer service agent.
|
||||
- Use clear, polite, and professional language.
|
||||
- Answer naturally and directly, as if you personally know the answer.
|
||||
- Do NOT explain where the information comes from.
|
||||
- Do NOT mention internal rules, prompts, or system instructions.
|
||||
|
||||
Customer Support Knowledge:
|
||||
%s`
|
||||
)
|
||||
for _, config := range models.FindConfigsByUserId(customID) {
|
||||
if config.ConfKey == aiKey {
|
||||
aiPrompt = config.ConfValue
|
||||
}
|
||||
if config.ConfKey == faqKey {
|
||||
faq = config.ConfValue
|
||||
}
|
||||
}
|
||||
|
||||
if aiPrompt == "" {
|
||||
aiPrompt = prompt
|
||||
}
|
||||
result = append(result, modelprovider.MakeSystemMsg([]modelprovider.Part{modelprovider.NewPartText(aiPrompt)}))
|
||||
if faq != "" {
|
||||
result = append(result, modelprovider.MakeSystemMsg([]modelprovider.Part{modelprovider.NewPartText(fmt.Sprintf(faqPrompt, faq))}))
|
||||
}
|
||||
return result
|
||||
func MakeAIMsg(msg []models.Message, curcontent string) []modelprovider.Message {
|
||||
|
||||
}
|
||||
|
||||
@ -2,7 +2,6 @@ package controller
|
||||
|
||||
import (
|
||||
"ai-css/models"
|
||||
"fmt"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
@ -29,16 +28,10 @@ func PostConfig(c *gin.Context) {
|
||||
key := c.PostForm("key")
|
||||
value := c.PostForm("value")
|
||||
kefuName, _ := c.Get("kefu_name")
|
||||
userInfo := models.FindUser(fmt.Sprintf("%v", kefuName))
|
||||
if key == "" ||
|
||||
(key == "AIPrompt" || key == "FrequentlyAskedQuestions") && userInfo.Role != 1 {
|
||||
errDesc := "无权限修改"
|
||||
if key == "" {
|
||||
errDesc = "参数错误"
|
||||
}
|
||||
if key == "" || value == "" {
|
||||
c.JSON(200, gin.H{
|
||||
"code": 400,
|
||||
"msg": errDesc,
|
||||
"msg": "error",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
@ -2,15 +2,12 @@ package controller
|
||||
|
||||
import (
|
||||
"ai-css/common"
|
||||
"ai-css/library/logger"
|
||||
"ai-css/middleware/xpink_auth"
|
||||
"ai-css/models"
|
||||
"ai-css/tools"
|
||||
"ai-css/ws"
|
||||
"encoding/json"
|
||||
"strconv"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// func PostVisitor(c *gin.Context) {
|
||||
@ -70,20 +67,11 @@ func PostVisitorLogin(c *gin.Context) {
|
||||
}
|
||||
|
||||
toId := c.PostForm("to_id")
|
||||
var id string
|
||||
id := c.PostForm("visitor_id")
|
||||
|
||||
if us := xpink_auth.GetXPINKUser(c); us.Userno != "" {
|
||||
logger.Infof("parse xpink user season success us:%v", us)
|
||||
id = us.Userno
|
||||
}
|
||||
if id == "" {
|
||||
logger.Errorf("parse xpin user season failed")
|
||||
id = c.PostForm("visitor_id")
|
||||
if id == "" {
|
||||
id = tools.Uuid()
|
||||
}
|
||||
}
|
||||
|
||||
refer := c.PostForm("refer")
|
||||
var (
|
||||
city string
|
||||
|
||||
@ -1,21 +0,0 @@
|
||||
#!/bin/bash
|
||||
RUN_NAME=aicss_service
|
||||
DOCKER_TAG=test
|
||||
set -e
|
||||
|
||||
go mod tidy
|
||||
|
||||
# 优化编译标志
|
||||
BUILD_FLAGS=(
|
||||
"-trimpath" # 移除文件系统路径,减少二进制大小
|
||||
"-ldflags=-s -w" # 移除符号表和调试信息,减少内存使用
|
||||
)
|
||||
|
||||
# 使用优化的编译标志
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build "${BUILD_FLAGS[@]}" -o output/bin/${RUN_NAME} gofly.go
|
||||
|
||||
echo 'build go success'
|
||||
|
||||
docker build -t 322814420330.dkr.ecr.ap-southeast-1.amazonaws.com/xpink/${RUN_NAME}:${DOCKER_TAG} -f Dockerfile .
|
||||
|
||||
docker push 322814420330.dkr.ecr.ap-southeast-1.amazonaws.com/xpink/${RUN_NAME}:${DOCKER_TAG}
|
||||
1
go.mod
1
go.mod
@ -13,7 +13,6 @@ require (
|
||||
github.com/go-sql-driver/mysql v1.5.0
|
||||
github.com/gobuffalo/packr/v2 v2.5.1
|
||||
github.com/golang-jwt/jwt v3.2.2+incompatible
|
||||
github.com/golang-jwt/jwt/v5 v5.2.1
|
||||
github.com/gorilla/websocket v1.4.2
|
||||
github.com/ipipdotnet/ipdb-go v1.3.0
|
||||
github.com/jinzhu/gorm v1.9.14
|
||||
|
||||
2
go.sum
2
go.sum
@ -54,8 +54,6 @@ github.com/gobuffalo/packr/v2 v2.5.1 h1:TFOeY2VoGamPjQLiNDT3mn//ytzk236VMO2j7iHx
|
||||
github.com/gobuffalo/packr/v2 v2.5.1/go.mod h1:8f9c96ITobJlPzI44jj+4tHnEKNt0xXWSVlXRN9X1Iw=
|
||||
github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY=
|
||||
github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I=
|
||||
github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk=
|
||||
github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
|
||||
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe h1:lXe2qZdvpiX5WZkZR4hgp4KJVfY3nMkvmwbVkpv1rVY=
|
||||
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
|
||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
|
||||
@ -1 +0,0 @@
|
||||
46412,46509
|
||||
117
import.sql
117
import.sql
@ -2,7 +2,6 @@ DROP TABLE IF EXISTS `user`;
|
||||
CREATE TABLE `user` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(50) NOT NULL DEFAULT '',
|
||||
`role` INT NOT NULL DEFAULT (0) COMMENT '1:管理员',
|
||||
`password` varchar(50) NOT NULL DEFAULT '',
|
||||
`nickname` varchar(50) NOT NULL DEFAULT '',
|
||||
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
@ -13,14 +12,8 @@ CREATE TABLE `user` (
|
||||
UNIQUE KEY `idx_name` (`name`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
TRUNCATE TABLE `user`;
|
||||
INSERT INTO `user` (`name`, `role`, `password`, `nickname`, `created_at`, `updated_at`, `deleted_at`, `avator`) VALUES
|
||||
('admin', 1, '0192023a7bbd73250516f069df18b500', 'admin', '2026-02-05 00:10:37', '2026-02-05 00:10:37', NULL, '/aicss/static/images/4.jpg');
|
||||
INSERT INTO `user` (`name`, `role`, `password`, `nickname`, `created_at`, `updated_at`, `deleted_at`, `avator`) VALUES
|
||||
('agent1', 0, '2ec199f1e2de31576869a57488e919ad', 'agent1', '2026-02-05 00:10:37', '2026-02-05 00:10:37', NULL, '/aicss/static/images/4.jpg');
|
||||
INSERT INTO `user` (`name`, `role`, `password`, `nickname`, `created_at`, `updated_at`, `deleted_at`, `avator`) VALUE
|
||||
('agent2', 0, '2ec199f1e2de31576869a57488e919ad', 'agent2', '2026-02-05 00:10:37', '2026-02-05 00:10:37', NULL, '/aicss/static/images/4.jpg');
|
||||
INSERT INTO `user` (`name`, `role`, `password`, `nickname`, `created_at`, `updated_at`, `deleted_at`, `avator`) VALUE
|
||||
('agent3', 0, '2ec199f1e2de31576869a57488e919ad', 'agent3', '2026-02-05 00:10:37', '2026-02-05 00:10:37', NULL, '/aicss/static/images/4.jpg');
|
||||
INSERT INTO `user` (`id`, `name`, `password`, `nickname`, `created_at`, `updated_at`, `deleted_at`, `avator`) VALUE
|
||||
(1, 'agent', 'b33aed8f3134996703dc39f9a7c95783', 'Open Source LiveChat Support', '2020-06-27 19:32:41', '2020-07-04 09:32:20', NULL, '/static/images/4.jpg');
|
||||
|
||||
DROP TABLE IF EXISTS `visitor`;
|
||||
CREATE TABLE `visitor` (
|
||||
@ -75,7 +68,7 @@ CREATE TABLE `config` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`conf_name` varchar(255) NOT NULL DEFAULT '',
|
||||
`conf_key` varchar(255) NOT NULL DEFAULT '',
|
||||
`conf_value` MEDIUMTEXT NOT NULL,
|
||||
`conf_value` varchar(255) NOT NULL DEFAULT '',
|
||||
`user_id` varchar(500) NOT NULL DEFAULT '',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `conf_key` (`conf_key`),
|
||||
@ -93,110 +86,6 @@ INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`, `user_id`) VA
|
||||
(NULL, 'Email Account', 'NoticeEmailAddress', '','agent');
|
||||
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`, `user_id`) VALUES
|
||||
(NULL, 'Email Password (SMTP)', 'NoticeEmailPassword', '','agent');
|
||||
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`, `user_id`) VALUES
|
||||
(NULL, 'AIPrompt', 'AIPrompt', 'You are an AI customer support assistant.\n\nYour primary goal is to help users resolve their issues accurately, politely, and efficiently.\nYou represent the official customer service of the product or platform.\n\nGeneral rules:\n- Always be polite, calm, and professional.\n- Use clear, concise, and user-friendly language.\n- Focus on solving the user’s problem step by step.\n- Do NOT fabricate information. If you are unsure or lack relevant knowledge, say so clearly.\n- Do NOT guess product policies, prices, or technical behaviors.\n- If a question cannot be resolved based on available information, guide the user to human support.\n\nKnowledge usage:\n- Only answer questions based on the provided knowledge, FAQs, or conversation context.\n- If the user’s question is outside the supported scope, respond with a brief explanation and suggest contacting a human agent.\n\nEscalation rules:\n- If the user explicitly requests a human agent, immediately stop responding and indicate the transfer.\n- If the user expresses frustration, repeated confusion, or dissatisfaction, suggest escalating to a human agent.\n\nSafety and compliance:\n- Do not provide sensitive, confidential, or internal information.\n- Do not provide legal, medical, or financial advice.\n- Avoid any harmful, abusive, or inappropriate content.\n\nResponse style:\n- Keep answers concise but helpful.\n- Prefer bullet points or numbered steps when explaining procedures.\n- Ask clarifying questions only when necessary to move forward.', 'admin');
|
||||
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`, `user_id`) VALUES
|
||||
(NULL, 'FrequentlyAskedQuestions', 'FrequentlyAskedQuestions', '【账号与登录】
|
||||
|
||||
Q: 登录提示账号或密码错误?
|
||||
A: 请确认手机号或密码是否正确;如忘记密码,在登录页选择【普通登录】→【忘记密码】通过验证码重置。
|
||||
|
||||
Q: 如何注册账号?
|
||||
A: 在登录页或首页点击【注册账号】,使用有效手机号注册,手机号可直接作为登录账号。
|
||||
|
||||
Q: 收不到验证码?
|
||||
A: 请确认信号正常,可每 2–3 分钟重试或更换地点。
|
||||
|
||||
【支付密码】
|
||||
|
||||
Q: 如何修改或找回支付密码?
|
||||
A: 需先登录账号。
|
||||
手机端:【我的】→【忘记支付密码】→验证码重置。
|
||||
电脑端:右上角【资金/头像】→【找回支付密码】。
|
||||
|
||||
【充值】
|
||||
|
||||
Q: 如何充值?
|
||||
A: 首页点击【存款/充值】,选择充值方式并按通道指引完成。
|
||||
|
||||
Q: 充值成功未到账?
|
||||
A: 通常 10 分钟内到账;超时请联系人工客服并提供含收款人及时间的转账凭证。
|
||||
|
||||
Q: 支持哪些充值货币?
|
||||
A: 支持人民币及 USDT(仅 TRC-20);USDT 将按汇率换算为人民币到账。
|
||||
|
||||
Q: 充值是否收手续费?
|
||||
A: 平台不收取;USDT 手续费由交易所或钱包收取。
|
||||
|
||||
【提现 / 取款】
|
||||
|
||||
Q: 如何提现?
|
||||
A:
|
||||
手机端:【我的】→【钱包管理】;
|
||||
电脑端:右上角【取款】→【钱包管理】。
|
||||
|
||||
Q: 提现提示打码量不足?
|
||||
A: 表示流水未达要求,具体数值可在取款页底部查看。
|
||||
|
||||
Q: 提现手续费?
|
||||
A: 每日前 5 笔免手续费,第 6 笔起收取 1%,次日 0 点重置。
|
||||
|
||||
Q: 提现多久到账?
|
||||
A: 银行卡约 5–30 分钟;虚拟币钱包可秒到账。
|
||||
|
||||
Q: 提现限制?
|
||||
A: 最低 100 元,无上限;虚拟币取款需钱包 KYC 且实名与账号一致。
|
||||
|
||||
【资金转账】
|
||||
|
||||
Q: 充值后余额为 0?
|
||||
A: 需转入游戏:点击【转账/资金】→选择游戏→【转入/闪入】。
|
||||
|
||||
Q: 如何转出游戏余额?
|
||||
A: 在【转账/资金】页面点击【一键转出】。
|
||||
|
||||
【流水 / 打码量】
|
||||
|
||||
Q: 什么是打码量?
|
||||
A: 投注结算的输赢金额,取较小值计算;和局、走水不计入。
|
||||
|
||||
Q: 提现需要多少流水?
|
||||
A: 通常为充值金额 1 倍;参与优惠则以活动规则为准。
|
||||
|
||||
【优惠与返水】
|
||||
|
||||
Q: 返水如何领取?
|
||||
A: 无需申请,系统按账号等级自动计算,次日凌晨派送,最迟不超过早上 8 点。
|
||||
|
||||
Q: 返水比例?
|
||||
A: 与账号等级及游戏有关,详见【优惠】页面。
|
||||
|
||||
Q: 如何申请彩金?
|
||||
A: 登录后进入【优惠】查看活动规则并按要求申请。
|
||||
|
||||
【游戏问题】
|
||||
|
||||
Q: 游戏无法打开或加载?
|
||||
A: 请确认网络及是否维护中;仍异常请联系人工客服并提供截图。
|
||||
|
||||
【客服与安全】
|
||||
|
||||
Q: 什么是专属客服?
|
||||
A: 除 24 小时人工客服外,提供线下专属客服(68Chat/QQ/微信),服务时间 10:00–20:00。
|
||||
|
||||
Q: 个人信息安全吗?
|
||||
A: 用户信息均经加密保护。
|
||||
|
||||
【体育相关】
|
||||
|
||||
Q: 体育注单未结算?
|
||||
A: 赛事结束后结算;如有争议将延迟,最长不超过 36 小时。
|
||||
|
||||
Q: 赛事中断或腰斩?
|
||||
A: 36 小时内无法继续或无重赛则取消注单并退还本金(除非已有官方结果)。
|
||||
|
||||
Q: 盈利消失或余额为负?
|
||||
A: 因二次结算导致,系统将按最终结果扣回或补发。', 'admin');
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `reply_group`;
|
||||
|
||||
@ -1 +0,0 @@
|
||||
gofly live chat installation complete
|
||||
@ -1,40 +0,0 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: aicss-s
|
||||
namespace: xpink
|
||||
labels:
|
||||
app: aicss-s
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: aicss-s
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: aicss-s
|
||||
spec:
|
||||
containers:
|
||||
- name: aicss-s
|
||||
image: 322814420330.dkr.ecr.ap-southeast-1.amazonaws.com/xpink/aicss_service:test
|
||||
imagePullPolicy: Always
|
||||
lifecycle:
|
||||
preStop:
|
||||
exec:
|
||||
command:
|
||||
- /bin/sh
|
||||
- -c
|
||||
- sleep 15
|
||||
resources:
|
||||
limits:
|
||||
cpu: 1000m
|
||||
memory: 512Mi
|
||||
requests:
|
||||
cpu: 10m
|
||||
memory: 10Mi
|
||||
env:
|
||||
- name: IS_TEST
|
||||
value: "true"
|
||||
imagePullSecrets:
|
||||
- name: coding
|
||||
@ -1,42 +0,0 @@
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: 2048-ingress
|
||||
namespace: xpink
|
||||
annotations:
|
||||
#alb.ingress.kubernetes.io/subnets: vpc-0b996d24feae0e2d5
|
||||
alb.ingress.kubernetes.io/scheme: internet-facing
|
||||
spec:
|
||||
ingressClassName: alb
|
||||
rules:
|
||||
- host: bressx-test.la
|
||||
http:
|
||||
paths:
|
||||
- path: /api
|
||||
pathType: ImplementationSpecific
|
||||
backend:
|
||||
service:
|
||||
name: hertz-s
|
||||
port:
|
||||
number: 8889
|
||||
- path: /admin
|
||||
pathType: ImplementationSpecific
|
||||
backend:
|
||||
service:
|
||||
name: hertz-s
|
||||
port:
|
||||
number: 8887
|
||||
- path: /callback
|
||||
pathType: ImplementationSpecific
|
||||
backend:
|
||||
service:
|
||||
name: hertz-s
|
||||
port:
|
||||
number: 8888
|
||||
- path: /ws
|
||||
pathType: ImplementationSpecific
|
||||
backend:
|
||||
service:
|
||||
name: hertz-s
|
||||
port:
|
||||
number: 8891
|
||||
@ -1,14 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: aicss-svc
|
||||
namespace: xpink # 如果不是 default,请改成你的 namespace
|
||||
spec:
|
||||
type: ClusterIP
|
||||
selector:
|
||||
app: aicss-s
|
||||
ports:
|
||||
- name: http
|
||||
port: 80 # 对外提供的端口
|
||||
targetPort: 8081 # 容器内部监听的端口
|
||||
protocol: TCP
|
||||
21
library/modelprovider/bootstrap/build.go
Executable file → Normal file
21
library/modelprovider/bootstrap/build.go
Executable file → Normal file
@ -10,18 +10,6 @@ import (
|
||||
"log"
|
||||
)
|
||||
|
||||
/*
|
||||
CI3r@f9x2#PX4fw
|
||||
ssh root@43.136.78.216
|
||||
|
||||
外网
|
||||
mysql -uroot1 -hgz-cdb-s15wkipx.sql.tencentcdb.com -P29151 -p"CI3r@f4x3#2X4fw" x_anime
|
||||
|
||||
内网
|
||||
mysql -uroot1 -h10.0.0.14 -P3306 -p'CI3r@f4x3#2X4fw' x_anime
|
||||
|
||||
*/
|
||||
|
||||
type AIManager struct {
|
||||
CfgMgr *config.Manager
|
||||
Registry *providers.Registry
|
||||
@ -31,14 +19,7 @@ var DefaultAIManager *AIManager
|
||||
|
||||
func init() {
|
||||
var err error
|
||||
|
||||
cfgMgr := config.NewManager(config.NewLocalRepo(map[consts.ProviderName]config.ProviderConfig{
|
||||
consts.ProviderOpenAI: config.NewProviderConfig(
|
||||
"https://api.zhizengzeng.com/v1/",
|
||||
[]string{"sk-zk2b3df841ed7b96299f915bcd9f7959fb566104b83e2d5b"}),
|
||||
}))
|
||||
|
||||
DefaultAIManager, err = Init(context.TODO(), cfgMgr)
|
||||
DefaultAIManager, err = Init(context.TODO(), &config.Manager{})
|
||||
if err != nil {
|
||||
log.Fatalf("init ai manager failed err:%v", err)
|
||||
}
|
||||
|
||||
0
library/modelprovider/bootstrap/options.go
Executable file → Normal file
0
library/modelprovider/bootstrap/options.go
Executable file → Normal file
0
library/modelprovider/bootstrap/provider.go
Executable file → Normal file
0
library/modelprovider/bootstrap/provider.go
Executable file → Normal file
6
library/modelprovider/client.go
Executable file → Normal file
6
library/modelprovider/client.go
Executable file → Normal file
@ -4,16 +4,14 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"time"
|
||||
|
||||
"github.com/openai/openai-go/v3/shared"
|
||||
)
|
||||
|
||||
type Client struct {
|
||||
provider Provider
|
||||
defaultModel shared.ResponsesModel
|
||||
defaultModel string
|
||||
}
|
||||
|
||||
func NewClient(p Provider, defaultModel shared.ResponsesModel) *Client {
|
||||
func NewClient(p Provider, defaultModel string) *Client {
|
||||
return &Client{provider: p, defaultModel: defaultModel}
|
||||
}
|
||||
|
||||
|
||||
@ -1,15 +0,0 @@
|
||||
package config
|
||||
|
||||
import ai "ai-css/library/modelprovider/consts"
|
||||
|
||||
type LocalRepo struct {
|
||||
cfg map[ai.ProviderName]ProviderConfig
|
||||
}
|
||||
|
||||
func NewLocalRepo(cfg map[ai.ProviderName]ProviderConfig) *LocalRepo {
|
||||
return &LocalRepo{cfg: cfg}
|
||||
}
|
||||
|
||||
func (repo *LocalRepo) GetAllConfig() (map[ai.ProviderName]ProviderConfig, error) {
|
||||
return repo.cfg, nil
|
||||
}
|
||||
0
library/modelprovider/config/storage.go
Executable file → Normal file
0
library/modelprovider/config/storage.go
Executable file → Normal file
0
library/modelprovider/config/types.go
Executable file → Normal file
0
library/modelprovider/config/types.go
Executable file → Normal file
0
library/modelprovider/consts/provider.go
Executable file → Normal file
0
library/modelprovider/consts/provider.go
Executable file → Normal file
125
library/modelprovider/dto.go
Executable file → Normal file
125
library/modelprovider/dto.go
Executable file → Normal file
@ -2,10 +2,6 @@ package modelprovider
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/openai/openai-go/v3"
|
||||
"github.com/openai/openai-go/v3/responses"
|
||||
"github.com/openai/openai-go/v3/shared"
|
||||
)
|
||||
|
||||
type Role string
|
||||
@ -41,7 +37,7 @@ type Part struct {
|
||||
}
|
||||
|
||||
type ChatRequest struct {
|
||||
Model shared.ResponsesModel `json:"model"`
|
||||
Model string `json:"model"`
|
||||
Messages []Message `json:"messages"`
|
||||
Temperature *float64 `json:"temperature,omitempty"`
|
||||
TopP *float64 `json:"top_p,omitempty"`
|
||||
@ -135,122 +131,3 @@ func MakeSystemMsg(p []Part) Message {
|
||||
Parts: p,
|
||||
}
|
||||
}
|
||||
|
||||
func PartsToOpenaiChatPartUnionParam(parts []Part) (result []openai.ChatCompletionContentPartUnionParam) {
|
||||
|
||||
for _, p := range parts {
|
||||
switch p.Type {
|
||||
|
||||
case PartText:
|
||||
if p.Text == "" {
|
||||
continue
|
||||
}
|
||||
result = append(result,
|
||||
openai.ChatCompletionContentPartUnionParam{
|
||||
OfText: &openai.ChatCompletionContentPartTextParam{
|
||||
Text: p.Text,
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
case PartImage:
|
||||
// 1️⃣ image_url 优先
|
||||
if p.ImageURL != "" {
|
||||
result = append(result,
|
||||
openai.ChatCompletionContentPartUnionParam{
|
||||
OfImageURL: &openai.ChatCompletionContentPartImageParam{
|
||||
ImageURL: openai.ChatCompletionContentPartImageImageURLParam{
|
||||
URL: p.ImageURL,
|
||||
},
|
||||
},
|
||||
},
|
||||
)
|
||||
continue
|
||||
}
|
||||
|
||||
// 2️⃣ image_bytes(inline image)
|
||||
if len(p.ImageBytes) > 0 {
|
||||
result = append(result,
|
||||
openai.ChatCompletionContentPartUnionParam{
|
||||
OfImageURL: &openai.ChatCompletionContentPartImageParam{
|
||||
ImageURL: openai.ChatCompletionContentPartImageImageURLParam{
|
||||
URL: p.ImageURL,
|
||||
},
|
||||
},
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func PartsToOpenaiChatContentPartTextParam(parts []Part) (result []openai.ChatCompletionContentPartTextParam) {
|
||||
|
||||
for _, p := range parts {
|
||||
if p.Type != PartText {
|
||||
continue
|
||||
}
|
||||
|
||||
if p.Text == "" {
|
||||
continue
|
||||
}
|
||||
|
||||
result = append(result,
|
||||
openai.ChatCompletionContentPartTextParam{
|
||||
Text: p.Text,
|
||||
},
|
||||
)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func PartsToOpenaiChatAssistantMessageParamContentArrayOfContentPartUnion(
|
||||
parts []Part,
|
||||
) (result []openai.ChatCompletionAssistantMessageParamContentArrayOfContentPartUnion) {
|
||||
|
||||
for _, p := range parts {
|
||||
switch p.Type {
|
||||
case PartText:
|
||||
if p.Text == "" {
|
||||
continue
|
||||
}
|
||||
result = append(result,
|
||||
openai.ChatCompletionAssistantMessageParamContentArrayOfContentPartUnion{
|
||||
OfText: &openai.ChatCompletionContentPartTextParam{
|
||||
Text: p.Text,
|
||||
},
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func PartsToResponseInputItemUnionParam(role Role, parts []Part) (result responses.ResponseInputItemUnionParam) {
|
||||
var openaiRole responses.EasyInputMessageRole
|
||||
switch role {
|
||||
case RoleUser:
|
||||
openaiRole = responses.EasyInputMessageRoleUser
|
||||
case RoleAssistant:
|
||||
openaiRole = responses.EasyInputMessageRoleAssistant
|
||||
case RoleSystem:
|
||||
openaiRole = responses.EasyInputMessageRoleSystem
|
||||
}
|
||||
|
||||
for _, p := range parts {
|
||||
switch p.Type {
|
||||
|
||||
case PartText:
|
||||
if p.Text == "" {
|
||||
continue
|
||||
}
|
||||
|
||||
result = responses.ResponseInputItemUnionParam{
|
||||
OfMessage: &responses.EasyInputMessageParam{Content: responses.EasyInputMessageContentUnionParam{OfString: openai.String(p.Text)},
|
||||
Role: openaiRole,
|
||||
}}
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
0
library/modelprovider/errorswrap/errors.go
Executable file → Normal file
0
library/modelprovider/errorswrap/errors.go
Executable file → Normal file
0
library/modelprovider/errorswrap/errors_test.go
Executable file → Normal file
0
library/modelprovider/errorswrap/errors_test.go
Executable file → Normal file
0
library/modelprovider/provider.go
Executable file → Normal file
0
library/modelprovider/provider.go
Executable file → Normal file
0
library/modelprovider/providers/openai/api.go
Executable file → Normal file
0
library/modelprovider/providers/openai/api.go
Executable file → Normal file
0
library/modelprovider/providers/openai/blackkeys.go
Executable file → Normal file
0
library/modelprovider/providers/openai/blackkeys.go
Executable file → Normal file
66
library/modelprovider/providers/openai/sdk.go
Executable file → Normal file
66
library/modelprovider/providers/openai/sdk.go
Executable file → Normal file
@ -12,11 +12,6 @@ import (
|
||||
"strings"
|
||||
|
||||
"ai-css/library/logger"
|
||||
|
||||
"github.com/openai/openai-go/v3"
|
||||
"github.com/openai/openai-go/v3/option"
|
||||
"github.com/openai/openai-go/v3/responses"
|
||||
"github.com/openai/openai-go/v3/shared"
|
||||
)
|
||||
|
||||
type Provider struct {
|
||||
@ -41,60 +36,11 @@ func (p *Provider) Capabilities() modelprovider2.Capability {
|
||||
}
|
||||
|
||||
func (p *Provider) InvokeCompletion(ctx context.Context, req *modelprovider2.ChatRequest) (*modelprovider2.ChatResponse, error) {
|
||||
var respParam = responses.ResponseNewParams{
|
||||
Model: req.Model,
|
||||
}
|
||||
var msg []responses.ResponseInputItemUnionParam
|
||||
for _, item := range req.Messages {
|
||||
msg = append(msg, modelprovider2.PartsToResponseInputItemUnionParam(item.Role, item.Parts))
|
||||
}
|
||||
respParam.Input = responses.ResponseNewParamsInputUnion{
|
||||
OfInputItemList: msg,
|
||||
}
|
||||
logger.Infof("ai chat msg:%v", msg)
|
||||
|
||||
var opts []option.RequestOption
|
||||
|
||||
if p.conf != nil {
|
||||
if len(p.conf.GetApiKeys()) > 0 {
|
||||
opts = []option.RequestOption{
|
||||
option.WithAPIKey(p.conf.GetApiKeys()[0]),
|
||||
}
|
||||
}
|
||||
if p.conf.GetBaseUrl() != "" {
|
||||
opts = append(opts, option.WithBaseURL(p.conf.GetBaseUrl()))
|
||||
}
|
||||
if p.httpClient != nil {
|
||||
opts = append(opts, option.WithHTTPClient(p.httpClient))
|
||||
}
|
||||
}
|
||||
|
||||
client := openai.NewClient(opts...)
|
||||
|
||||
resp, err := client.Responses.New(context.TODO(), respParam)
|
||||
if err != nil {
|
||||
logger.Errorf("error while calling OpenAI response api failed err: %v", err)
|
||||
return nil, err
|
||||
}
|
||||
if resp.Error.Code != "" {
|
||||
logger.Errorf("error while calling OpenAI response api failed err: %v", resp.Error.RawJSON())
|
||||
return nil, fmt.Errorf("call openai response failed err: %v", resp.Error.RawJSON())
|
||||
}
|
||||
|
||||
content := ""
|
||||
for _, item := range resp.Output {
|
||||
if item.Type == "message" {
|
||||
for _, cn := range item.Content {
|
||||
if cn.Type == "output_text" {
|
||||
content = cn.Text
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// TODO: 将 req 映射到 OpenAI Responses/Chat API,发起 HTTP,解析返回
|
||||
return &modelprovider2.ChatResponse{
|
||||
ID: resp.ID,
|
||||
Model: resp.Model,
|
||||
Content: content,
|
||||
ID: "mock-openai-id",
|
||||
Model: req.Model,
|
||||
Content: "hello from openai (mock)",
|
||||
Meta: modelprovider2.Meta{Vendor: "openai"},
|
||||
}, nil
|
||||
}
|
||||
@ -245,8 +191,8 @@ func (p *Provider) ListModels(ctx context.Context) (result []modelprovider2.Mode
|
||||
return
|
||||
}
|
||||
|
||||
func (p *Provider) GetDefaultModel() shared.ResponsesModel {
|
||||
return responses.ChatModelGPT5Mini
|
||||
func (p *Provider) GetDefaultModel() string {
|
||||
return "gpt-4o"
|
||||
}
|
||||
|
||||
func IsGPT4Model(model string) bool {
|
||||
|
||||
2
library/modelprovider/providers/proxy.go
Executable file → Normal file
2
library/modelprovider/providers/proxy.go
Executable file → Normal file
@ -7,7 +7,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
PROXY_ENV_NAME = "AI-CSS_CLOUD_MODEL_PROXY"
|
||||
PROXY_ENV_NAME = "ai-css_CLOUD_MODEL_PROXY"
|
||||
)
|
||||
|
||||
var envProxyUrl string
|
||||
|
||||
13
library/modelprovider/providers/registry.go
Executable file → Normal file
13
library/modelprovider/providers/registry.go
Executable file → Normal file
@ -7,16 +7,11 @@ import (
|
||||
"ai-css/library/modelprovider/providers/openai"
|
||||
"net"
|
||||
"net/http"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
var (
|
||||
HttpClientTimeout = 5 * 60 * time.Second
|
||||
|
||||
client *http.Client
|
||||
|
||||
InitClient sync.Once
|
||||
)
|
||||
|
||||
type ProviderFactory func(conf *config.ProviderConfig) (modelprovider.Provider, error)
|
||||
@ -35,10 +30,6 @@ func BuildRegistry() *Registry {
|
||||
}
|
||||
|
||||
func NewHttpClient() *http.Client {
|
||||
if client != nil {
|
||||
return client
|
||||
}
|
||||
InitClient.Do(func() {
|
||||
var proxyURL = GetRemoteProxy()
|
||||
|
||||
transport := &http.Transport{
|
||||
@ -57,10 +48,8 @@ func NewHttpClient() *http.Client {
|
||||
transport.Proxy = http.ProxyURL(proxyURL)
|
||||
}
|
||||
|
||||
client = &http.Client{
|
||||
return &http.Client{
|
||||
Transport: transport,
|
||||
Timeout: HttpClientTimeout,
|
||||
}
|
||||
})
|
||||
return client
|
||||
}
|
||||
|
||||
0
library/modelprovider/stream.go
Executable file → Normal file
0
library/modelprovider/stream.go
Executable file → Normal file
@ -1,30 +0,0 @@
|
||||
time="2026-02-11 20:42:53" level=info msg="start server...\r\ngo:http://0.0.0.0:8081"
|
||||
time="2026-02-11 20:43:08" level=info msg="| 200 | 12.674667ms | ::1 | GET | /chatIndex |"
|
||||
time="2026-02-11 20:43:09" level=info msg="| 200 | 48.423333ms | ::1 | GET | /kefu_idle?visitor_id=2e81d4f8-f19a-4c88-a9f6-8b7e1302b488 |"
|
||||
time="2026-02-11 20:43:09" level=info msg="| 200 | 53.5045ms | ::1 | POST | /visitor_login |"
|
||||
time="2026-02-11 20:43:09" level=info msg="| 200 | 50.610375ms | ::1 | GET | /2/messagesPages?page=1&pagesize=5&visitor_id=2eaabc7e-a519-4a61-8341-35dc5ef8d37c |"
|
||||
time="2026-02-11 20:43:09" level=info msg="| 200 | 48.057791ms | ::1 | GET | /notice?kefu_id=agent3 |"
|
||||
time="2026-02-11 20:43:09" level=info msg="| 404 | 10.125µs | ::1 | GET | /aicss/static/images/4.jpg |"
|
||||
time="2026-02-11 20:43:11" level=info msg="| 404 | 3.084µs | ::1 | GET | /.well-known/appspecific/com.chrome.devtools.json |"
|
||||
time="2026-02-11 20:43:14" level=info msg="| 200 | 11.136958ms | ::1 | GET | /chatIndex |"
|
||||
time="2026-02-11 20:43:14" level=info msg="| 404 | 1.75µs | ::1 | GET | /.well-known/appspecific/com.chrome.devtools.json |"
|
||||
time="2026-02-11 20:43:14" level=info msg="| 200 | 4.796556834s | ::1 | GET | /ws_visitor?visitor_id=2eaabc7e-a519-4a61-8341-35dc5ef8d37c |"
|
||||
time="2026-02-11 20:43:14" level=info msg="| 200 | 18.30025ms | ::1 | GET | /kefu_idle?visitor_id=2eaabc7e-a519-4a61-8341-35dc5ef8d37c |"
|
||||
time="2026-02-11 20:43:15" level=info msg="| 200 | 179.864875ms | ::1 | POST | /visitor_login |"
|
||||
time="2026-02-11 20:43:15" level=info msg="| 200 | 23.262375ms | ::1 | GET | /2/messagesPages?page=1&pagesize=5&visitor_id=2eaabc7e-a519-4a61-8341-35dc5ef8d37c |"
|
||||
time="2026-02-11 20:43:15" level=info msg="| 200 | 35.343125ms | ::1 | GET | /notice?kefu_id=agent3 |"
|
||||
time="2026-02-11 20:43:15" level=info msg="| 404 | 2.292µs | ::1 | GET | /aicss/static/images/4.jpg |"
|
||||
time="2026-02-11 20:47:20" level=info msg="start server...\r\ngo:http://0.0.0.0:8081"
|
||||
time="2026-02-11 20:47:31" level=info msg="| 200 | 21.5275ms | ::1 | GET | /notice?kefu_id=agent3 |"
|
||||
time="2026-02-11 20:48:19" level=info msg="| 200 | 48.496443334s | ::1 | GET | /ws_visitor?visitor_id=2eaabc7e-a519-4a61-8341-35dc5ef8d37c |"
|
||||
time="2026-02-11 20:48:48" level=info msg="| 200 | 12.375404125s | ::1 | POST | /visitor_login |"
|
||||
time="2026-02-11 20:51:23" level=info msg="| 200 | 32.74598375s | ::1 | POST | /visitor_login |"
|
||||
time="2026-02-11 20:51:25" level=info msg="start server...\r\ngo:http://0.0.0.0:8081"
|
||||
time="2026-02-11 21:18:45" level=info msg="start server...\r\ngo:http://0.0.0.0:8081"
|
||||
time="2026-02-11 21:20:39" level=info msg="| 200 | 1m41.329861042s | ::1 | POST | /visitor_login |"
|
||||
time="2026-02-11 21:20:39" level=info msg="| 200 | 28.047054875s | ::1 | POST | /visitor_login |"
|
||||
time="2026-02-11 21:21:27" level=info msg="| 200 | 44.447656791s | ::1 | POST | /visitor_login |"
|
||||
time="2026-02-11 21:22:42" level=info msg="| 200 | 1m12.9288685s | ::1 | POST | /visitor_login |"
|
||||
time="2026-02-11 21:23:36" level=info msg="| 200 | 48.521523375s | ::1 | POST | /visitor_login |"
|
||||
time="2026-02-11 21:23:54" level=info msg="start server...\r\ngo:http://0.0.0.0:8081"
|
||||
time="2026-02-11 21:26:45" level=info msg="| 200 | 2m46.418859542s | ::1 | POST | /visitor_login |"
|
||||
@ -2,9 +2,8 @@ package middleware
|
||||
|
||||
import (
|
||||
"ai-css/tools"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"time"
|
||||
)
|
||||
|
||||
func JwtPageMiddleware(c *gin.Context) {
|
||||
@ -17,9 +16,9 @@ func JwtPageMiddleware(c *gin.Context) {
|
||||
//}
|
||||
}
|
||||
func JwtApiMiddleware(c *gin.Context) {
|
||||
token := c.GetHeader("aicss-token")
|
||||
token := c.GetHeader("token")
|
||||
if token == "" {
|
||||
token = c.Query("aicss-token")
|
||||
token = c.Query("token")
|
||||
}
|
||||
userinfo := tools.ParseToken(token)
|
||||
if userinfo == nil || userinfo["kefu_name"] == nil || userinfo["create_time"] == nil {
|
||||
|
||||
@ -1,295 +0,0 @@
|
||||
package xpink_auth
|
||||
|
||||
import (
|
||||
"ai-css/library/logger"
|
||||
"crypto/rsa"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/golang-jwt/jwt/v5"
|
||||
)
|
||||
|
||||
var (
|
||||
IdentityKey = "XPINK_USER"
|
||||
TokenLookup = "header:Authorization,query:Authorization,referer:Authorization"
|
||||
SigningAlgorithm = "RS256"
|
||||
pubKey *rsa.PublicKey // runtime load
|
||||
|
||||
pubkeyContent = []byte(`-----BEGIN PUBLIC KEY-----
|
||||
MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAqD/o6TI7AZyNEbFQTy4g
|
||||
K4Hd+aLAoLRwOe0iKqDWK4HRZABtLLvLFZLdwP4iUNAQOoy+WXz3CGqwzvs36531
|
||||
6rOzeCKtYGSN64+Pnn6UWaricnCZ2Tqng2eNln9kHALbguGVtrOSQNZr97OCOOk3
|
||||
ZDCnNwnz0hA9AhIRX1LNswPPC18q2Itdb5C//nxoEJPyY3u0r1YDL6sPD1eUDI0x
|
||||
+4A8Dgqny4Z84XALn2ucR9bcUGSbtyTR1pg42MYyw6I7MV4P0YGXD3kcItd+9qlX
|
||||
rULFZh5RLFl52PeA7bmXUpxKeg2lvv4CzNlk+eM7UyHctjYmM5rk+6QencjHk+qo
|
||||
doVMzeX0e3sby72aq7g66QWThwGgVwwRFxsodtSwl6TAXH3TAVd3nyZ9tSqM/BT7
|
||||
B8acMVzG/lzMVvrEtJHUcPlfHNDKmWuLWo6ywblc/MGj7z8Fe/pk+wJ1Nv4WCBMj
|
||||
3kv4durqVNh4YhPvxt+wAZzsNxmliFEGXb+yC/8qpZv13EgNt4f1voKYML7StIj5
|
||||
oYslqoYvzN3j5ROBRDlJaxqErEwDLwEeiqBuSME6H6hJFD3SRujmcdFtl4GYyZb9
|
||||
F7VlEGHjQqKljkjB5DOno2tV5EzGNu21dAwBHSHfto7nqG781QmQrDAVs681pNpU
|
||||
iWNoAGc0L/VR0YPuV2X+ml8CAwEAAQ==
|
||||
-----END PUBLIC KEY-----`)
|
||||
|
||||
key = ""
|
||||
TokenHeadName = "Bearer"
|
||||
|
||||
ErrEmptyFormToken = fmt.Errorf("empty form token")
|
||||
ErrEmptyParamToken = fmt.Errorf("empty param token")
|
||||
ErrEmptyCookieToken = fmt.Errorf("empty cookie token")
|
||||
ErrEmptyQueryToken = fmt.Errorf("empty query token")
|
||||
ErrEmptyAuthHeader = fmt.Errorf("empty auth header")
|
||||
|
||||
ErrInvalidAuthHeader = fmt.Errorf("invalid auth header")
|
||||
|
||||
loadPbk sync.Once
|
||||
)
|
||||
|
||||
type UserSession struct {
|
||||
Id uint64
|
||||
Userno string
|
||||
NickName string
|
||||
Jti string
|
||||
}
|
||||
|
||||
func Identity(c *gin.Context) interface{} {
|
||||
|
||||
loadPbk.Do(func() {
|
||||
var err error
|
||||
pubKey, err = jwt.ParseRSAPublicKeyFromPEM(pubkeyContent)
|
||||
if err != nil {
|
||||
logger.Error("parse rsa public key fail err:%v", err)
|
||||
}
|
||||
})
|
||||
|
||||
claims, err := GetClaimsFromJWT(c)
|
||||
if err != nil {
|
||||
logger.Error("parse claims failed", err)
|
||||
}
|
||||
|
||||
c.Set("JWT_PAYLOAD", claims)
|
||||
return JwtToUserSession(ExtractClaims(c))
|
||||
}
|
||||
|
||||
func JwtToUserSession(payload jwt.MapClaims) UserSession {
|
||||
// 安全地提取 Id
|
||||
var id uint64
|
||||
if idVal, ok := payload["Id"]; ok && idVal != nil {
|
||||
switch v := idVal.(type) {
|
||||
case float64:
|
||||
id = uint64(v)
|
||||
case int64:
|
||||
id = uint64(v)
|
||||
case int:
|
||||
id = uint64(v)
|
||||
case uint64:
|
||||
id = v
|
||||
}
|
||||
}
|
||||
|
||||
// 安全地提取其他字段
|
||||
userno := ""
|
||||
if val, ok := payload["Userno"]; ok && val != nil {
|
||||
userno = val.(string)
|
||||
}
|
||||
|
||||
nickName := ""
|
||||
if val, ok := payload["NickName"]; ok && val != nil {
|
||||
nickName = val.(string)
|
||||
}
|
||||
|
||||
jti := ""
|
||||
if val, ok := payload["Jti"]; ok && val != nil {
|
||||
jti = val.(string)
|
||||
}
|
||||
|
||||
return UserSession{
|
||||
Id: id,
|
||||
Userno: userno,
|
||||
NickName: nickName,
|
||||
Jti: jti,
|
||||
}
|
||||
}
|
||||
|
||||
// ExtractClaims help to extract the JWT claims
|
||||
func ExtractClaims(c *gin.Context) jwt.MapClaims {
|
||||
claims, exists := c.Get("JWT_PAYLOAD")
|
||||
if !exists {
|
||||
return make(jwt.MapClaims)
|
||||
}
|
||||
|
||||
return claims.(jwt.MapClaims)
|
||||
}
|
||||
|
||||
// ParseToken parse jwt token from hertz context
|
||||
func ParseToken(c *gin.Context) (*jwt.Token, error) {
|
||||
var token string
|
||||
var err error
|
||||
|
||||
methods := strings.Split(TokenLookup, ",")
|
||||
for _, method := range methods {
|
||||
if len(token) > 0 {
|
||||
break
|
||||
}
|
||||
parts := strings.Split(strings.TrimSpace(method), ":")
|
||||
k := strings.TrimSpace(parts[0])
|
||||
v := strings.TrimSpace(parts[1])
|
||||
switch k {
|
||||
case "header":
|
||||
token, err = jwtFromHeader(c, v)
|
||||
case "query":
|
||||
token, err = jwtFromQuery(c, v)
|
||||
case "cookie":
|
||||
token, err = jwtFromCookie(c, v)
|
||||
case "param":
|
||||
token, err = jwtFromParam(c, v)
|
||||
case "form":
|
||||
token, err = jwtFromForm(c, v)
|
||||
case "referer":
|
||||
token, err = jwtFromReferer(c, v)
|
||||
}
|
||||
if token != "" && err == nil {
|
||||
logger.Infof("capture token:%s", token)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// save token string if valid
|
||||
c.Set("JWT_TOKEN", token)
|
||||
|
||||
return jwt.Parse(token, func(t *jwt.Token) (interface{}, error) {
|
||||
if jwt.GetSigningMethod(SigningAlgorithm) != t.Method {
|
||||
return nil, fmt.Errorf("err invalid signingalgorithm")
|
||||
}
|
||||
|
||||
var usingPublickkey bool
|
||||
switch SigningAlgorithm {
|
||||
case "RS256", "RS512", "RS384":
|
||||
usingPublickkey = true
|
||||
default:
|
||||
usingPublickkey = false
|
||||
}
|
||||
|
||||
if usingPublickkey {
|
||||
return pubKey, nil
|
||||
}
|
||||
return key, nil
|
||||
})
|
||||
}
|
||||
|
||||
func GetClaimsFromJWT(c *gin.Context) (jwt.MapClaims, error) {
|
||||
token, err := ParseToken(c)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
claims := jwt.MapClaims{}
|
||||
for key, value := range token.Claims.(jwt.MapClaims) {
|
||||
claims[key] = value
|
||||
}
|
||||
|
||||
return claims, nil
|
||||
}
|
||||
|
||||
func MiddlewareSetIdentity(c *gin.Context) {
|
||||
identity := Identity(c)
|
||||
|
||||
if identity != nil {
|
||||
c.Set(IdentityKey, identity)
|
||||
}
|
||||
}
|
||||
|
||||
func GetXPINKUser(c *gin.Context) UserSession {
|
||||
data, ok := c.Get(IdentityKey)
|
||||
if data != nil && ok {
|
||||
if us, isUs := data.(UserSession); isUs {
|
||||
return us
|
||||
}
|
||||
}
|
||||
return UserSession{}
|
||||
}
|
||||
|
||||
func jwtFromHeader(c *gin.Context, key string) (string, error) {
|
||||
authHeader := c.Request.Header.Get(key)
|
||||
|
||||
if authHeader == "" {
|
||||
return "", ErrEmptyAuthHeader
|
||||
}
|
||||
|
||||
parts := strings.SplitN(authHeader, " ", 2)
|
||||
if !(len(parts) == 2 && parts[0] == TokenHeadName) {
|
||||
return "", ErrInvalidAuthHeader
|
||||
}
|
||||
|
||||
return parts[len(parts)-1], nil
|
||||
}
|
||||
|
||||
func jwtFromQuery(c *gin.Context, key string) (string, error) {
|
||||
token := c.Query(key)
|
||||
|
||||
if token == "" {
|
||||
return "", ErrEmptyQueryToken
|
||||
}
|
||||
|
||||
return token, nil
|
||||
}
|
||||
|
||||
func jwtFromCookie(c *gin.Context, key string) (string, error) {
|
||||
cookie, _ := c.Cookie(key)
|
||||
|
||||
if cookie == "" {
|
||||
return "", ErrEmptyCookieToken
|
||||
}
|
||||
|
||||
return cookie, nil
|
||||
}
|
||||
|
||||
func jwtFromParam(c *gin.Context, key string) (string, error) {
|
||||
token := c.Param(key)
|
||||
|
||||
if token == "" {
|
||||
return "", ErrEmptyParamToken
|
||||
}
|
||||
|
||||
return token, nil
|
||||
}
|
||||
|
||||
func jwtFromForm(c *gin.Context, key string) (string, error) {
|
||||
token := c.PostForm(key)
|
||||
|
||||
if token == "" {
|
||||
return "", ErrEmptyFormToken
|
||||
}
|
||||
|
||||
return token, nil
|
||||
}
|
||||
|
||||
func jwtFromReferer(c *gin.Context, key string) (string, error) {
|
||||
refererPath := c.GetHeader("Referer")
|
||||
|
||||
if refererPath == "" {
|
||||
return "", fmt.Errorf("err empty Referer")
|
||||
}
|
||||
rul, err := url.Parse(refererPath)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("err invalid Referer %s", refererPath)
|
||||
}
|
||||
token := rul.Query().Get(key)
|
||||
if token == "" {
|
||||
return "", ErrEmptyQueryToken
|
||||
}
|
||||
|
||||
parts := strings.SplitN(token, " ", 2)
|
||||
|
||||
if !(len(parts) == 2 && parts[0] == TokenHeadName) {
|
||||
return "", ErrInvalidAuthHeader
|
||||
}
|
||||
|
||||
return parts[len(parts)-1], nil
|
||||
}
|
||||
@ -14,7 +14,7 @@ func UpdateConfig(userid interface{}, key string, value string) {
|
||||
config := FindConfigByUserId(userid, key)
|
||||
if config.ID != 0 {
|
||||
config.ConfValue = value
|
||||
DB.Model(Config{}).Where("user_id = ? and conf_key = ?", userid, key).Update(map[string]interface{}{"conf_value": value})
|
||||
DB.Where("user_id = ? and conf_key = ?", userid, key).Update(config)
|
||||
} else {
|
||||
newConfig := &Config{
|
||||
ID: 0,
|
||||
@ -34,9 +34,7 @@ func FindConfigs() []Config {
|
||||
}
|
||||
func FindConfigsByUserId(userid interface{}) []Config {
|
||||
var config []Config
|
||||
var globalConfig = []string{"AIPrompt", "FrequentlyAskedQuestions"}
|
||||
var globalUser = "admin"
|
||||
DB.Where("user_id = ? or (conf_name in (?) and user_id = ?)", userid, globalConfig, globalUser).Find(&config)
|
||||
DB.Where("user_id = ?", userid).Find(&config)
|
||||
return config
|
||||
}
|
||||
|
||||
|
||||
@ -3,10 +3,9 @@ package models
|
||||
import (
|
||||
"ai-css/common"
|
||||
"fmt"
|
||||
"github.com/jinzhu/gorm"
|
||||
"log"
|
||||
"time"
|
||||
|
||||
"github.com/jinzhu/gorm"
|
||||
)
|
||||
|
||||
var DB *gorm.DB
|
||||
|
||||
@ -1,10 +1,8 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
_ "github.com/jinzhu/gorm/dialects/mysql"
|
||||
"time"
|
||||
)
|
||||
|
||||
type User struct {
|
||||
@ -13,7 +11,6 @@ type User struct {
|
||||
Password string `json:"password"`
|
||||
Nickname string `json:"nickname"`
|
||||
Avator string `json:"avator"`
|
||||
Role int32 `json:"role"`
|
||||
RoleName string `json:"role_name" sql:"-"`
|
||||
RoleId string `json:"role_id" sql:"-"`
|
||||
}
|
||||
@ -59,43 +56,6 @@ func FindUser(username string) User {
|
||||
DB.Where("name = ?", username).First(&user)
|
||||
return user
|
||||
}
|
||||
|
||||
var (
|
||||
lastAssignedId uint
|
||||
assignMutex sync.Mutex
|
||||
)
|
||||
|
||||
func FindIdleUser() User {
|
||||
assignMutex.Lock()
|
||||
defer assignMutex.Unlock()
|
||||
|
||||
var users []User
|
||||
DB.Where("name != ?", "admin").Order("id desc").Find(&users)
|
||||
|
||||
if len(users) == 0 {
|
||||
return User{}
|
||||
}
|
||||
|
||||
targetIndex := 0
|
||||
if lastAssignedId > 0 {
|
||||
for i, user := range users {
|
||||
if user.ID == lastAssignedId {
|
||||
targetIndex = i + 1
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if targetIndex >= len(users) {
|
||||
targetIndex = 0
|
||||
}
|
||||
|
||||
targetUser := users[targetIndex]
|
||||
lastAssignedId = targetUser.ID
|
||||
|
||||
return targetUser
|
||||
}
|
||||
|
||||
func FindUserById(id interface{}) User {
|
||||
var user User
|
||||
DB.Select("user.*,role.name role_name,role.id role_id").Joins("join user_role on user.id=user_role.user_id").Joins("join role on user_role.role_id=role.id").Where("user.id = ?", id).First(&user)
|
||||
|
||||
Binary file not shown.
114
readme.md
114
readme.md
@ -1,114 +0,0 @@
|
||||
## GOFLY LIVE CHAT
|
||||
Open-source live chat support system, built for modern customer service
|
||||
|
||||
Real-time messaging - Instant connection between customers and support teams
|
||||
|
||||
Lightning-fast performance - Powered by Golang for high-concurrency handling
|
||||
|
||||
### Technical Architecture
|
||||
|
||||
A modern stack built for performance and scalability
|
||||
|
||||
- Backend: `gin`, `jwt-go`, `websocket`, `go.uuid`, `gorm`, `cobra`
|
||||
- Frontend: `VueJS`, `ElementUI`
|
||||
- Database: `MySQL`
|
||||
|
||||
---
|
||||
|
||||
### Installation & Usage
|
||||
|
||||
#### 1. Set Up MySQL Database
|
||||
- Install and run MySQL (version ≥ 5.5).
|
||||
- Create a database:
|
||||
```sql
|
||||
CREATE DATABASE goflychat CHARSET utf8mb4;
|
||||
```
|
||||
* Configure Database Connection
|
||||
Edit mysql.json in the config directory:
|
||||
```php
|
||||
{
|
||||
"Server":"127.0.0.1",
|
||||
"Port":"3306",
|
||||
"Database":"goflychat",
|
||||
"Username":"goflychat",
|
||||
"Password":"goflychat"
|
||||
}
|
||||
```
|
||||
* Install and Configure Golang
|
||||
Run the following commands:
|
||||
```php
|
||||
wget https://studygolang.com/dl/golang/go1.20.2.linux-amd64.tar.gz
|
||||
tar -C /usr/local -xvf go1.20.2.linux-amd64.tar.gz
|
||||
mv go1.20.2.linux-amd64.tar.gz /tmp
|
||||
echo "PATH=\$PATH:/usr/local/go/bin" >> /etc/profile
|
||||
echo "PATH=\$PATH:/usr/local/go/bin" >> ~/.bashrc
|
||||
source /etc/profile
|
||||
go version
|
||||
go env -w GO111MODULE=on
|
||||
go env -w GOPROXY=https://goproxy.cn,direct
|
||||
```
|
||||
* Download the Source Code
|
||||
|
||||
Clone the repository in any directory:
|
||||
```php
|
||||
git clone https://github.com/taoshihan1991/goflylivechat.git
|
||||
cd goflylivechat
|
||||
```
|
||||
* Initialize the Database
|
||||
```php
|
||||
go run gofly.go install
|
||||
```
|
||||
* Run the Application
|
||||
```php
|
||||
go run gofly.go server
|
||||
```
|
||||
* Build executable
|
||||
```php
|
||||
go build -o gochat
|
||||
```
|
||||
* Run binary:
|
||||
```php
|
||||
Linux: ./gochat server (optional flags: -p 8082 -d)
|
||||
|
||||
Windows: gochat.exe server (optional flags: -p 8082 -d)
|
||||
```
|
||||
* Terminate the Process
|
||||
```php
|
||||
killall gochat
|
||||
```
|
||||
|
||||
Once running, the service listens on port 8081. Access via http://[your-ip]:8081.
|
||||
|
||||
For domain access, configure a reverse proxy to port 8081 to hide the port number.
|
||||
### Customer Service Integration
|
||||
Chat Link
|
||||
|
||||
http://127.0.0.1:8081/livechat?kefu_id=agent
|
||||
|
||||
Popup Integration
|
||||
|
||||
```
|
||||
(function(a, b, c, d) {
|
||||
let h = b.getElementsByTagName('head')[0];let s = b.createElement('script');
|
||||
s.type = 'text/javascript';s.src = c+"/static/js/kefu-front.js";s.onload = s.onreadystatechange = function () {
|
||||
if (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") d(c);
|
||||
};h.appendChild(s);
|
||||
})(window, document,"http://127.0.0.1:8081",function(u){
|
||||
KEFU.init({
|
||||
KEFU_URL:u,
|
||||
KEFU_KEFU_ID: "agent",
|
||||
})
|
||||
});
|
||||
|
||||
```
|
||||
### Important Notice
|
||||
The use of this project for illegal or non-compliant purposes, including but not limited to viruses, trojans, pornography, gambling, fraud, prohibited items, counterfeit products, false information, cryptocurrencies, and financial violations, is strictly prohibited.
|
||||
|
||||
This project is intended solely for personal learning and testing purposes. Any commercial use or illegal activities are explicitly forbidden!!!
|
||||
|
||||
|
||||
|
||||
### Copyright Notice
|
||||
This project provides full-featured code but is intended only for personal demonstration and testing. Commercial use is strictly prohibited.
|
||||
|
||||
By using this software, you agree to comply with all applicable local laws and regulations. You are solely responsible for any legal consequences arising from misuse.
|
||||
@ -4,7 +4,6 @@ import (
|
||||
"ai-css/controller"
|
||||
"ai-css/middleware"
|
||||
"ai-css/ws"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
@ -43,7 +42,6 @@ func InitApiRouter(engine *gin.Engine) {
|
||||
engine.POST("/message_status", controller.GetVisitorMessage)
|
||||
|
||||
//获取客服信息
|
||||
engine.GET("/kefu_idle", controller.GetIdleKefu)
|
||||
engine.POST("/kefuinfo_client", middleware.JwtApiMiddleware, controller.PostKefuClient)
|
||||
engine.GET("/kefuinfo", middleware.JwtApiMiddleware, middleware.RbacAuth, controller.GetKefuInfo)
|
||||
engine.GET("/kefuinfo_setting", middleware.JwtApiMiddleware, middleware.RbacAuth, controller.GetKefuInfoSetting)
|
||||
|
||||
BIN
static/.DS_Store
vendored
Normal file
BIN
static/.DS_Store
vendored
Normal file
Binary file not shown.
BIN
static/cdn/.DS_Store
vendored
Normal file
BIN
static/cdn/.DS_Store
vendored
Normal file
Binary file not shown.
BIN
static/css/.DS_Store
vendored
Normal file
BIN
static/css/.DS_Store
vendored
Normal file
Binary file not shown.
@ -167,7 +167,7 @@
|
||||
}
|
||||
.chatCenter {
|
||||
background: #fff;
|
||||
/* max-width: 840px; */
|
||||
max-width: 840px;
|
||||
margin: 0 auto;
|
||||
box-shadow: 2px 2px 6px rgba(0,0,0,.3);
|
||||
border-top: none;
|
||||
@ -190,7 +190,7 @@
|
||||
overflow-y: auto;
|
||||
}
|
||||
.chatVisitorPage .chatBox{
|
||||
padding: 5px 14px;
|
||||
padding: 5px 4px;
|
||||
}
|
||||
.chatBox .el-col{margin:10px 0;}
|
||||
.chatUser{
|
||||
@ -203,12 +203,6 @@
|
||||
.chatMainPage{
|
||||
margin-top: 1px;
|
||||
}
|
||||
.kefuMe{
|
||||
padding-left: 10px;
|
||||
}
|
||||
.chatMsgContent{
|
||||
padding-right: 10px;
|
||||
}
|
||||
.chatContent {
|
||||
background-color: rgb(255,255,255);
|
||||
color: #000;
|
||||
@ -223,36 +217,17 @@
|
||||
font-size: 14px;
|
||||
}
|
||||
.chatContent2 {
|
||||
border-radius: 5px;
|
||||
padding: 6px 15px;
|
||||
border-radius: 8px 8px 8px 0px;
|
||||
padding: 10px 15px;
|
||||
}
|
||||
.chatBoxMe{
|
||||
margin-top: 10px;
|
||||
}
|
||||
.chatBoxMe .chatContent2 {
|
||||
border-radius: 5px;
|
||||
border-radius: 8px 8px 0px 8px;
|
||||
background-color: #cde0ff;
|
||||
color: #000;
|
||||
}
|
||||
.msg-bubble-wrap {
|
||||
display: inline-flex;
|
||||
align-items: flex-end;
|
||||
gap: 4px;
|
||||
}
|
||||
.msg-status-icon {
|
||||
flex-shrink: 0;
|
||||
font-size: 12px;
|
||||
line-height: 1;
|
||||
margin-bottom: 1px;
|
||||
}
|
||||
.msg-status-sending {
|
||||
color: #999;
|
||||
}
|
||||
.msg-status-failed {
|
||||
color: #ff4d4f;
|
||||
cursor: pointer;
|
||||
font-size: 15px;
|
||||
}
|
||||
a{color: #07a9fe;text-decoration: none;}
|
||||
|
||||
|
||||
@ -274,9 +249,6 @@ a{color: #07a9fe;text-decoration: none;}
|
||||
z-index: 99;
|
||||
border-top: 1px solid #e4e4e4;
|
||||
}
|
||||
.el-button--primary{
|
||||
border-radius: 5px;
|
||||
}
|
||||
.chatBoxSendBtn{float: right;margin: 12px 4px 0 0;}
|
||||
.footContact{text-align: center;
|
||||
position: absolute;
|
||||
@ -378,8 +350,7 @@ a{color: #07a9fe;text-decoration: none;}
|
||||
overflow: hidden;
|
||||
background-color: rgb(11 113 236);
|
||||
background-image: url(../images/visitor_title_bg.png);
|
||||
background-repeat: no-repeat;
|
||||
background-size: 100% 72px;
|
||||
background-size: auto 72px;
|
||||
background-position: center 0;
|
||||
align-items: center;
|
||||
}
|
||||
@ -396,7 +367,6 @@ a{color: #07a9fe;text-decoration: none;}
|
||||
position: relative;
|
||||
}
|
||||
.chatArticle{
|
||||
height: 100%;
|
||||
display: none;
|
||||
}
|
||||
.visitorIconBox{
|
||||
@ -433,7 +403,7 @@ a{color: #07a9fe;text-decoration: none;}
|
||||
}
|
||||
@media screen and (min-width: 900px) {
|
||||
.chatCenter {
|
||||
/* max-height: 650px; */
|
||||
max-height: 650px;
|
||||
box-shadow: 0 2px 8px rgba(0,0,0,.15);
|
||||
border-radius: 8px;
|
||||
}
|
||||
@ -454,7 +424,7 @@ a{color: #07a9fe;text-decoration: none;}
|
||||
.chatEntBox {
|
||||
width: calc(100% - 265px);
|
||||
float: left;
|
||||
/* border-right: 1px solid #e6e6e6; */
|
||||
border-right: 1px solid #e6e6e6;
|
||||
}
|
||||
.chatArticle {
|
||||
display: block;
|
||||
@ -474,32 +444,18 @@ a{color: #07a9fe;text-decoration: none;}
|
||||
color: rgb(250, 84, 28);
|
||||
}
|
||||
}
|
||||
.message-box-send{
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
}
|
||||
.message-box-send .btn-box{
|
||||
display: flex;
|
||||
align-items: end;
|
||||
padding-right: 10px;
|
||||
|
||||
}
|
||||
.message-box-send .el-textarea__inner{
|
||||
background-color: rgba(0, 0, 0, 0.1);
|
||||
color: #000;
|
||||
}
|
||||
.visitorEditorArea{
|
||||
margin-top: 5px;
|
||||
padding-left: 8px;
|
||||
}
|
||||
.visitorEditorArea textarea {
|
||||
padding: 7px 0 7px 8px;
|
||||
font-size:14px;
|
||||
line-height: 15px;
|
||||
font-size:16px;
|
||||
line-height: 21px;
|
||||
border: none;
|
||||
}
|
||||
.visitorEditorBtn{
|
||||
padding: 8px 20px;
|
||||
position: absolute;
|
||||
right: 10px;
|
||||
bottom: 2px;
|
||||
}
|
||||
.mainLeftMenu {
|
||||
width: 70px;
|
||||
@ -575,13 +531,7 @@ a{color: #07a9fe;text-decoration: none;}
|
||||
line-height: 23px;
|
||||
color: #666;
|
||||
}
|
||||
.el-textarea{
|
||||
|
||||
/* padding: 5px 10px ; */
|
||||
|
||||
}
|
||||
.chatArea .el-textarea__inner{
|
||||
|
||||
border: none;
|
||||
}
|
||||
.tongji{
|
||||
|
||||
@ -1,220 +0,0 @@
|
||||
/* Dark Mode Styles for Customer Service Chat - Deep Green Theme */
|
||||
|
||||
/* 暗色模式下的背景和文字颜色 */
|
||||
body.dark-mode {
|
||||
background-color: #1a3d35 !important;
|
||||
color: #FFFFFF !important;
|
||||
}
|
||||
|
||||
body.dark-mode .visitorBody {
|
||||
/* background-color: #1E3838 !important; */
|
||||
}
|
||||
|
||||
/* 聊天容器 */
|
||||
body.dark-mode .chatCenter {
|
||||
|
||||
background-color: #1a3d35 !important;
|
||||
/* background-color: red !important; */
|
||||
}
|
||||
|
||||
/* 聊天标题区域 */
|
||||
body.dark-mode .chatEntTitle {
|
||||
background: linear-gradient(to right, #001E14 0%, #007C34 100%);
|
||||
color: #FFFFFF !important;
|
||||
border-bottom: 1px solid #355050 !important;
|
||||
}
|
||||
|
||||
/* 聊天内容区域 */
|
||||
body.dark-mode .chatEntBox {
|
||||
background-color: #1a3d35 !important;
|
||||
}
|
||||
|
||||
body.dark-mode .chatVisitorPage {
|
||||
background-color: #1a3d35 !important;
|
||||
}
|
||||
|
||||
body.dark-mode .chatBox {
|
||||
background-color: #1a3d35 !important;
|
||||
}
|
||||
|
||||
/* 聊天消息气泡 - 客服消息 */
|
||||
body.dark-mode .chatContent {
|
||||
background-color: #2D5050 !important;
|
||||
color: #FFFFFF !important;
|
||||
border: 1px solid #355858 !important;
|
||||
}
|
||||
|
||||
/* 聊天消息气泡 - 访客消息 */
|
||||
body.dark-mode .chatBoxMe .chatContent {
|
||||
background-color: #246153 !important;
|
||||
color: #FFFFFF !important;
|
||||
border: 1px solid #246153 !important;
|
||||
}
|
||||
|
||||
/* 消息发送状态 */
|
||||
body.dark-mode .msg-status-sending { color: #7a9e9e; }
|
||||
body.dark-mode .msg-status-failed { color: #ff6b6b; }
|
||||
|
||||
/* 时间戳 */
|
||||
body.dark-mode .chatTime {
|
||||
color: #A0BFBF !important;
|
||||
}
|
||||
|
||||
body.dark-mode .chatTime span {
|
||||
background-color: #2A4848 !important;
|
||||
color: #A0BFBF !important;
|
||||
}
|
||||
|
||||
/* 通知消息 */
|
||||
body.dark-mode .chatNotice {
|
||||
/* background-color: #2D4A4A !important; */
|
||||
}
|
||||
|
||||
body.dark-mode .chatNoticeContent {
|
||||
color: #fff !important;
|
||||
background-color: #2D5050;
|
||||
}
|
||||
|
||||
|
||||
/* 输入框区域 */
|
||||
body.dark-mode .chatBoxSend {
|
||||
background-color: #065946 !important;
|
||||
border-top: 1px solid #355050 !important;
|
||||
}
|
||||
|
||||
/* Element UI 输入框暗色模式 */
|
||||
body.dark-mode .el-textarea__inner {
|
||||
background-color: rgba(0,0,0,0.2) !important;
|
||||
border-color: #fff !important;
|
||||
color: #FFFFFF !important;
|
||||
}
|
||||
|
||||
body.dark-mode .el-textarea__inner:focus {
|
||||
border-color: #507070 !important;
|
||||
}
|
||||
|
||||
body.dark-mode .el-textarea__inner::placeholder {
|
||||
color: #7A9999 !important;
|
||||
}
|
||||
|
||||
/* 图标按钮 */
|
||||
body.dark-mode .iconBtn {
|
||||
color: #FFFFFF !important;
|
||||
}
|
||||
|
||||
body.dark-mode .iconBtn:hover {
|
||||
color: #FFB84D !important;
|
||||
}
|
||||
|
||||
body.dark-mode .visitorIconBtns {
|
||||
color: #FFFFFF !important;
|
||||
}
|
||||
|
||||
body.dark-mode .visitorIconBtns:hover {
|
||||
color: #FFB84D !important;
|
||||
}
|
||||
|
||||
/* 表情面板 */
|
||||
body.dark-mode .faceBox {
|
||||
background-color: #2A4848 !important;
|
||||
border: 1px solid #355050 !important;
|
||||
}
|
||||
|
||||
body.dark-mode .faceBoxList li {
|
||||
border-color: #355050 !important;
|
||||
background-color: #1E3838 !important;
|
||||
}
|
||||
|
||||
body.dark-mode .faceBoxList li:hover {
|
||||
background-color: #355050 !important;
|
||||
}
|
||||
|
||||
/* 公告区域 */
|
||||
body.dark-mode .chatArticle {
|
||||
background-color: #27463f !important;
|
||||
border-top: 1px solid #355050 !important;
|
||||
}
|
||||
|
||||
body.dark-mode .hotQuestionTitle {
|
||||
color: #FFFFFF !important;
|
||||
border-bottom: 1px solid #355050 !important;
|
||||
}
|
||||
|
||||
body.dark-mode .allNotice {
|
||||
color: #A0BFBF !important;
|
||||
}
|
||||
|
||||
/* Element UI 组件暗色模式 */
|
||||
body.dark-mode .el-button--primary {
|
||||
background-color: #ffc800 !important;
|
||||
border-color: #ffc800 !important;
|
||||
color: #000;
|
||||
}
|
||||
|
||||
body.dark-mode .el-button--primary:hover {
|
||||
background-color: #ffc800 !important;
|
||||
}
|
||||
|
||||
body.dark-mode .el-button--primary.is-disabled {
|
||||
opacity: 0.5;
|
||||
color: #000 !important;
|
||||
}
|
||||
|
||||
/* 链接 */
|
||||
body.dark-mode a {
|
||||
color: #FFB84D !important;
|
||||
}
|
||||
|
||||
body.dark-mode a:hover {
|
||||
color: #FFC870 !important;
|
||||
}
|
||||
|
||||
/* 滚动条 */
|
||||
body.dark-mode ::-webkit-scrollbar {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
}
|
||||
|
||||
body.dark-mode ::-webkit-scrollbar-track {
|
||||
background-color: #1E3838;
|
||||
}
|
||||
|
||||
body.dark-mode ::-webkit-scrollbar-thumb {
|
||||
background-color: #355050;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
body.dark-mode ::-webkit-scrollbar-thumb:hover {
|
||||
background-color: #406060;
|
||||
}
|
||||
|
||||
/* Badge */
|
||||
body.dark-mode .el-badge__content {
|
||||
background-color: #FFB84D !important;
|
||||
}
|
||||
|
||||
/* Message 组件 */
|
||||
body.dark-mode .el-message {
|
||||
background-color: #2A4848 !important;
|
||||
border-color: #355050 !important;
|
||||
color: #FFFFFF !important;
|
||||
}
|
||||
|
||||
body.dark-mode .el-message--warning {
|
||||
background-color: #6A5A3A !important;
|
||||
border-color: #8A7A5A !important;
|
||||
}
|
||||
|
||||
/* Tooltip */
|
||||
body.dark-mode .el-tooltip__popper {
|
||||
background-color: #2A4848 !important;
|
||||
color: #FFFFFF !important;
|
||||
}
|
||||
|
||||
body.dark-mode .el-tooltip__popper[x-placement^=top] .popper__arrow {
|
||||
border-top-color: #2A4848 !important;
|
||||
}
|
||||
|
||||
body.dark-mode .el-tooltip__popper[x-placement^=bottom] .popper__arrow {
|
||||
border-bottom-color: #2A4848 !important;
|
||||
}
|
||||
@ -1,212 +0,0 @@
|
||||
/* Dark Mode Styles for Customer Service Chat */
|
||||
|
||||
/* 暗色模式下的背景和文字颜色 */
|
||||
body.dark-mode {
|
||||
/* background-color: #1a1a1a !important; */
|
||||
color: #e0e0e0 !important;
|
||||
}
|
||||
|
||||
body.dark-mode .visitorBody {
|
||||
background-color: #1a1a1a !important;
|
||||
}
|
||||
|
||||
/* 聊天容器 */
|
||||
body.dark-mode .chatCenter {
|
||||
/* background-color: #1a1a1a !important; */
|
||||
}
|
||||
|
||||
/* 聊天标题区域 */
|
||||
body.dark-mode .chatEntTitle {
|
||||
background-color: #2d2d2d !important;
|
||||
color: #e0e0e0 !important;
|
||||
border-bottom: 1px solid #3d3d3d !important;
|
||||
}
|
||||
|
||||
/* 聊天内容区域 */
|
||||
body.dark-mode .chatEntBox {
|
||||
/* background-color: #1a1a1a !important; */
|
||||
}
|
||||
|
||||
body.dark-mode .chatVisitorPage {
|
||||
/* background-color: #1a1a1a !important; */
|
||||
}
|
||||
|
||||
body.dark-mode .chatBox {
|
||||
/* background-color: #1a1a1a !important; */
|
||||
}
|
||||
|
||||
/* 聊天消息气泡 - 客服消息 */
|
||||
body.dark-mode .chatContent {
|
||||
background-color: #2d2d2d !important;
|
||||
color: #e0e0e0 !important;
|
||||
border: 1px solid #3d3d3d !important;
|
||||
}
|
||||
|
||||
/* 聊天消息气泡 - 访客消息 */
|
||||
body.dark-mode .chatBoxMe .chatContent {
|
||||
background-color: #1e5a8e !important;
|
||||
color: #ffffff !important;
|
||||
border: 1px solid #2d7ab8 !important;
|
||||
}
|
||||
|
||||
/* 时间戳 */
|
||||
body.dark-mode .chatTime {
|
||||
color: #888888 !important;
|
||||
}
|
||||
|
||||
body.dark-mode .chatTime span {
|
||||
background-color: #2d2d2d !important;
|
||||
color: #888888 !important;
|
||||
}
|
||||
|
||||
/* 通知消息 */
|
||||
body.dark-mode .chatNotice {
|
||||
/* background-color: #2d2d2d !important; */
|
||||
}
|
||||
|
||||
body.dark-mode .chatNoticeContent {
|
||||
color: #4a9eff !important;
|
||||
}
|
||||
|
||||
/* 输入框区域 */
|
||||
body.dark-mode .chatBoxSend {
|
||||
background-color: #2d2d2d !important;
|
||||
border-top: 1px solid #3d3d3d !important;
|
||||
}
|
||||
|
||||
/* Element UI 输入框暗色模式 */
|
||||
body.dark-mode .el-textarea__inner {
|
||||
background-color: #1a1a1a !important;
|
||||
border-color: #3d3d3d !important;
|
||||
color: #e0e0e0 !important;
|
||||
}
|
||||
|
||||
body.dark-mode .el-textarea__inner:focus {
|
||||
border-color: #4a9eff !important;
|
||||
}
|
||||
|
||||
body.dark-mode .el-textarea__inner::placeholder {
|
||||
color: #666666 !important;
|
||||
}
|
||||
|
||||
/* 图标按钮 */
|
||||
body.dark-mode .iconBtn {
|
||||
color: #b0b0b0 !important;
|
||||
}
|
||||
|
||||
body.dark-mode .iconBtn:hover {
|
||||
color: #4a9eff !important;
|
||||
}
|
||||
|
||||
body.dark-mode .visitorIconBtns {
|
||||
color: #b0b0b0 !important;
|
||||
}
|
||||
|
||||
body.dark-mode .visitorIconBtns:hover {
|
||||
color: #4a9eff !important;
|
||||
}
|
||||
|
||||
/* 表情面板 */
|
||||
body.dark-mode .faceBox {
|
||||
background-color: #2d2d2d !important;
|
||||
border: 1px solid #3d3d3d !important;
|
||||
}
|
||||
|
||||
body.dark-mode .faceBoxList li {
|
||||
border-color: #3d3d3d !important;
|
||||
background-color: #1a1a1a !important;
|
||||
}
|
||||
|
||||
body.dark-mode .faceBoxList li:hover {
|
||||
background-color: #3d3d3d !important;
|
||||
}
|
||||
|
||||
/* 公告区域 */
|
||||
body.dark-mode .chatArticle {
|
||||
background-color: #2d2d2d !important;
|
||||
border-top: 1px solid #3d3d3d !important;
|
||||
}
|
||||
|
||||
body.dark-mode .hotQuestionTitle {
|
||||
color: #e0e0e0 !important;
|
||||
border-bottom: 1px solid #3d3d3d !important;
|
||||
}
|
||||
|
||||
body.dark-mode .allNotice {
|
||||
color: #b0b0b0 !important;
|
||||
}
|
||||
|
||||
/* Element UI 组件暗色模式 */
|
||||
body.dark-mode .el-button--primary {
|
||||
background-color: #1e5a8e !important;
|
||||
border-color: #2d7ab8 !important;
|
||||
}
|
||||
|
||||
body.dark-mode .el-button--primary:hover {
|
||||
background-color: #2d7ab8 !important;
|
||||
}
|
||||
|
||||
body.dark-mode .el-button--primary.is-disabled {
|
||||
background-color: #3d3d3d !important;
|
||||
border-color: #3d3d3d !important;
|
||||
color: #666666 !important;
|
||||
}
|
||||
|
||||
/* 链接 */
|
||||
body.dark-mode a {
|
||||
color: #4a9eff !important;
|
||||
}
|
||||
|
||||
body.dark-mode a:hover {
|
||||
color: #70b4ff !important;
|
||||
}
|
||||
|
||||
/* 滚动条 */
|
||||
body.dark-mode ::-webkit-scrollbar {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
}
|
||||
|
||||
body.dark-mode ::-webkit-scrollbar-track {
|
||||
background-color: #1a1a1a;
|
||||
}
|
||||
|
||||
body.dark-mode ::-webkit-scrollbar-thumb {
|
||||
background-color: #3d3d3d;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
body.dark-mode ::-webkit-scrollbar-thumb:hover {
|
||||
background-color: #4d4d4d;
|
||||
}
|
||||
|
||||
/* Badge */
|
||||
body.dark-mode .el-badge__content {
|
||||
background-color: #4a9eff !important;
|
||||
}
|
||||
|
||||
/* Message 组件 */
|
||||
body.dark-mode .el-message {
|
||||
background-color: #2d2d2d !important;
|
||||
border-color: #3d3d3d !important;
|
||||
color: #e0e0e0 !important;
|
||||
}
|
||||
|
||||
body.dark-mode .el-message--warning {
|
||||
background-color: #5a4e1e !important;
|
||||
border-color: #7a6e3e !important;
|
||||
}
|
||||
|
||||
/* Tooltip */
|
||||
body.dark-mode .el-tooltip__popper {
|
||||
background-color: #2d2d2d !important;
|
||||
color: #e0e0e0 !important;
|
||||
}
|
||||
|
||||
body.dark-mode .el-tooltip__popper[x-placement^=top] .popper__arrow {
|
||||
border-top-color: #2d2d2d !important;
|
||||
}
|
||||
|
||||
body.dark-mode .el-tooltip__popper[x-placement^=bottom] .popper__arrow {
|
||||
border-bottom-color: #2d2d2d !important;
|
||||
}
|
||||
BIN
static/images/.DS_Store
vendored
Normal file
BIN
static/images/.DS_Store
vendored
Normal file
Binary file not shown.
@ -321,7 +321,7 @@
|
||||
rightTabActive:"visitorInfo",
|
||||
users:[],
|
||||
usersMap:[],
|
||||
server:getWsBaseUrl()+"/ws_kefu?aicss-token="+localStorage.getItem("aicss-token"),
|
||||
server:getWsBaseUrl()+"/ws_kefu?token="+localStorage.getItem("token"),
|
||||
//server:getWsBaseUrl()+"/chat_server",
|
||||
socket:null,
|
||||
socketClosed:false,
|
||||
@ -369,7 +369,6 @@
|
||||
sendDisabled:false,
|
||||
showFaceIcon:false,
|
||||
showLoadMore:false,
|
||||
pollTimer:null,
|
||||
messages:{
|
||||
page:1,
|
||||
pagesize:15,
|
||||
@ -420,7 +419,7 @@
|
||||
this.$alert('客服在其他地方登录,当前登录状态退出', '通知', {
|
||||
confirmButtonText: '确定',
|
||||
callback:function () {
|
||||
localStorage.removeItem("aicss-token");
|
||||
localStorage.removeItem("token");
|
||||
window.location.href="/login";
|
||||
}
|
||||
});
|
||||
@ -641,7 +640,7 @@
|
||||
type:"get",
|
||||
url:"/kefuinfo",
|
||||
headers:{
|
||||
"aicss-token":localStorage.getItem("aicss-token")
|
||||
"token":localStorage.getItem("token")
|
||||
},
|
||||
success: function(data) {
|
||||
if(data.code==200 && data.result!=null){
|
||||
@ -666,7 +665,7 @@
|
||||
type:"get",
|
||||
url:"/visitors_kefu_online",
|
||||
headers:{
|
||||
"aicss-token":localStorage.getItem("aicss-token")
|
||||
"token":localStorage.getItem("token")
|
||||
},
|
||||
success: function(data) {
|
||||
if(data.code==200 && data.result!=null){
|
||||
@ -719,67 +718,10 @@
|
||||
}
|
||||
if(_this.messages.page==1){
|
||||
_this.scrollBottom();
|
||||
_this.startPollMessages();
|
||||
}
|
||||
_this.messages.page++;
|
||||
});
|
||||
},
|
||||
startPollMessages(){
|
||||
let _this=this;
|
||||
if(_this.pollTimer){
|
||||
clearInterval(_this.pollTimer);
|
||||
}
|
||||
_this.pollTimer=setInterval(function(){
|
||||
if(!_this.currentGuest) return;
|
||||
let params={
|
||||
page:1,
|
||||
pagesize: 20,
|
||||
visitor_id: _this.currentGuest,
|
||||
}
|
||||
$.get("/2/messagesPages",params,function(res){
|
||||
let msgList=res.result.list;
|
||||
let existIds={};
|
||||
var existList=[];
|
||||
for(let i=0;i<_this.msgList.length;i++){
|
||||
var m=_this.msgList[i];
|
||||
if(m.id) existIds[m.id]=true;
|
||||
if(m.time) existList.push({time:new Date(m.time).getTime(),content:m.content});
|
||||
}
|
||||
function isDuplicate(item){
|
||||
if(item.id && existIds[item.id]) return true;
|
||||
var t=new Date(item["create_time"]).getTime();
|
||||
var c=replaceContent(item["content"]);
|
||||
for(var j=0;j<existList.length;j++){
|
||||
if(existList[j].content===c && Math.abs(existList[j].time-t)<=3000) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
let newMsgs=[];
|
||||
for(let i=msgList.length-1;i>=0;i--){
|
||||
let item=msgList[i];
|
||||
if(isDuplicate(item)) continue;
|
||||
if (item["mes_type"] == "kefu") {
|
||||
item.is_kefu = true;
|
||||
item.avator=item["kefu_avator"];
|
||||
item.name=item["kefu_name"];
|
||||
} else {
|
||||
item.is_kefu = false;
|
||||
item.avator=item["visitor_avator"];
|
||||
item.name=item["visitor_name"];
|
||||
}
|
||||
item.content=replaceContent(item["content"]);
|
||||
item.time = item["create_time"];
|
||||
newMsgs.push(item);
|
||||
}
|
||||
if(newMsgs.length>0){
|
||||
for(let i=0;i<newMsgs.length;i++){
|
||||
_this.msgList.push(newMsgs[i]);
|
||||
}
|
||||
_this.scrollBottom();
|
||||
}
|
||||
});
|
||||
},5000);
|
||||
},
|
||||
//获取信息列表
|
||||
getMesssagesByVisitorId(visitorId,isAll){
|
||||
let _this=this;
|
||||
@ -787,7 +729,7 @@
|
||||
type:"get",
|
||||
url:"/messages?visitorId="+visitorId,
|
||||
headers:{
|
||||
"aicss-token":localStorage.getItem("aicss-token")
|
||||
"token":localStorage.getItem("token")
|
||||
},
|
||||
success: function(data) {
|
||||
if(data.code==200 && data.result!=null){
|
||||
@ -836,7 +778,7 @@
|
||||
url:"/visitor",
|
||||
data:{visitorId:vid},
|
||||
headers:{
|
||||
"aicss-token":localStorage.getItem("aicss-token")
|
||||
"token":localStorage.getItem("token")
|
||||
},
|
||||
success: function(data) {
|
||||
if(data.result!=null){
|
||||
@ -887,7 +829,7 @@
|
||||
url:"/2/message_close",
|
||||
data:{visitor_id:visitorId},
|
||||
headers:{
|
||||
"aicss-token":localStorage.getItem("aicss-token")
|
||||
"token":localStorage.getItem("token")
|
||||
},
|
||||
success: function(data) {
|
||||
if(data.code!=200){
|
||||
@ -923,7 +865,7 @@
|
||||
url:"/visitors",
|
||||
data:{page:page},
|
||||
headers:{
|
||||
"aicss-token":localStorage.getItem("aicss-token")
|
||||
"token":localStorage.getItem("token")
|
||||
},
|
||||
success: function(data) {
|
||||
if(data.result.list!=null){
|
||||
@ -1052,7 +994,7 @@
|
||||
url:"/ipblack",
|
||||
data:{ip:ip},
|
||||
headers:{
|
||||
"aicss-token":localStorage.getItem("aicss-token")
|
||||
"token":localStorage.getItem("token")
|
||||
},
|
||||
success: function(data) {
|
||||
if(data.code!=200){
|
||||
@ -1088,7 +1030,7 @@
|
||||
var formData = new FormData();
|
||||
formData.append('imgfile', file);
|
||||
$.ajax({
|
||||
url: '/aicss/uploadimg',
|
||||
url: '/uploadimg',
|
||||
type: "post",
|
||||
data: formData,
|
||||
contentType: false,
|
||||
@ -1269,7 +1211,7 @@
|
||||
url: url,
|
||||
data:params,
|
||||
headers: {
|
||||
"aicss-token": localStorage.getItem("aicss-token")
|
||||
"token": localStorage.getItem("token")
|
||||
},
|
||||
error:function(res){
|
||||
var data=JSON.parse(res.responseText);
|
||||
@ -1296,12 +1238,6 @@
|
||||
});
|
||||
},
|
||||
},
|
||||
beforeDestroy(){
|
||||
if(this.pollTimer){
|
||||
clearInterval(this.pollTimer);
|
||||
this.pollTimer=null;
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
document.addEventListener('paste', this.onPasteUpload)
|
||||
},
|
||||
|
||||
@ -5,73 +5,6 @@
|
||||
<meta name="keywords" content="Golang Open Source LiveChat Software"/>
|
||||
<meta name="description" content="Golang Open Source LiveChat Software"/>
|
||||
<title>Live Chat Support</title>
|
||||
|
||||
<!-- 防止闪烁:在页面渲染前应用主题 -->
|
||||
<script>
|
||||
(function() {
|
||||
// 1. 从 URL 参数获取主题
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const themeParam = urlParams.get('theme');
|
||||
|
||||
// 2. 从 localStorage 获取保存的主题
|
||||
const savedTheme = localStorage.getItem('theme');
|
||||
|
||||
// 3. 检测是否在 iframe 中
|
||||
const isInIframe = window.parent !== window;
|
||||
|
||||
// 4. 确定要使用的主题
|
||||
// 如果在 iframe 中且没有明确指定主题,默认使用暗色模式(避免闪烁)
|
||||
let theme;
|
||||
if (themeParam) {
|
||||
theme = themeParam;
|
||||
} else if (savedTheme) {
|
||||
theme = savedTheme;
|
||||
} else if (isInIframe) {
|
||||
// iframe 环境默认暗色,等待父页面发送实际主题
|
||||
theme = 'dark';
|
||||
} else {
|
||||
theme = 'light';
|
||||
}
|
||||
|
||||
// 5. 立即设置HTML背景色和应用主题类
|
||||
if (theme === 'dark') {
|
||||
// 暗色模式:立即设置内联样式防止闪烁
|
||||
document.documentElement.style.backgroundColor = '#1a3d35';
|
||||
document.documentElement.style.color = '#FFFFFF';
|
||||
document.documentElement.classList.add('dark-mode-init');
|
||||
} else {
|
||||
// 白天模式:移除可能存在的暗色类和样式
|
||||
document.documentElement.classList.remove('dark-mode-init');
|
||||
document.documentElement.style.backgroundColor = '';
|
||||
document.documentElement.style.color = '';
|
||||
}
|
||||
|
||||
// 6. 在脚本末尾立即尝试给body添加类(此时body可能还不存在)
|
||||
// 使用定时器快速重试,确保尽早添加
|
||||
let retryCount = 0;
|
||||
const maxRetries = 50; // 最多重试50次
|
||||
const applyBodyClass = function() {
|
||||
if (document.body) {
|
||||
if (theme === 'dark') {
|
||||
document.body.classList.add('dark-mode');
|
||||
// 移除html的内联样式,让CSS接管
|
||||
document.documentElement.style.backgroundColor = '';
|
||||
document.documentElement.style.color = '';
|
||||
} else {
|
||||
// 白天模式:确保移除暗色类
|
||||
document.body.classList.remove('dark-mode');
|
||||
}
|
||||
return true;
|
||||
} else if (retryCount < maxRetries) {
|
||||
retryCount++;
|
||||
setTimeout(applyBodyClass, 10); // 10ms后重试
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
applyBodyClass();
|
||||
})();
|
||||
</script>
|
||||
<link rel="stylesheet" href="/static/cdn/element-ui/2.15.1/theme-chalk/index.min.css">
|
||||
<script src="/static/cdn/vue/2.6.11/vue.min.js"></script>
|
||||
<script src="/static/cdn/element-ui/2.15.1/index.js"></script>
|
||||
@ -82,7 +15,6 @@
|
||||
<link rel="stylesheet" href="/static/css/common.css?v=sdsderfrgfgdfdf" />
|
||||
<link rel="stylesheet" href="/static/css/icono.min.css" />
|
||||
<link rel="stylesheet" href="/static/css/icon/iconfont.css?v=fgjlgfda"/>
|
||||
<link rel="stylesheet" href="/static/css/dark-mode.css" />
|
||||
</head>
|
||||
<body class="visitorBody">
|
||||
<div id="app" class="chatCenter">
|
||||
@ -93,14 +25,14 @@
|
||||
<el-avatar class="chatEntTitleLogo" :size="35" :src="kefuInfo.avatar"></el-avatar>
|
||||
</el-badge>
|
||||
<div>
|
||||
<div>在线客服</div>
|
||||
<div>Live Chat Support</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="chatEntBox">
|
||||
<div class="chatContext chatVisitorPage">
|
||||
<div class="chatBox">
|
||||
<div class="chatNotice" v-on:click="getHistoryMessage" v-show="showLoadMore">
|
||||
<a href="javascript:;" class="chatNoticeContent" style="color: #07a9fe;">加载更多消息</a>
|
||||
<a href="javascript:;" class="chatNoticeContent" style="color: #07a9fe;">Load more messages</a>
|
||||
</div>
|
||||
<el-row :gutter="2" v-for="v in msgList" v-bind:class="{'chatBoxMe': v.is_kefu==false}">
|
||||
<div class="chatTime" v-bind:class="{'chatTimeHide': v.show_time==false}"><span><{v.time}></span></div>
|
||||
@ -111,11 +43,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="kefuMe" v-if="v.is_kefu==false" style="display: flex;justify-content: flex-end;">
|
||||
<div class="chatContent chatContent2 replyContentBtn msg-bubble-wrap" :class="{'msg-bubble-failed': v.status=='failed'}">
|
||||
<span v-html="v.content"></span>
|
||||
<span class="msg-status-icon msg-status-sending" v-if="v.status=='sending'"><i class="el-icon-loading"></i></span>
|
||||
<span class="msg-status-icon msg-status-failed" v-if="v.status=='failed'" @click.stop="resendMessage(v)" title="发送失败,点击重试"><i class="el-icon-warning"></i></span>
|
||||
</div>
|
||||
<div class="chatContent chatContent2 replyContentBtn" v-html="v.content"></div>
|
||||
<el-avatar style="margin-left:10px;flex-shrink: 0;" :size="36" :src="v.avator"></el-avatar>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
@ -125,14 +53,14 @@
|
||||
<div class="chatBoxSend">
|
||||
<div class="visitorIconBox">
|
||||
<el-tooltip content="Send emoji" placement="top">
|
||||
<div class="iconBtn iconfont icon-xiaolian" style="margin-left:15px;font-size: 20px;cursor: pointer;" @click.stop="showFaceIcon==true?showFaceIcon=false:showFaceIcon=true"></div>
|
||||
<div class="iconBtn iconfont icon-xiaolian" style="margin-left:10px;font-size: 24px;cursor: pointer;" @click.stop="showFaceIcon==true?showFaceIcon=false:showFaceIcon=true"></div>
|
||||
</el-tooltip>
|
||||
|
||||
<el-tooltip content="Upload image" placement="top">
|
||||
<div class="iconBtn el-icon-picture" id="uploadImg" v-on:click="uploadImg('/uploadimg')" style="font-size: 20px;"></div>
|
||||
<div class="iconBtn el-icon-picture" id="uploadImg" v-on:click="uploadImg('/uploadimg')" style="font-size: 24px;"></div>
|
||||
</el-tooltip>
|
||||
<el-tooltip content="Upload file" placement="top">
|
||||
<div class="iconBtn el-icon-upload" id="uploadFile" v-on:click="uploadFile('/uploadfile')" style="font-size: 20px;"></div>
|
||||
<div class="iconBtn el-icon-upload" id="uploadFile" v-on:click="uploadFile('/uploadfile')" style="font-size: 26px;"></div>
|
||||
</el-tooltip>
|
||||
|
||||
<div style="display: none" title="Emoji" class="icono-smile visitorIconBtns visitorFaceBtn"></div>
|
||||
@ -145,17 +73,13 @@
|
||||
</ul>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
<div class="message-box-send">
|
||||
<el-input :rows="2" type="textarea" resize="none" class="visitorEditorArea" @focus="scrollBottom;showIconBtns=false" @blur="scrollBottom;showIconBtns=false" v-model="messageContent" v-on:keyup.enter.native="chatToUser">
|
||||
<el-input show-word-limit maxlength="100" :rows="2" type="textarea" resize="none" class="visitorEditorArea" @focus="scrollBottom;showIconBtns=false" @blur="scrollBottom;showIconBtns=false" v-model="messageContent" v-on:keyup.enter.native="chatToUser">
|
||||
</el-input>
|
||||
<div class="btn-box">
|
||||
<el-button type="primary" size="mini" class="visitorEditorBtn" :disabled="messageContent==''" v-on:click="chatToUser();showIconBtns=false">发送</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<el-button type="primary" size="mini" class="visitorEditorBtn" :disabled="sendDisabled||messageContent==''" v-on:click="chatToUser();showIconBtns=false">Send</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="chatArticle">
|
||||
<h3 class="hotQuestionTitle">公告</h3>
|
||||
<h3 class="hotQuestionTitle">Announcements</h3>
|
||||
<div class="allNotice" v-html><{kefuInfo.allNotice}></div>
|
||||
</div>
|
||||
|
||||
@ -167,54 +91,9 @@
|
||||
<script>
|
||||
var KEFU_ID='{{.KEFU_ID}}';
|
||||
var REFER='{{.Refer}}';
|
||||
|
||||
// 主题切换函数
|
||||
function setTheme(theme) {
|
||||
if (theme === 'dark') {
|
||||
document.body.classList.add('dark-mode');
|
||||
localStorage.setItem('theme', 'dark');
|
||||
} else {
|
||||
document.body.classList.remove('dark-mode');
|
||||
localStorage.setItem('theme', 'light');
|
||||
}
|
||||
}
|
||||
|
||||
// 监听来自父页面的主题变化消息
|
||||
window.addEventListener('message', function(event) {
|
||||
// 安全检查:可以添加 origin 验证
|
||||
// if (event.origin !== 'https://your-parent-domain.com') return;
|
||||
|
||||
if (event.data && event.data.type === 'theme-change') {
|
||||
console.log('Received theme change:', event.data.theme);
|
||||
setTheme(event.data.theme);
|
||||
}
|
||||
});
|
||||
|
||||
// 页面加载时,应用主题(已在 head 中预设)
|
||||
(function() {
|
||||
// 检查是否在 head 中已经设置了暗色模式
|
||||
const isDarkInit = document.documentElement.classList.contains('dark-mode-init');
|
||||
|
||||
if (isDarkInit) {
|
||||
// 已在 head 中设置为暗色,直接应用
|
||||
document.body.classList.add('dark-mode');
|
||||
localStorage.setItem('theme', 'dark');
|
||||
// 移除临时类
|
||||
document.documentElement.classList.remove('dark-mode-init');
|
||||
} else {
|
||||
// 确保是亮色模式
|
||||
document.body.classList.remove('dark-mode');
|
||||
localStorage.setItem('theme', 'light');
|
||||
}
|
||||
|
||||
// 通知父页面已准备好接收主题消息
|
||||
if (window.parent !== window) {
|
||||
window.parent.postMessage({ type: 'iframe-ready' }, '*');
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
<script>
|
||||
var initVue=function(){
|
||||
KEFU_ID=KEFU_ID!=""? KEFU_ID:"kefu2";
|
||||
new Vue({
|
||||
el: '#app',
|
||||
delimiters:["<{","}>"],
|
||||
@ -270,7 +149,7 @@
|
||||
return;
|
||||
}
|
||||
this.visitor.to_id=msg.id;
|
||||
this.showTitle(msg.name+", 正正与您对话");
|
||||
this.showTitle(msg.name+", is chatting with you");
|
||||
this.scrollBottom();
|
||||
this.showKfonline=true;
|
||||
}
|
||||
@ -353,6 +232,7 @@
|
||||
});
|
||||
return;
|
||||
}
|
||||
this.sendDisabled=true;
|
||||
let _this=this;
|
||||
|
||||
let content = {}
|
||||
@ -362,7 +242,6 @@
|
||||
content.is_kefu = false;
|
||||
content.time = _this.getNowDate();
|
||||
content.show_time=false;
|
||||
content.status = 'sending';
|
||||
_this.msgList.push(content);
|
||||
_this.scrollBottom();
|
||||
|
||||
@ -372,37 +251,22 @@
|
||||
mes.from_id = this.visitor.visitor_id;
|
||||
mes.to_id = this.visitor.to_id;
|
||||
mes.content = this.messageContent;
|
||||
content._rawMsg = Object.assign({}, mes);
|
||||
this.messageContent = ""
|
||||
$.post("/2/message",mes,function(res){
|
||||
_this.sendDisabled=false;
|
||||
if(res.code!=200){
|
||||
_this.$set(content, 'status', 'failed');
|
||||
_this.msgList.pop();
|
||||
_this.$message({
|
||||
message: res.msg,
|
||||
type: 'error'
|
||||
});
|
||||
return;
|
||||
}
|
||||
_this.$set(content, 'status', 'sent');
|
||||
_this.messageContent = "";
|
||||
clearInterval(_this.timer);
|
||||
_this.sendSound();
|
||||
}).fail(function(){
|
||||
_this.$set(content, 'status', 'failed');
|
||||
});
|
||||
|
||||
},
|
||||
resendMessage:function(msg) {
|
||||
if(msg.status !== 'failed') return;
|
||||
let _this = this;
|
||||
_this.$set(msg, 'status', 'sending');
|
||||
let mes = msg._rawMsg;
|
||||
$.post("/2/message", mes, function(res){
|
||||
if(res.code!=200){
|
||||
_this.$set(msg, 'status', 'failed');
|
||||
return;
|
||||
}
|
||||
_this.$set(msg, 'status', 'sent');
|
||||
_this.sendSound();
|
||||
}).fail(function(){
|
||||
_this.$set(msg, 'status', 'failed');
|
||||
});
|
||||
},
|
||||
OnClose:function() {
|
||||
console.log("ws:onclose");
|
||||
this.focusSendConn=true;
|
||||
@ -496,7 +360,7 @@
|
||||
var code=res.code;
|
||||
if(code!=200) return;
|
||||
_this.kefuInfo=res.result;
|
||||
_this.showTitle(_this.kefuInfo.nickname+" 为您服务.");
|
||||
_this.showTitle(_this.kefuInfo.nickname+" at your service.");
|
||||
if(!_this.kefuInfo.welcome) return;
|
||||
var msg={
|
||||
content:replaceContent(_this.kefuInfo.welcome),
|
||||
@ -651,7 +515,7 @@
|
||||
var formData = new FormData();
|
||||
formData.append('imgfile', file);
|
||||
$.ajax({
|
||||
url: '/aicss/uploadimg',
|
||||
url: '/uploadimg',
|
||||
type: "post",
|
||||
data: formData,
|
||||
contentType: false,
|
||||
@ -724,39 +588,5 @@
|
||||
this.getUserInfo();
|
||||
}
|
||||
})
|
||||
}
|
||||
if(KEFU_ID==""){
|
||||
var visitor_id="";
|
||||
if(window.localStorage){
|
||||
for(var i=0;i<localStorage.length;i++){
|
||||
var key = localStorage.key(i);
|
||||
if(key.indexOf("visitor_")==0){
|
||||
var obj = JSON.parse(localStorage.getItem(key));
|
||||
if(obj && obj.visitor_id){
|
||||
visitor_id = obj.visitor_id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$.ajax({
|
||||
type: "get",
|
||||
url: "/kefu_idle?visitor_id="+visitor_id,
|
||||
success: function(data) {
|
||||
if(data.code==200 && data.msg=="ok"){
|
||||
KEFU_ID=data.result;
|
||||
}else{
|
||||
KEFU_ID="default";
|
||||
}
|
||||
initVue();
|
||||
},
|
||||
error: function(){
|
||||
KEFU_ID="default";
|
||||
initVue();
|
||||
}
|
||||
});
|
||||
}else{
|
||||
initVue();
|
||||
}
|
||||
</script>
|
||||
</html>
|
||||
@ -162,7 +162,7 @@
|
||||
message: 'Welcome back!',
|
||||
type: 'success'
|
||||
});
|
||||
localStorage.setItem("aicss-token", response.result.token);
|
||||
localStorage.setItem("token", response.result.token);
|
||||
window.location.href = "/main";
|
||||
} else {
|
||||
this.$message({
|
||||
|
||||
@ -123,7 +123,7 @@
|
||||
this.iframeUrl=url;
|
||||
},
|
||||
logout(){
|
||||
localStorage.removeItem("aicss-token");
|
||||
localStorage.removeItem("token");
|
||||
this.openIframeUrl('/login');
|
||||
},
|
||||
openUrl(url){
|
||||
@ -140,7 +140,7 @@
|
||||
type:"GET",
|
||||
url:"/kefuinfo",
|
||||
headers:{
|
||||
"aicss-token":localStorage.getItem("aicss-token")
|
||||
"token":localStorage.getItem("token")
|
||||
},
|
||||
success: function(data) {
|
||||
if (data.code != 200) {
|
||||
|
||||
@ -70,9 +70,9 @@
|
||||
</style>
|
||||
<div id="app" style="width:100%; background: #f5f7fa;">
|
||||
<template>
|
||||
<el-tabs type="border-card">
|
||||
<el-tab-pane label="Profile Settings">
|
||||
<div class="profile-form">
|
||||
<h3 class="form-title">Profile Settings</h3>
|
||||
|
||||
<el-form label-width="180px" label-position="left">
|
||||
<el-form-item label="Username">
|
||||
<el-input v-model="kefuInfo.username" placeholder="Enter your username"></el-input>
|
||||
@ -98,7 +98,7 @@
|
||||
<el-form-item label="Upload New Avatar">
|
||||
<el-upload
|
||||
class="avatar-uploader"
|
||||
action="/aicss/uploadimg"
|
||||
action="/uploadimg"
|
||||
:show-file-list="false"
|
||||
name="imgfile"
|
||||
:on-success="handleAvatarSuccess"
|
||||
@ -113,12 +113,11 @@
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane v-if="kefuInfo.role === 1" label="System Configuration">
|
||||
|
||||
<div class="profile-form" style="margin-top: 20px">
|
||||
<h3 class="form-title">System Configuration</h3>
|
||||
<el-table
|
||||
:data="configList.filter(item => !['OfflineMessage', 'WelcomeMessage', 'NoticeEmailSmtp', 'NoticeEmailAddress', 'NoticeEmailPassword', 'AllNotice'].includes(item.conf_key))"
|
||||
:data="configList"
|
||||
class="config-table"
|
||||
stripe
|
||||
style="width: 100%">
|
||||
@ -143,37 +142,6 @@
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="Personal Configuration">
|
||||
<div class="profile-form" style="margin-top: 20px">
|
||||
<el-table
|
||||
:data="configList.filter(item => ['OfflineMessage', 'WelcomeMessage', 'NoticeEmailSmtp', 'NoticeEmailAddress', 'NoticeEmailPassword', 'AllNotice'].includes(item.conf_key))"
|
||||
class="config-table"
|
||||
stripe
|
||||
style="width: 100%">
|
||||
<el-table-column
|
||||
width="180"
|
||||
prop="conf_name"
|
||||
label="Parameter Name">
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column
|
||||
prop="id"
|
||||
label="Value">
|
||||
<template slot-scope="scope">
|
||||
<el-input
|
||||
type="textarea"
|
||||
class="config-textarea"
|
||||
@change="setConfigItem(scope.row.conf_key,scope.row.conf_value)"
|
||||
v-model="scope.row.conf_value"
|
||||
:autosize="{ minRows: 1, maxRows: 4 }">
|
||||
</el-input>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</template>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
@ -42,7 +42,7 @@
|
||||
<el-form-item label="新头像">
|
||||
<el-upload
|
||||
class="avatar-uploader"
|
||||
action="/aicss/uploadimg"
|
||||
action="/uploadimg"
|
||||
:show-file-list="false"
|
||||
name="imgfile"
|
||||
:on-success="handleAvatarSuccess"
|
||||
|
||||
@ -30,151 +30,40 @@
|
||||
chatEndpoint: "",
|
||||
configList:[
|
||||
{
|
||||
"conf_name": "公告",
|
||||
"conf_name": "Announcement",
|
||||
"conf_key": "AllNotice",
|
||||
"conf_value":"",
|
||||
},
|
||||
{
|
||||
|
||||
"conf_name": "离线提示语",
|
||||
"conf_name": "Offline Message",
|
||||
"conf_key": "OfflineMessage",
|
||||
"conf_value":"",
|
||||
},
|
||||
{
|
||||
|
||||
"conf_name": "欢迎语",
|
||||
"conf_name": "Welcome Message",
|
||||
"conf_key": "WelcomeMessage",
|
||||
"conf_value":"",
|
||||
},
|
||||
{
|
||||
|
||||
"conf_name": "邮箱地址",
|
||||
"conf_name": "Email Address (SMTP)",
|
||||
"conf_key": "NoticeEmailSmtp",
|
||||
"conf_value":"",
|
||||
},
|
||||
{
|
||||
|
||||
"conf_name": "邮箱帐号",
|
||||
"conf_name": "Email Account",
|
||||
"conf_key": "NoticeEmailAddress",
|
||||
"conf_value":"",
|
||||
},
|
||||
{
|
||||
|
||||
"conf_name": "邮箱密码",
|
||||
"conf_name": "Email Password (SMTP)",
|
||||
"conf_key": "NoticeEmailPassword",
|
||||
"conf_value":"",
|
||||
},
|
||||
{
|
||||
|
||||
"conf_name": "AI提示词设置",
|
||||
"conf_key": "AIPrompt",
|
||||
"conf_value":"You are an AI customer support assistant.\n\nYour primary goal is to help users resolve their issues accurately, politely, and efficiently.\nYou represent the official customer service of the product or platform.\n\nGeneral rules:\n- Always be polite, calm, and professional.\n- Use clear, concise, and user-friendly language.\n- Focus on solving the user’s problem step by step.\n- Do NOT fabricate information. If you are unsure or lack relevant knowledge, say so clearly.\n- Do NOT guess product policies, prices, or technical behaviors.\n- If a question cannot be resolved based on available information, guide the user to human support.\n\nKnowledge usage:\n- Only answer questions based on the provided knowledge, FAQs, or conversation context.\n- If the user’s question is outside the supported scope, respond with a brief explanation and suggest contacting a human agent.\n\nEscalation rules:\n- If the user explicitly requests a human agent, immediately stop responding and indicate the transfer.\n- If the user expresses frustration, repeated confusion, or dissatisfaction, suggest escalating to a human agent.\n\nSafety and compliance:\n- Do not provide sensitive, confidential, or internal information.\n- Do not provide legal, medical, or financial advice.\n- Avoid any harmful, abusive, or inappropriate content.\n\nResponse style:\n- Keep answers concise but helpful.\n- Prefer bullet points or numbered steps when explaining procedures.\n- Ask clarifying questions only when necessary to move forward.",
|
||||
},
|
||||
{
|
||||
|
||||
"conf_name": "常见问答FAQ\n(提升ai回答精准度)",
|
||||
"conf_key": "FrequentlyAskedQuestions",
|
||||
"conf_value": `【账号与登录】
|
||||
|
||||
Q: 登录提示账号或密码错误?
|
||||
A: 请确认手机号或密码是否正确;如忘记密码,在登录页选择【普通登录】→【忘记密码】通过验证码重置。
|
||||
|
||||
Q: 如何注册账号?
|
||||
A: 在登录页或首页点击【注册账号】,使用有效手机号注册,手机号可直接作为登录账号。
|
||||
|
||||
Q: 收不到验证码?
|
||||
A: 请确认信号正常,可每 2–3 分钟重试或更换地点。
|
||||
|
||||
【支付密码】
|
||||
|
||||
Q: 如何修改或找回支付密码?
|
||||
A: 需先登录账号。
|
||||
手机端:【我的】→【忘记支付密码】→验证码重置。
|
||||
电脑端:右上角【资金/头像】→【找回支付密码】。
|
||||
|
||||
【充值】
|
||||
|
||||
Q: 如何充值?
|
||||
A: 首页点击【存款/充值】,选择充值方式并按通道指引完成。
|
||||
|
||||
Q: 充值成功未到账?
|
||||
A: 通常 10 分钟内到账;超时请联系人工客服并提供含收款人及时间的转账凭证。
|
||||
|
||||
Q: 支持哪些充值货币?
|
||||
A: 支持人民币及 USDT(仅 TRC-20);USDT 将按汇率换算为人民币到账。
|
||||
|
||||
Q: 充值是否收手续费?
|
||||
A: 平台不收取;USDT 手续费由交易所或钱包收取。
|
||||
|
||||
【提现 / 取款】
|
||||
|
||||
Q: 如何提现?
|
||||
A:
|
||||
手机端:【我的】→【钱包管理】;
|
||||
电脑端:右上角【取款】→【钱包管理】。
|
||||
|
||||
Q: 提现提示打码量不足?
|
||||
A: 表示流水未达要求,具体数值可在取款页底部查看。
|
||||
|
||||
Q: 提现手续费?
|
||||
A: 每日前 5 笔免手续费,第 6 笔起收取 1%,次日 0 点重置。
|
||||
|
||||
Q: 提现多久到账?
|
||||
A: 银行卡约 5–30 分钟;虚拟币钱包可秒到账。
|
||||
|
||||
Q: 提现限制?
|
||||
A: 最低 100 元,无上限;虚拟币取款需钱包 KYC 且实名与账号一致。
|
||||
|
||||
【资金转账】
|
||||
|
||||
Q: 充值后余额为 0?
|
||||
A: 需转入游戏:点击【转账/资金】→选择游戏→【转入/闪入】。
|
||||
|
||||
Q: 如何转出游戏余额?
|
||||
A: 在【转账/资金】页面点击【一键转出】。
|
||||
|
||||
【流水 / 打码量】
|
||||
|
||||
Q: 什么是打码量?
|
||||
A: 投注结算的输赢金额,取较小值计算;和局、走水不计入。
|
||||
|
||||
Q: 提现需要多少流水?
|
||||
A: 通常为充值金额 1 倍;参与优惠则以活动规则为准。
|
||||
|
||||
【优惠与返水】
|
||||
|
||||
Q: 返水如何领取?
|
||||
A: 无需申请,系统按账号等级自动计算,次日凌晨派送,最迟不超过早上 8 点。
|
||||
|
||||
Q: 返水比例?
|
||||
A: 与账号等级及游戏有关,详见【优惠】页面。
|
||||
|
||||
Q: 如何申请彩金?
|
||||
A: 登录后进入【优惠】查看活动规则并按要求申请。
|
||||
|
||||
【游戏问题】
|
||||
|
||||
Q: 游戏无法打开或加载?
|
||||
A: 请确认网络及是否维护中;仍异常请联系人工客服并提供截图。
|
||||
|
||||
【客服与安全】
|
||||
|
||||
Q: 什么是专属客服?
|
||||
A: 除 24 小时人工客服外,提供线下专属客服(68Chat/QQ/微信),服务时间 10:00–20:00。
|
||||
|
||||
Q: 个人信息安全吗?
|
||||
A: 用户信息均经加密保护。
|
||||
|
||||
【体育相关】
|
||||
|
||||
Q: 体育注单未结算?
|
||||
A: 赛事结束后结算;如有争议将延迟,最长不超过 36 小时。
|
||||
|
||||
Q: 赛事中断或腰斩?
|
||||
A: 36 小时内无法继续或无重赛则取消注单并退还本金(除非已有官方结果)。
|
||||
|
||||
Q: 盈利消失或余额为负?
|
||||
A: 因二次结算导致,系统将按最终结果扣回或补发。`}
|
||||
}
|
||||
],
|
||||
},
|
||||
|
||||
@ -196,7 +85,7 @@ A: 因二次结算导致,系统将按最终结果扣回或补发。`}
|
||||
url: url,
|
||||
data:params,
|
||||
headers: {
|
||||
"aicss-token": localStorage.getItem("aicss-token")
|
||||
"token": localStorage.getItem("token")
|
||||
},
|
||||
success: function(data) {
|
||||
if(data.code!=200){
|
||||
@ -294,7 +183,7 @@ A: 因二次结算导致,系统将按最终结果扣回或补发。`}
|
||||
type:"get",
|
||||
url:"/kefuinfo",
|
||||
headers:{
|
||||
"aicss-token":localStorage.getItem("aicss-token")
|
||||
"token":localStorage.getItem("token")
|
||||
},
|
||||
success: function(data) {
|
||||
if(data.result.username==""){
|
||||
@ -302,7 +191,7 @@ A: 因二次结算导致,系统将按最终结果扣回或补发。`}
|
||||
}
|
||||
if(data.code==200 && data.result!=null){
|
||||
_this.kefuInfo=data.result;
|
||||
_this.chatEndpoint=window.location.origin + '/livechat?kefu_id='+data.result.username;
|
||||
_this.chatEndpoint=window.location.origin + '/livechat?kefu_id='+_this.kefuInfo.username;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
7
ws/ws.go
7
ws/ws.go
@ -17,8 +17,6 @@ import (
|
||||
|
||||
const (
|
||||
MaxAIAnswerCycleTimes int = 3
|
||||
|
||||
EnableMaxAIAnswer = false
|
||||
)
|
||||
|
||||
type User struct {
|
||||
@ -154,10 +152,5 @@ func UpdateVisitorUser(visitorId string, toId string) {
|
||||
}
|
||||
|
||||
func AIAnswerAvailable(u *User) bool {
|
||||
if !EnableMaxAIAnswer {
|
||||
// 未开启最大AI回复轮次则永远不进入人工
|
||||
return true
|
||||
|
||||
}
|
||||
return u.AIAnswerCycle < MaxAIAnswerCycleTimes
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user