12 changed files with 1141 additions and 10 deletions
@ -0,0 +1,107 @@ |
|||
<?php |
|||
/** |
|||
* |
|||
*/ |
|||
include_once(SERVER_ROOT . "/model/mBase.php"); |
|||
|
|||
class mEs extends mBase { |
|||
public $es_host = '127.0.0.1'; |
|||
public $es_port = 9200; |
|||
public $es_index = ''; |
|||
|
|||
public function __construct($index) { |
|||
$this->es_index = $index; |
|||
} |
|||
|
|||
public function search($body) { |
|||
$es_url = "http://" . $this->es_host . ":" . $this->es_port . "/{$this->es_index}/_search"; |
|||
return $this->postCUrl($es_url, $body, 10, false, true); |
|||
} |
|||
|
|||
public function searchWeibo($keywords) { |
|||
if(empty($keywords)) return false; |
|||
|
|||
$from = 0; |
|||
$size = 50; |
|||
|
|||
$body = [ |
|||
'query' => [ |
|||
'bool' => [ |
|||
'should' => [ |
|||
[ |
|||
'match' => [ |
|||
'content' => [ |
|||
'query' => $keywords, |
|||
'boost' => 4, |
|||
] |
|||
] |
|||
], |
|||
], |
|||
], |
|||
], |
|||
'highlight' => [ |
|||
'fields' => [ |
|||
'content' => [ |
|||
'fragment_size' => 2, |
|||
'number_of_fragments' => 20, |
|||
'pre_tags' => [''], |
|||
'post_tags' => [''] |
|||
] |
|||
] |
|||
], |
|||
'from' => $from, |
|||
'size' => $size |
|||
]; |
|||
|
|||
$res = $this->search(json_encode($body)); |
|||
$list = json_decode($res, true); |
|||
if(empty($res) || empty($list['hits'])) { |
|||
$this->setError('获取失败'); |
|||
return false; |
|||
} |
|||
|
|||
$rdata['total'] = $list['hits']['total']+0; |
|||
$data['list'] = $list['hits']['hits']; |
|||
if($rdata['total'] <= 0) { |
|||
$rdata['list'] = array(); |
|||
return $rdata; |
|||
} |
|||
|
|||
$rdata['total'] = $size; |
|||
$weibo_ids = array_column($data['list'], '_id'); |
|||
|
|||
$obj = new mWeibo(); |
|||
$list = $obj->getWeiboByIds($weibo_ids); |
|||
|
|||
$rlist = array(); |
|||
foreach($data['list'] as $v) { |
|||
$weibo_id = $v['_id']; |
|||
$weibo = $list[$weibo_id]; |
|||
if(empty($weibo)) continue; |
|||
|
|||
$highlights = $v['highlight']["content"]; |
|||
if(!empty($highlights)) { |
|||
foreach($highlights as $k=>$val) { |
|||
$weibo['text'] = str_replace($val, '<em class="highlight" style="color:green;">'.$val.'</em>', $weibo['text']); |
|||
} |
|||
} |
|||
|
|||
$weibo['name'] = '张宝旬'; |
|||
$pic_ids = json_decode($weibo['pic_ids'], 1); |
|||
$pic_arr = array(); |
|||
if ($pic_ids) { |
|||
foreach ($pic_ids as $pic_id) { |
|||
$pic_arr[] = $obj->getPicOssUrl($pic_id, $weibo['created_at']); |
|||
} |
|||
} |
|||
$weibo['pic_arr'] = $pic_arr; |
|||
|
|||
if ($weibo['video_url']) $weibo['video_url'] = $obj->getVideoOssUrl($weibo['wid'], $weibo['created_at']); |
|||
if ($weibo['video_cover']) $weibo['video_cover'] = $obj->getPicOssUrl($weibo['video_cover'], $weibo['created_at']); |
|||
|
|||
$rdata['list'][] = $weibo; |
|||
} |
|||
|
|||
return $rdata; |
|||
} |
|||
} |
@ -0,0 +1,326 @@ |
|||
<?php |
|||
use Elasticsearch\ClientBuilder; |
|||
|
|||
class ES |
|||
{ |
|||
//ES客户端链接 |
|||
private $client; |
|||
private $index_name; |
|||
|
|||
/** |
|||
* 初始化ES连接 |
|||
* ES constructor. |
|||
*/ |
|||
public function __construct($index) |
|||
{ |
|||
$params = array( |
|||
'127.0.0.1:9200' |
|||
); |
|||
|
|||
$this->client = ClientBuilder::create()->setHosts($params)->build(); |
|||
$this->index_name = $index; |
|||
|
|||
return $this->client; |
|||
} |
|||
|
|||
/** |
|||
* 判断索引是否存在 |
|||
* @param string $index_name |
|||
* @return bool|mixed|string |
|||
*/ |
|||
public function exists_index($index_name = 'test_ik') |
|||
{ |
|||
$params = [ |
|||
'index' => $index_name |
|||
]; |
|||
try { |
|||
return $this->client->indices()->exists($params); |
|||
} catch (\Exception $e) { |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 创建索引 |
|||
* @param string $index_name |
|||
* @return array|mixed|string |
|||
*/ |
|||
public function create_index($index_name = 'test_ik') |
|||
{ |
|||
$params = [ |
|||
'index' => $index_name, |
|||
'body' => [ |
|||
'settings' => [ |
|||
'number_of_shards' => 3, |
|||
'number_of_replicas' => 0 |
|||
] |
|||
] |
|||
]; |
|||
try { |
|||
return $this->client->indices()->create($params); |
|||
} catch (\Exception $e) { |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 删除索引 |
|||
* @param string $index_name |
|||
* @return array |
|||
*/ |
|||
public function delete_index($index_name = 'test_ik') |
|||
{ |
|||
$params = ['index' => $index_name]; |
|||
$response = $this->client->indices()->delete($params); |
|||
return $response; |
|||
} |
|||
|
|||
/** |
|||
* 添加文档 |
|||
* @param $params |
|||
* $params = [ |
|||
* 'index' => "es", |
|||
* 'type' => "article", |
|||
* "body" => [ |
|||
* "title" => "", |
|||
* ] |
|||
* ]; |
|||
* @return array |
|||
*/ |
|||
public function add_doc($params) |
|||
{ |
|||
return $this->client->index($params); |
|||
} |
|||
|
|||
/** |
|||
* 判断文档存在 |
|||
* @param int $id |
|||
* @param string $index_name |
|||
* @param string $type_name |
|||
* @return array|bool |
|||
*/ |
|||
public function exists_doc($id = 1, $index_name = 'test_ik', $type_name = 'goods') |
|||
{ |
|||
$params = [ |
|||
'index' => $index_name, |
|||
'type' => $type_name, |
|||
'id' => $id |
|||
]; |
|||
|
|||
$response = $this->client->exists($params); |
|||
return $response; |
|||
} |
|||
|
|||
/** |
|||
* 获取文档 |
|||
* @param int $id |
|||
* @param string $index_name |
|||
* @param string $type_name |
|||
* @return array |
|||
*/ |
|||
public function get_doc($id = 1, $index_name = 'test_ik', $type_name = 'goods') |
|||
{ |
|||
$params = [ |
|||
'index' => $index_name, |
|||
'type' => $type_name, |
|||
'id' => $id |
|||
]; |
|||
|
|||
$response = $this->client->get($params); |
|||
return $response; |
|||
} |
|||
|
|||
/** |
|||
* 修改文档 |
|||
*$params = [ |
|||
'index' => "es", |
|||
'type' => "article", |
|||
'id' => "OIwzxXgBzF70K-DobSSC", |
|||
"body" => [ |
|||
"doc" => [ |
|||
"title" => "6100万颗心的共同记忆 再次C位亮相,闪耀全球!", |
|||
"desn" => "刚刚过去的这个清明节,与往年一样,有人凭寄哀思,有人缅怀忠魂。但也有一些瞬间,让人记起久久不能释怀,给这个特殊节气增添了一些格外不同的味道。" |
|||
] |
|||
] |
|||
]; |
|||
* @param array $params |
|||
* @return array |
|||
*/ |
|||
public function update_doc($params = []) |
|||
{ |
|||
$response = $this->client->update($params); |
|||
return $response; |
|||
} |
|||
|
|||
/** |
|||
* 删除文档 |
|||
* @param int $id |
|||
* @param string $index_name |
|||
* @param string $type_name |
|||
* @return array |
|||
*/ |
|||
public function delete_doc($id = 1, $index_name = 'test_ik', $type_name = 'goods') |
|||
{ |
|||
$params = [ |
|||
'index' => $index_name, |
|||
'type' => $type_name, |
|||
'id' => $id |
|||
]; |
|||
|
|||
$response = $this->client->delete($params); |
|||
return $response; |
|||
} |
|||
|
|||
/** |
|||
* 搜索文档 (分页,排序,权重,过滤) |
|||
* @param string $index_name |
|||
* @param string $type_name |
|||
* @param array $body |
|||
$body = [ |
|||
'query' => [ |
|||
'bool' => [ |
|||
'should' => [ |
|||
[ |
|||
'match' => [ |
|||
'cate_name' => [ |
|||
'query' => $keywords, |
|||
'boost' => 4, // 权重大 |
|||
] |
|||
] |
|||
], |
|||
[ |
|||
'match' => [ |
|||
'goods_name' => [ |
|||
'query' => $keywords, |
|||
'boost' => 3, |
|||
] |
|||
] |
|||
], |
|||
[ |
|||
'match' => [ |
|||
'goods_introduce' => [ |
|||
'query' => $keywords, |
|||
'boost' => 2, |
|||
] |
|||
] |
|||
] |
|||
], |
|||
], |
|||
], |
|||
'sort' => ['id'=>['order'=>'desc']], |
|||
'from' => $from, |
|||
'size' => $size |
|||
]; |
|||
* @return array |
|||
*/ |
|||
public function search_doc($index_name = "test_ik", $type_name = "goods", $body = []) |
|||
{ |
|||
$params = [ |
|||
'index' => $index_name, |
|||
'type' => $type_name, |
|||
'body' => $body |
|||
]; |
|||
|
|||
$results = $this->client->search($params); |
|||
return $results; |
|||
} |
|||
|
|||
/** |
|||
* @param string $index_name 搜索列表 |
|||
* @param string $type_name |
|||
* @return array|callable |
|||
* |
|||
*/ |
|||
public function select_doc($index_name = 'test_ik', $type_name = 'goods'){ |
|||
$params=[ |
|||
'index' => $index_name, |
|||
'type' => $type_name, |
|||
]; |
|||
$response = $this->client->search($params); |
|||
return $response; |
|||
} |
|||
|
|||
/** |
|||
* @param string $index_name // 高亮显示 |
|||
* @param string $type_name |
|||
* @param array $body |
|||
* @return array|callable |
|||
* |
|||
* |
|||
$body=[ |
|||
'query' => [ |
|||
'match' => [ |
|||
'desn' => '董事长' |
|||
] |
|||
], |
|||
'highlight' => [ |
|||
'pre_tags' => ["<b class='key' style='color:red'>"], |
|||
'post_tags' => ["</b>"], |
|||
'fields' => [ |
|||
"desn" => new \stdClass() |
|||
] |
|||
], |
|||
]; |
|||
*/ |
|||
public function highlight_doc($index_name = 'test_ik', $type_name = 'goods' , $body = []){ |
|||
$params=[ |
|||
'index' => $index_name, |
|||
'type' => $type_name, |
|||
'body' => $body |
|||
|
|||
]; |
|||
$response = $this->client->search($params); |
|||
return $response; |
|||
} |
|||
|
|||
public function create_weibo_index() { |
|||
$res = $this->exists_index($this->index_name); |
|||
if($res) return true; |
|||
|
|||
$params = [ |
|||
'index' => $this->index_name, |
|||
'body' => [ |
|||
'settings' => [ |
|||
'number_of_shards' => 2, |
|||
'number_of_replicas' => 1, |
|||
'analysis' => [ |
|||
'analyzer' => [ |
|||
'ik_analyzer' => [ |
|||
'type' => 'custom', |
|||
'tokenizer' => 'ik_max_word' |
|||
] |
|||
] |
|||
] |
|||
], |
|||
'mappings' => [ |
|||
'properties' => [ |
|||
'id' => ['type' => 'long'], |
|||
'uid' => ['type' => 'long'], |
|||
'wid' => ['type' => 'long'], |
|||
'content' => [ |
|||
'type' => 'text', |
|||
'analyzer' => 'ik_max_word', |
|||
// 'fields' => [ |
|||
// 'semantic' => [ |
|||
// 'type' => 'dense_vector', |
|||
// 'dims' => 768 |
|||
// ] |
|||
// ] |
|||
], |
|||
'created_at' => ['type' => 'date'], |
|||
'comments_count' => ['type' => 'long'], |
|||
'attitudes_count' => ['type' => 'long'], |
|||
'status' => ['type' => 'long'] |
|||
] |
|||
] |
|||
] |
|||
]; |
|||
|
|||
try { |
|||
return $this->client->indices()->create($params); |
|||
} catch (\Exception $e) { |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
} |
@ -0,0 +1,92 @@ |
|||
<?php |
|||
// nohup php /data1/www/zhishiku.kuailelunwen.com/tools/es_add_comments.php & |
|||
include_once(dirname(dirname(__FILE__))."/vendor/autoload.php"); |
|||
include_once(dirname(dirname(__FILE__))."/tools/es.php"); |
|||
|
|||
function parseDbCnf($dbflag) { |
|||
$configs = parse_ini_file(dirname(dirname(__FILE__)).'/config/database.ini', true); |
|||
$config = $configs[strtolower($dbflag)]; |
|||
|
|||
$host_port = $config['master']; |
|||
|
|||
$hps = explode(',', $host_port); |
|||
$random = rand(0, count($hps)-1); |
|||
$hp = $hps[$random]; |
|||
|
|||
list($host, $port) = explode(':', $hp); |
|||
|
|||
$cnf = array(); |
|||
$cnf['host'] = trim($host); |
|||
$cnf['port'] = trim($port); |
|||
$cnf['user'] = trim($config['user']); |
|||
$cnf['pwd'] = trim($config['passwd']); |
|||
$cnf['db'] = trim($config['db']); |
|||
return $cnf; |
|||
} |
|||
|
|||
$mysqlconfig = parseDbCnf('simplyphp'); |
|||
$servername = $mysqlconfig['host']; |
|||
$username = $mysqlconfig['user']; |
|||
$password = $mysqlconfig['pwd']; |
|||
$dbname = $mysqlconfig['db']; |
|||
|
|||
$obj = new \ES('weibo'); |
|||
$conn = new mysqli($servername, $username, $password, $dbname); |
|||
if ($conn->connect_error) { |
|||
die("连接失败: " . $conn->connect_error); |
|||
} |
|||
$conn->set_charset("utf8mb4"); |
|||
|
|||
$limit = 5000; |
|||
$min_id = 0; |
|||
|
|||
$log_path = '/datacenter/zhishiku/es_comment.log'; |
|||
$log_path_success = '/datacenter/zhishiku/es_success_comment.log'; |
|||
$log_path_err = '/datacenter/zhishiku/es_error_comment.log'; |
|||
|
|||
for($page=0;;$page++){ |
|||
$sql = "SELECT * FROM spider_weibo_comments where is_search=1 and id>".$min_id." order by id asc limit ".$limit; |
|||
$result = $conn->query($sql); |
|||
if ($result->num_rows > 0) { |
|||
while($row = $result->fetch_assoc()) { |
|||
$min_id = $row['id']; |
|||
|
|||
if(str_replace(" ", "", $row["content"])=="") continue; |
|||
|
|||
$data['id'] = $row['id']+0; |
|||
|
|||
$data['uid'] = $row['uid']+0; |
|||
$data['weibo_id'] = $row['weibo_id']+0; |
|||
$data['content'] = $row['content']; |
|||
|
|||
if (!empty($row['comment_time'])) { |
|||
$data['comment_time'] = date('c', strtotime($row['comment_time'])); |
|||
} else { |
|||
$data['comment_time'] = null; |
|||
} |
|||
|
|||
$params['index'] = 'comments'; |
|||
$params['type'] = 'doc'; |
|||
$params['id'] = $data['id']; |
|||
$params['body'] = $data; |
|||
|
|||
try { |
|||
$resc = $obj->add_doc($params); |
|||
if($resc['result'] != 'created') { |
|||
error_log('error:'.json_encode($data)."\n", 3, $log_path_err); |
|||
}else{ |
|||
error_log($resc['_id']."|{$min_id}\n", 3, $log_path_success); |
|||
} |
|||
} catch (\Exception $th) { |
|||
error_log('excption:'.$th->getMessage().'|'.json_encode($data).'|'.$min_id."\n", 3, $log_path_err); |
|||
} |
|||
} |
|||
error_log((($page*$limit)+$result->num_rows)."|".$page."\n", 3, $log_path); |
|||
if($result->num_rows<$limit) break; |
|||
} else { |
|||
error_log((($page*$limit)+$result->num_rows)."|".$page."\n", 3, $log_path); |
|||
break; |
|||
} |
|||
} |
|||
$conn->close(); |
|||
?> |
@ -0,0 +1,66 @@ |
|||
<?php |
|||
error_reporting(0); |
|||
ini_set('display_errors', 0); |
|||
|
|||
// nohup php /data1/www/zhishiku.kuailelunwen.com/tools/es_search.php & |
|||
include_once(dirname(dirname(__FILE__))."/vendor/autoload.php"); |
|||
include_once(dirname(dirname(__FILE__))."/tools/es.php"); |
|||
|
|||
$data['status'] = false; |
|||
$data['info'] = ''; |
|||
$data['data'] = []; |
|||
|
|||
$obj = new \ES('weibo'); |
|||
$from = 0; |
|||
$size = 25; |
|||
$keywords = $_POST['key']; |
|||
$token = $_POST['token']; |
|||
|
|||
// $keywords = '发烧'; |
|||
// $token = "ahckexb@!@#!@#$%cdasd%$"; |
|||
|
|||
if($token != "ahckexb@!@#!@#$%cdasd%$") { |
|||
echo 'succ'; |
|||
exit; |
|||
} |
|||
|
|||
if(empty($keywords)) { |
|||
$data['info'] = '错误'; |
|||
echo json_encode($data, true); |
|||
exit; |
|||
} |
|||
|
|||
$body = [ |
|||
'query' => [ |
|||
'bool' => [ |
|||
'should' => [ |
|||
[ |
|||
'match' => [ |
|||
'content' => [ |
|||
'query' => $keywords, |
|||
'boost' => 4, |
|||
] |
|||
] |
|||
], |
|||
], |
|||
], |
|||
], |
|||
'from' => $from, |
|||
'size' => $size |
|||
]; |
|||
$res = $obj->search_doc('weibo', 'doc', $body); |
|||
$hits = $res['hits']['hits']; |
|||
if(empty($hits)){ |
|||
$data['info'] = '数据为空'; |
|||
echo json_encode($data, true); |
|||
exit; |
|||
} |
|||
|
|||
$rdata = []; |
|||
foreach($hits as $val) { |
|||
$rdata[] = $val['_source']; |
|||
} |
|||
$data['status'] = true; |
|||
$data['data'] = $rdata; |
|||
echo json_encode($data, true); |
|||
exit; |
@ -0,0 +1,95 @@ |
|||
<?php |
|||
// nohup php /data1/www/zhishiku.kuailelunwen.com/tools/es_setting.php & |
|||
include_once(dirname(dirname(__FILE__))."/vendor/autoload.php"); |
|||
include_once(dirname(dirname(__FILE__))."/tools/es.php"); |
|||
|
|||
function parseDbCnf($dbflag) { |
|||
$configs = parse_ini_file(dirname(dirname(__FILE__)).'/config/database.ini', true); |
|||
$config = $configs[strtolower($dbflag)]; |
|||
|
|||
$host_port = $config['master']; |
|||
|
|||
$hps = explode(',', $host_port); |
|||
$random = rand(0, count($hps)-1); |
|||
$hp = $hps[$random]; |
|||
|
|||
list($host, $port) = explode(':', $hp); |
|||
|
|||
$cnf = array(); |
|||
$cnf['host'] = trim($host); |
|||
$cnf['port'] = trim($port); |
|||
$cnf['user'] = trim($config['user']); |
|||
$cnf['pwd'] = trim($config['passwd']); |
|||
$cnf['db'] = trim($config['db']); |
|||
return $cnf; |
|||
} |
|||
|
|||
$mysqlconfig = parseDbCnf('simplyphp'); |
|||
$servername = $mysqlconfig['host']; |
|||
$username = $mysqlconfig['user']; |
|||
$password = $mysqlconfig['pwd']; |
|||
$dbname = $mysqlconfig['db']; |
|||
|
|||
$obj = new \ES('weibo'); |
|||
$conn = new mysqli($servername, $username, $password, $dbname); |
|||
if ($conn->connect_error) { |
|||
die("连接失败: " . $conn->connect_error); |
|||
} |
|||
|
|||
$conn->set_charset("utf8mb4"); |
|||
|
|||
$limit = 5000; |
|||
$min_id = 0; |
|||
|
|||
$log_path = '/datacenter/zhishiku/es.log'; |
|||
$log_path_success = '/datacenter/zhishiku/es_success.log'; |
|||
$log_path_err = '/datacenter/zhishiku/es_error.log'; |
|||
|
|||
for($page=0;;$page++){ |
|||
$sql = "SELECT * FROM spider_weibo where uid=2282201403 and id>".$min_id." order by id asc limit ".$limit; |
|||
$result = $conn->query($sql); |
|||
if ($result->num_rows > 0) { |
|||
while($row = $result->fetch_assoc()) { |
|||
$min_id = $row['id']; |
|||
|
|||
if(str_replace(" ", "", $row["text"])=="") continue; |
|||
|
|||
$data['id'] = $row['id']+0; |
|||
$data['uid'] = $row['uid']+0; |
|||
$data['wid'] = $row['wid']+0; |
|||
$data['content'] = $row['text']; |
|||
|
|||
if (!empty($row['created_at'])) { |
|||
$data['created_at'] = date('c', strtotime($row['created_at'])); |
|||
} else { |
|||
$data['created_at'] = null; |
|||
} |
|||
$data['comments_count'] = $row['comments_count']+0; |
|||
$data['attitudes_count'] = $row['attitudes_count']+0; |
|||
$data['reposts_count'] = $row['reposts_count']+0; |
|||
$data['status'] = $row['status']+0; |
|||
|
|||
$params['index'] = 'weibo'; |
|||
$params['type'] = 'doc'; |
|||
$params['id'] = $data['id']; |
|||
$params['body'] = $data; |
|||
try { |
|||
$resc = $obj->add_doc($params); |
|||
if($resc['result'] != 'created') { |
|||
error_log('error:'.json_encode($data)."\n", 3, $log_path_err); |
|||
}else{ |
|||
error_log($resc['_id']."|{$min_id}\n", 3, $log_path_success); |
|||
} |
|||
} catch (\Exception $th) { |
|||
error_log('excption:'.$th->getMessage().'|'.json_encode($data).'|'.$min_id."\n", 3, $log_path_err); |
|||
} |
|||
} |
|||
error_log((($page*$limit)+$result->num_rows)."|".$page."\n", 3, $log_path); |
|||
if($result->num_rows<$limit) break; |
|||
} else { |
|||
error_log((($page*$limit)+$result->num_rows)."|".$page."\n", 3, $log_path); |
|||
break; |
|||
} |
|||
} |
|||
$conn->close(); |
|||
?> |
@ -0,0 +1,211 @@ |
|||
<!DOCTYPE html> |
|||
<html lang="en"> |
|||
|
|||
<head> |
|||
<meta charset="UTF-8"> |
|||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
|||
<title>知识库</title> |
|||
<link rel="stylesheet" href="{$smarty.const.CSS_URL}/css/common.css?v={$smarty.const.CSS_JS_VERSION}"> |
|||
<link rel="stylesheet" href="{$smarty.const.CSS_URL}/css/index.css?v={$smarty.const.CSS_JS_VERSION}"> |
|||
<script src="{$smarty.const.CSS_URL}/js/jquery-3.6.0.min.js"></script> |
|||
{literal} |
|||
<style> |
|||
.search-wrapper{ |
|||
column-gap: 12px; |
|||
width: 100%; |
|||
} |
|||
.search-wrapper input{ |
|||
width: 200px; |
|||
padding-left: 8px; |
|||
} |
|||
.addNewBtn2 { |
|||
width: 121px; |
|||
display: flex; |
|||
flex-direction: row; |
|||
justify-content: center; |
|||
align-items: center; |
|||
height: 32px; |
|||
border-radius: 3px; |
|||
opacity: 1; |
|||
height: 32px; |
|||
border:none; |
|||
background: #006AFF; |
|||
font-weight: normal; |
|||
line-height: normal; |
|||
letter-spacing: 0.08em; |
|||
color: #FFFFFF; |
|||
} |
|||
</style> |
|||
{/literal} |
|||
</head> |
|||
|
|||
<body> |
|||
<div class="home-page"> |
|||
{include file="include/header.html"} |
|||
|
|||
<div class="home-main-content"> |
|||
<div class="home-main"> |
|||
<div class="tab-list index-nav-wrap flex"> |
|||
<div class="search-wrapper flex"> |
|||
<input type="text" placeholder="输入症状进行查询" id="search-input" value="{$keyword}"> |
|||
<button class="addNewBtn2" id="searchWeibo"> |
|||
搜索 |
|||
</button> |
|||
</div> |
|||
</div> |
|||
|
|||
|
|||
<div class="list_all" id="data-list"> |
|||
</div> |
|||
|
|||
|
|||
<!-- 数据列表 --> |
|||
<!-- <ul id="data-list"></ul> --> |
|||
|
|||
<!-- 分页控件 --> |
|||
<div class="pagination hide"> |
|||
<img id="prev-page" src="{$smarty.const.CSS_URL}/images/prev.svg" alt=""> |
|||
<ul id="page-numbers"></ul> |
|||
<img id="next-page" src="{$smarty.const.CSS_URL}/images/next.svg" alt=""> |
|||
<div class="input-page"> |
|||
<span>前往</span> |
|||
<input type="number" id="jump-to-page" min="1" placeholder="页码"> |
|||
<span>页</span> |
|||
</div> |
|||
<button id="go-to-page">跳转</button> |
|||
</div> |
|||
|
|||
<!-- 放大后的图片容器 --> |
|||
<div id="large-image-container"> |
|||
<h2>预览</h2> |
|||
<img id="large-image" src="{$smarty.const.CSS_URL}/images/viewimg1.png" alt="Large Image"> |
|||
<span id="close-btn2">×</span> |
|||
</div> |
|||
|
|||
<!-- 放大后的视频容器 --> |
|||
<div id="large-video-container"> |
|||
<video id="large-video" controls> |
|||
<source id="large-viedo-url" src="" type="video/mp4"> |
|||
Your browser does not support the video tag. |
|||
</video> |
|||
<button id="close-btn">×</button> |
|||
</div> |
|||
|
|||
<!-- 弹框 --> |
|||
<div class="modal-overlay"></div> |
|||
<div class="modal"> |
|||
<div class="modal_top"> |
|||
<b id="header_title">编辑</b> |
|||
<img src="{$smarty.const.CSS_URL}/images/close_modal.svg" id="close_modal" alt=""> |
|||
</div> |
|||
|
|||
<div class="add-form"> |
|||
<div class="form-item radio-form"> |
|||
<input type="hidden" id="id" value=""> |
|||
<div class="form-left"> |
|||
录入形式 |
|||
</div> |
|||
<div class="form-right radio-wrap flex"> |
|||
<div class="radio_box radio_box_active"> |
|||
<input value="1" type="radio"id="edu1"> |
|||
<div></div> |
|||
<label >信息段录入</label> |
|||
</div> |
|||
<div class="radio_box"> |
|||
<input value="2" type="radio"id="edu2"> |
|||
<div></div> |
|||
<label >问答式录入</label> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
<div class="form-item normal-form" style="display: none;"> |
|||
<div class="form-left"> |
|||
提问信息 |
|||
</div> |
|||
<div class="form-right"> |
|||
<div class="text-area-container"> |
|||
<textarea class="edit-input normal-input" ></textarea> |
|||
<div class="char-count wordNum">0/200</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
|
|||
<div class="form-item"> |
|||
<div class="form-left common-input"> |
|||
回答信息 |
|||
</div> |
|||
<div class="form-right"> |
|||
<div class="text-area-container"> |
|||
<textarea class="edit-input answer-input" ></textarea> |
|||
<div class="char-count1 wordNum">0/200</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
{literal} |
|||
<script> |
|||
const maxLength = 100; // 设置最大字数限制 |
|||
$('.normal-input').on('input', function () { |
|||
var currentLength = $(this).val().length; |
|||
$('.char-count').text(currentLength + '/' + maxLength); |
|||
if (currentLength > maxLength) { |
|||
$('.normal-input').val($('.normal-input').val().slice(0, maxLength)) |
|||
$('.char-count').text(maxLength + '/' + maxLength); |
|||
} |
|||
}); |
|||
$('.answer-input').on('input', function () { |
|||
var currentLength = $(this).val().length; |
|||
$('.char-count1').text(currentLength + '/' + maxLength); |
|||
if (currentLength > maxLength) { |
|||
$('.answer-input').val($('.answer-input').val().slice(0, maxLength)) |
|||
$('.char-count1').text(maxLength + '/' + maxLength); |
|||
} |
|||
}); |
|||
</script> |
|||
{/literal} |
|||
<div class="img_list2" style="display: none;"></div> |
|||
<div class="preview"></div> |
|||
|
|||
<div class="modal_upload_btn flex hide"> |
|||
<div class="flex modal_btns"> |
|||
<button id="upload-image-btn" class="button upload_btn"> |
|||
<img src="{$smarty.const.CSS_URL}/images/img_upload.svg" alt="">上传图片 |
|||
</button> |
|||
<button id="upload-video-btn" class="button upload_btn"> |
|||
<img src="{$smarty.const.CSS_URL}/images/vedio_upload.svg" alt="">上传视频 |
|||
</button> |
|||
</div> |
|||
<p>支持 jpg、png、mp4 格式,单个文件不超过 10MB</p> |
|||
</div> |
|||
<input type="file" id="upload-image" accept="image/*" style="display: none;" multiple> |
|||
<input type="file" id="upload-video" accept="video/*" style="display: none;" multiple> |
|||
<div class="buttons flex"> |
|||
<button id="submit" class="button ">仅保存</button> |
|||
<button id="savePass" class="button button-primary">保存并通过审批</button> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
{include file="include/footer.html"} |
|||
</div> |
|||
|
|||
<div id="hidecomments" style="display: none;"></div> |
|||
<div id="hidesearch" style="display: none;"></div> |
|||
<div id="hidekeyword" style="display: none;">{$keyword}</div> |
|||
|
|||
</body> |
|||
<script src="{$smarty.const.CSS_URL}/js/index.js?v={$smarty.const.CSS_JS_VERSION}589"></script> |
|||
|
|||
{literal} |
|||
<script> |
|||
$('#searchWeibo').click(function () { |
|||
var keyword = $('#search-input').val() |
|||
if (keyword) { |
|||
window.location.href = '/weibo/search?keyword=' + keyword |
|||
} else { |
|||
window.location.href = '/weibo/search' |
|||
} |
|||
}) |
|||
</script> |
|||
{/literal} |
|||
</html> |
@ -0,0 +1,170 @@ |
|||
<!DOCTYPE html> |
|||
<html lang="en"> |
|||
|
|||
<head> |
|||
<meta charset="UTF-8"> |
|||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
|||
<title>知识库</title> |
|||
<link rel="stylesheet" href="{$smarty.const.CSS_URL}/css/common.css?v={$smarty.const.CSS_JS_VERSION}"> |
|||
<link rel="stylesheet" href="{$smarty.const.CSS_URL}/css/index.css?v={$smarty.const.CSS_JS_VERSION}"> |
|||
<script src="{$smarty.const.CSS_URL}/js/jquery-3.6.0.min.js"></script> |
|||
</head> |
|||
|
|||
<body> |
|||
<div class="home-page"> |
|||
{include file="include/header.html"} |
|||
|
|||
<div class="home-main-content"> |
|||
<div class="home-main"> |
|||
<div class="tab-list index-nav-wrap flex"> |
|||
<ul class="tab-wrap" style="display: none;"> |
|||
<li class="index-nav-wrap-li" type="1"><span class="active">待审批</span></li> |
|||
<li class="index-nav-wrap-li" type="2"><span>已审批</span></li> |
|||
<li class="index-nav-wrap-li" type="3"><span>已删除</span></li> |
|||
</ul> |
|||
<button class="addNewBtn" style="display: none;"> |
|||
<img src="{$smarty.const.CSS_URL}/images/add.svg" alt="">新增自录入 |
|||
</button> |
|||
</div> |
|||
|
|||
|
|||
<div class="list_all" id="data-list"> |
|||
</div> |
|||
|
|||
|
|||
<!-- 数据列表 --> |
|||
<!-- <ul id="data-list"></ul> --> |
|||
|
|||
<!-- 分页控件 --> |
|||
<div class="pagination hide"> |
|||
<img id="prev-page" src="{$smarty.const.CSS_URL}/images/prev.svg" alt=""> |
|||
<ul id="page-numbers"></ul> |
|||
<img id="next-page" src="{$smarty.const.CSS_URL}/images/next.svg" alt=""> |
|||
<div class="input-page"> |
|||
<span>前往</span> |
|||
<input type="number" id="jump-to-page" min="1" placeholder="页码"> |
|||
<span>页</span> |
|||
</div> |
|||
<button id="go-to-page">跳转</button> |
|||
</div> |
|||
|
|||
<!-- 放大后的图片容器 --> |
|||
<div id="large-image-container"> |
|||
<h2>预览</h2> |
|||
<img id="large-image" src="{$smarty.const.CSS_URL}/images/viewimg1.png" alt="Large Image"> |
|||
<span id="close-btn2">×</span> |
|||
</div> |
|||
|
|||
<!-- 放大后的视频容器 --> |
|||
<div id="large-video-container"> |
|||
<video id="large-video" controls> |
|||
<source id="large-viedo-url" src="" type="video/mp4"> |
|||
Your browser does not support the video tag. |
|||
</video> |
|||
<button id="close-btn">×</button> |
|||
</div> |
|||
|
|||
<!-- 弹框 --> |
|||
<div class="modal-overlay"></div> |
|||
<div class="modal"> |
|||
<div class="modal_top"> |
|||
<b id="header_title">编辑</b> |
|||
<img src="{$smarty.const.CSS_URL}/images/close_modal.svg" id="close_modal" alt=""> |
|||
</div> |
|||
|
|||
<div class="add-form"> |
|||
<div class="form-item radio-form"> |
|||
<input type="hidden" id="id" value=""> |
|||
<div class="form-left"> |
|||
录入形式 |
|||
</div> |
|||
<div class="form-right radio-wrap flex"> |
|||
<div class="radio_box radio_box_active"> |
|||
<input value="1" type="radio"id="edu1"> |
|||
<div></div> |
|||
<label >信息段录入</label> |
|||
</div> |
|||
<div class="radio_box"> |
|||
<input value="2" type="radio"id="edu2"> |
|||
<div></div> |
|||
<label >问答式录入</label> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
<div class="form-item normal-form" style="display: none;"> |
|||
<div class="form-left"> |
|||
提问信息 |
|||
</div> |
|||
<div class="form-right"> |
|||
<div class="text-area-container"> |
|||
<textarea class="edit-input normal-input" ></textarea> |
|||
<div class="char-count wordNum">0/200</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
|
|||
<div class="form-item"> |
|||
<div class="form-left common-input"> |
|||
回答信息 |
|||
</div> |
|||
<div class="form-right"> |
|||
<div class="text-area-container"> |
|||
<textarea class="edit-input answer-input" ></textarea> |
|||
<div class="char-count1 wordNum">0/200</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
{literal} |
|||
<script> |
|||
const maxLength = 100; // 设置最大字数限制 |
|||
$('.normal-input').on('input', function () { |
|||
var currentLength = $(this).val().length; |
|||
$('.char-count').text(currentLength + '/' + maxLength); |
|||
if (currentLength > maxLength) { |
|||
$('.normal-input').val($('.normal-input').val().slice(0, maxLength)) |
|||
$('.char-count').text(maxLength + '/' + maxLength); |
|||
} |
|||
}); |
|||
$('.answer-input').on('input', function () { |
|||
var currentLength = $(this).val().length; |
|||
$('.char-count1').text(currentLength + '/' + maxLength); |
|||
if (currentLength > maxLength) { |
|||
$('.answer-input').val($('.answer-input').val().slice(0, maxLength)) |
|||
$('.char-count1').text(maxLength + '/' + maxLength); |
|||
} |
|||
}); |
|||
</script> |
|||
{/literal} |
|||
<div class="img_list2" style="display: none;"></div> |
|||
<div class="preview"></div> |
|||
|
|||
<div class="modal_upload_btn flex hide"> |
|||
<div class="flex modal_btns"> |
|||
<button id="upload-image-btn" class="button upload_btn"> |
|||
<img src="{$smarty.const.CSS_URL}/images/img_upload.svg" alt="">上传图片 |
|||
</button> |
|||
<button id="upload-video-btn" class="button upload_btn"> |
|||
<img src="{$smarty.const.CSS_URL}/images/vedio_upload.svg" alt="">上传视频 |
|||
</button> |
|||
</div> |
|||
<p>支持 jpg、png、mp4 格式,单个文件不超过 10MB</p> |
|||
</div> |
|||
<input type="file" id="upload-image" accept="image/*" style="display: none;" multiple> |
|||
<input type="file" id="upload-video" accept="video/*" style="display: none;" multiple> |
|||
<div class="buttons flex"> |
|||
<button id="submit" class="button ">仅保存</button> |
|||
<button id="savePass" class="button button-primary">保存并通过审批</button> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
{include file="include/footer.html"} |
|||
</div> |
|||
|
|||
<div id="hidecomments" style="display: none;"></div> |
|||
|
|||
</body> |
|||
<script src="{$smarty.const.CSS_URL}/js/index.js?v={$smarty.const.CSS_JS_VERSION}589"></script> |
|||
|
|||
</html> |
Loading…
Reference in new issue